From 860d4b3bf29f8184da107460d756d2c4af3e18c0 Mon Sep 17 00:00:00 2001 From: mgn Date: Thu, 19 Feb 2015 17:00:52 +0300 Subject: [PATCH] Issue 0022843: EDF GEOM: [HYDRO] Polyline using a former polyline - Properly process closed polyline --- src/CurveCreator/CurveCreator_Utils.cxx | 30 +++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/CurveCreator/CurveCreator_Utils.cxx b/src/CurveCreator/CurveCreator_Utils.cxx index c999e4c48..035f0b35c 100644 --- a/src/CurveCreator/CurveCreator_Utils.cxx +++ b/src/CurveCreator/CurveCreator_Utils.cxx @@ -841,7 +841,8 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints anExp.Next(); - if (IsBSpline) { + if (IsBSpline) + { // There should be a single BSpline curve in the wire. if (anExp.More()) { return aResult; @@ -869,16 +870,20 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints IsClosed = aV[0].IsSame(aV[1]) ? true : false; - const Standard_Integer aNbPoints = aBSplCurve->NbKnots(); - TColStd_Array1OfReal aKnots(1, aNbPoints); - + Standard_Integer aNbPoints = aBSplCurve->NbKnots(); + TColStd_Array1OfReal aKnots(1, aNbPoints); aBSplCurve->Knots(aKnots); - aResult = new TColgp_HArray1OfPnt(1, aBSplCurve->NbKnots()); - for (i = aKnots.Lower(); i <= aKnots.Upper(); ++i) { - aResult->SetValue(i, aBSplCurve->Value(aKnots.Value(i))); - } - } else { + // Don't consider the last point as it coincides with the first + if (IsClosed) + --aNbPoints; + + aResult = new TColgp_HArray1OfPnt(1, aNbPoints); + for (i = 1; i <= aNbPoints; ++i) + aResult->SetValue(i, aBSplCurve->Value( aKnots.Value(i) )); + } + else + { // This is a polyline. TopTools_ListOfShape aVertices; Standard_Integer aNbVtx = 1; @@ -910,6 +915,13 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints IsClosed = aFirstVtx.IsSame(aLastVtx) ? true : false; + // Store a last vertex + if (!IsClosed) + { + aVertices.Append(aLastVtx); + aNbVtx++; + } + // Fill the array of points. aResult = new TColgp_HArray1OfPnt(1, aNbVtx); -- 2.39.2