X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_CurveBuilder.cpp;h=ffec79e30a7aeed5a2549ded6b41cb449e35daa4;hb=09365c927ebe8d881de2eda7f96bc33a2d9511c8;hp=04966cbd655d14b0e8215592c79127d25687e408;hpb=704b13912d9014fca20c36fe91a389b9d12353e8;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_CurveBuilder.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_CurveBuilder.cpp index 04966cbd6..ffec79e30 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_CurveBuilder.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_CurveBuilder.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "GeomAlgoAPI_CurveBuilder.h" @@ -35,7 +34,7 @@ #include -static void reorder(Handle(TColgp_HArray1OfPnt) thePoints); +static void reorder(Handle(TColgp_HArray1OfPnt)& thePoints); //================================================================================================= GeomEdgePtr GeomAlgoAPI_CurveBuilder::edge(const std::list& thePoints, @@ -52,17 +51,17 @@ GeomEdgePtr GeomAlgoAPI_CurveBuilder::edge(const std::list& thePoi aPoints->SetValue(i, aPoint->impl()); } - // Reorder points if required - if (theIsToReorder) { - reorder(aPoints); - } - // If the curve to be closed - remove last point if it is too close to the first one bool isClose = aPoints->First().Distance(aPoints->Last()) <= gp::Resolution(); if (isClose && theIsClosed) { aPoints->Resize(aPoints->Lower(), aPoints->Upper() - 1, Standard_True); } + // Reorder points if required + if (theIsToReorder) { + reorder(aPoints); + } + // Initialize interpolator GeomAPI_Interpolate anInterp(aPoints, theIsClosed, gp::Resolution()); @@ -94,7 +93,7 @@ GeomEdgePtr GeomAlgoAPI_CurveBuilder::edge(const std::list& thePoi } //================ Auxiliary functions ======================================================== -void reorder(Handle(TColgp_HArray1OfPnt) thePoints) +void reorder(Handle(TColgp_HArray1OfPnt)& thePoints) { if (thePoints->Length() < 3) { return; @@ -103,7 +102,7 @@ void reorder(Handle(TColgp_HArray1OfPnt) thePoints) int aNbPoints = thePoints->Length(); int aNbDup = 0; gp_Pnt aPrevPnt = thePoints->Value(1); - for (int i = 1; i < aNbPoints - 1; i++) { + for (int i = 1; i < aNbPoints; i++) { gp_Pnt aPnt = thePoints->Value(i); int aNearest = 0; double aMinDist = RealLast(); @@ -118,7 +117,7 @@ void reorder(Handle(TColgp_HArray1OfPnt) thePoints) // Keep given order of points to use it in case of equidistant candidates // .-<---<-. // / \ - // o o o c o->o->o->o->n o o + // o o o c o->o->o->o->n o o // | | | // i i+1 nearest gp_Pnt aNearestPnt = thePoints->Value(aNearest);