Salome HOME
ObjectPool and SMDS_Position
[modules/smesh.git] / src / SMESH / SMESH_Block.cxx
index 0fd49966a84c9af44cb85036dd4805043686ff51..821d8fa9f7940c3208bcad592856a7a297e86abd 100644 (file)
@@ -36,6 +36,7 @@
 #include <Extrema_ExtPC.hxx>
 #include <Extrema_POnCurv.hxx>
 #include <Geom2d_Curve.hxx>
+#include <ShapeAnalysis.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
@@ -951,23 +952,39 @@ int SMESH_Block::GetShapeIDByParams ( const gp_XYZ& theCoord )
   return id + 1; // shape ids start at 1
 }
 
-//=======================================================================
-//function : GetOrderedEdges
-//purpose  : return nb wires and a list of oredered edges
-//=======================================================================
+//================================================================================
+/*!
+ * \brief Return number of wires and a list of oredered edges.
+ *  \param theFace - the face to process
+ *  \param theFirstVertex - the vertex of the outer wire to set first in the returned
+ *         list ( theFirstVertex may be NULL )
+ *  \param theEdges - all ordered edges of theFace (outer edges goes first).
+ *  \param theNbVertexInWires - nb of vertices (== nb of edges) in each wire
+ *  \param theShapeAnalysisAlgo - if true, ShapeAnalysis::OuterWire() is used to find
+ *         the outer wire else BRepTools::OuterWire() is used.
+ *  \retval int - nb of wires
+ * 
+ * Always try to set a seam edge first.
+ * BRepTools::OuterWire() fails e.g. in the case of issue 0020184,
+ * ShapeAnalysis::OuterWire() fails in the case of issue 0020452
+ */
+//================================================================================
 
 int SMESH_Block::GetOrderedEdges (const TopoDS_Face&   theFace,
                                   TopoDS_Vertex        theFirstVertex,
                                   list< TopoDS_Edge >& theEdges,
-                                  list< int >  &       theNbVertexInWires)
+                                  list< int >  &       theNbVertexInWires,
+                                  const bool           theShapeAnalysisAlgo)
 {
   // put wires in a list, so that an outer wire comes first
   list<TopoDS_Wire> aWireList;
-  TopoDS_Wire anOuterWire = BRepTools::OuterWire( theFace );
-  aWireList.push_back( anOuterWire );
+  TopoDS_Wire anOuterWire =
+    theShapeAnalysisAlgo ? ShapeAnalysis::OuterWire( theFace ) : BRepTools::OuterWire( theFace );
   for ( TopoDS_Iterator wIt (theFace); wIt.More(); wIt.Next() )
     if ( !anOuterWire.IsSame( wIt.Value() ))
       aWireList.push_back( TopoDS::Wire( wIt.Value() ));
+    else
+      aWireList.push_front( TopoDS::Wire( wIt.Value() ));
 
   // loop on edges of wires
   theNbVertexInWires.clear();
@@ -979,7 +996,8 @@ int SMESH_Block::GetOrderedEdges (const TopoDS_Face&   theFace,
     for ( iE = 0; wExp.More(); wExp.Next(), iE++ )
     {
       TopoDS_Edge edge = wExp.Current();
-      edge = TopoDS::Edge( edge.Oriented( wExp.Orientation() ));
+      // commented for issue 0020557, other related ones: 0020526, PAL19080
+      // edge = TopoDS::Edge( edge.Oriented( wExp.Orientation() ));
       theEdges.push_back( edge );
     }
     theNbVertexInWires.push_back( iE );