#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepOffsetAPI_NormalProjection.hxx>
const bool& theIsClosed,
const NCollection_Sequence<gp_XYZ>& thePoints )
{
- BRepBuilderAPI_MakeWire aMakeWire;
-
+ TopoDS_Wire aWire;
if( theType == SECTION_POLYLINE )
{
- for( int i = 1, n = thePoints.Size(); i <= n; ++i )
+ BRepBuilderAPI_MakePolygon aMakeWire;
+ for ( int i = 1, n = thePoints.Length(); 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() );
-
- if ( aPnt1.IsEqual( aPnt2, LOCAL_SELECTION_TOLERANCE ) )
- continue;
-
- TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aPnt1, aPnt2 ).Edge();
- aMakeWire.Add( anEdge );
+ gp_XYZ aPoint = thePoints.Value( i );
+ gp_Pnt aPnt( aPoint.X(), aPoint.Y(), aPoint.Z() );
+ aMakeWire.Add( aPnt );
}
+ if( theIsClosed )
+ aMakeWire.Close();//.Add( thePoints.Value( 1 ) );
+
+ if ( aMakeWire.IsDone() )
+ aWire = aMakeWire.Wire();
}
else //if( theType == PolylineSection::SECTION_SPLINE )
{
- HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
+ BRepBuilderAPI_MakeWire aMakeWire;
- TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
- aMakeWire.Add( anEdge );
- }
+ if ( thePoints.Size() > 1 )
+ {
+ HYDROData_BSplineOperation aBSpline( thePoints, theIsClosed, LOCAL_SELECTION_TOLERANCE );
- TopoDS_Wire aWire;
- aMakeWire.Build();
- if ( aMakeWire.IsDone() )
- aWire = aMakeWire;
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
+ aMakeWire.Add( anEdge );
+ }
+ aMakeWire.Build();
+ if ( aMakeWire.IsDone() )
+ aWire = aMakeWire;
+ }
return aWire;
}