From f177d54444d1a248e4f724469682173c6b266399 Mon Sep 17 00:00:00 2001 From: abk Date: Mon, 29 Jun 2015 16:18:57 +0300 Subject: [PATCH] Algorithms to cut any closed section at any point were written. --- src/HYDROData/HYDROData_PolylineOperator.cxx | 36 ++++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index 6f8ef42a..f95789d6 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -417,6 +417,24 @@ static void CollectCurveWire( } } +static void CollectCurveWire( + const NCollection_Vector& theEdges1, + const NCollection_Vector& theEdges2, + TopoDS_Wire& theWire) +{ + BRep_Builder aBulder; + aBulder.MakeWire(theWire); + const NCollection_Vector* aEdges[] = {&theEdges1, &theEdges2}; + for (Standard_Integer aEI = 0; aEI < 2; ++aEI) + { + NCollection_Vector::Iterator aEIt(*aEdges[aEI]); + for (; aEIt.More(); aEIt.Next()) + { + aBulder.Add(theWire, aEIt.Value()); + } + } +} + std::vector HYDROData_PolylineOperator::Split( const TopoDS_Wire& theWire, const gp_Pnt2d& thePoint, double theTolerance ) @@ -450,14 +468,20 @@ std::vector HYDROData_PolylineOperator::Split( const TopoDS_Wire& NCollection_Vector aEdges1, aEdges2; SplitCurveByPoint(aEdges, aSEI, aSParam, aEdges1, aEdges2); TopoDS_Wire aWire; - CollectCurveWire(aEdges1, aWire); - aResult.push_back(aWire); - if (!aEdges2.IsEmpty()) + if (!isClosed) { - CollectCurveWire(aEdges2, aWire); - aResult.push_back(aWire); + CollectCurveWire(aEdges1, aWire); + if (!aEdges2.IsEmpty()) + { + aResult.push_back(aWire); + CollectCurveWire(aEdges2, aWire); + } } - + else + { + CollectCurveWire(aEdges2, aEdges1, aWire); + } + aResult.push_back(aWire); return aResult; } -- 2.39.2