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 IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
44 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
46 HYDROData_PolylineXY::HYDROData_PolylineXY()
47 : HYDROData_IPolyline()
51 HYDROData_PolylineXY::~HYDROData_PolylineXY()
55 QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
59 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
60 if ( aDocument.IsNull() )
63 QString aDocName = aDocument->GetDocPyName();
64 QString aPolylineName = GetName();
66 aResList << QString( "%1 = %2.CreateObject( %3 );" )
67 .arg( aPolylineName ).arg( aDocName ).arg( PYTHON_POLYLINEXY_ID );
68 aResList << QString( "%1.SetName( \"%1\" );" ).arg( aPolylineName );
71 NCollection_Sequence<TCollection_AsciiString> aSectNames;
72 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
73 NCollection_Sequence<bool> aSectClosures;
74 GetSections( aSectNames, aSectTypes, aSectClosures );
76 for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
78 const TCollection_AsciiString& aSectName = aSectNames.Value( i );
79 const SectionType& aSectType = aSectTypes.Value( i );
80 bool aSectClosure = aSectClosures.Value( i );
82 aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName )
83 .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
85 HYDROData_PolylineXY::PointsList aSectPointsList = GetPoints( i );
86 for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
88 const Point& aSectPoint = aSectPointsList.Value( k );
90 aResList << QString( "%1.AddPoint( %2, QPointF( %3, %4 ) );" ).arg( aPolylineName )
91 .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() );
98 QVariant HYDROData_PolylineXY::GetDataVariant()
100 QPainterPath aPath = GetPainterPath();
103 aVarData.setValue<QPainterPath>( aPath );
108 TopoDS_Shape HYDROData_PolylineXY::GetShape()
110 return getPolylineShape();
113 TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& theType,
114 const bool& theIsClosed,
115 const NCollection_Sequence<gp_XYZ>& thePoints )
117 BRepBuilderAPI_MakeWire aMakeWire;
119 if( theType == SECTION_POLYLINE )
121 for( int i = 1, n = thePoints.Size(); i <= n; ++i )
123 const gp_XYZ& aFirstPoint = thePoints.Value( i );
129 aLastPoint = thePoints.Value( 1 );
135 aLastPoint = thePoints.Value( i + 1 );
138 gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z() );
139 gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), aLastPoint.Z() );
141 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
142 aMakeWire.Add( anEdge );
145 else //if( theType == PolylineSection::SECTION_SPLINE )
147 HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
149 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
150 aMakeWire.Add( anEdge );
155 if ( aMakeWire.IsDone() )
161 void HYDROData_PolylineXY::BuildPainterPath( QPainterPath& thePath,
162 const SectionType& theType,
163 const bool& theIsClosed,
164 const NCollection_Sequence<gp_XYZ>& thePoints )
166 if ( thePoints.IsEmpty() )
169 if ( theType == SECTION_POLYLINE )
171 const gp_XYZ& aFirstPoint = thePoints.Value( 1 );
172 thePath.moveTo( aFirstPoint.X(), aFirstPoint.Y() );
174 for( int i = 2, n = thePoints.Size(); i <= n; ++i )
176 const gp_XYZ& aSectPoint = thePoints.Value( i );
178 thePath.lineTo( aSectPoint.X(), aSectPoint.Y() );
182 thePath.closeSubpath();
186 HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
187 aBSpline.ComputePath( thePath );
191 void HYDROData_PolylineXY::Update()
193 HYDROData_IPolyline::Update();
195 NCollection_Sequence<TCollection_AsciiString> aSectNames;
196 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
197 NCollection_Sequence<bool> aSectClosures;
198 GetSections( aSectNames, aSectTypes, aSectClosures );
200 BRepBuilderAPI_MakeWire aMakeWire;
202 TopTools_ListOfShape aSectionWiresList;
204 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
206 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
207 SectionType aSectionType = aSectTypes.Value( aSectionId );
208 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
210 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
211 if ( aSectPointsList.IsEmpty() )
214 NCollection_Sequence<gp_XYZ> aPoints;
215 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
217 const Point& aSectPoint = aSectPointsList.Value( i );
219 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
220 aPoints.Append( aPoint );
223 TopoDS_Wire aSectionWire = BuildWire( aSectionType, anIsSectionClosed, aPoints );
224 aSectionWiresList.Append( aSectionWire );
225 aMakeWire.Add( aSectionWire );
230 if ( aMakeWire.IsDone() )
232 aShape = aMakeWire.Shape();
234 else if ( !aSectionWiresList.IsEmpty() )
237 TopoDS_Compound aCompound;
239 BRep_Builder aBuilder;
240 aBuilder.MakeCompound( aCompound );
242 TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
243 for ( ; anIter.More(); anIter.Next() )
245 aBuilder.Add( aCompound, anIter.Value() );
251 setPolylineShape( aShape );
255 * Returns true if polyline is closed
257 bool HYDROData_PolylineXY::IsClosed() const
259 NCollection_Sequence<TCollection_AsciiString> aSectNames;
260 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
261 NCollection_Sequence<bool> aSectClosures;
262 GetSections( aSectNames, aSectTypes, aSectClosures );
263 if( aSectNames.IsEmpty() )
266 bool anIsClosed = true;
267 for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i )
268 anIsClosed = anIsClosed && aSectClosures.Value( i );
273 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
274 const int thePointIndex ) const
276 double aResDistance = -1;
277 if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
280 if ( thePointIndex == 0 )
283 SectionType aSectionType = GetSectionType( theSectionIndex );
284 bool anIsSectionClosed = IsClosedSection( theSectionIndex );
285 PointsList aSectPointsList = GetPoints( theSectionIndex );
286 if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
289 if ( aSectionType == SECTION_POLYLINE )
293 Point aPrevPoint = aSectPointsList.Value( 1 );
294 for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
296 const Point& aSectPoint = aSectPointsList.Value( i );
297 aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
298 aPrevPoint = aSectPoint;
305 int aSectNbPoints = aSectPointsList.Size();
306 NCollection_Sequence<gp_XYZ> aPoints;
307 for( int i = 1 ; i <= aSectNbPoints; ++i )
309 const Point& aSectPoint = aSectPointsList.Value( i );
311 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
312 aPoints.Append( aPoint );
314 if ( thePointIndex == i - 1 )
315 aPointToTest = aPoint;
318 HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed );
320 Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter();
321 Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter();
323 if ( thePointIndex != aSectNbPoints - 1 )
325 GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aBSpline.Curve() );
326 aSecondParam = aProject.LowerDistanceParameter();
329 GeomAdaptor_Curve anAdap( aBSpline.Curve() );
331 aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
337 int HYDROData_PolylineXY::NbSections() const
339 Handle(TDataStd_ExtStringList) aNamesList;
340 Handle(TDataStd_IntegerList) aTypesList;
341 Handle(TDataStd_BooleanList) aClosuresList;
342 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
344 return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
347 TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
349 NCollection_Map<TCollection_ExtendedString> aNamesMap;
351 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
352 for ( ; aNamesIter.More(); aNamesIter.Next() )
353 aNamesMap.Add( aNamesIter.Value() );
355 TCollection_ExtendedString aResName;
360 aResName = "Section_" + aPrefIdx;
363 while ( aNamesMap.Contains( aResName ) );
368 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
369 const SectionType theSectionType,
370 const bool theIsClosed )
372 Handle(TDataStd_ExtStringList) aNamesList;
373 Handle(TDataStd_IntegerList) aTypesList;
374 Handle(TDataStd_BooleanList) aClosuresList;
375 getSectionsLists( aNamesList, aTypesList, aClosuresList );
377 TCollection_ExtendedString aSectName( theSectName );
378 if ( aSectName.Length() <= 0 )
379 aSectName = getUniqueSectionName( aNamesList );
381 aNamesList->Append( aSectName );
382 aTypesList->Append( theSectionType );
383 aClosuresList->Append( theIsClosed );
388 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
390 TCollection_AsciiString aResName;
392 Handle(TDataStd_ExtStringList) aNamesList;
393 Handle(TDataStd_IntegerList) aTypesList;
394 Handle(TDataStd_BooleanList) aClosuresList;
395 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
396 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
399 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
400 for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
402 if ( aNamesIter.More() )
403 aResName = aNamesIter.Value();
408 void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex,
409 const TCollection_AsciiString& theSectionName )
411 Handle(TDataStd_ExtStringList) aNamesList;
412 Handle(TDataStd_IntegerList) aTypesList;
413 Handle(TDataStd_BooleanList) aClosuresList;
414 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
415 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
418 TDataStd_ListOfExtendedString anOldNamesList;
419 anOldNamesList = aNamesList->List();
421 // Refill the existing list
424 TCollection_ExtendedString aNewSectName = theSectionName;
426 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
427 for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
428 aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
433 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
435 Handle(TDataStd_ExtStringList) aNamesList;
436 Handle(TDataStd_IntegerList) aTypesList;
437 Handle(TDataStd_BooleanList) aClosuresList;
438 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
439 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
440 return SECTION_POLYLINE;
442 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
443 for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
445 return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
448 void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex,
449 const SectionType theSectionType )
451 Handle(TDataStd_ExtStringList) aNamesList;
452 Handle(TDataStd_IntegerList) aTypesList;
453 Handle(TDataStd_BooleanList) aClosuresList;
454 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
455 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
458 TColStd_ListOfInteger anOldTypesList;
459 anOldTypesList = aTypesList->List();
461 // Refill the existing list
464 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
465 for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
466 aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
471 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
473 Handle(TDataStd_ExtStringList) aNamesList;
474 Handle(TDataStd_IntegerList) aTypesList;
475 Handle(TDataStd_BooleanList) aClosuresList;
476 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
477 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
480 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
481 for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
483 return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
486 void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex,
487 const bool theIsClosed )
489 Handle(TDataStd_ExtStringList) aNamesList;
490 Handle(TDataStd_IntegerList) aTypesList;
491 Handle(TDataStd_BooleanList) aClosuresList;
492 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
493 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
496 TDataStd_ListOfByte anOldClosuresList;
497 anOldClosuresList = aClosuresList->List();
499 // Refill the existing list
500 aClosuresList->Clear();
502 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
503 for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
504 aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
509 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
510 NCollection_Sequence<SectionType>& theSectTypes,
511 NCollection_Sequence<bool>& theSectClosures ) const
513 theSectNames.Clear();
514 theSectTypes.Clear();
515 theSectClosures.Clear();
517 Handle(TDataStd_ExtStringList) aNamesList;
518 Handle(TDataStd_IntegerList) aTypesList;
519 Handle(TDataStd_BooleanList) aClosuresList;
520 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
521 if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
524 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
525 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
526 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
527 for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
528 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
530 const TCollection_ExtendedString& aSectName = aNamesIter.Value();
531 SectionType aSectType = (SectionType)aTypesIter.Value();
532 bool aSectClosures = aClosuresIter.Value();
534 theSectNames.Append( aSectName );
535 theSectTypes.Append( aSectType );
536 theSectClosures.Append( aSectClosures );
540 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
542 Handle(TDataStd_ExtStringList) aNamesList;
543 Handle(TDataStd_IntegerList) aTypesList;
544 Handle(TDataStd_BooleanList) aClosuresList;
545 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
546 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
549 if ( aNamesList->Extent() == 1 )
551 removeSectionsLists();
556 TDataStd_ListOfExtendedString anOldNamesList;
557 anOldNamesList = aNamesList->List();
559 TColStd_ListOfInteger anOldTypesList;
560 anOldTypesList = aTypesList->List();
562 TDataStd_ListOfByte anOldClosuresList;
563 anOldClosuresList = aClosuresList->List();
565 // Refill the existing lists
568 aClosuresList->Clear();
570 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
571 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
572 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
573 for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
574 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
576 if ( i == theSectionIndex )
577 continue; // skip index to remove
579 aNamesList->Append( aNamesIter.Value() );
580 aTypesList->Append( aTypesIter.Value() );
581 aClosuresList->Append( (bool)aClosuresIter.Value() );
584 // Remove points that belongs to removed section
585 removePointsLists( theSectionIndex );
591 void HYDROData_PolylineXY::RemoveSections()
593 removeSectionsLists();
598 void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
599 const Point& thePoint,
600 const int thePointIndex )
602 Handle(TDataStd_RealList) aListX, aListY;
603 getPointsLists( theSectionIndex, aListX, aListY );
605 if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
607 aListX->Append( thePoint.X() );
608 aListY->Append( thePoint.Y() );
612 TColStd_ListOfReal anOldListX;
613 anOldListX = aListX->List();
615 TColStd_ListOfReal anOldListY;
616 anOldListY = aListY->List();
618 // Refill the existing lists
622 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
623 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
624 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
626 double aCoordX = anIterX.Value();
627 double aCoordY = anIterY.Value();
629 if ( i == thePointIndex )
631 // Insert our new point
632 aListX->Append( thePoint.X() );
633 aListY->Append( thePoint.Y() );
636 aListX->Append( aCoordX );
637 aListY->Append( aCoordY );
644 void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
645 const Point& thePoint,
646 const int thePointIndex )
648 Handle(TDataStd_RealList) aListX, aListY;
649 getPointsLists( theSectionIndex, aListX, aListY );
651 if ( thePointIndex < 0 )
653 aListX->Prepend( thePoint.X() );
654 aListY->Prepend( thePoint.Y() );
656 else if ( thePointIndex >= aListX->Extent() )
658 aListX->Append( thePoint.X() );
659 aListY->Append( thePoint.Y() );
663 TColStd_ListOfReal anOldListX;
664 anOldListX = aListX->List();
666 TColStd_ListOfReal anOldListY;
667 anOldListY = aListY->List();
669 // Refill the existing lists
673 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
674 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
675 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
677 double aCoordX = anIterX.Value();
678 double aCoordY = anIterY.Value();
680 if ( i == thePointIndex )
682 // Insert our new point instead of old one
683 aCoordX = thePoint.X();
684 aCoordY = thePoint.Y();
687 aListX->Append( aCoordX );
688 aListY->Append( aCoordY );
695 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
696 const int thePointIndex )
698 Handle(TDataStd_RealList) aListX, aListY;
699 getPointsLists( theSectionIndex, aListX, aListY, false );
700 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
703 if ( aListX->Extent() == 1 )
705 removePointsLists( theSectionIndex );
709 TColStd_ListOfReal anOldListX;
710 anOldListX = aListX->List();
712 TColStd_ListOfReal anOldListY;
713 anOldListY = aListY->List();
715 // Refill the existing lists
719 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
720 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
721 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
723 if ( i == thePointIndex )
724 continue; // skip index to remove
726 aListX->Append( anIterX.Value() );
727 aListY->Append( anIterY.Value() );
734 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const
738 Handle(TDataStd_RealList) aListX, aListY;
739 getPointsLists( theSectionIndex, aListX, aListY, false );
740 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
743 TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
744 TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
745 for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
747 Point aPoint( anIterX.Value(), anIterY.Value() );
748 aResList.Append( aPoint );
754 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
758 NCollection_Sequence<TCollection_AsciiString> aSectNames;
759 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
760 NCollection_Sequence<bool> aSectClosures;
761 GetSections( aSectNames, aSectTypes, aSectClosures );
763 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
765 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
766 SectionType aSectionType = aSectTypes.Value( aSectionId );
767 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
769 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
770 if ( aSectPointsList.IsEmpty() )
773 NCollection_Sequence<gp_XYZ> aPoints;
774 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
776 const Point& aSectPoint = aSectPointsList.Value( i );
778 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
779 aPoints.Append( aPoint );
782 BuildPainterPath( aPath, aSectionType, anIsSectionClosed, aPoints );