From 202bc779c82dfdce91e187d0ff34824b3940ecd2 Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 21 Mar 2011 09:41:19 +0000 Subject: [PATCH] IMP 21044 --- src/GEOMImpl/GEOMImpl_SplineDriver.cxx | 29 +++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx index 8b051493c..c8684cb19 100644 --- a/src/GEOMImpl/GEOMImpl_SplineDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_SplineDriver.cxx @@ -126,9 +126,35 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const } else { //GeomAPI_PointsToBSpline GBC (CurvePoints); //aShape = BRepBuilderAPI_MakeEdge(GBC).Edge(); + Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aLen); + if (aCI.GetDoReordering()) { - // TODO + for (int curInd = 1; curInd < aLen - 1; curInd++) { + gp_Pnt curPnt = CurvePoints.Value(curInd); + int nearInd = 0; + double nearDist = RealLast(); + for (ind = curInd + 1; ind <= aLen; ind++) { + double dist = curPnt.SquareDistance(CurvePoints.Value(ind)); + if (dist < nearDist && (nearDist - dist) > Precision::Confusion()) { + nearInd = ind; + nearDist = dist; + } + } + if (nearInd > 0 && nearInd != curInd + 1) { + // Keep given order of points to use it in case of equidistant candidates + // .-<---<-. + // / \ + // o o o c o->o->o->o->n o o + // | | | + // curInd curInd+1 nearInd + gp_Pnt nearPnt = CurvePoints.Value(nearInd); + for (ind = nearInd; ind > curInd + 1; ind--) { + CurvePoints.SetValue(ind, CurvePoints.Value(ind - 1)); + } + CurvePoints.SetValue(curInd + 1, nearPnt); + } + } for (ind = 1; ind <= aLen; ind++) { aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); } @@ -138,6 +164,7 @@ Standard_Integer GEOMImpl_SplineDriver::Execute(TFunction_Logbook& log) const aHCurvePoints->SetValue(ind, CurvePoints.Value(ind)); } } + bool isClosed = aCI.GetIsClosed(); GeomAPI_Interpolate GBC (aHCurvePoints, isClosed, gp::Resolution()); GBC.Perform(); -- 2.39.2