Salome HOME
comments and debug traces on split polylines
[modules/hydro.git] / src / HYDROData / HYDROData_TopoCurve.cxx
index 2323240709a5ca436f4d7c3a041ed3de93549f0c..54888d1c532d6d60b2f30e7a69e0a17933b14f72 100644 (file)
@@ -39,7 +39,7 @@
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
 #include <TopTools_ListOfShape.hxx>
 
-//#define _DEVDEBUG_
+#define _DEVDEBUG_
 #include "HYDRO_trace.hxx"
 #include <BRepTools.hxx>
 
@@ -375,7 +375,7 @@ bool HYDROData_TopoCurve::Initialize(const TopoDS_Wire& theWire)
   TopTools_IndexedDataMapOfShapeListOfShape aVertexToEdges;
   TopExp::MapShapesAndAncestors(theWire,
     TopAbs_VERTEX, TopAbs_EDGE, aVertexToEdges);
-  const int aVCount = aVertexToEdges.Extent();
+  const int aVCount = aVertexToEdges.Extent();   // number of edges (an edge can be a spline with intermediate vertices)
   DEBTRACE("initialize VCount= "<< aVCount);
   if (aVCount == 0)
   {
@@ -404,8 +404,11 @@ bool HYDROData_TopoCurve::Initialize(const TopoDS_Wire& theWire)
       return false;
     }
   }
+  std::string brepName = "theWireToSplit";
+  brepName += ".brep";
+  BRepTools::Write( theWire, brepName.c_str() );
 
-  // Find the start.
+  // Find the start, i.e. the end which is the first vertex (or just the first vertex when closed) ==> aVN
   int aVN = 1;
   if (!isClosed)
   {
@@ -428,19 +431,19 @@ bool HYDROData_TopoCurve::Initialize(const TopoDS_Wire& theWire)
     }
   }
 
-  // Calculate the edge order.
-  TopTools_ListOfShape* aEdges = &aVertexToEdges.ChangeFromIndex(aVN);
+  // Calculate the edge order ==> list in myEdges
+  TopTools_ListOfShape* aEdges = &aVertexToEdges.ChangeFromIndex(aVN); // 1 or 2 edges from first vertex
   while (!aEdges->IsEmpty())
   {
     const TopoDS_Edge aEdge = TopoDS::Edge(aEdges->First());
     aEdges->RemoveFirst();
-    myEdges.push_back(aEdge);
+    myEdges.push_back(aEdge);                                          // add an edge in the list
     int aVN2 = aVertexToEdges.FindIndex(TopExp::FirstVertex(aEdge));
     if (aVN2 == aVN)
     {
       aVN2 = aVertexToEdges.FindIndex(TopExp::LastVertex(aEdge));
     }
-    aVN = aVN2;
+    aVN = aVN2;                                                        // next vertex
 
     aEdges = &aVertexToEdges.ChangeFromIndex(aVN2);
     const TopoDS_Edge aEdge2 = TopoDS::Edge(aEdges->First());
@@ -451,12 +454,12 @@ bool HYDROData_TopoCurve::Initialize(const TopoDS_Wire& theWire)
     else
     {
       aEdges->Clear();
-      aEdges->Append(aEdge2);
+      aEdges->Append(aEdge2);                                          // next edge
     }
   }
 
   // Check for connectedness and free vertex.
-  return aVCount - myEdges.size() == (isClosed ? 0 : 1);
+  return (aVCount - myEdges.size()) == (isClosed ? 0 : 1);
 }
 
 TopoDS_Wire HYDROData_TopoCurve::Wire() const
@@ -663,7 +666,7 @@ int HYDROData_TopoCurve::Intersect(
   const TopoDS_Wire& theWire,
   std::deque<std::list<double> >& theParameters) const
 {
-  std::string brepName = "theWireToIntersect";
+  std::string brepName = "theWireTool";
   brepName += ".brep";
   BRepTools::Write( theWire, brepName.c_str() );