+ // sort normalized params, taking into account theReverse
+ TColStd_SequenceOfReal Params;
+ double tol = 1e-7 / theLength; // GCPnts_UniformAbscissa allows u2-u1 > 1e-7
+ for ( size_t i = 0; i < aPnts.size(); i++ )
+ {
+ if( aPnts[i] < tol || aPnts[i] > 1 - tol )
+ continue;
+ double u = theReverse ? ( 1 - aPnts[i] ) : aPnts[i];
+ int j = 1;
+ bool IsExist = false;
+ for ( ; j <= Params.Length(); j++ ) {
+ if ( Abs( u - Params.Value(j) ) < tol ) {
+ IsExist = true;
+ break;
+ }
+ if ( u < Params.Value(j) ) break;
+ }
+ if ( !IsExist ) Params.InsertBefore( j, u );
+ }
+
+ // transform normalized Params into real ones
+ std::vector< double > uVec( Params.Length() + 2 );
+ uVec[ 0 ] = theFirstU;
+ double abscissa;
+ for ( int i = 1; i <= Params.Length(); i++ )
+ {
+ abscissa = Params( i ) * theLength;
+ tol = Min( Precision::Confusion(), 0.01 * abscissa );
+ GCPnts_AbscissaPoint APnt( tol, theC3d, abscissa, theFirstU );
+ if ( !APnt.IsDone() )
+ return error( "GCPnts_AbscissaPoint failed");
+ uVec[ i ] = APnt.Parameter();
+ }
+ uVec.back() = theLastU;
+
+ // divide segments
+ if ( theReverse )
+ {
+ if ((int) nbsegs.size() > Params.Length() + 1 )
+ nbsegs.resize( Params.Length() + 1 );
+ std::reverse( nbsegs.begin(), nbsegs.end() );
+ }
+ if ( nbsegs.empty() )
+ {
+ nbsegs.push_back( 1 );
+ }
+ Params.InsertBefore( 1, 0.0 );
+ Params.Append( 1.0 );
+ double eltSize, segmentSize, par1, par2;
+ for ( size_t i = 0; i < uVec.size()-1; i++ )
+ {
+ par1 = uVec[ i ];
+ par2 = uVec[ i+1 ];
+ int nbseg = ( i < nbsegs.size() ) ? nbsegs[i] : nbsegs[0];
+ if ( nbseg == 1 )
+ {
+ theParams.push_back( par2 );
+ }
+ else
+ {
+ segmentSize = ( Params( i+2 ) - Params( i+1 )) * theLength;
+ eltSize = segmentSize / nbseg;
+ tol = Min( Precision::Confusion(), 0.01 * eltSize );
+ GCPnts_UniformAbscissa Discret( theC3d, eltSize, par1, par2, tol );
+ if ( !Discret.IsDone() )
+ return error( "GCPnts_UniformAbscissa failed");
+ if ( Discret.NbPoints() < nbseg + 1 ) {
+ eltSize = segmentSize / ( nbseg + 0.5 );
+ Discret.Initialize( theC3d, eltSize, par1, par2, tol );
+ }
+ int NbPoints = Discret.NbPoints();
+ for ( int i = 2; i <= NbPoints; i++ ) {
+ double param = Discret.Parameter(i);
+ theParams.push_back( param );
+ }
+ }
+ }
+ theParams.pop_back();
+
+ return true;
+ }
+
+ case DEFLECTION:
+ {
+ GCPnts_UniformDeflection Discret( theC3d, _value[ DEFLECTION_IND ], f, l, true );