-// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
#include <Standard_Stream.hxx>
#include <GEOMImpl_Block6Explorer.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <GeomFill_Generator.hxx>
+#include <gce_MakePln.hxx>
+
#include <Precision.hxx>
#include <gp_Pnt.hxx>
+#include <gp_Pln.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <StdFail_NotDone.hxx>
myEdges(edge_id(2, i)) = anEdges2(nb);
}
+ // check the wires closure
+ TopoDS_Wire wire1 = TopoDS::Wire(aWire1);
+ TopoDS_Wire wire2 = TopoDS::Wire(aWire2);
+ TopoDS_Vertex aV1, aV2;
+
+ TopExp::Vertices(wire1, aV1, aV2);
+ if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+ aWire1.Closed( true );
+
+ TopExp::Vertices(wire2, aV1, aV2);
+ if ( !aV1.IsNull() && !aV2.IsNull() && aV1.IsSame(aV2) )
+ aWire2.Closed( true );
+
// 4. Generate side surface
if (!aWire1.Closed() || !aWire2.Closed()) {
// BRepOffsetAPI_ThruSections is not applicable on not closed wires
const Standard_Boolean isPlanarWanted,
TopoDS_Shape& theResult)
{
- // try to build face on plane or on any surface under the edges of the wire
- BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
- if (MK.IsDone()) {
- theResult = MK.Shape();
- return;
+ // Workaround for Mantis issue 0020956
+ if (isPlanarWanted) {
+ // Count the number of points in the wire.
+ // Collect the first three points.
+ gp_Pnt p1, p2, p3;
+ bool is3Pnts(false);
+ bool p1set(false), p2set(false), p3set(false);
+ BRepTools_WireExplorer wexpl(theWire);
+ for (; wexpl.More(); wexpl.Next()) {
+ if (!p1set) {
+ p1set = true;
+ p1 = BRep_Tool::Pnt(wexpl.CurrentVertex());
+ }
+ else if (!p2set) {
+ p2set = true;
+ p2 = BRep_Tool::Pnt(wexpl.CurrentVertex());
+ }
+ else if (!p3set) {
+ p3set = true;
+ is3Pnts = true;
+ p3 = BRep_Tool::Pnt(wexpl.CurrentVertex());
+ }
+ else {
+ is3Pnts = false;
+ break;
+ }
+ }
+
+ // Construct a plane for the case of three points in the wire.
+ gp_Pln plane;
+ if (is3Pnts) {
+ gce_MakePln mkPln(p1, p2, p3);
+ if (mkPln.IsDone()) {
+ plane = mkPln.Value();
+ }
+ else {
+ is3Pnts = false;
+ }
+ }
+
+ // Construct a face based on the plane (in case of three points in the wire) or
+ // allow MakeFace to build the plane itself (in case of the number of points is greater than 3).
+ if (is3Pnts) {
+ BRepBuilderAPI_MakeFace MK (plane, theWire, isPlanarWanted);
+ if (MK.IsDone()) {
+ theResult = MK.Shape();
+ return;
+ }
+ }
+ else {
+ BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
+ if (MK.IsDone()) {
+ theResult = MK.Shape();
+ return;
+ }
+ }
+ }
+ else {
+ // try to build face on plane or on any surface under the edges of the wire
+ BRepBuilderAPI_MakeFace MK (theWire, isPlanarWanted);
+ if (MK.IsDone()) {
+ theResult = MK.Shape();
+ return;
+ }
}
if (!isPlanarWanted) {