From: Clarisse Genrault Date: Thu, 16 Feb 2017 14:52:06 +0000 (+0100) Subject: Added direct Shape API for the multitranslation. X-Git-Tag: V_2.7.0~279 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=60d78c5367d036afa0ad7fc43b7633ef80d8e7af;p=modules%2Fshaper.git Added direct Shape API for the multitranslation. --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index b10e028ab..a27dc623b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -16,6 +17,8 @@ #include +#include + namespace GeomAlgoAPI_ShapeAPI { //=============================================================================================== @@ -329,6 +332,81 @@ namespace GeomAlgoAPI_ShapeAPI return aScaleAlgo.shape(); } + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeScale( + std::shared_ptr theSourceShape, + std::shared_ptr theCenterPoint, + const double theScaleFactorX, + const double theScaleFactorY, + const double theScaleFactorZ) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint, + theScaleFactorX, theScaleFactorY, theScaleFactorZ); + + if (!aScaleAlgo.check()) { + throw GeomAlgoAPI_Exception(aScaleAlgo.getError()); + } + + aScaleAlgo.build(); + + if(!aScaleAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aScaleAlgo.getError()); + } + if (!aScaleAlgo.checkValid("Scale builder by dimensions")) { + throw GeomAlgoAPI_Exception(aScaleAlgo.getError()); + } + return aScaleAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeMultiTranslation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const double theStep, + const int theNumber) throw (GeomAlgoAPI_Exception) + { + ListOfShape aListOfShape; + for (int i=0; i GeomAlgoAPI_ShapeAPI::makeMultiTranslation( + std::shared_ptr theSourceShape, + std::shared_ptr theFirstAxis, + const double theFirstStep, + const int theFirstNumber, + std::shared_ptr theSecondAxis, + const double theSecondStep, + const int theSecondNumber) throw (GeomAlgoAPI_Exception) + { + // Coord theFirstAxis + double x1 = theFirstAxis->dir()->x(); + double y1 = theFirstAxis->dir()->y(); + double z1 = theFirstAxis->dir()->z(); + double norm1 = sqrt(x1*x1 + y1*y1 + z1*z1); + + // Coord theSecondAxis + double x2 = theSecondAxis->dir()->x(); + double y2 = theSecondAxis->dir()->y(); + double z2 = theSecondAxis->dir()->z(); + double norm2 = sqrt(x2*x2 + y2*y2 + z2*z2); + + ListOfShape aListOfShape; + for (int j=0; j GeomAlgoAPI_ShapeAPI::makeConeSegment( const double theRMin1, const double theRMax1, diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index bbabbf902..81dbfd705 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -78,7 +78,7 @@ public: /// \return a shape static std::shared_ptr makeTranslation( std::shared_ptr theSourceShape, - std::shared_ptr theAxis, + std::shared_ptr theAxis, const double theDistance) throw (GeomAlgoAPI_Exception); /// Performs a translation from dimensions. @@ -100,29 +100,29 @@ public: /// \return a shape static std::shared_ptr makeTranslation( std::shared_ptr theSourceShape, - std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception); + std::shared_ptr theStartPoint, + std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception); /// Performs a symmetry by a point. /// \param theSourceShape Shape be symmetrized /// \param thePoint Point of symmetry static std::shared_ptr makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr thePoint) throw (GeomAlgoAPI_Exception); + std::shared_ptr thePoint) throw (GeomAlgoAPI_Exception); /// Performs a symmetry by an axis. /// \param theSourceShape Shape be symmetrized /// \param theAxis Axis of symmetry static std::shared_ptr makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr theAxis) throw (GeomAlgoAPI_Exception); + std::shared_ptr theAxis) throw (GeomAlgoAPI_Exception); /// Performs a symmetry by a plane. /// \param theSourceShape Shape be symmetrized /// \param thePlane Plane of symmetry static std::shared_ptr makeSymmetry( std::shared_ptr theSourceShape, - std::shared_ptr thePlane) throw (GeomAlgoAPI_Exception); + std::shared_ptr thePlane) throw (GeomAlgoAPI_Exception); /// Performs a scale by a scale factor. /// \param theSourceShape Shape be scaled @@ -130,8 +130,52 @@ public: /// \param theScaleFactor Factor of scale static std::shared_ptr makeScale( std::shared_ptr theSourceShape, - std::shared_ptr theCenterPoint, - const double theScaleFactor) throw (GeomAlgoAPI_Exception); + std::shared_ptr theCenterPoint, + const double theScaleFactor) throw (GeomAlgoAPI_Exception); + + /// Performs a scale by dimensions. + /// \param theSourceShape Shape be scaled + /// \param theCenterPoint Point of scale + /// \param theScaleFactorX Factor of scale in X + /// \param theScaleFactorY Factor of scale in Y + /// \param theScaleFactorZ Factor of scale in Z + static std::shared_ptr makeScale( + std::shared_ptr theSourceShape, + std::shared_ptr theCenterPoint, + const double theScaleFactorX, + const double theScaleFactorY, + const double theScaleFactorZ) throw (GeomAlgoAPI_Exception); + + /// Performs a multi translation along one axis, at a distance and a number of times + /// \param theSourceShape Shape to be moved + /// \param theAxis Movement axis + /// \param theStep Movement step + /// \param theNumber Movement number + /// \return a shape + static std::shared_ptr makeMultiTranslation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const double theStep, + const int theNumber) throw (GeomAlgoAPI_Exception); + + /// Performs a multi translation along two axis : a different distance on each axis + /// and a different number of times for each axis + /// \param theSourceShape Shape to be moved + /// \param theFirstAxis First movement axis + /// \param theFirstStep First movement step + /// \param theFirstNumber First movement number + /// \param theSecondAxis First movement axis + /// \param theSecondStep First movement step + /// \param theSecondNumber First movement number + /// \return a shape + static std::shared_ptr makeMultiTranslation( + std::shared_ptr theSourceShape, + std::shared_ptr theFirstAxis, + const double theFirstStep, + const int theFirstNumber, + std::shared_ptr theSecondAxis, + const double theSecondStep, + const int theSecondNumber) throw (GeomAlgoAPI_Exception); /// Creates a cone segment using standard GDML parameters. /// \param theRMin1 Inner radius at base of cone