Salome HOME
Comments moved.
[modules/hydro.git] / src / HYDROData / HYDROData_BSplineOperation.cxx
index 293dbd442b6c6032e802982bbf1b17e46f87ffca..97fd9a57ffc5e6cb860b4b2435d2a4ef9cf5cee1 100644 (file)
 
 HYDROData_BSplineOperation::HYDROData_BSplineOperation(
   const NCollection_Sequence<gp_XYZ>& thePoints,
-  const bool                          theIsClosed )
+  const bool                          theIsClosed,
+  const double                        theTolerance )
 {
-  // fill array for algorithm by the received coordinates
+  // skip equal points
   int aNbPoints = thePoints.Size();
+  NCollection_Sequence<gp_XYZ> aPoints;
+  if ( aNbPoints > 0 ) {
+    gp_XYZ aPrevPoint = thePoints.Value( 1 );
+    aPoints.Append( aPrevPoint );
+    for( int i = 2 ; i <= aNbPoints; ++i )
+    {
+      gp_XYZ aPoint( thePoints.Value( i ) );
+      if ( !aPoint.IsEqual( aPrevPoint, theTolerance ) )
+        aPoints.Append( aPoint );
+      aPrevPoint = aPoint;
+    }
+  }
 
+  // fill array for algorithm by the received coordinates
+  aNbPoints = aPoints.Size();
   Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt( 1, aNbPoints );
   for ( int i = 1; i <= aNbPoints; i++ )
   {
-    gp_Pnt aPnt( thePoints.Value( i ) );
+    gp_Pnt aPnt( aPoints.Value( i ) );
     aHCurvePoints->SetValue( i, aPnt );
   }