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 QPainterPath HYDROData_PolylineXY::BuildPainterPath( const SectionType& theType,
162 const bool& theIsClosed,
163 const NCollection_Sequence<gp_XYZ>& thePoints )
166 if ( thePoints.IsEmpty() )
169 if ( theType == SECTION_POLYLINE )
171 aPath.moveTo( thePoints.Value( 1 ).X(), thePoints.Value( 1 ).Y() );
173 for( int i = 2, n = thePoints.Size(); i <= n; ++i )
175 const gp_XYZ& aSectPoint = thePoints.Value( i );
177 aPath.lineTo( aSectPoint.X(), aSectPoint.Y() );
181 aPath.closeSubpath();
185 HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
186 aPath = aBSpline.ComputePath();
192 void HYDROData_PolylineXY::Update()
194 NCollection_Sequence<TCollection_AsciiString> aSectNames;
195 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
196 NCollection_Sequence<bool> aSectClosures;
197 GetSections( aSectNames, aSectTypes, aSectClosures );
199 BRepBuilderAPI_MakeWire aMakeWire;
201 TopTools_ListOfShape aSectionWiresList;
203 for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
205 TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
206 SectionType aSectionType = aSectTypes.Value( aSectionId );
207 bool anIsSectionClosed = aSectClosures.Value( aSectionId );
209 PointsList aSectPointsList = GetPoints( aSectionId - 1 );
210 if ( aSectPointsList.IsEmpty() )
213 NCollection_Sequence<gp_XYZ> aPoints;
214 for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
216 const Point& aSectPoint = aSectPointsList.Value( i );
218 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
219 aPoints.Append( aPoint );
222 TopoDS_Wire aSectionWire = BuildWire( aSectionType, anIsSectionClosed, aPoints );
223 aSectionWiresList.Append( aSectionWire );
224 aMakeWire.Add( aSectionWire );
229 if ( aMakeWire.IsDone() )
231 aShape = aMakeWire.Shape();
233 else if ( !aSectionWiresList.IsEmpty() )
236 TopoDS_Compound aCompound;
238 BRep_Builder aBuilder;
239 aBuilder.MakeCompound( aCompound );
241 TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
242 for ( ; anIter.More(); anIter.Next() )
244 aBuilder.Add( aCompound, anIter.Value() );
250 setPolylineShape( aShape );
254 * Returns true if polyline is closed
256 bool HYDROData_PolylineXY::IsClosed() const
258 NCollection_Sequence<TCollection_AsciiString> aSectNames;
259 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
260 NCollection_Sequence<bool> aSectClosures;
261 GetSections( aSectNames, aSectTypes, aSectClosures );
262 if( aSectNames.IsEmpty() )
265 bool anIsClosed = true;
266 for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i )
267 anIsClosed = anIsClosed && aSectClosures.Value( i );
272 double HYDROData_PolylineXY::GetDistance( const int theSectionIndex,
273 const int thePointIndex ) const
275 double aResDistance = -1;
276 if ( theSectionIndex < 0 || theSectionIndex >= NbSections() )
279 if ( thePointIndex == 0 )
282 SectionType aSectionType = GetSectionType( theSectionIndex );
283 bool anIsSectionClosed = IsClosedSection( theSectionIndex );
284 PointsList aSectPointsList = GetPoints( theSectionIndex );
285 if ( thePointIndex < 0 || thePointIndex >= aSectPointsList.Size() )
288 if ( aSectionType == SECTION_POLYLINE )
292 Point aPrevPoint = aSectPointsList.Value( 1 );
293 for ( int i = 2, aNbPoints = aSectPointsList.Size(); i <= aNbPoints; ++i )
295 const Point& aSectPoint = aSectPointsList.Value( i );
296 aResDistance += gp_Pnt2d( aPrevPoint ).Distance( aSectPoint );
297 aPrevPoint = aSectPoint;
304 int aSectNbPoints = aSectPointsList.Size();
305 NCollection_Sequence<gp_XYZ> aPoints;
306 for( int i = 1 ; i <= aSectNbPoints; ++i )
308 const Point& aSectPoint = aSectPointsList.Value( i );
310 gp_XYZ aPoint( aSectPoint.X(), aSectPoint.Y(), 0.0 );
311 aPoints.Append( aPoint );
313 if ( thePointIndex == i - 1 )
314 aPointToTest = aPoint;
317 HYDROData_BSplineOperation aBSpline( aPoints, anIsSectionClosed );
319 Quantity_Parameter aFirstParam = aBSpline.Curve()->FirstParameter();
320 Quantity_Parameter aSecondParam = aBSpline.Curve()->LastParameter();
322 if ( thePointIndex != aSectNbPoints - 1 )
324 GeomAPI_ProjectPointOnCurve aProject( aPointToTest, aBSpline.Curve() );
325 aSecondParam = aProject.LowerDistanceParameter();
328 GeomAdaptor_Curve anAdap( aBSpline.Curve() );
330 aResDistance = GCPnts_AbscissaPoint::Length( anAdap, aFirstParam, aSecondParam );
336 int HYDROData_PolylineXY::NbSections() const
338 Handle(TDataStd_ExtStringList) aNamesList;
339 Handle(TDataStd_IntegerList) aTypesList;
340 Handle(TDataStd_BooleanList) aClosuresList;
341 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
343 return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
346 TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
348 NCollection_Map<TCollection_ExtendedString> aNamesMap;
350 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
351 for ( ; aNamesIter.More(); aNamesIter.Next() )
352 aNamesMap.Add( aNamesIter.Value() );
354 TCollection_ExtendedString aResName;
359 aResName = "Section_" + aPrefIdx;
362 while ( aNamesMap.Contains( aResName ) );
367 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
368 const SectionType theSectionType,
369 const bool theIsClosed )
371 Handle(TDataStd_ExtStringList) aNamesList;
372 Handle(TDataStd_IntegerList) aTypesList;
373 Handle(TDataStd_BooleanList) aClosuresList;
374 getSectionsLists( aNamesList, aTypesList, aClosuresList );
376 TCollection_ExtendedString aSectName( theSectName );
377 if ( aSectName.Length() <= 0 )
378 aSectName = getUniqueSectionName( aNamesList );
380 aNamesList->Append( aSectName );
381 aTypesList->Append( theSectionType );
382 aClosuresList->Append( theIsClosed );
385 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
387 TCollection_AsciiString aResName;
389 Handle(TDataStd_ExtStringList) aNamesList;
390 Handle(TDataStd_IntegerList) aTypesList;
391 Handle(TDataStd_BooleanList) aClosuresList;
392 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
393 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
396 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
397 for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
399 if ( aNamesIter.More() )
400 aResName = aNamesIter.Value();
405 void HYDROData_PolylineXY::SetSectionName( const int theSectionIndex,
406 const TCollection_AsciiString& theSectionName )
408 Handle(TDataStd_ExtStringList) aNamesList;
409 Handle(TDataStd_IntegerList) aTypesList;
410 Handle(TDataStd_BooleanList) aClosuresList;
411 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
412 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
415 TDataStd_ListOfExtendedString anOldNamesList;
416 anOldNamesList = aNamesList->List();
418 // Refill the existing list
421 TCollection_ExtendedString aNewSectName = theSectionName;
423 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
424 for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
425 aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
428 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
430 Handle(TDataStd_ExtStringList) aNamesList;
431 Handle(TDataStd_IntegerList) aTypesList;
432 Handle(TDataStd_BooleanList) aClosuresList;
433 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
434 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
435 return SECTION_POLYLINE;
437 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
438 for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
440 return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
443 void HYDROData_PolylineXY::SetSectionType( const int theSectionIndex,
444 const SectionType theSectionType )
446 Handle(TDataStd_ExtStringList) aNamesList;
447 Handle(TDataStd_IntegerList) aTypesList;
448 Handle(TDataStd_BooleanList) aClosuresList;
449 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
450 if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
453 TColStd_ListOfInteger anOldTypesList;
454 anOldTypesList = aTypesList->List();
456 // Refill the existing list
459 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
460 for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
461 aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
464 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
466 Handle(TDataStd_ExtStringList) aNamesList;
467 Handle(TDataStd_IntegerList) aTypesList;
468 Handle(TDataStd_BooleanList) aClosuresList;
469 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
470 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
473 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
474 for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
476 return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
479 void HYDROData_PolylineXY::SetSectionClosed( const int theSectionIndex,
480 const bool theIsClosed )
482 Handle(TDataStd_ExtStringList) aNamesList;
483 Handle(TDataStd_IntegerList) aTypesList;
484 Handle(TDataStd_BooleanList) aClosuresList;
485 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
486 if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
489 TDataStd_ListOfByte anOldClosuresList;
490 anOldClosuresList = aClosuresList->List();
492 // Refill the existing list
493 aClosuresList->Clear();
495 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
496 for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
497 aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
500 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
501 NCollection_Sequence<SectionType>& theSectTypes,
502 NCollection_Sequence<bool>& theSectClosures ) const
504 theSectNames.Clear();
505 theSectTypes.Clear();
506 theSectClosures.Clear();
508 Handle(TDataStd_ExtStringList) aNamesList;
509 Handle(TDataStd_IntegerList) aTypesList;
510 Handle(TDataStd_BooleanList) aClosuresList;
511 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
512 if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
515 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
516 TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
517 TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
518 for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
519 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
521 const TCollection_ExtendedString& aSectName = aNamesIter.Value();
522 SectionType aSectType = (SectionType)aTypesIter.Value();
523 bool aSectClosures = aClosuresIter.Value();
525 theSectNames.Append( aSectName );
526 theSectTypes.Append( aSectType );
527 theSectClosures.Append( aSectClosures );
531 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
533 Handle(TDataStd_ExtStringList) aNamesList;
534 Handle(TDataStd_IntegerList) aTypesList;
535 Handle(TDataStd_BooleanList) aClosuresList;
536 getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
537 if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
540 if ( aNamesList->Extent() == 1 )
542 removeSectionsLists();
547 TDataStd_ListOfExtendedString anOldNamesList;
548 anOldNamesList = aNamesList->List();
550 TColStd_ListOfInteger anOldTypesList;
551 anOldTypesList = aTypesList->List();
553 TDataStd_ListOfByte anOldClosuresList;
554 anOldClosuresList = aClosuresList->List();
556 // Refill the existing lists
559 aClosuresList->Clear();
561 TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
562 TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
563 TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
564 for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
565 aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
567 if ( i == theSectionIndex )
568 continue; // skip index to remove
570 aNamesList->Append( aNamesIter.Value() );
571 aTypesList->Append( aTypesIter.Value() );
572 aClosuresList->Append( (bool)aClosuresIter.Value() );
575 // Remove points that belongs to removed section
576 removePointsLists( theSectionIndex );
580 void HYDROData_PolylineXY::RemoveSections()
582 removeSectionsLists();
586 void HYDROData_PolylineXY::AddPoint( const int theSectionIndex,
587 const Point& thePoint,
588 const int thePointIndex )
590 Handle(TDataStd_RealList) aListX, aListY;
591 getPointsLists( theSectionIndex, aListX, aListY );
593 if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
595 aListX->Append( thePoint.X() );
596 aListY->Append( thePoint.Y() );
600 TColStd_ListOfReal anOldListX;
601 anOldListX = aListX->List();
603 TColStd_ListOfReal anOldListY;
604 anOldListY = aListY->List();
606 // Refill the existing lists
610 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
611 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
612 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
614 double aCoordX = anIterX.Value();
615 double aCoordY = anIterY.Value();
617 if ( i == thePointIndex )
619 // Insert our new point
620 aListX->Append( thePoint.X() );
621 aListY->Append( thePoint.Y() );
624 aListX->Append( aCoordX );
625 aListY->Append( aCoordY );
630 void HYDROData_PolylineXY::SetPoint( const int theSectionIndex,
631 const Point& thePoint,
632 const int thePointIndex )
634 Handle(TDataStd_RealList) aListX, aListY;
635 getPointsLists( theSectionIndex, aListX, aListY );
637 if ( thePointIndex < 0 )
639 aListX->Prepend( thePoint.X() );
640 aListY->Prepend( thePoint.Y() );
642 else if ( thePointIndex >= aListX->Extent() )
644 aListX->Append( thePoint.X() );
645 aListY->Append( thePoint.Y() );
649 TColStd_ListOfReal anOldListX;
650 anOldListX = aListX->List();
652 TColStd_ListOfReal anOldListY;
653 anOldListY = aListY->List();
655 // Refill the existing lists
659 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
660 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
661 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
663 double aCoordX = anIterX.Value();
664 double aCoordY = anIterY.Value();
666 if ( i == thePointIndex )
668 // Insert our new point instead of old one
669 aCoordX = thePoint.X();
670 aCoordY = thePoint.Y();
673 aListX->Append( aCoordX );
674 aListY->Append( aCoordY );
679 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
680 const int thePointIndex )
682 Handle(TDataStd_RealList) aListX, aListY;
683 getPointsLists( theSectionIndex, aListX, aListY, false );
684 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
687 if ( aListX->Extent() == 1 )
689 removePointsLists( theSectionIndex );
693 TColStd_ListOfReal anOldListX;
694 anOldListX = aListX->List();
696 TColStd_ListOfReal anOldListY;
697 anOldListY = aListY->List();
699 // Refill the existing lists
703 TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
704 TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
705 for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
707 if ( i == thePointIndex )
708 continue; // skip index to remove
710 aListX->Append( anIterX.Value() );
711 aListY->Append( anIterY.Value() );
716 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const
720 Handle(TDataStd_RealList) aListX, aListY;
721 getPointsLists( theSectionIndex, aListX, aListY, false );
722 if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
725 TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
726 TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
727 for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
729 Point aPoint( anIterX.Value(), anIterY.Value() );
730 aResList.Append( aPoint );
736 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
740 NCollection_Sequence<TCollection_AsciiString> aSectNames;
741 NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
742 NCollection_Sequence<bool> aSectClosures;
743 GetSections( aSectNames, aSectTypes, aSectClosures );
744 if( aSectNames.IsEmpty() )
747 PointsList aSectPointsList = GetPoints( 0 );
748 if( aSectPointsList.IsEmpty() )
751 SectionType aSectionType = aSectTypes.Value( 1 );
752 bool anIsSectionClosed = aSectClosures.Value( 1 );
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 aPath = BuildPainterPath( aSectionType, anIsSectionClosed, aPoints );