]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added MultiRotation feature (parametric API).
authorClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 5 Apr 2017 13:15:04 +0000 (15:15 +0200)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Wed, 5 Apr 2017 13:15:04 +0000 (15:15 +0200)
src/FeaturesAPI/CMakeLists.txt
src/FeaturesAPI/FeaturesAPI.i
src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_MultiRotation.h [new file with mode: 0644]
src/FeaturesAPI/FeaturesAPI_MultiTranslation.h
src/FeaturesAPI/FeaturesAPI_swig.h
src/GeomAlgoAPI/GeomAlgoAPI_Rotation.cpp
src/PythonAPI/model/features/__init__.py

index 4b94f992a795a675c04155fddb9468a36cfa49c1..881c8bdf26f30ce945414adac858fd2a44437f34 100644 (file)
@@ -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
index f8f7e7e90877a34cb54747847c94746ef7e99727..01c87a57bce0b65cd19c046d6c4615c58f66fc72 100644 (file)
@@ -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 (file)
index 0000000..9d23177
--- /dev/null
@@ -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 <FeaturesAPI_MultiRotation.h>
+
+#include <ModelHighAPI_Dumper.h>
+#include <ModelHighAPI_Tools.h>
+
+//==================================================================================================
+FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+  initialize();
+}
+
+
+//==================================================================================================
+FeaturesAPI_MultiRotation::FeaturesAPI_MultiRotation(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& 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<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& 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<ModelHighAPI_Selection>& 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<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Integer& theNumber)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesAPI_MultiRotation::ID());
+  return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
+                                                        theAxis, theNumber));
+}
+
+//==================================================================================================
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theStep,
+                                  const ModelHighAPI_Integer& theNumber)
+{
+  std::shared_ptr<ModelAPI_Feature> 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 (file)
index 0000000..d1ae1c7
--- /dev/null
@@ -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 <FeaturesPlugin_MultiRotation.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+
+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<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  FeaturesAPI_MultiRotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                            const std::list<ModelHighAPI_Selection>& theMainObjects,
+                            const ModelHighAPI_Selection& theAxis,
+                            const ModelHighAPI_Integer& theNumber);
+
+  /// Constructor with values.
+  FEATURESAPI_EXPORT
+  FeaturesAPI_MultiRotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                            const std::list<ModelHighAPI_Selection>& 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<ModelHighAPI_Selection>& 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<FeaturesAPI_MultiRotation> MultiRotationPtr;
+
+/// \ingroup CPPHighAPI
+/// \brief Create MultiRotation feature.
+FEATURESAPI_EXPORT
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Integer& theNumber);
+
+/// \ingroup CPPHighAPI
+/// \brief Create MultiRotation feature.
+FEATURESAPI_EXPORT
+MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theMainObjects,
+                                  const ModelHighAPI_Selection& theAxis,
+                                  const ModelHighAPI_Double& theStep,
+                                  const ModelHighAPI_Integer& theNumber);
+
+#endif // FEATURESAPI_MULTIROTATION_H_
index 09e75f9c1137f63973504a88974fff2dbe340018..f8414f13e6ba362e7eaa24110b17ede882a1e7b0 100644 (file)
@@ -98,7 +98,7 @@ public:
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 };
 
-/// Pointer on Translation object.
+/// Pointer on MultiTranslation object.
 typedef std::shared_ptr<FeaturesAPI_MultiTranslation> MultiTranslationPtr;
 
 /// \ingroup CPPHighAPI
index 280e93eb5215588ecdd31bcd1d04dfaa7688faf5..ff8aadeb3bc3e7182c51bcc4c13d592315eca029 100644 (file)
@@ -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"
index 9041474edf534f17d4806c09cbac0ca858937f9f..285e7219a4dae09359fda123816346097648124b 100644 (file)
@@ -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: {
index 7f678f5d320c38385036816822868868109f3fef..a69fea2d010d28f9cb992ecfdaef9b1f10b2e4c9 100644 (file)
@@ -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