From b851046de2152419176f85af43fb5c9c144e0108 Mon Sep 17 00:00:00 2001 From: Paul RASCLE Date: Fri, 27 Nov 2020 18:19:39 +0100 Subject: [PATCH] comments and debug traces on split polylines --- src/HYDROData/HYDROData_PolylineOperator.cxx | 7 +++--- src/HYDROData/HYDROData_TopoCurve.cxx | 23 +++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index c506dcf8..01537030 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -53,7 +53,7 @@ #include #include -//#define _DEVDEBUG_ +#define _DEVDEBUG_ #include "HYDRO_trace.hxx" #include #include @@ -247,8 +247,6 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD std::vector aSectColors; int nbSec = thePolyline->NbSections(); - - const int aPSCount = aCurves.size(); const int aTSCount = aToolCurves.size(); std::vector aResult; @@ -269,8 +267,9 @@ bool HYDROData_PolylineOperator::split( const Handle( HYDROData_Document )& theD { HYDROData_TopoCurve aCurve; DEBTRACE("Initialize curve " << aPSI); - if (!aCurve.Initialize(aCurves[aPSI])) + if (!aCurve.Initialize(aCurves[aPSI])) // empty, non manifold (or internal bug!) { + DEBTRACE("discarded curve (empty or non manifold)!"); continue; } diff --git a/src/HYDROData/HYDROData_TopoCurve.cxx b/src/HYDROData/HYDROData_TopoCurve.cxx index 23232407..54888d1c 100644 --- a/src/HYDROData/HYDROData_TopoCurve.cxx +++ b/src/HYDROData/HYDROData_TopoCurve.cxx @@ -39,7 +39,7 @@ #include #include -//#define _DEVDEBUG_ +#define _DEVDEBUG_ #include "HYDRO_trace.hxx" #include @@ -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 >& theParameters) const { - std::string brepName = "theWireToIntersect"; + std::string brepName = "theWireTool"; brepName += ".brep"; BRepTools::Write( theWire, brepName.c_str() ); -- 2.39.2