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>
11 #include <gp_Circ.hxx>
13 TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed )
15 int n = theXYList.size()/2;
16 Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
17 for( int i=1; i<=n; i++ )
19 double x = theXYList[2*i-2];
20 double y = theXYList[2*i-1];
21 gp_Pnt aPnt( x, y, 0 );
22 aPointsArray->SetValue( i, aPnt );
24 GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 );
25 anInterpolator.Perform();
26 bool aResult = anInterpolator.IsDone() == Standard_True;
29 Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve();
30 return BRepBuilderAPI_MakeEdge( aCurve ).Edge();
36 TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed )
38 return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire();
41 TopoDS_Face Face( const QList<double>& theXYList )
43 return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face();
46 TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius )
48 gp_Circ aCircle( gp_Ax2( theCenter, gp_Dir( 0, 0, 1 ) ), theRadius );
49 TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aCircle ).Edge();
50 return BRepBuilderAPI_MakeWire( anEdge ).Wire();