X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2FTestShape.cxx;h=70ce0866aca0b77dbe89918a6da28062b0225556;hb=15aed67b5f26dad1f17035be35bcd570e947158c;hp=1054ead91b6a0be366a5611b70c8fbf4852cb774;hpb=9c947f35615e69e9e54a8c4b074dd1f2be13689c;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/TestShape.cxx b/src/HYDRO_tests/TestShape.cxx index 1054ead9..70ce0866 100644 --- a/src/HYDRO_tests/TestShape.cxx +++ b/src/HYDRO_tests/TestShape.cxx @@ -1,3 +1,20 @@ +// Copyright (C) 2014-2015 EDF-R&D +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include #include @@ -10,7 +27,7 @@ #include #include -TopoDS_Edge Edge( const QList& theXYList, bool isClosed ) +TopoDS_Edge Edge2d( const QList& theXYList, bool isClosed ) { int n = theXYList.size()/2; Handle(TColgp_HArray1OfPnt) aPointsArray = new TColgp_HArray1OfPnt( 1, n ); @@ -33,14 +50,48 @@ TopoDS_Edge Edge( const QList& theXYList, bool isClosed ) return TopoDS_Edge(); } -TopoDS_Wire Wire( const QList& theXYList, bool isClosed ) +TopoDS_Wire Wire2d( const QList& theXYList, bool isClosed ) { - return BRepBuilderAPI_MakeWire( Edge( theXYList, isClosed ) ).Wire(); + return BRepBuilderAPI_MakeWire( Edge2d( theXYList, isClosed ) ).Wire(); } -TopoDS_Face Face( const QList& theXYList ) +TopoDS_Edge Edge3d( const QList& 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& theXYZList, bool isClosed ) +{ + return BRepBuilderAPI_MakeWire( Edge3d( theXYZList, isClosed ) ).Wire(); +} + +TopoDS_Face Face2d( const QList& theXYList ) +{ + return BRepBuilderAPI_MakeFace( Wire2d( theXYList, true ), Standard_True ).Face(); +} + +TopoDS_Face Face3d( const QList& theXYZList ) +{ + return BRepBuilderAPI_MakeFace( Wire3d( theXYZList, true ), Standard_True ).Face(); } TopoDS_Wire WireCirc( const gp_Pnt& theCenter, double theRadius )