2 #include "HYDROData_ProfileUZ.h"
4 #include "HYDROData_Tool.h"
8 #include <TColStd_ListIteratorOfListOfReal.hxx>
10 #include <TDataStd_RealList.hxx>
12 #include <TopoDS_Shape.hxx>
15 IMPLEMENT_STANDARD_HANDLE(HYDROData_ProfileUZ, HYDROData_IPolyline)
16 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_ProfileUZ, HYDROData_IPolyline)
18 HYDROData_ProfileUZ::HYDROData_ProfileUZ()
19 : HYDROData_IPolyline()
23 HYDROData_ProfileUZ::~HYDROData_ProfileUZ()
27 TopoDS_Shape HYDROData_ProfileUZ::GetShape()
30 return TopoDS_Shape();
33 int HYDROData_ProfileUZ::NbSections() const
38 void HYDROData_ProfileUZ::AddSection( const TCollection_AsciiString& /*theSectName*/,
39 const SectionType /*theSectionType*/,
40 const bool /*theIsClosed*/ )
44 TCollection_AsciiString HYDROData_ProfileUZ::GetSectionName( const int /*theSectionIndex*/ ) const
49 void HYDROData_ProfileUZ::SetSectionName( const int /*theSectionIndex*/,
50 const TCollection_AsciiString& /*theSectionName*/ )
54 HYDROData_ProfileUZ::SectionType HYDROData_ProfileUZ::GetSectionType( const int /*theSectionIndex*/ ) const
56 return SECTION_POLYLINE;
59 void HYDROData_ProfileUZ::SetSectionType( const int /*theSectionIndex*/,
60 const SectionType /*theSectionType*/ )
64 bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const
69 void HYDROData_ProfileUZ::SetSectionClosed( const int /*theSectionIndex*/,
70 const bool /*theIsClosed*/ )
74 void HYDROData_ProfileUZ::RemoveSection( const int /*theSectionIndex*/ )
79 void HYDROData_ProfileUZ::RemoveSections()
81 removePointsLists( 0 );
84 void HYDROData_ProfileUZ::AddPoint( const int /*theSectionIndex*/,
85 const Point& thePoint,
86 const int thePointIndex )
88 double aNewCoordU = thePoint.X();
89 double aNewCoordZ = thePoint.Y();
91 Handle(TDataStd_RealList) aListU, aListZ;
92 getPointsLists( 0, aListU, aListZ );
94 if ( aListU->IsEmpty() || aNewCoordU > aListU->Last() )
96 aListU->Append( aNewCoordU );
97 aListZ->Append( aNewCoordZ );
100 else if ( aNewCoordU < aListU->First() )
102 aListU->Prepend( aNewCoordU );
103 aListZ->Prepend( aNewCoordZ );
107 TColStd_ListOfReal anOldListU;
108 anOldListU = aListU->List();
110 TColStd_ListOfReal anOldListZ;
111 anOldListZ = aListZ->List();
114 removePointsLists( 0 );
115 getPointsLists( 0, aListU, aListZ );
117 bool anIsInserted = false;
118 TColStd_ListIteratorOfListOfReal anIterU( anOldListU );
119 TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ );
120 for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() )
122 double aCoordU = anIterU.Value();
123 double aCoordZ = anIterZ.Value();
127 if ( ValuesEquals( aNewCoordU, aCoordU ) )
129 // Just update Z value
130 aCoordZ = aNewCoordZ;
133 else if ( aNewCoordU < aCoordU )
136 aListU->Append( aNewCoordU );
137 aListZ->Append( aNewCoordZ );
142 aListU->Append( aCoordU );
143 aListZ->Append( aCoordZ );
147 void HYDROData_ProfileUZ::SetPoint( const int theSectionIndex,
148 const Point& thePoint,
149 const int /*thePointIndex*/ )
151 AddPoint( theSectionIndex, thePoint );
154 void HYDROData_ProfileUZ::RemovePoint( const int /*theSectionIndex*/,
155 const int thePointIndex )
157 Handle(TDataStd_RealList) aListU, aListZ;
158 getPointsLists( 0, aListU, aListZ, false );
159 if ( aListU.IsNull() || aListZ.IsNull() || aListU->IsEmpty() )
162 TColStd_ListOfReal anOldListU;
163 anOldListU = aListU->List();
165 TColStd_ListOfReal anOldListZ;
166 anOldListZ = aListZ->List();
169 removePointsLists( 0 );
170 getPointsLists( 0, aListU, aListZ );
172 bool anIsInserted = false;
173 TColStd_ListIteratorOfListOfReal anIterU( anOldListU );
174 TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ );
175 for ( int i = 0; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next(), ++i )
177 if ( i == thePointIndex )
178 continue; // skip index to remove
180 aListU->Append( anIterU.Value() );
181 aListZ->Append( anIterZ.Value() );
185 HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theSectionIndex*/ ) const
189 Handle(TDataStd_RealList) aListU, aListZ;
190 getPointsLists( 0, aListU, aListZ, false );
191 if ( aListU.IsNull() || aListZ.IsNull() )
194 TColStd_ListIteratorOfListOfReal anIterU( aListU->List() );
195 TColStd_ListIteratorOfListOfReal anIterZ( aListZ->List() );
196 for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() )
198 Point aPoint( anIterU.Value(), anIterZ.Value() );
199 aResList.Append( aPoint );