-// 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
//
// 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<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "GeomAlgoAPI_CurveBuilder.h"
#include <Precision.hxx>
-static void reorder(Handle(TColgp_HArray1OfPnt) thePoints);
+static void reorder(Handle(TColgp_HArray1OfPnt)& thePoints);
//=================================================================================================
GeomEdgePtr GeomAlgoAPI_CurveBuilder::edge(const std::list<GeomPointPtr>& thePoints,
aPoints->SetValue(i, aPoint->impl<gp_Pnt>());
}
- // 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());
}
//================ Auxiliary functions ========================================================
-void reorder(Handle(TColgp_HArray1OfPnt) thePoints)
+void reorder(Handle(TColgp_HArray1OfPnt)& thePoints)
{
if (thePoints->Length() < 3) {
return;
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();
// 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);