2 #include "HYDROData_PolylineXY.h"
4 #include "HYDROData_BSplineOperation.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Tool.h"
8 #include <BRep_Builder.hxx>
9 #include <BRepBuilderAPI_MakeEdge.hxx>
10 #include <BRepBuilderAPI_MakeWire.hxx>
12 #include <GeomAPI_ProjectPointOnCurve.hxx>
13 #include <GeomAdaptor_Curve.hxx>
15 #include <GCPnts_AbscissaPoint.hxx>
17 #include <ImageComposer_MetaTypes.h>
22 #include <NCollection_Map.hxx>
24 #include <TCollection_ExtendedString.hxx>
26 #include <TDataStd_ListIteratorOfListOfByte.hxx>
27 #include <TColStd_ListIteratorOfListOfInteger.hxx>
28 #include <TColStd_ListIteratorOfListOfReal.hxx>
30 #include <TDataStd_BooleanList.hxx>
31 #include <TDataStd_ExtStringList.hxx>
32 #include <TDataStd_IntegerList.hxx>
33 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
34 #include <TDataStd_RealList.hxx>
36 #include <TopTools_ListIteratorOfListOfShape.hxx>
38 #include <QPainterPath>
41 #define PYTHON_POLYLINEXY_ID "KIND_POLYLINEXY"
43 const double LOCAL_SELECTION_TOLERANCE = 0.0001;
45 IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
46 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
48 HYDROData_PolylineXY::HYDROData_PolylineXY()
49 : HYDROData_IPolyline()
53 HYDROData_PolylineXY::~HYDROData_PolylineXY()
57 QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
61 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
62 if ( aDocument.IsNull() )
65 QString aDocName = aDocument->GetDocPyName();
66 QString aPolylineName = GetName();
68 aResList << QString( "%1 = %2.CreateObject( %3 );" )
69 .arg( aPolylineName ).arg( aDocName ).arg( PYTHON_POLYLINEXY_ID );
70 aResList << QString( "%1.SetName( \"%1\" );" ).arg( aPolylineName );
73 NCollection_Sequence<TCollection_AsciiString> aSectNames;
74 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
75 NCollection_Sequence<bool> aSectClosures;
76 GetSections( aSectNames, aSectTypes, aSectClosures );
78 for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
80 const TCollection_AsciiString& aSectName = aSectNames.Value( i );
81 const SectionType& aSectType = aSectTypes.Value( i );
82 bool aSectClosure = aSectClosures.Value( i );
84 aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName )
85 .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
87 HYDROData_PolylineXY::PointsList aSectPointsList = GetPoints( i );
88 for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
90 const Point& aSectPoint = aSectPointsList.Value( k );
92 aResList << QString( "%1.AddPoint( %2, QPointF( %3, %4 ) );" ).arg( aPolylineName )
93 .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() );
100 QVariant HYDROData_PolylineXY::GetDataVariant()
102 QPainterPath aPath = GetPainterPath();
105 aVarData.setValue<QPainterPath>( aPath );
110 TopoDS_Shape HYDROData_PolylineXY::GetShape()
112 return getPolylineShape();
115 TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& theType,
116 const bool& theIsClosed,
117 const NCollection_Sequence<gp_XYZ>& thePoints )
119 BRepBuilderAPI_MakeWire aMakeWire;
121 if( theType == SECTION_POLYLINE )
123 for( int i = 1, n = thePoints.Size(); i <= n; ++i )
125 const gp_XYZ& aFirstPoint = thePoints.Value( i );
131 aLastPoint = thePoints.Value( 1 );
137 aLastPoint = thePoints.Value( i + 1 );
140 gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z() );
141 gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), aLastPoint.Z() );
143 if ( aPnt1.IsEqual( aPnt2, LOCAL_SELECTION_TOLERANCE ) )
146 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
147 aMakeWire.Add( anEdge );
150 else //if( theType == PolylineSection::SECTION_SPLINE )
152 HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
154 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
155 aMakeWire.Add( anEdge );
160 if ( aMakeWire.IsDone() )
166 void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& thePath,
167 const SectionType& theType,
168 const bool& theIsClosed,
169 const NCollection_Sequence<gp_XYZ>& thePoints )
171 if ( thePoints.IsEmpty() )
174 if ( theType == SECTION_POLYLINE )
176 const gp_XYZ& aFirstPoint = thePoints.Value( 1 );
177 thePath.moveTo( aFirstPoint.X(), aFirstPoint.Y() );
179 for( int i = 2, n = thePoints.Size(); i <= n; ++i )
181 const gp_XYZ& aSectPoint = thePoints.Value( i );
183 thePath.lineTo( aSectPoint.X(), aSectPoint.Y() );
187 thePath.closeSubpath();
191 HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
192 aBSpline.ComputePath( thePath );
196 void HYDROData_PolylineXY::Update()
198 HYDROData_IPolyline::Update();
200 NCollection_Sequence<TCollection_AsciiString> aSectNames;
201 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
202 NCollection_Sequence<bool> aSectClosures;
203 GetSections( aSectNames, aSectTypes, aSectClosures );
205 BRepBuilderAPI_MakeWire aMakeWire;
207 TopTools_ListOfShape aSectionWiresList;
209 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
211 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
212 SectionType aSectionType = aSectTypes.Value( aSectionId );
213 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
215 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
216 if ( aSectPointsList.IsEmpty() )
219 NCollection_Sequence<gp_XYZ> aPoints;
220 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
222 const Point& aSectPoint = aSectPointsList.Value( i );
224 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
225 aPoints.Append( aPoint );
228 TopoDS_Wire aSectionWire = BuildWire( aSectionType, anIsSectionClosed, aPoints );
229 aSectionWiresList.Append( aSectionWire );
230 aMakeWire.Add( aSectionWire );
235 if ( aMakeWire.IsDone() )
237 aShape = aMakeWire.Shape();
239 else if ( !aSectionWiresList.IsEmpty() )
242 TopoDS_Compound aCompound;
244 BRep_Builder aBuilder;
245 aBuilder.MakeCompound( aCompound );
247 TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
248 for ( ; anIter.More(); anIter.Next() )
250 aBuilder.Add( aCompound, anIter.Value() );
256 setPolylineShape( aShape );
260 * Returns true if polyline is closed
262 bool HYDROData_PolylineXY::IsClosed() const
264 NCollection_Sequence<TCollection_AsciiString> aSectNames;
265 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
266 NCollection_Sequence<bool> aSectClosures;
267 GetSections( aSectNames, aSectTypes, aSectClosures );
268 if( aSectNames.IsEmpty() )
271 bool anIsClosed = true;
272 for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i )
273 anIsClosed = anIsClosed && aSectClosures.Value( i );
278 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
279 const int thePointIndex ) const
281 double aResDistance = -1;
282 if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
285 if ( thePointIndex == 0 )
288 SectionType aSectionType = GetSectionType( theSectionIndex );
289 bool anIsSectionClosed = IsClosedSection( theSectionIndex );
290 PointsList aSectPointsList = GetPoints( theSectionIndex );
291 if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
294 if ( aSectionType == SECTION_POLYLINE )
298 Point aPrevPoint = aSectPointsList.Value( 1 );
299 for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
301 const Point& aSectPoint = aSectPointsList.Value( i );
302 aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
303 aPrevPoint = aSectPoint;
305 if ( thePointIndex == i - 1 )
313 int aSectNbPoints = aSectPointsList.Size();
314 NCollection_Sequence<gp_XYZ> aPoints;
315 for( int i = 1 ; i <= aSectNbPoints; ++i )
317 const Point& aSectPoint = aSectPointsList.Value( i );
319 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
320 aPoints.Append( aPoint );
322 if ( thePointIndex == i - 1 )
323 aPointToTest = aPoint;
326 HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed, LOCAL_SELECTION_TOLERANCE );
328 Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter();
329 Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter();
331 if ( thePointIndex != aSectNbPoints - 1 )
333 GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aBSpline.Curve() );
334 aSecondParam = aProject.LowerDistanceParameter();
337 GeomAdaptor_Curve anAdap( aBSpline.Curve() );
339 aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
345 int HYDROData_PolylineXY::NbSections() const
347 Handle(TDataStd_ExtStringList) aNamesList;
348 Handle(TDataStd_IntegerList) aTypesList;
349 Handle(TDataStd_BooleanList) aClosuresList;
350 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
352 return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
355 TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
357 NCollection_Map<TCollection_ExtendedString> aNamesMap;
359 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
360 for ( ; aNamesIter.More(); aNamesIter.Next() )
361 aNamesMap.Add( aNamesIter.Value() );
363 TCollection_ExtendedString aResName;
368 aResName = "Section_" + aPrefIdx;
371 while ( aNamesMap.Contains( aResName ) );
376 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
377 const SectionType theSectionType,
378 const bool theIsClosed )
380 Handle(TDataStd_ExtStringList) aNamesList;
381 Handle(TDataStd_IntegerList) aTypesList;
382 Handle(TDataStd_BooleanList) aClosuresList;
383 getSectionsLists( aNamesList, aTypesList, aClosuresList );
385 TCollection_ExtendedString aSectName( theSectName );
386 if ( aSectName.Length() <= 0 )
387 aSectName = getUniqueSectionName( aNamesList );
389 aNamesList->Append( aSectName );
390 aTypesList->Append( theSectionType );
391 aClosuresList->Append( theIsClosed );
396 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
398 TCollection_AsciiString aResName;
400 Handle(TDataStd_ExtStringList) aNamesList;
401 Handle(TDataStd_IntegerList) aTypesList;
402 Handle(TDataStd_BooleanList) aClosuresList;
403 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
404 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
407 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
408 for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
410 if ( aNamesIter.More() )
411 aResName = aNamesIter.Value();
416 void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex,
417 const TCollection_AsciiString& theSectionName )
419 Handle(TDataStd_ExtStringList) aNamesList;
420 Handle(TDataStd_IntegerList) aTypesList;
421 Handle(TDataStd_BooleanList) aClosuresList;
422 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
423 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
426 TDataStd_ListOfExtendedString anOldNamesList;
427 anOldNamesList = aNamesList->List();
429 // Refill the existing list
432 TCollection_ExtendedString aNewSectName = theSectionName;
434 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
435 for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
436 aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
441 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
443 Handle(TDataStd_ExtStringList) aNamesList;
444 Handle(TDataStd_IntegerList) aTypesList;
445 Handle(TDataStd_BooleanList) aClosuresList;
446 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
447 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
448 return SECTION_POLYLINE;
450 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
451 for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
453 return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
456 void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex,
457 const SectionType theSectionType )
459 Handle(TDataStd_ExtStringList) aNamesList;
460 Handle(TDataStd_IntegerList) aTypesList;
461 Handle(TDataStd_BooleanList) aClosuresList;
462 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
463 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
466 TColStd_ListOfInteger anOldTypesList;
467 anOldTypesList = aTypesList->List();
469 // Refill the existing list
472 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
473 for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
474 aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
479 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
481 Handle(TDataStd_ExtStringList) aNamesList;
482 Handle(TDataStd_IntegerList) aTypesList;
483 Handle(TDataStd_BooleanList) aClosuresList;
484 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
485 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
488 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
489 for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
491 return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
494 void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex,
495 const bool theIsClosed )
497 Handle(TDataStd_ExtStringList) aNamesList;
498 Handle(TDataStd_IntegerList) aTypesList;
499 Handle(TDataStd_BooleanList) aClosuresList;
500 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
501 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
504 TDataStd_ListOfByte anOldClosuresList;
505 anOldClosuresList = aClosuresList->List();
507 // Refill the existing list
508 aClosuresList->Clear();
510 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
511 for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
512 aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
517 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
518 NCollection_Sequence<SectionType>& theSectTypes,
519 NCollection_Sequence<bool>& theSectClosures ) const
521 theSectNames.Clear();
522 theSectTypes.Clear();
523 theSectClosures.Clear();
525 Handle(TDataStd_ExtStringList) aNamesList;
526 Handle(TDataStd_IntegerList) aTypesList;
527 Handle(TDataStd_BooleanList) aClosuresList;
528 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
529 if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
532 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
533 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
534 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
535 for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
536 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
538 const TCollection_ExtendedString& aSectName = aNamesIter.Value();
539 SectionType aSectType = (SectionType)aTypesIter.Value();
540 bool aSectClosures = aClosuresIter.Value();
542 theSectNames.Append( aSectName );
543 theSectTypes.Append( aSectType );
544 theSectClosures.Append( aSectClosures );
548 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
550 Handle(TDataStd_ExtStringList) aNamesList;
551 Handle(TDataStd_IntegerList) aTypesList;
552 Handle(TDataStd_BooleanList) aClosuresList;
553 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
554 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
557 if ( aNamesList->Extent() == 1 )
559 removeSectionsLists();
564 TDataStd_ListOfExtendedString anOldNamesList;
565 anOldNamesList = aNamesList->List();
567 TColStd_ListOfInteger anOldTypesList;
568 anOldTypesList = aTypesList->List();
570 TDataStd_ListOfByte anOldClosuresList;
571 anOldClosuresList = aClosuresList->List();
573 // Refill the existing lists
576 aClosuresList->Clear();
578 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
579 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
580 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
581 for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
582 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
584 if ( i == theSectionIndex )
585 continue; // skip index to remove
587 aNamesList->Append( aNamesIter.Value() );
588 aTypesList->Append( aTypesIter.Value() );
589 aClosuresList->Append( (bool)aClosuresIter.Value() );
592 // Remove points that belongs to removed section
593 removePointsLists( theSectionIndex );
599 void HYDROData_PolylineXY::RemoveSections()
601 removeSectionsLists();
606 void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
607 const Point& thePoint,
608 const int thePointIndex )
610 Handle(TDataStd_RealList) aListX, aListY;
611 getPointsLists( theSectionIndex, aListX, aListY );
613 if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
615 aListX->Append( thePoint.X() );
616 aListY->Append( thePoint.Y() );
620 TColStd_ListOfReal anOldListX;
621 anOldListX = aListX->List();
623 TColStd_ListOfReal anOldListY;
624 anOldListY = aListY->List();
626 // Refill the existing lists
630 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
631 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
632 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
634 double aCoordX = anIterX.Value();
635 double aCoordY = anIterY.Value();
637 if ( i == thePointIndex )
639 // Insert our new point
640 aListX->Append( thePoint.X() );
641 aListY->Append( thePoint.Y() );
644 aListX->Append( aCoordX );
645 aListY->Append( aCoordY );
652 void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
653 const Point& thePoint,
654 const int thePointIndex )
656 Handle(TDataStd_RealList) aListX, aListY;
657 getPointsLists( theSectionIndex, aListX, aListY );
659 if ( thePointIndex < 0 )
661 aListX->Prepend( thePoint.X() );
662 aListY->Prepend( thePoint.Y() );
664 else if ( thePointIndex >= aListX->Extent() )
666 aListX->Append( thePoint.X() );
667 aListY->Append( thePoint.Y() );
671 TColStd_ListOfReal anOldListX;
672 anOldListX = aListX->List();
674 TColStd_ListOfReal anOldListY;
675 anOldListY = aListY->List();
677 // Refill the existing lists
681 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
682 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
683 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
685 double aCoordX = anIterX.Value();
686 double aCoordY = anIterY.Value();
688 if ( i == thePointIndex )
690 // Insert our new point instead of old one
691 aCoordX = thePoint.X();
692 aCoordY = thePoint.Y();
695 aListX->Append( aCoordX );
696 aListY->Append( aCoordY );
703 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
704 const int thePointIndex )
706 Handle(TDataStd_RealList) aListX, aListY;
707 getPointsLists( theSectionIndex, aListX, aListY, false );
708 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
711 if ( aListX->Extent() == 1 )
713 removePointsLists( theSectionIndex );
717 TColStd_ListOfReal anOldListX;
718 anOldListX = aListX->List();
720 TColStd_ListOfReal anOldListY;
721 anOldListY = aListY->List();
723 // Refill the existing lists
727 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
728 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
729 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
731 if ( i == thePointIndex )
732 continue; // skip index to remove
734 aListX->Append( anIterX.Value() );
735 aListY->Append( anIterY.Value() );
742 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const
746 Handle(TDataStd_RealList) aListX, aListY;
747 getPointsLists( theSectionIndex, aListX, aListY, false );
748 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
751 TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
752 TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
753 for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
755 Point aPoint( anIterX.Value(), anIterY.Value() );
756 aResList.Append( aPoint );
762 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
766 NCollection_Sequence<TCollection_AsciiString> aSectNames;
767 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
768 NCollection_Sequence<bool> aSectClosures;
769 GetSections( aSectNames, aSectTypes, aSectClosures );
771 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
773 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
774 SectionType aSectionType = aSectTypes.Value( aSectionId );
775 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
777 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
778 if ( aSectPointsList.IsEmpty() )
781 NCollection_Sequence<gp_XYZ> aPoints;
782 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
784 const Point& aSectPoint = aSectPointsList.Value( i );
786 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
787 aPoints.Append( aPoint );
790 BuildPainterPath( aPath, aSectionType, anIsSectionClosed, aPoints );