+
+void HYDROData_Polyline::SetZValue( const double theZValue )
+{
+ TDataStd_Real::Set(myLab.FindChild(DataTag_ZValue), theZValue);
+}
+
+double HYDROData_Polyline::ZValue() const
+{
+ Handle(TDataStd_Real) aZValue;
+ if(myLab.FindChild(DataTag_ZValue).FindAttribute(TDataStd_Real::GetID(), aZValue))
+ return aZValue->Get();
+ return 0;
+}
+
+void HYDROData_Polyline::UpdateWire( const PolylineData& theSections )
+{
+ BRepBuilderAPI_MakeWire aMakeWire;
+
+ int aDim = GetDimension();
+
+ double aZValue = ZValue();
+
+ int aSectionCount = theSections.size();
+ for( int aSectionId = 0; aSectionId < aSectionCount; aSectionId++ )
+ {
+ const PolylineSection& aSection = theSections[ aSectionId ];
+ PolylineSection::SectionType aSectionType = aSection.myType;
+ bool anIsSectionClosed = aSection.myIsClosed;
+ int aPointCount = aSection.myCoords.size() / aDim;
+ if( aPointCount > 1 )
+ {
+ BRepBuilderAPI_MakeWire aMakeSectionWire;
+ if( aSectionType == PolylineSection::SECTION_POLYLINE )
+ {
+ for( int aPointId = 0; aPointId < aPointCount; aPointId++ )
+ {
+ int anId1 = aDim * aPointId;
+ int anId2 = aDim * ( aPointId + 1 );
+ if( aPointId == aPointCount - 1 )
+ {
+ if( anIsSectionClosed )
+ anId2 = 0;
+ else
+ break;
+ }
+
+ gp_Pnt aPnt1( aSection.myCoords[ anId1 ], aSection.myCoords[ anId1 + 1 ], aZValue );
+ gp_Pnt aPnt2( aSection.myCoords[ anId2 ], aSection.myCoords[ anId2 + 1 ], aZValue );
+
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
+ aMakeSectionWire.Add( anEdge );
+ }
+ }
+ else //if( aSectionType == PolylineSection::SECTION_SPLINE )
+ {
+ QList<double> aPoints;
+ for( int aPointId = 0; aPointId < aPointCount; aPointId++ )
+ {
+ int anId = aPointId * aDim;
+ double x = aSection.myCoords[ anId ];
+ double y = aSection.myCoords[ anId+1 ];
+ aPoints << x << y;
+ }
+
+ HYDROData_BSplineOperation aBSpline( aPoints, aZValue, anIsSectionClosed );
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
+ aMakeSectionWire.Add( anEdge );
+ }
+ TopoDS_Wire aSectionWire = aMakeSectionWire.Wire();
+ aMakeWire.Add( aSectionWire );
+ }
+ }
+
+ TopoDS_Shape aShape = aMakeWire.Shape();
+ SetTopShape( aShape );
+}