Salome HOME
Issue #19725: Error when loading python dump
[modules/shaper.git] / src / GeomAPI / GeomAPI_BSpline2d.cpp
index 5835d9707d4a06a278429c48375e45382ab0f91f..a5bd94a16b38f853ccd561543c3acf0e5db717fe 100644 (file)
@@ -48,8 +48,15 @@ static Handle_Geom2d_BSplineCurve* newBSpline2d(
     return newBSpline2d(thePoles, theWeights, theDegree, thePeriodic);
 
   int anAuxPole = 0;
-  if (thePeriodic && thePoles.front()->distance(thePoles.back()) < Precision::Confusion())
-    anAuxPole = -1;
+  if (thePeriodic && thePoles.front()->distance(thePoles.back()) < Precision::Confusion()) {
+    // additionally check the number of poles is greater than needed for th periodic B-spline
+    int aNbPoles = 0;
+    std::list<int>::const_iterator it = theMults.begin();
+    for (++it; it != theMults.end(); ++it)
+      aNbPoles += *it;
+    if ((int)thePoles.size() > aNbPoles)
+      anAuxPole = -1;
+  }
 
   // collect arrays of poles, weights, knots and multiplicities
   TColgp_Array1OfPnt2d aPoles(1, (int)thePoles.size() + anAuxPole);