From: Clarisse Genrault Date: Wed, 5 Apr 2017 14:42:05 +0000 (+0200) Subject: Added MultiRotation feature (Shape API). X-Git-Tag: V_2.9.0~40 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=66de0bb2ec3364c39bebb7554e5c04498f788d50;p=modules%2Fshaper.git Added MultiRotation feature (Shape API). --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MultiRotation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MultiRotation.cpp deleted file mode 100644 index 0c706d358..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MultiRotation.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAlgoAPI_MultiRotation.cpp -// Created: 30 Mar 2017 -// Author: Clarisse Genrault (CEA) - -#include "GeomAlgoAPI_MultiRotation.h" - -//================================================================================================= -GeomAlgoAPI_MultiRotation::GeomAlgoAPI_MultiRotation(std::shared_ptr theSourceShape, - std::shared_ptr theAxis, - double theAngle) -{ -} - -//================================================================================================= -bool GeomAlgoAPI_MultiRotation::check() -{ - return true; -} - -//================================================================================================= -void GeomAlgoAPI_MultiRotation::build() -{ - setDone(true); -} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MultiRotation.h b/src/GeomAlgoAPI/GeomAlgoAPI_MultiRotation.h deleted file mode 100644 index d687e4ae7..000000000 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MultiRotation.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomAlgoAPI_MultiRotation.h -// Created: 30 Mar 2017 -// Author: Clarisse Genrault (CEA) - -#ifndef GEOMALGOAPI_MULTIROTATION_H_ -#define GEOMALGOAPI_MULTIROTATION_H_ - -#include -#include - -#include -#include - -/// \class GeomAlgoAPI_MultiRotation -/// \ingroup DataAlgo -/// \brief Creates a copy of the object by rotating it around the axis. -class GeomAlgoAPI_MultiRotation : public GeomAlgoAPI_MakeShape -{ -public: - - /// \brief Creates an object which is obtained from current object by rotating it around the axis - /// with the angle. - /// \param[in] theSourceShape a shape to be rotated. - /// \param[in] theAxis rotation axis. - /// \param[in] theAngle rotation angle(in degree). - GEOMALGOAPI_EXPORT GeomAlgoAPI_MultiRotation(std::shared_ptr theSourceShape, - std::shared_ptr theAxis, - double theAngle); - - /// Checks if data for the translation execution is OK. - GEOMALGOAPI_EXPORT bool check(); - - /// Execute the translation. - GEOMALGOAPI_EXPORT void build(); - -private: - std::shared_ptr mySourceShape; /// Shape to be rotated. - std::shared_ptr myAxis; /// Rotation axis. - double myAngle; /// Rotation angle. - std::shared_ptr myCenterPoint; /// Rotation center point. - std::shared_ptr myStartPoint; /// Rotation start point. - std::shared_ptr myEndPoint; /// Rotation end point. -}; - -#endif // GEOMALGOAPI_MULTIROTATION_H_ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index 6b26c3eb2..a3c700e13 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -673,6 +673,61 @@ namespace GeomAlgoAPI_ShapeAPI return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape); } + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeMultiRotation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const int theNumber) + { + if (!theAxis) { + std::string aError = "Multirotation builder "; + aError+=":: the axis is not valid"; + throw GeomAlgoAPI_Exception(aError); + } + + if (theNumber <=0) { + std::string aError = "Multirotation builder "; + aError+=":: the number of copies is null or negative."; + throw GeomAlgoAPI_Exception(aError); + } + + double anAngle = 360./theNumber; + + ListOfShape aListOfShape; + for (int i=0; i GeomAlgoAPI_ShapeAPI::makeMultiRotation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const double theStep, + const int theNumber) + { + if (!theAxis) { + std::string aError = "Multirotation builder "; + aError+=":: the axis is not valid"; + throw GeomAlgoAPI_Exception(aError); + } + + if (theNumber <=0) { + std::string aError = "Multirotation builder "; + aError+=":: the number of copies is null or negative."; + throw GeomAlgoAPI_Exception(aError); + } + + ListOfShape aListOfShape; + for (int i=0; i GeomAlgoAPI_ShapeAPI::makeConeSegment( const double theRMin1, const double theRMax1, diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index d7bd12034..72797970d 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -242,6 +242,26 @@ public: const double theSecondStep, const int theSecondNumber) throw (GeomAlgoAPI_Exception); + /// Performs a multi rotation along one axis and a number of times + /// \param[in] theSourceShape Shape to be rotated + /// \param[in] theAxis Axis for the rotation + /// \param[in] theNumber Number of copies + static std::shared_ptr makeMultiRotation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const int theNumber); + + /// Performs a multi rotation along one axis, at a step and a number of times + /// \param theSourceShape Shape to be moved + /// \param[in] theAxis Axis for the rotation + /// \param[in] theStep Angle for each rotation + /// \param[in] theNumber Number of copies + static std::shared_ptr makeMultiRotation( + std::shared_ptr theSourceShape, + std::shared_ptr theAxis, + const double theStep, + const int theNumber); + /// Creates a cone segment using standard GDML parameters. /// \param theRMin1 Inner radius at base of cone /// \param theRMax1 Outer radius at base of cone