Salome HOME
updated copyright message
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_CurveBuilder.cpp
index 2ec8797c6662dc0f30f3a9ab4e1d4fa817f0f316..c24b3bc810d09fdd8972a08a057499c7c07c4b18 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -172,7 +172,6 @@ void GeomAlgoAPI_CurveBuilder::reorderPoints(std::list<GeomPointPtr>& thePoints)
     return;
   }
 
-  int aNbDup = 0;
   std::list<GeomPointPtr>::iterator aPIt = thePoints.begin();
   GeomPointPtr aPrevPnt = *aPIt;
   for (; aPIt != thePoints.end(); ++aPIt) {
@@ -186,6 +185,8 @@ void GeomAlgoAPI_CurveBuilder::reorderPoints(std::list<GeomPointPtr>& thePoints)
         // remove duplicates
         std::list<GeomPointPtr>::iterator aRemoveIt = aNextIt++;
         thePoints.erase(aRemoveIt);
+        // update iterator showing the nearest point, because it may become invalid
+        aNearestIt = aPIt; ++aNearestIt;
         continue;
       }
       if (aDist < aMinDist && (aMinDist - aDist) > Precision::Confusion()) {
@@ -197,8 +198,8 @@ void GeomAlgoAPI_CurveBuilder::reorderPoints(std::list<GeomPointPtr>& thePoints)
     aNextIt = aPIt; ++aNextIt;
     if (aNearestIt != aNextIt) {
       // Keep given order of points to use it in case of equidistant candidates
-      //               .-<---<-.
-      //              /         \
+      //              .--<---<--.
+      //             |           |
       // o  o  o  c  o->o->o->o->n  o  o
       //          |  |           |
       //          i i+1       nearest