3 #include <BRepBuilderAPI_MakeEdge.hxx>
4 #include <BRepBuilderAPI_MakeFace.hxx>
5 #include <BRepBuilderAPI_MakeWire.hxx>
6 #include <TopoDS_Edge.hxx>
7 #include <TopoDS_Wire.hxx>
8 #include <TopoDS_Face.hxx>
9 #include <TColgp_HArray1OfPnt.hxx>
10 #include <GeomAPI_Interpolate.hxx>
12 TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed )
14 int n = theXYList.size()/2;
15 Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
16 for( int i=1; i<=n; i++ )
18 double x = theXYList[2*i-2];
19 double y = theXYList[2*i-1];
20 gp_Pnt aPnt( x, y, 0 );
21 aPointsArray->SetValue( i, aPnt );
23 GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 );
24 anInterpolator.Perform();
25 bool aResult = anInterpolator.IsDone() == Standard_True;
28 Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve();
29 return BRepBuilderAPI_MakeEdge( aCurve ).Edge();
35 TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed )
37 return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire();
40 TopoDS_Face Face( const QList<double>& theXYList )
42 return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face();