#include <HYDROGUI_CurveCreatorProfile.h>
#include <CurveCreator_Displayer.hxx>
#include <CurveCreator_Section.hxx>
+#include <QVector>
HYDROGUI_CurveCreatorProfile::HYDROGUI_CurveCreatorProfile()
: CurveCreator_Curve( CurveCreator::Dim2d )
aSection->myIsClosed = false;
mySections.push_back( aSection );
+ mySkipSorting = true;
}
HYDROGUI_CurveCreatorProfile::~HYDROGUI_CurveCreatorProfile()
bool HYDROGUI_CurveCreatorProfile::canPointsBeSorted()
{
- return true;
+ return false;
}
/**
return CurveCreator_Curve::addPoints( theCoords, theISection, anIPnt );
}
+
+bool ULess( const gp_Pnt& p1, const gp_Pnt& p2 )
+{
+ return p1.X() < p2.X();
+}
+
+Handle(TColgp_HArray1OfPnt) HYDROGUI_CurveCreatorProfile::GetDifferentPoints( int theISection ) const
+{
+ Handle(TColgp_HArray1OfPnt) points = CurveCreator_Curve::GetDifferentPoints( theISection );
+ if( points.IsNull() )
+ return points;
+
+ QVector<gp_Pnt> vpoints( points->Size() );
+ for( int i=points->Lower(), j=0, n=points->Upper(); i<=n; i++, j++ )
+ vpoints[j] = points->Value( i );
+
+ qSort( vpoints.begin(), vpoints.end(), ULess );
+
+ for( int i=points->Lower(), j=0, n=points->Upper(); i<=n; i++, j++ )
+ points->SetValue( i, vpoints[j] );
+
+ return points;
+}
aPolylineObj->AddSection( aSectName, aSectType, aSectClosure );
- // Add the points fro section
- CurveCreator::Coordinates aCurveCoords = myCurve->getPoints( i );
+ // Add the points from section
+ CurveCreator::Coordinates aCurveCoords = myCurve->getCoords( i );
if ( aCurveCoords.size() <= 2 )
{
HYDROData_ProfileUZ::PointsList aProfileParamPoints;
- CurveCreator::Coordinates aCurveCoords = myProfile->getPoints( 0 );
- if ( aCurveCoords.size() <= 2 )
+ Handle(TColgp_HArray1OfPnt) aCurveCoords = myProfile->GetDifferentPoints( 0 );
+ if ( aCurveCoords.IsNull() || aCurveCoords->Size() <= 2 )
{
theErrorMsg = tr( "NUMBER_OF_PROFILE_POINTS_INCORRECT" );
return false;
}
- for ( int k = 0 ; k + 1 < aCurveCoords.size() ; k++ )
+ for ( int k = aCurveCoords->Lower(); k <= aCurveCoords->Upper() ; k++ )
{
HYDROData_ProfileUZ::Point aProfileParamPoint;
- aProfileParamPoint.SetX( aCurveCoords.at( k ) );
- k++;
- aProfileParamPoint.SetY( aCurveCoords.at( k ) );
+ aProfileParamPoint.SetX( aCurveCoords->Value( k ).X() );
+ aProfileParamPoint.SetY( aCurveCoords->Value( k ).Y() );
aProfileParamPoints.Append( aProfileParamPoint );
}