From: abk Date: Tue, 30 Jun 2015 17:16:09 +0000 (+0300) Subject: The algorithm to split any curve by any point was fixed to rightly split the curve... X-Git-Tag: BR_quadtree_20150925~16^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f165c19739951b4490e4c86df56b603935fc0d16;p=modules%2Fhydro.git The algorithm to split any curve by any point was fixed to rightly split the curve if the curve is closed and the point is a vertex of the curve. --- diff --git a/src/HYDROData/HYDROData_PolylineOperator.cxx b/src/HYDROData/HYDROData_PolylineOperator.cxx index 92c766c3..acec03bc 100644 --- a/src/HYDROData/HYDROData_PolylineOperator.cxx +++ b/src/HYDROData/HYDROData_PolylineOperator.cxx @@ -49,6 +49,25 @@ template void append( std::vector& theList, const std::vector& th theList[i] = theList2[j]; } +static TopoDS_Edge ReplaceVertex( + const TopoDS_Edge& theEdge, Standard_Integer theVertexIndex) +{ + TopoDS_Vertex aVertices[] = + {TopExp::FirstVertex(theEdge), TopExp::LastVertex(theEdge)}; + const TopAbs_Orientation aOrient = theEdge.Orientation(); + if (aOrient == TopAbs_REVERSED) + { + theVertexIndex ^= 1; + } + aVertices[theVertexIndex].EmptyCopy(); + aVertices[0].Orientation(TopAbs_FORWARD); + aVertices[1].Orientation(TopAbs_REVERSED); + TopoDS_Edge aFE = TopoDS::Edge(theEdge.Oriented(TopAbs_FORWARD)); + TopoDS_Edge aNewEdge = + ShapeBuild_Edge().CopyReplaceVertices(aFE, aVertices[0], aVertices[1]); + return TopoDS::Edge(aNewEdge.Oriented(aOrient)); +} + static Standard_Boolean WireToCurve( const TopoDS_Wire& theWire, NCollection_Vector& theEdges, @@ -253,22 +272,16 @@ static void SplitCurveByPoint( aParamI ^= 1; } + NCollection_Vector* aEdges = &theEdges2; const Standard_Integer aECount = theEdges.Size(); if (aParamI == 0) { - NCollection_Vector* aEdges = (theEdgeIndex != 0) ? &theEdges1 : &theEdges2; - for (Standard_Integer aEI = theEdgeIndex; aEI < aECount; ++aEI) - { - aEdges->Append(theEdges(aEI)); - } + aEdges = (theEdgeIndex == 0) ? &theEdges1 : &theEdges2; + aEdges->Append(ReplaceVertex(aEdge, 0)); } else if (aParamI == 1) { - theEdges1.Append(aEdge); - for (Standard_Integer aEI = theEdgeIndex; aEI < aECount; ++aEI) - { - theEdges2.Append(theEdges(aEI)); - } + theEdges1.Append(ReplaceVertex(aEdge, 1)); } else { @@ -280,7 +293,6 @@ static void SplitCurveByPoint( aSplitV1, aCurve.Value(theParameter), Precision::Confusion()); BRep_Builder().MakeVertex( aSplitV2, aCurve.Value(theParameter), Precision::Confusion()); - TopoDS_Edge aEParts[] = { ShapeBuild_Edge().CopyReplaceVertices(aFE, TopoDS_Vertex(), TopoDS::Vertex(aSplitV1.Oriented(TopAbs_REVERSED))), @@ -301,11 +313,10 @@ static void SplitCurveByPoint( const Standard_Integer aFirstPI = (aOrient != TopAbs_REVERSED) ? 0 : 1; theEdges1.Append(aEParts[aFirstPI]); theEdges2.Append(aEParts[1 - aFirstPI]); - - for (Standard_Integer aEI = theEdgeIndex + 1; aEI < aECount; ++aEI) - { - theEdges2.Append(theEdges(aEI)); - } + } + for (Standard_Integer aEI = theEdgeIndex + 1; aEI < aECount; ++aEI) + { + aEdges->Append(theEdges(aEI)); } }