]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
linear stream interpolator : insertPoints() : deny to add more points than needed
authorisn <isn@opencascade.com>
Fri, 7 Jun 2019 14:16:06 +0000 (17:16 +0300)
committerisn <isn@opencascade.com>
Fri, 7 Jun 2019 14:17:14 +0000 (17:17 +0300)
src/HYDROData/HYDROData_StreamLinearInterpolation.cxx

index 68a06bac127b06c3d290ff82894f98035755ee6a..23eab97ec0a30466d10ae142e26394099fac8f1f 100644 (file)
@@ -107,7 +107,7 @@ static void GetMaxDist(const std::vector<gp_Pnt2d>& PNTS,
 static void InsertPoints(std::vector<gp_Pnt2d>& points, int nbpoints)
 {
   points.reserve(points.size() + nbpoints);
-  while (nbpoints)
+  while (nbpoints>0)
   {
     double dmax=0, dmax2=0;
     int imax=-1;
@@ -124,6 +124,8 @@ static void InsertPoints(std::vector<gp_Pnt2d>& points, int nbpoints)
     double Y0 = p1.Y();
     double X1 = p2.X();
     double Y1 = p2.Y();
+    if (nbPins>nbpoints) //deny to add more points than needed
+      nbPins = nbpoints;
     for (int i=0;i<nbPins;i++)
     {
       double t = ((double)i+1)/((double)nbPins+1);
@@ -134,6 +136,7 @@ static void InsertPoints(std::vector<gp_Pnt2d>& points, int nbpoints)
     }
     nbpoints-=nbPins;
   }
+  assert (nbpoints == 0);
 }
 
 static void PolyToCurve2d(const Handle(HYDROData_PolylineXY)& poly, Handle(Geom2d_Curve)& c2d)