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 );
}
//! Creates a spline by list of coordinates: pairs X and Y
//! \param thePoints coordinates of curve
//! \param theIsClosed flag indicating that the result spline should be closed
+ //! \param theTolerance flag indicating the tolerance to skip equal points
HYDROData_BSplineOperation( const NCollection_Sequence<gp_XYZ>& thePoints,
- const bool theIsClosed );
+ const bool theIsClosed,
+ const double theTolerance );
//! Returns the BSpline curve passing through the points
//! \returns Null if Computation of BSpline was failed
}
else //if( theType == PolylineSection::SECTION_SPLINE )
{
- HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
+ HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
aMakeWire.Add( anEdge );
}
else
{
- HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
+ HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
aBSpline.ComputePath( thePath );
}
}
aPointToTest = aPoint;
}
- HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed );
+ HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE );
Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter();
Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter();
#include <gp_Pnt.hxx>
#include <QTransform>
+const double LOCAL_SELECTION_TOLERANCE = 0.0001;
+
void test_HYDROData_BSplineOperation::testCurve()
{
// prepare points: function of sin(x)
aPoints.Append( aPoint );
}
// compute BSpline
- HYDROData_BSplineOperation aBSpline( aPoints, false );
+ HYDROData_BSplineOperation aBSpline( aPoints, false, LOCAL_SELECTION_TOLERANCE );
Handle(Geom_BSplineCurve) aBS = aBSpline.Curve();
CPPUNIT_ASSERT( !aBS.IsNull() );
}
// convert to QPainterPath
- HYDROData_BSplineOperation aBSpline( aPoints, false );
+ HYDROData_BSplineOperation aBSpline( aPoints, false, LOCAL_SELECTION_TOLERANCE );
CPPUNIT_ASSERT( !aBSpline.Curve().IsNull() );