From 8c0c4ee7412fe13fdffca96d5f56d0fb06ac2543 Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Wed, 5 Apr 2017 15:15:04 +0200 Subject: [PATCH] Added MultiRotation feature (parametric API). --- src/FeaturesAPI/CMakeLists.txt | 2 + src/FeaturesAPI/FeaturesAPI.i | 2 + src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp | 144 ++++++++++++++++++ src/FeaturesAPI/FeaturesAPI_MultiRotation.h | 105 +++++++++++++ .../FeaturesAPI_MultiTranslation.h | 2 +- src/FeaturesAPI/FeaturesAPI_swig.h | 1 + src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp | 8 - src/PythonAPI/model/features/__init__.py | 2 +- 8 files changed, 256 insertions(+), 10 deletions(-) create mode 100644 src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp create mode 100644 src/FeaturesAPI/FeaturesAPI_MultiRotation.h diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index 4b94f992a..881c8bdf2 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -8,6 +8,7 @@ SET(PROJECT_HEADERS FeaturesAPI_Extrusion.h FeaturesAPI_ExtrusionBoolean.h FeaturesAPI_Intersection.h + FeaturesAPI_MultiRotation.h FeaturesAPI_MultiTranslation.h FeaturesAPI_Partition.h FeaturesAPI_Pipe.h @@ -28,6 +29,7 @@ SET(PROJECT_SOURCES FeaturesAPI_Extrusion.cpp FeaturesAPI_ExtrusionBoolean.cpp FeaturesAPI_Intersection.cpp + FeaturesAPI_MultiRotation.cpp FeaturesAPI_MultiTranslation.cpp FeaturesAPI_Partition.cpp FeaturesAPI_Pipe.cpp diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index f8f7e7e90..01c87a57b 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -25,6 +25,7 @@ %shared_ptr(FeaturesAPI_ExtrusionCut) %shared_ptr(FeaturesAPI_ExtrusionFuse) %shared_ptr(FeaturesAPI_Intersection) +%shared_ptr(FeaturesAPI_MultiRotation) %shared_ptr(FeaturesAPI_MultiTranslation) %shared_ptr(FeaturesAPI_Partition) %shared_ptr(FeaturesAPI_Pipe) @@ -46,6 +47,7 @@ %include "FeaturesAPI_Extrusion.h" %include "FeaturesAPI_ExtrusionBoolean.h" %include "FeaturesAPI_Intersection.h" +%include "FeaturesAPI_MultiRotation.h" %include "FeaturesAPI_MultiTranslation.h" %include "FeaturesAPI_Partition.h" %include "FeaturesAPI_Pipe.h" diff --git a/src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp b/src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp new file mode 100644 index 000000000..9d23177d2 --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp @@ -0,0 +1,144 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_MultiRotation.cpp +// Created: 04 Apr 2017 +// Author: Clarisse Genrault (CEA) + +#include + +#include +#include + +//================================================================================================== +FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation( + const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + + +//================================================================================================== +FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Integer& theNumber) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mainObjects()); + fillAttribute(theAxis, axisAngular()); + fillAttribute("",useStepAngular()); + setNumberAngular(theNumber); + } +} + +//================================================================================================== +FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Double& theStep, + const ModelHighAPI_Integer& theNumber) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mainObjects()); + fillAttribute(theAxis, axisAngular()); + fillAttribute(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(),useStepAngular()); + fillAttribute(theStep, stepAngular()); + setNumberAngular(theNumber); + } +} + +//================================================================================================== +FeaturesAPI_MultiRotation::~FeaturesAPI_MultiRotation() +{ +} + +//================================================================================================== +void FeaturesAPI_MultiRotation::setMainObjects( + const std::list& theMainObjects) +{ + fillAttribute(theMainObjects, mainObjects()); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_MultiRotation::setAxisAngular(const ModelHighAPI_Selection& theAxis) +{ + fillAttribute(theAxis, axisAngular()); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_MultiRotation::setStepAngular(const ModelHighAPI_Double& theStep) +{ + fillAttribute(theStep, stepAngular()); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_MultiRotation::setNumberAngular(const ModelHighAPI_Integer& theNumber) +{ + fillAttribute(theNumber, nbAngular()); + + execute(); +} + +//================================================================================================== +void FeaturesAPI_MultiRotation::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + AttributeSelectionListPtr anAttrObjects = + aBase->selectionList(FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID()); + theDumper << aBase << " = model.addMultiRotation(" << aDocName << ", " << anAttrObjects; + + AttributeSelectionPtr anAttrAxis = + aBase->selection(FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID()); + theDumper << ", " << anAttrAxis; + + if (aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->isInitialized() + && !aBase->string(FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID())->value().empty()) { + AttributeDoublePtr anAttrStepAngular = + aBase->real(FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID()); + theDumper << ", " << anAttrStepAngular; + } + + AttributeIntegerPtr anAttrNumberAngular = + aBase->integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID()); + theDumper << ", " << anAttrNumberAngular; + + theDumper << ")" << std::endl; +} + +//================================================================================================== +MultiRotationPtr addMultiRotation(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Integer& theNumber) +{ + std::shared_ptr aFeature = + thePart->addFeature(FeaturesAPI_MultiRotation::ID()); + return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects, + theAxis, theNumber)); +} + +//================================================================================================== +MultiRotationPtr addMultiRotation(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Double& theStep, + const ModelHighAPI_Integer& theNumber) +{ + std::shared_ptr aFeature = + thePart->addFeature(FeaturesAPI_MultiRotation::ID()); + return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects, + theAxis, theStep, theNumber)); +} \ No newline at end of file diff --git a/src/FeaturesAPI/FeaturesAPI_MultiRotation.h b/src/FeaturesAPI/FeaturesAPI_MultiRotation.h new file mode 100644 index 000000000..d1ae1c75c --- /dev/null +++ b/src/FeaturesAPI/FeaturesAPI_MultiRotation.h @@ -0,0 +1,105 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: FeaturesAPI_MultiRotation.h +// Created: 04 Apr 2017 +// Author: Clarisse Genrault (CEA) + +#ifndef FEATURESAPI_MULTIROTATION_H_ +#define FEATURESAPI_MULTIROTATION_H_ + +#include "FeaturesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Double; +class ModelHighAPI_Dumper; +class ModelHighAPI_Integer; +class ModelHighAPI_Selection; + +/// \class FeaturesAPI_MultiRotation +/// \ingroup CPPHighAPI +/// \brief Interface for Translation feature. +class FeaturesAPI_MultiRotation: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + FEATURESAPI_EXPORT + explicit FeaturesAPI_MultiRotation(const std::shared_ptr& theFeature); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_MultiRotation(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Integer& theNumber); + + /// Constructor with values. + FEATURESAPI_EXPORT + FeaturesAPI_MultiRotation(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Double& theStep, + const ModelHighAPI_Integer& theNumber); + + /// Destructor. + FEATURESAPI_EXPORT + virtual ~FeaturesAPI_MultiRotation(); + + INTERFACE_5(FeaturesPlugin_MultiRotation::ID(), + mainObjects, FeaturesPlugin_MultiRotation::OBJECTS_LIST_ID(), + ModelAPI_AttributeSelectionList, /** Main objects */, + axisAngular, FeaturesPlugin_MultiRotation::AXIS_ANGULAR_ID(), + ModelAPI_AttributeSelection, /** Angular direction */, + useStepAngular, FeaturesPlugin_MultiRotation::USE_ANGULAR_STEP_ID(), + ModelAPI_AttributeString, /** Use step angular */, + stepAngular, FeaturesPlugin_MultiRotation::STEP_ANGULAR_ID(), + ModelAPI_AttributeDouble, /** Step angular */, + nbAngular, FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID(), + ModelAPI_AttributeInteger, /** Number of copies for angular */ + ) + + /// Set main objects. + FEATURESAPI_EXPORT + void setMainObjects(const std::list& theMainObjects); + + /// Modify CreationMethod, axis_angular attribute of the feature. + FEATURESAPI_EXPORT + void setAxisAngular(const ModelHighAPI_Selection& theAxis); + + /// Modify CreationMethod, step_angular attribute of the feature. + FEATURESAPI_EXPORT + void setStepAngular(const ModelHighAPI_Double& theStep); + + /// Modify CreationMethod, nb_angular attribute of the feature. + FEATURESAPI_EXPORT + void setNumberAngular(const ModelHighAPI_Integer& theNumber); + + /// Dump wrapped feature + FEATURESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on Multirotation object. +typedef std::shared_ptr MultiRotationPtr; + +/// \ingroup CPPHighAPI +/// \brief Create MultiRotation feature. +FEATURESAPI_EXPORT +MultiRotationPtr addMultiRotation(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Integer& theNumber); + +/// \ingroup CPPHighAPI +/// \brief Create MultiRotation feature. +FEATURESAPI_EXPORT +MultiRotationPtr addMultiRotation(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxis, + const ModelHighAPI_Double& theStep, + const ModelHighAPI_Integer& theNumber); + +#endif // FEATURESAPI_MULTIROTATION_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_MultiTranslation.h b/src/FeaturesAPI/FeaturesAPI_MultiTranslation.h index 09e75f9c1..f8414f13e 100644 --- a/src/FeaturesAPI/FeaturesAPI_MultiTranslation.h +++ b/src/FeaturesAPI/FeaturesAPI_MultiTranslation.h @@ -98,7 +98,7 @@ public: virtual void dump(ModelHighAPI_Dumper& theDumper) const; }; -/// Pointer on Translation object. +/// Pointer on MultiTranslation object. typedef std::shared_ptr MultiTranslationPtr; /// \ingroup CPPHighAPI diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index 280e93eb5..ff8aadeb3 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -14,6 +14,7 @@ #include "FeaturesAPI_Extrusion.h" #include "FeaturesAPI_ExtrusionBoolean.h" #include "FeaturesAPI_Intersection.h" + #include "FeaturesAPI_MultiRotation.h" #include "FeaturesAPI_MultiTranslation.h" #include "FeaturesAPI_Partition.h" #include "FeaturesAPI_Pipe.h" diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp index 9041474ed..285e7219a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp @@ -54,14 +54,6 @@ bool GeomAlgoAPI_Rotation::check() myError = "Rotation builder :: source shape is not valid."; return false; } - if (myAngle < -360.) { - myError = "Rotation builder :: angle smaller than -360 degrees."; - return false; - } - if (myAngle > 360.) { - myError = "Rotation builder :: angle greater than 360 degrees."; - return false; - } return true; } case BY_POINTS: { diff --git a/src/PythonAPI/model/features/__init__.py b/src/PythonAPI/model/features/__init__.py index 7f678f5d3..a69fea2d0 100644 --- a/src/PythonAPI/model/features/__init__.py +++ b/src/PythonAPI/model/features/__init__.py @@ -2,7 +2,7 @@ """ from FeaturesAPI import addPlacement, addRotation, addScale, addSymmetry, addTranslation -from FeaturesAPI import addMultiTranslation +from FeaturesAPI import addMultiTranslation, addMultiRotation from FeaturesAPI import addExtrusion, addExtrusionCut, addExtrusionFuse from FeaturesAPI import addRevolution, addRevolutionCut, addRevolutionFuse from FeaturesAPI import addPipe -- 2.39.2