+TopoDS_Wire HYDROData_PolylineXY::BuildWire( const SectionType& theType,
+ const bool& theIsClosed,
+ const NCollection_Sequence<gp_XYZ>& thePoints )
+{
+ BRepBuilderAPI_MakeWire aMakeWire;
+
+ if( theType == SECTION_POLYLINE )
+ {
+ for( int i = 1, n = thePoints.Size(); i <= n; ++i )
+ {
+ const gp_XYZ& aFirstPoint = thePoints.Value( i );
+
+ gp_XYZ aLastPoint;
+ if ( i == n )
+ {
+ if( theIsClosed )
+ aLastPoint = thePoints.Value( 1 );
+ else
+ break;
+ }
+ else
+ {
+ aLastPoint = thePoints.Value( i + 1 );
+ }
+
+ gp_Pnt aPnt1( aFirstPoint.X(), aFirstPoint.Y(), aFirstPoint.Z() );
+ gp_Pnt aPnt2( aLastPoint.X(), aLastPoint.Y(), aLastPoint.Z() );
+
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
+ aMakeWire.Add( anEdge );
+ }
+ }
+ else //if( theType == PolylineSection::SECTION_SPLINE )
+ {
+ HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
+
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
+ aMakeWire.Add( anEdge );
+ }
+
+ TopoDS_Wire aWire;
+ aMakeWire.Build();
+ if ( aMakeWire.IsDone() )
+ aWire = aMakeWire;
+
+ return aWire;
+}
+
+QPainterPath HYDROData_PolylineXY::BuildPainterPath( const SectionType& theType,
+ const bool& theIsClosed,
+ const NCollection_Sequence<gp_XYZ>& thePoints )
+{
+ QPainterPath aPath;
+ if ( thePoints.IsEmpty() )
+ return aPath;
+
+ if ( theType == SECTION_POLYLINE )
+ {
+ aPath.moveTo( thePoints.Value( 1 ).X(), thePoints.Value( 1 ).Y() );
+
+ for( int i = 2, n = thePoints.Size(); i <= n; ++i )
+ {
+ const gp_XYZ& aSectPoint = thePoints.Value( i );
+
+ aPath.lineTo( aSectPoint.X(), aSectPoint.Y() );
+ }
+
+ if( theIsClosed )
+ aPath.closeSubpath();
+ }
+ else
+ {
+ HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed );
+ aPath = aBSpline.ComputePath();
+ }
+
+ return aPath;
+}
+