Salome HOME
Debug minor changes.
[modules/hydro.git] / src / HYDROData / HYDROData_PolylineXY.cxx
1
2 #include "HYDROData_PolylineXY.h"
3
4 #include "HYDROData_BSplineOperation.h"
5 #include "HYDROData_Document.h"
6 #include "HYDROData_Tool.h"
7
8 #include <BRep_Builder.hxx>
9 #include <BRepBuilderAPI_MakeEdge.hxx>
10 #include <BRepBuilderAPI_MakeWire.hxx>
11
12 #include <ImageComposer_MetaTypes.h>
13
14 #include <gp_Pnt.hxx>
15 #include <gp_XY.hxx>
16
17 #include <NCollection_Map.hxx>
18
19 #include <TCollection_ExtendedString.hxx>
20
21 #include <TDataStd_ListIteratorOfListOfByte.hxx>
22 #include <TColStd_ListIteratorOfListOfInteger.hxx>
23 #include <TColStd_ListIteratorOfListOfReal.hxx>
24
25 #include <TDataStd_BooleanList.hxx>
26 #include <TDataStd_ExtStringList.hxx>
27 #include <TDataStd_IntegerList.hxx>
28 #include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
29 #include <TDataStd_RealList.hxx>
30
31 #include <TopTools_ListIteratorOfListOfShape.hxx>
32
33 #include <QPainterPath>
34 #include <QVariant>
35
36 #define PYTHON_POLYLINEXY_ID "KIND_POLYLINEXY"
37
38 IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
39 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
40
41 HYDROData_PolylineXY::HYDROData_PolylineXY()
42 : HYDROData_IPolyline()
43 {
44 }
45
46 HYDROData_PolylineXY::~HYDROData_PolylineXY()
47 {
48 }
49
50 QStringList HYDROData_PolylineXY::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
51 {
52   QStringList aResList;
53
54   Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
55   if ( aDocument.IsNull() )
56     return aResList;
57                              
58   QString aDocName = aDocument->GetDocPyName();
59   QString aPolylineName = GetName();
60
61   aResList << QString( "%1 = %2.CreateObject( %3 );" )
62               .arg( aPolylineName ).arg( aDocName ).arg( PYTHON_POLYLINEXY_ID );
63   aResList << QString( "%1.SetName( \"%1\" );" ).arg( aPolylineName );
64
65   // Set polilyne data
66   NCollection_Sequence<TCollection_AsciiString>           aSectNames;
67   NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
68   NCollection_Sequence<bool>                              aSectClosures;
69   GetSections( aSectNames, aSectTypes, aSectClosures );
70
71   for ( int i = 1, n = aSectNames.Size(); i <= n; ++i )
72   {
73     const TCollection_AsciiString& aSectName = aSectNames.Value( i );
74     const SectionType& aSectType = aSectTypes.Value( i );
75     bool aSectClosure = aSectClosures.Value( i );
76
77     aResList << QString( "%1.AddSection( \"%2\", %3, %4 );" ).arg( aPolylineName )
78                 .arg( aSectName.ToCString() ).arg( aSectType ).arg( aSectClosure );
79
80     HYDROData_PolylineXY::PointsList aSectPointsList = GetPoints( i );
81     for ( int k = 1, aNbPoints = aSectPointsList.Size(); k <= aNbPoints; ++k )
82     {
83       const HYDROData_PolylineXY::Point& aSectPoint = aSectPointsList.Value( k );
84
85       aResList << QString( "%1.AddPoint( %2, QPointF( %3, %4 ) );" ).arg( aPolylineName )
86         .arg( i - 1 ).arg( aSectPoint.X() ).arg( aSectPoint.Y() );
87     }
88   }
89
90   return aResList;
91 }
92
93 QVariant HYDROData_PolylineXY::GetDataVariant()
94 {
95   QPainterPath aPath = GetPainterPath();
96
97   QVariant aVarData;
98   aVarData.setValue<QPainterPath>( aPath );
99   
100   return aVarData;
101 }
102
103 TopoDS_Shape HYDROData_PolylineXY::GetShape()
104 {
105   return getPolylineShape();
106 }
107
108 void HYDROData_PolylineXY::Update()
109 {
110   NCollection_Sequence<TCollection_AsciiString>           aSectNames;
111   NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
112   NCollection_Sequence<bool>                              aSectClosures;
113   GetSections( aSectNames, aSectTypes, aSectClosures );
114
115   BRepBuilderAPI_MakeWire aMakeWire;
116
117   TopTools_ListOfShape aSectionWiresList;
118
119   for ( int aSectionId = 1, aNbSects = aSectNames.Size(); aSectionId <= aNbSects; aSectionId++ )
120   {
121     TCollection_AsciiString aSectName = aSectNames.Value( aSectionId );
122     SectionType aSectionType = aSectTypes.Value( aSectionId );
123     bool anIsSectionClosed = aSectClosures.Value( aSectionId );
124
125     PointsList aSectPointsList = GetPoints( aSectionId - 1 );
126     if ( aSectPointsList.IsEmpty() )
127       continue;
128
129     BRepBuilderAPI_MakeWire aMakeSectionWire;
130     if( aSectionType == SECTION_POLYLINE )
131     {
132       for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
133       {
134         const Point& aFirstPoint = aSectPointsList.Value( i );
135
136         Point aLastPoint;
137         if ( i == n )
138         {
139           if( anIsSectionClosed )
140             aLastPoint = aSectPointsList.Value( 1 );
141           else
142             break;
143         }
144         else
145         {
146           aLastPoint = aSectPointsList.Value( i + 1 );
147         }
148
149         gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), 0.0 );
150         gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), 0.0 );
151
152         TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
153         aMakeSectionWire.Add( anEdge );
154       }
155     }
156     else //if( aSectionType == PolylineSection::SECTION_SPLINE )
157     {
158       QList<double> aPoints;
159       for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
160       {
161         const Point& aSectPoint = aSectPointsList.Value( i );
162         aPoints << aSectPoint.X() << aSectPoint.Y();
163       }
164
165       HYDROData_BSplineOperation aBSpline( aPoints, 0.0, anIsSectionClosed );
166
167       TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
168       aMakeSectionWire.Add( anEdge );
169     }
170    
171     TopoDS_Wire aSectionWire = aMakeSectionWire.Wire();
172     aSectionWiresList.Append( aSectionWire );
173     aMakeWire.Add( aSectionWire );
174   }
175
176   TopoDS_Shape aShape;
177
178   if ( aMakeWire.IsDone() )
179   {
180     aShape = aMakeWire.Shape();
181   }
182   else if ( !aSectionWiresList.IsEmpty() )
183   {
184     // build compound
185     TopoDS_Compound aCompound;
186     
187     BRep_Builder aBuilder;
188     aBuilder.MakeCompound( aCompound );
189     
190     TopTools_ListIteratorOfListOfShape anIter( aSectionWiresList );
191     for ( ; anIter.More(); anIter.Next() )
192     {
193       aBuilder.Add( aCompound, anIter.Value() );
194     }
195     
196     aShape = aCompound;
197   }
198
199   setPolylineShape( aShape );
200 }
201
202 /**
203  * Returns true if polyline is closed
204  */
205 bool HYDROData_PolylineXY::IsClosed() const
206 {
207   NCollection_Sequence<TCollection_AsciiString>           aSectNames;
208   NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
209   NCollection_Sequence<bool>                              aSectClosures;
210   GetSections( aSectNames, aSectTypes, aSectClosures );
211   if( aSectNames.IsEmpty() )
212     return false;
213
214   bool anIsClosed = true;
215   for( int i = 1, n = aSectClosures.Size(); i <= n && anIsClosed; ++i )
216     anIsClosed = anIsClosed && aSectClosures.Value( i );
217
218   return anIsClosed;
219 }
220
221 int HYDROData_PolylineXY::NbSections() const
222 {
223   Handle(TDataStd_ExtStringList) aNamesList;
224   Handle(TDataStd_IntegerList)   aTypesList;
225   Handle(TDataStd_BooleanList)   aClosuresList;
226   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
227
228   return !aClosuresList.IsNull() ? aClosuresList->Extent() : 0;
229 }
230
231 TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
232 {
233   NCollection_Map<TCollection_ExtendedString> aNamesMap;
234
235   TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
236   for ( ; aNamesIter.More(); aNamesIter.Next() )
237     aNamesMap.Add( aNamesIter.Value() );
238
239   TCollection_ExtendedString aResName;
240
241   int aPrefIdx = 1;
242   do
243   {
244     aResName = "Section_" + aPrefIdx;
245     ++aPrefIdx;
246   }
247   while ( aNamesMap.Contains( aResName ) );
248
249   return aResName;
250 }
251
252 void HYDROData_PolylineXY::AddSection( const TCollection_AsciiString& theSectName,
253                                        const SectionType              theSectionType,
254                                        const bool                     theIsClosed )
255 {
256   Handle(TDataStd_ExtStringList) aNamesList;
257   Handle(TDataStd_IntegerList)   aTypesList;
258   Handle(TDataStd_BooleanList)   aClosuresList;
259   getSectionsLists( aNamesList, aTypesList, aClosuresList );
260
261   TCollection_ExtendedString aSectName( theSectName );
262   if ( aSectName.Length() <= 0 )
263     aSectName = getUniqueSectionName( aNamesList );
264
265   aNamesList->Append( aSectName );
266   aTypesList->Append( theSectionType );
267   aClosuresList->Append( theIsClosed );
268 }
269
270 TCollection_AsciiString HYDROData_PolylineXY::GetSectionName( const int theSectionIndex ) const
271 {
272   TCollection_AsciiString aResName;
273
274   Handle(TDataStd_ExtStringList) aNamesList;
275   Handle(TDataStd_IntegerList) aTypesList;
276   Handle(TDataStd_BooleanList) aClosuresList;
277   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
278   if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
279     return aResName;
280
281   TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
282   for ( int i = 0; aNamesIter.More() && i != theSectionIndex; aNamesIter.Next(), ++i );
283
284   if ( aNamesIter.More() )
285     aResName = aNamesIter.Value();
286
287   return aResName;
288 }
289
290 void HYDROData_PolylineXY::SetSectionName( const int                      theSectionIndex, 
291                                            const TCollection_AsciiString& theSectionName )
292 {
293   Handle(TDataStd_ExtStringList) aNamesList;
294   Handle(TDataStd_IntegerList) aTypesList;
295   Handle(TDataStd_BooleanList) aClosuresList;
296   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
297   if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
298     return;
299
300   TDataStd_ListOfExtendedString anOldNamesList;
301   anOldNamesList = aNamesList->List();
302
303   // Refill the existing list
304   aNamesList->Clear();
305
306   TCollection_ExtendedString aNewSectName = theSectionName;
307
308   TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
309   for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
310     aNamesList->Append( i == theSectionIndex ? aNewSectName : aNamesIter.Value() );
311 }
312
313 HYDROData_PolylineXY::SectionType HYDROData_PolylineXY::GetSectionType( const int theSectionIndex ) const
314 {
315   Handle(TDataStd_ExtStringList) aNamesList;
316   Handle(TDataStd_IntegerList) aTypesList;
317   Handle(TDataStd_BooleanList) aClosuresList;
318   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
319   if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
320     return SECTION_POLYLINE;
321
322   TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
323   for ( int i = 0; aTypesIter.More() && i != theSectionIndex; aTypesIter.Next(), ++i );
324
325   return aTypesIter.More() ? (SectionType)aTypesIter.Value() : SECTION_POLYLINE;
326 }
327
328 void HYDROData_PolylineXY::SetSectionType( const int         theSectionIndex, 
329                                            const SectionType theSectionType )
330 {
331   Handle(TDataStd_ExtStringList) aNamesList;
332   Handle(TDataStd_IntegerList) aTypesList;
333   Handle(TDataStd_BooleanList) aClosuresList;
334   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
335   if ( aTypesList.IsNull() || theSectionIndex >= aTypesList->Extent() )
336     return;
337
338   TColStd_ListOfInteger anOldTypesList;
339   anOldTypesList = aTypesList->List();
340
341   // Refill the existing list
342   aTypesList->Clear();
343
344   TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
345   for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
346     aTypesList->Append( i == theSectionIndex ? theSectionType : aTypesIter.Value() );
347 }
348
349 bool HYDROData_PolylineXY::IsClosedSection( const int theSectionIndex ) const
350 {
351   Handle(TDataStd_ExtStringList) aNamesList;
352   Handle(TDataStd_IntegerList) aTypesList;
353   Handle(TDataStd_BooleanList) aClosuresList;
354   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
355   if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
356     return false;
357
358   TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
359   for ( int i = 0; aClosuresIter.More() && i != theSectionIndex; aClosuresIter.Next(), ++i );
360
361   return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
362 }
363
364 void HYDROData_PolylineXY::SetSectionClosed( const int  theSectionIndex, 
365                                              const bool theIsClosed )
366 {
367   Handle(TDataStd_ExtStringList) aNamesList;
368   Handle(TDataStd_IntegerList) aTypesList;
369   Handle(TDataStd_BooleanList) aClosuresList;
370   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
371   if ( aClosuresList.IsNull() || theSectionIndex >= aClosuresList->Extent() )
372     return;
373
374   TDataStd_ListOfByte anOldClosuresList;
375   anOldClosuresList = aClosuresList->List();
376
377   // Refill the existing list
378   aClosuresList->Clear();
379
380   TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
381   for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
382     aClosuresList->Append( i == theSectionIndex ? theIsClosed : (bool)aClosuresIter.Value() );
383 }
384
385 void HYDROData_PolylineXY::GetSections( NCollection_Sequence<TCollection_AsciiString>& theSectNames,
386                                         NCollection_Sequence<SectionType>&             theSectTypes,
387                                         NCollection_Sequence<bool>&                    theSectClosures ) const
388 {
389   theSectNames.Clear();
390   theSectTypes.Clear();
391   theSectClosures.Clear();
392
393   Handle(TDataStd_ExtStringList) aNamesList;
394   Handle(TDataStd_IntegerList) aTypesList;
395   Handle(TDataStd_BooleanList) aClosuresList;
396   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
397   if ( aNamesList.IsNull() || aTypesList.IsNull() || aClosuresList.IsNull() )
398     return;
399
400   TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
401   TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
402   TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
403   for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
404           aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next() )
405   {
406     const TCollection_ExtendedString& aSectName = aNamesIter.Value();
407     SectionType aSectType = (SectionType)aTypesIter.Value();
408     bool aSectClosures = aClosuresIter.Value();
409
410     theSectNames.Append( aSectName );
411     theSectTypes.Append( aSectType );
412     theSectClosures.Append( aSectClosures );
413   }
414 }
415
416 void HYDROData_PolylineXY::RemoveSection( const int theSectionIndex )
417 {
418   Handle(TDataStd_ExtStringList) aNamesList;
419   Handle(TDataStd_IntegerList)   aTypesList;
420   Handle(TDataStd_BooleanList)   aClosuresList;
421   getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
422   if ( aNamesList.IsNull() || theSectionIndex >= aNamesList->Extent() )
423     return;
424
425   if ( aNamesList->Extent() == 1 )
426   {
427     removeSectionsLists();
428     removePointsLists();
429   }
430   else
431   {
432     TDataStd_ListOfExtendedString anOldNamesList;
433     anOldNamesList = aNamesList->List();
434
435     TColStd_ListOfInteger anOldTypesList;
436     anOldTypesList = aTypesList->List();
437
438     TDataStd_ListOfByte anOldClosuresList;
439     anOldClosuresList = aClosuresList->List();
440
441     // Refill the existing lists
442     aNamesList->Clear();
443     aTypesList->Clear();
444     aClosuresList->Clear();
445
446     TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
447     TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
448     TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
449     for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
450                      aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
451     {
452       if ( i == theSectionIndex )
453         continue; // skip index to remove
454
455       aNamesList->Append( aNamesIter.Value() );
456       aTypesList->Append( aTypesIter.Value() );
457       aClosuresList->Append( (bool)aClosuresIter.Value() );
458     }
459
460     // Remove points that belongs to removed section
461     removePointsLists( theSectionIndex );
462   }
463 }
464
465 void HYDROData_PolylineXY::RemoveSections()
466 {
467   removeSectionsLists();
468   removePointsLists();
469 }
470
471 void HYDROData_PolylineXY::AddPoint( const int    theSectionIndex,
472                                      const Point& thePoint,
473                                      const int    thePointIndex )
474 {
475   Handle(TDataStd_RealList) aListX, aListY;
476   getPointsLists( theSectionIndex, aListX, aListY );
477
478   if ( thePointIndex < 0 || thePointIndex >= aListX->Extent() )
479   {
480     aListX->Append( thePoint.X() );
481     aListY->Append( thePoint.Y() );
482   }
483   else
484   {
485     TColStd_ListOfReal anOldListX;
486     anOldListX = aListX->List();
487
488     TColStd_ListOfReal anOldListY;
489     anOldListY = aListY->List();
490
491     // Refill the existing lists
492     aListX->Clear();
493     aListY->Clear();
494
495     TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
496     TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
497     for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
498     {
499       double aCoordX = anIterX.Value();
500       double aCoordY = anIterY.Value();
501
502       if ( i == thePointIndex )
503       {
504         // Insert our new point
505         aListX->Append( thePoint.X() );
506         aListY->Append( thePoint.Y() );
507       }
508
509       aListX->Append( aCoordX );
510       aListY->Append( aCoordY );
511     }
512   }
513 }
514
515 void HYDROData_PolylineXY::SetPoint( const int    theSectionIndex,
516                                      const Point& thePoint,
517                                      const int    thePointIndex )
518 {
519   Handle(TDataStd_RealList) aListX, aListY;
520   getPointsLists( theSectionIndex, aListX, aListY );
521
522   if ( thePointIndex < 0 )
523   {
524     aListX->Prepend( thePoint.X() );
525     aListY->Prepend( thePoint.Y() );
526   }
527   else if ( thePointIndex >= aListX->Extent() )
528   {
529     aListX->Append( thePoint.X() );
530     aListY->Append( thePoint.Y() );
531   }
532   else
533   {
534     TColStd_ListOfReal anOldListX;
535     anOldListX = aListX->List();
536
537     TColStd_ListOfReal anOldListY;
538     anOldListY = aListY->List();
539
540     // Refill the existing lists
541     aListX->Clear();
542     aListY->Clear();
543
544     TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
545     TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
546     for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
547     {
548       double aCoordX = anIterX.Value();
549       double aCoordY = anIterY.Value();
550
551       if ( i == thePointIndex )
552       {
553         // Insert our new point instead of old one
554         aCoordX = thePoint.X();
555         aCoordY = thePoint.Y();
556       }
557
558       aListX->Append( aCoordX );
559       aListY->Append( aCoordY );
560     }
561   }
562 }
563
564 void HYDROData_PolylineXY::RemovePoint( const int theSectionIndex,
565                                         const int thePointIndex )
566 {
567   Handle(TDataStd_RealList) aListX, aListY;
568   getPointsLists( theSectionIndex, aListX, aListY, false );
569   if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
570     return;
571
572   if ( aListX->Extent() == 1 )
573   {
574     removePointsLists( theSectionIndex );
575   }
576   else
577   {
578     TColStd_ListOfReal anOldListX;
579     anOldListX = aListX->List();
580
581     TColStd_ListOfReal anOldListY;
582     anOldListY = aListY->List();
583
584     // Refill the existing lists
585     aListX->Clear();
586     aListY->Clear();
587
588     TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
589     TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
590     for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
591     {
592       if ( i == thePointIndex )
593         continue; // skip index to remove
594
595       aListX->Append( anIterX.Value() );
596       aListY->Append( anIterY.Value() );
597     }
598   }
599 }
600
601 HYDROData_PolylineXY::PointsList HYDROData_PolylineXY::GetPoints( const int theSectionIndex ) const
602 {
603   PointsList aResList;
604
605   Handle(TDataStd_RealList) aListX, aListY;
606   getPointsLists( theSectionIndex, aListX, aListY, false );
607   if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
608     return aResList;
609
610   TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
611   TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
612   for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
613   {
614     Point aPoint( anIterX.Value(), anIterY.Value() );
615     aResList.Append( aPoint );
616   }
617
618   return aResList;
619 }
620
621 QPainterPath HYDROData_PolylineXY::GetPainterPath() const
622 {
623   QPainterPath aPath;
624
625   NCollection_Sequence<TCollection_AsciiString>           aSectNames;
626   NCollection_Sequence<HYDROData_PolylineXY::SectionType> aSectTypes;
627   NCollection_Sequence<bool>                              aSectClosures;
628   GetSections( aSectNames, aSectTypes, aSectClosures );
629   if( aSectNames.IsEmpty() )
630     return aPath;
631
632   PointsList aSectPointsList = GetPoints( 0 );
633   if( aSectPointsList.IsEmpty() )
634     return aPath;
635
636   SectionType aSectionType = aSectTypes.Value( 1 );
637   bool anIsSectionClosed = aSectClosures.Value( 1 );
638
639   if ( aSectionType == SECTION_POLYLINE )
640   {
641     aPath.moveTo( aSectPointsList.Value( 1 ).X(), aSectPointsList.Value( 1 ).Y() );
642
643     for( int i = 2, n = aSectPointsList.Size(); i <= n; ++i )
644     {
645       const Point& aSectPoint = aSectPointsList.Value( i );
646
647       aPath.lineTo( aSectPoint.X(), aSectPoint.Y() );
648     }
649
650     if( anIsSectionClosed )
651       aPath.closeSubpath();
652   }
653   else
654   {
655     QList<double> aPoints;
656     for( int i = 1, n = aSectPointsList.Size(); i <= n; ++i )
657     {
658       const Point& aSectPoint = aSectPointsList.Value( i );
659       aPoints << aSectPoint.X() << aSectPoint.Y();
660     }
661
662     HYDROData_BSplineOperation aBSpline( aPoints, 0, anIsSectionClosed );
663     aPath = aBSpline.ComputePath();
664   }
665
666   return aPath;
667 }
668
669