#include <GeomAPI_Interpolate.hxx>
#include <gp_Circ.hxx>
-TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed )
+TopoDS_Edge Edge2d( const QList<double>& theXYList, bool isClosed )
{
int n = theXYList.size()/2;
Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
return TopoDS_Edge();
}
-TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed )
+TopoDS_Wire Wire2d( const QList<double>& theXYList, bool isClosed )
{
- return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire();
+ return BRepBuilderAPI_MakeWire( Edge2d( theXYList, isClosed ) ).Wire();
}
-TopoDS_Face Face( const QList<double>& theXYList )
+TopoDS_Edge Edge3d( const QList<double>& theXYZList, bool isClosed )
{
- return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face();
+ int n = theXYZList.size()/3;
+ Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
+ for( int i=1; i<=n; i++ )
+ {
+ double x = theXYZList[3*i-3];
+ double y = theXYZList[3*i-2];
+ double z = theXYZList[3*i-1];
+ gp_Pnt aPnt( x, y, z );
+ aPointsArray->SetValue( i, aPnt );
+ }
+ GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 );
+ anInterpolator.Perform();
+ bool aResult = anInterpolator.IsDone() == Standard_True;
+ if( aResult )
+ {
+ Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve();
+ return BRepBuilderAPI_MakeEdge( aCurve ).Edge();
+ }
+ else
+ return TopoDS_Edge();
+}
+
+TopoDS_Wire Wire3d( const QList<double>& theXYZList, bool isClosed )
+{
+ return BRepBuilderAPI_MakeWire( Edge3d( theXYZList, isClosed ) ).Wire();
+}
+
+TopoDS_Face Face2d( const QList<double>& theXYList )
+{
+ return BRepBuilderAPI_MakeFace( Wire2d( theXYList, true ), Standard_True ).Face();
+}
+
+TopoDS_Face Face3d( const QList<double>& theXYZList )
+{
+ return BRepBuilderAPI_MakeFace( Wire3d( theXYZList, true ), Standard_True ).Face();
}
TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius )