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 NCollection_Sequence<TCollection_AsciiString> aSectNames;
194 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
195 NCollection_Sequence<bool> aSectClosures;
196 GetSections( aSectNames, aSectTypes, aSectClosures );
198 BRepBuilderAPI_MakeWire aMakeWire;
200 TopTools_ListOfShape aSectionWiresList;
202 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
204 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
205 SectionType aSectionType = aSectTypes.Value( aSectionId );
206 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
208 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
209 if ( aSectPointsList.IsEmpty() )
212 NCollection_Sequence<gp_XYZ> aPoints;
213 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
215 const Point& aSectPoint = aSectPointsList.Value( i );
217 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
218 aPoints.Append( aPoint );
221 TopoDS_Wire aSectionWire = BuildWire( aSectionType, anIsSectionClosed, aPoints );
222 aSectionWiresList.Append( aSectionWire );
223 aMakeWire.Add( aSectionWire );
228 if ( aMakeWire.IsDone() )
230 aShape = aMakeWire.Shape();
232 else if ( !aSectionWiresList.IsEmpty() )
235 TopoDS_Compound aCompound;
237 BRep_Builder aBuilder;
238 aBuilder.MakeCompound( aCompound );
240 TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
241 for ( ; anIter.More(); anIter.Next() )
243 aBuilder.Add( aCompound, anIter.Value() );
249 setPolylineShape( aShape );
253 * Returns true if polyline is closed
255 bool HYDROData_PolylineXY::IsClosed() const
257 NCollection_Sequence<TCollection_AsciiString> aSectNames;
258 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
259 NCollection_Sequence<bool> aSectClosures;
260 GetSections( aSectNames, aSectTypes, aSectClosures );
261 if( aSectNames.IsEmpty() )
264 bool anIsClosed = true;
265 for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i )
266 anIsClosed = anIsClosed && aSectClosures.Value( i );
271 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
272 const int thePointIndex ) const
274 double aResDistance = -1;
275 if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
278 if ( thePointIndex == 0 )
281 SectionType aSectionType = GetSectionType( theSectionIndex );
282 bool anIsSectionClosed = IsClosedSection( theSectionIndex );
283 PointsList aSectPointsList = GetPoints( theSectionIndex );
284 if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
287 if ( aSectionType == SECTION_POLYLINE )
291 Point aPrevPoint = aSectPointsList.Value( 1 );
292 for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
294 const Point& aSectPoint = aSectPointsList.Value( i );
295 aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
296 aPrevPoint = aSectPoint;
303 int aSectNbPoints = aSectPointsList.Size();
304 NCollection_Sequence<gp_XYZ> aPoints;
305 for( int i = 1 ; i <= aSectNbPoints; ++i )
307 const Point& aSectPoint = aSectPointsList.Value( i );
309 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
310 aPoints.Append( aPoint );
312 if ( thePointIndex == i - 1 )
313 aPointToTest = aPoint;
316 HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed );
318 Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter();
319 Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter();
321 if ( thePointIndex != aSectNbPoints - 1 )
323 GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aBSpline.Curve() );
324 aSecondParam = aProject.LowerDistanceParameter();
327 GeomAdaptor_Curve anAdap( aBSpline.Curve() );
329 aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
335 int HYDROData_PolylineXY::NbSections() const
337 Handle(TDataStd_ExtStringList) aNamesList;
338 Handle(TDataStd_IntegerList) aTypesList;
339 Handle(TDataStd_BooleanList) aClosuresList;
340 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
342 return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
345 TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
347 NCollection_Map<TCollection_ExtendedString> aNamesMap;
349 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
350 for ( ; aNamesIter.More(); aNamesIter.Next() )
351 aNamesMap.Add( aNamesIter.Value() );
353 TCollection_ExtendedString aResName;
358 aResName = "Section_" + aPrefIdx;
361 while ( aNamesMap.Contains( aResName ) );
366 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
367 const SectionType theSectionType,
368 const bool theIsClosed )
370 Handle(TDataStd_ExtStringList) aNamesList;
371 Handle(TDataStd_IntegerList) aTypesList;
372 Handle(TDataStd_BooleanList) aClosuresList;
373 getSectionsLists( aNamesList, aTypesList, aClosuresList );
375 TCollection_ExtendedString aSectName( theSectName );
376 if ( aSectName.Length() <= 0 )
377 aSectName = getUniqueSectionName( aNamesList );
379 aNamesList->Append( aSectName );
380 aTypesList->Append( theSectionType );
381 aClosuresList->Append( theIsClosed );
384 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
386 TCollection_AsciiString aResName;
388 Handle(TDataStd_ExtStringList) aNamesList;
389 Handle(TDataStd_IntegerList) aTypesList;
390 Handle(TDataStd_BooleanList) aClosuresList;
391 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
392 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
395 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
396 for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
398 if ( aNamesIter.More() )
399 aResName = aNamesIter.Value();
404 void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex,
405 const TCollection_AsciiString& theSectionName )
407 Handle(TDataStd_ExtStringList) aNamesList;
408 Handle(TDataStd_IntegerList) aTypesList;
409 Handle(TDataStd_BooleanList) aClosuresList;
410 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
411 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
414 TDataStd_ListOfExtendedString anOldNamesList;
415 anOldNamesList = aNamesList->List();
417 // Refill the existing list
420 TCollection_ExtendedString aNewSectName = theSectionName;
422 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
423 for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
424 aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
427 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
429 Handle(TDataStd_ExtStringList) aNamesList;
430 Handle(TDataStd_IntegerList) aTypesList;
431 Handle(TDataStd_BooleanList) aClosuresList;
432 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
433 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
434 return SECTION_POLYLINE;
436 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
437 for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
439 return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
442 void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex,
443 const SectionType theSectionType )
445 Handle(TDataStd_ExtStringList) aNamesList;
446 Handle(TDataStd_IntegerList) aTypesList;
447 Handle(TDataStd_BooleanList) aClosuresList;
448 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
449 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
452 TColStd_ListOfInteger anOldTypesList;
453 anOldTypesList = aTypesList->List();
455 // Refill the existing list
458 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
459 for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
460 aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
463 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
465 Handle(TDataStd_ExtStringList) aNamesList;
466 Handle(TDataStd_IntegerList) aTypesList;
467 Handle(TDataStd_BooleanList) aClosuresList;
468 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
469 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
472 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
473 for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
475 return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
478 void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex,
479 const bool theIsClosed )
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_ListOfByte anOldClosuresList;
489 anOldClosuresList = aClosuresList->List();
491 // Refill the existing list
492 aClosuresList->Clear();
494 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
495 for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
496 aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
499 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
500 NCollection_Sequence<SectionType>& theSectTypes,
501 NCollection_Sequence<bool>& theSectClosures ) const
503 theSectNames.Clear();
504 theSectTypes.Clear();
505 theSectClosures.Clear();
507 Handle(TDataStd_ExtStringList) aNamesList;
508 Handle(TDataStd_IntegerList) aTypesList;
509 Handle(TDataStd_BooleanList) aClosuresList;
510 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
511 if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
514 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
515 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
516 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
517 for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
518 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
520 const TCollection_ExtendedString& aSectName = aNamesIter.Value();
521 SectionType aSectType = (SectionType)aTypesIter.Value();
522 bool aSectClosures = aClosuresIter.Value();
524 theSectNames.Append( aSectName );
525 theSectTypes.Append( aSectType );
526 theSectClosures.Append( aSectClosures );
530 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
532 Handle(TDataStd_ExtStringList) aNamesList;
533 Handle(TDataStd_IntegerList) aTypesList;
534 Handle(TDataStd_BooleanList) aClosuresList;
535 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
536 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
539 if ( aNamesList->Extent() == 1 )
541 removeSectionsLists();
546 TDataStd_ListOfExtendedString anOldNamesList;
547 anOldNamesList = aNamesList->List();
549 TColStd_ListOfInteger anOldTypesList;
550 anOldTypesList = aTypesList->List();
552 TDataStd_ListOfByte anOldClosuresList;
553 anOldClosuresList = aClosuresList->List();
555 // Refill the existing lists
558 aClosuresList->Clear();
560 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
561 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
562 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
563 for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
564 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
566 if ( i == theSectionIndex )
567 continue; // skip index to remove
569 aNamesList->Append( aNamesIter.Value() );
570 aTypesList->Append( aTypesIter.Value() );
571 aClosuresList->Append( (bool)aClosuresIter.Value() );
574 // Remove points that belongs to removed section
575 removePointsLists( theSectionIndex );
579 void HYDROData_PolylineXY::RemoveSections()
581 removeSectionsLists();
585 void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
586 const Point& thePoint,
587 const int thePointIndex )
589 Handle(TDataStd_RealList) aListX, aListY;
590 getPointsLists( theSectionIndex, aListX, aListY );
592 if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
594 aListX->Append( thePoint.X() );
595 aListY->Append( thePoint.Y() );
599 TColStd_ListOfReal anOldListX;
600 anOldListX = aListX->List();
602 TColStd_ListOfReal anOldListY;
603 anOldListY = aListY->List();
605 // Refill the existing lists
609 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
610 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
611 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
613 double aCoordX = anIterX.Value();
614 double aCoordY = anIterY.Value();
616 if ( i == thePointIndex )
618 // Insert our new point
619 aListX->Append( thePoint.X() );
620 aListY->Append( thePoint.Y() );
623 aListX->Append( aCoordX );
624 aListY->Append( aCoordY );
629 void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
630 const Point& thePoint,
631 const int thePointIndex )
633 Handle(TDataStd_RealList) aListX, aListY;
634 getPointsLists( theSectionIndex, aListX, aListY );
636 if ( thePointIndex < 0 )
638 aListX->Prepend( thePoint.X() );
639 aListY->Prepend( thePoint.Y() );
641 else if ( thePointIndex >= aListX->Extent() )
643 aListX->Append( thePoint.X() );
644 aListY->Append( thePoint.Y() );
648 TColStd_ListOfReal anOldListX;
649 anOldListX = aListX->List();
651 TColStd_ListOfReal anOldListY;
652 anOldListY = aListY->List();
654 // Refill the existing lists
658 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
659 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
660 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
662 double aCoordX = anIterX.Value();
663 double aCoordY = anIterY.Value();
665 if ( i == thePointIndex )
667 // Insert our new point instead of old one
668 aCoordX = thePoint.X();
669 aCoordY = thePoint.Y();
672 aListX->Append( aCoordX );
673 aListY->Append( aCoordY );
678 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
679 const int thePointIndex )
681 Handle(TDataStd_RealList) aListX, aListY;
682 getPointsLists( theSectionIndex, aListX, aListY, false );
683 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
686 if ( aListX->Extent() == 1 )
688 removePointsLists( theSectionIndex );
692 TColStd_ListOfReal anOldListX;
693 anOldListX = aListX->List();
695 TColStd_ListOfReal anOldListY;
696 anOldListY = aListY->List();
698 // Refill the existing lists
702 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
703 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
704 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
706 if ( i == thePointIndex )
707 continue; // skip index to remove
709 aListX->Append( anIterX.Value() );
710 aListY->Append( anIterY.Value() );
715 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const
719 Handle(TDataStd_RealList) aListX, aListY;
720 getPointsLists( theSectionIndex, aListX, aListY, false );
721 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
724 TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
725 TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
726 for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
728 Point aPoint( anIterX.Value(), anIterY.Value() );
729 aResList.Append( aPoint );
735 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
739 NCollection_Sequence<TCollection_AsciiString> aSectNames;
740 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
741 NCollection_Sequence<bool> aSectClosures;
742 GetSections( aSectNames, aSectTypes, aSectClosures );
744 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
746 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
747 SectionType aSectionType = aSectTypes.Value( aSectionId );
748 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
750 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
751 if ( aSectPointsList.IsEmpty() )
754 NCollection_Sequence<gp_XYZ> aPoints;
755 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
757 const Point& aSectPoint = aSectPointsList.Value( i );
759 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
760 aPoints.Append( aPoint );
763 BuildPainterPath( aPath, aSectionType, anIsSectionClosed, aPoints );