]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDRO_tests/TestShape.cxx
Salome HOME
106ee9b579620d81a4e8cda108dc0e31c32cd714
[modules/hydro.git] / src / HYDRO_tests / TestShape.cxx
1
2 #include <TestShape.h>
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
12 TopoDS_Edge Edge( const QList<double>& theXYList, bool isClosed )
13 {
14   int n = theXYList.size()/2;
15   Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n );
16   for( int i=1; i<=n; i++ )
17   {
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 );
22   }
23   GeomAPI_Interpolate anInterpolator( aPointsArray, isClosed, 1E-3 );
24   anInterpolator.Perform();
25   bool aResult = anInterpolator.IsDone() == Standard_True;
26   if( aResult )
27   {
28     Handle( Geom_BSplineCurve ) aCurve = anInterpolator.Curve();
29     return BRepBuilderAPI_MakeEdge( aCurve ).Edge();
30   }
31   else
32     return TopoDS_Edge();
33 }
34
35 TopoDS_Wire Wire( const QList<double>& theXYList, bool isClosed )
36 {
37   return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire();
38 }
39
40 TopoDS_Face Face( const QList<double>& theXYList )
41 {
42   return BRepBuilderAPI_MakeFace( Wire( theXYList, true ), Standard_True ).Face();
43 }