From 359cdde7edcdde86af2a058b56a2a18e2a2118eb Mon Sep 17 00:00:00 2001 From: razmyslovich Date: Mon, 12 Sep 2016 12:52:36 +0200 Subject: [PATCH] 0027358: ShapeAnalysis_Curve::GetSamplePoints iteration logic isn't robust The iterating logic in ShapeAnalysis_Curve::GetSamplePoints() is made more robust: instead of iterative incrementing parameter by adding step, parameter at each point is calculated independently from index. This avoids possible accumulation of numeric errors, and ensures that generated points are equally spaced and their quantity is respected in all cases. --- src/ShapeAnalysis/ShapeAnalysis_Curve.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx b/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx index e33ae0eb04..d97d1f452e 100644 --- a/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx +++ b/src/ShapeAnalysis/ShapeAnalysis_Curve.cxx @@ -1070,9 +1070,8 @@ Standard_Boolean ShapeAnalysis_Curve::GetSamplePoints (const Handle(Geom_Curve)& GeomAdaptor_Curve GAC(curve); Standard_Real step = ( last - first ) / (Standard_Real)( nbp - 1 ); - Standard_Real par = first, stop = last - 0.5 * step; - for ( ; par < stop; par += step ) - seq.Append(GAC.Value(par)); + for (Standard_Integer i = 0; i < nbp - 1; ++i) + seq.Append(GAC.Value(first + step * i)); seq.Append(GAC.Value(last)); return Standard_True; } @@ -1093,9 +1092,8 @@ Standard_Boolean ShapeAnalysis_Curve::GetSamplePoints (const Handle(Geom2d_Curve //-- Attention aux bsplines rationnelles de degree 3. (bouts de cercles entre autres) if (nbs > 2) nbs*=4; Standard_Real step = ( last - first ) / (Standard_Real)( nbs - 1 ); - Standard_Real par = first, stop = last - 0.5 * step; - for ( ; par < stop; par += step ) - seq.Append(C.Value(par)); + for (Standard_Integer i = 0; i < nbs - 1; ++i) + seq.Append(C.Value(first + step * i)); seq.Append(C.Value(last)); return Standard_True; /*