- // Move the list which are after theISectionTo to correct place
- for ( int i = theISectionTo + 1, j = theISectionFrom + 1; i < aNbSect; ++i, j++ )
- {
- CurveCreator::Coordinates aPoints = getPoints( i );
- removePointsLists( i );
- addPoints( aPoints, j );
- }
+ setPolylineShape( aShape );
+}
+
+/**
+ * Returns true if polyline is closed
+ */
+bool HYDROData_PolylineXY::IsClosed() const
+{
+ NCollection_Sequence<TCollection_AsciiString> aSectNames;
+ NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
+ NCollection_Sequence<bool> aSectClosures;
+ GetSections( aSectNames, aSectTypes, aSectClosures );
+ if( aSectNames.IsEmpty() )
+ return false;
+
+ bool anIsClosed = true;
+ for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i )
+ anIsClosed = anIsClosed && aSectClosures.Value( i );
+
+ return anIsClosed;
+}
+
+double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
+ const int thePointIndex ) const
+{
+ double aResDistance = -1;
+ if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
+ return aResDistance;
+
+ if ( thePointIndex == 0 )
+ return 0.0;
+
+ SectionType aSectionType = GetSectionType( theSectionIndex );
+ bool anIsSectionClosed = IsClosedSection( theSectionIndex );
+ PointsList aSectPointsList = GetPoints( theSectionIndex );
+ if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
+ return aResDistance;
+
+ if ( aSectionType == SECTION_POLYLINE )
+ {
+ aResDistance = 0.0;
+
+ Point aPrevPoint = aSectPointsList.Value( 1 );
+ for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
+ {
+ const Point& aSectPoint = aSectPointsList.Value( i );
+ aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
+ aPrevPoint = aSectPoint;