X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMImpl%2FGEOMImpl_Block6Explorer.cxx;h=27056c52c354fce18c03978be2420b2a73f4de6a;hb=ac9b96fa48d7b1eeebfda9fefa04ab74487422ef;hp=2df09e3526f38de03ee27c8528e4ce459b398a86;hpb=d2046800b5f3ab6a56c3b9a72766f5d317a235e7;p=modules%2Fgeom.git diff --git a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx index 2df09e352..27056c52c 100644 --- a/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx +++ b/src/GEOMImpl/GEOMImpl_Block6Explorer.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -61,8 +61,11 @@ #include #include +#include + #include #include +#include #include #include @@ -1197,11 +1200,70 @@ void GEOMImpl_Block6Explorer::MakeFace (const TopoDS_Wire& theWire, 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) {