+++ /dev/null
-// 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<GeomAPI_Shape> theSourceShape,
- std::shared_ptr<GeomAPI_Ax1> theAxis,
- double theAngle)
-{
-}
-
-//=================================================================================================
-bool GeomAlgoAPI_MultiRotation::check()
-{
- return true;
-}
-
-//=================================================================================================
-void GeomAlgoAPI_MultiRotation::build()
-{
- setDone(true);
-}
+++ /dev/null
-// 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 <GeomAlgoAPI.h>
-#include <GeomAlgoAPI_MakeShape.h>
-
-#include <GeomAPI_Ax1.h>
-#include <GeomAPI_Shape.h>
-
-/// \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<GeomAPI_Shape> theSourceShape,
- std::shared_ptr<GeomAPI_Ax1> 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<GeomAPI_Shape> mySourceShape; /// Shape to be rotated.
- std::shared_ptr<GeomAPI_Ax1> myAxis; /// Rotation axis.
- double myAngle; /// Rotation angle.
- std::shared_ptr<GeomAPI_Pnt> myCenterPoint; /// Rotation center point.
- std::shared_ptr<GeomAPI_Pnt> myStartPoint; /// Rotation start point.
- std::shared_ptr<GeomAPI_Pnt> myEndPoint; /// Rotation end point.
-};
-
-#endif // GEOMALGOAPI_MULTIROTATION_H_
return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
}
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> 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<theNumber; i++) {
+ aListOfShape.
+ push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*anAngle));
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ }
+
+ //===============================================================================================
+ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeMultiRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> 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<theNumber; i++) {
+ aListOfShape.
+ push_back(GeomAlgoAPI_ShapeAPI::makeRotation(theSourceShape, theAxis, i*theStep));
+ }
+ return GeomAlgoAPI_CompoundBuilder::compound(aListOfShape);
+ }
+
//===============================================================================================
std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
const double theRMin1, const double theRMax1,
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<GeomAPI_Shape> makeMultiRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> 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<GeomAPI_Shape> makeMultiRotation(
+ std::shared_ptr<GeomAPI_Shape> theSourceShape,
+ std::shared_ptr<GeomAPI_Ax1> 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