]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/FeaturesAPI/FeaturesAPI_MultiRotation.cpp
Salome HOME
Task 3.2. To keep compounds’ sub-shapes for all operations (issue #3139)
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_MultiRotation.cpp
index 8e59da5f22c912ffd96c0f85c3c4e8cf402cf0fa..44bbd0b2babe8148faad268be341162bc94c34f6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <FeaturesAPI_MultiRotation.h>
 
+#include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
@@ -132,19 +133,10 @@ void FeaturesAPI_MultiRotation::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->integer(FeaturesPlugin_MultiRotation::NB_COPIES_ANGULAR_ID());
   theDumper << ", " << anAttrNumberAngular;
 
-  theDumper << ")" << std::endl;
-}
+  if (!aBase->data()->version().empty())
+    theDumper << ", keepSubResults = True";
 
-//==================================================================================================
-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));
+  theDumper << ")" << std::endl;
 }
 
 //==================================================================================================
@@ -152,10 +144,30 @@ MultiRotationPtr addMultiRotation(const std::shared_ptr<ModelAPI_Document>& theP
                                   const std::list<ModelHighAPI_Selection>& theMainObjects,
                                   const ModelHighAPI_Selection& theAxis,
                                   const ModelHighAPI_Double& theStep,
-                                  const ModelHighAPI_Integer& theNumber)
+                                  const ModelHighAPI_Integer& theNumber,
+                                  const bool keepSubResults)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
     thePart->addFeature(FeaturesAPI_MultiRotation::ID());
-  return MultiRotationPtr(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
-                                                        theAxis, theStep, theNumber));
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+
+  MultiRotationPtr aResult;
+  if (theNumber.string().empty()) {
+    // rotate for the whole circle
+    double aStepVal = theStep.value();
+    std::string aStepStr = theStep.string();
+    std::ostringstream aStepValAsStr;
+    aStepValAsStr << aStepVal;
+
+    ModelHighAPI_Integer aNumber = aStepStr == aStepValAsStr.str()
+                                 ? ModelHighAPI_Integer(aStepVal)
+                                 : ModelHighAPI_Integer(aStepStr);
+    aResult.reset(new FeaturesAPI_MultiRotation(aFeature, theMainObjects, theAxis, aNumber));
+  }
+  else {
+    aResult.reset(new FeaturesAPI_MultiRotation(aFeature, theMainObjects,
+                                                theAxis, theStep, theNumber));
+  }
+  return aResult;
 }