Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_MultiRotation.cpp
index 9d23177d290142d90997e820fa78e7bb5a9561da..58188025ebc697bab1bdd3f3536ac855d42538f4 100644 (file)
@@ -1,4 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+// Copyright (C) 2017-2023  CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 // File:        FeaturesAPI_MultiRotation.cpp
 // Created:     04 Apr 2017
@@ -6,6 +23,7 @@
 
 #include <FeaturesAPI_MultiRotation.h>
 
+#include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Tools.h>
 
@@ -115,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;
 }
 
 //==================================================================================================
@@ -135,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));
-}
\ No newline at end of file
+  if (!keepSubResults)
+    aFeature->data()->setVersion("");
+
+  MultiRotationPtr aResult;
+  if (theNumber.string().empty()) {
+    // rotate for the whole circle
+    double aStepVal = theStep.value();
+    std::wstring aStepStr = theStep.string();
+    std::wostringstream aStepValAsStr;
+    aStepValAsStr << aStepVal;
+
+    ModelHighAPI_Integer aNumber = aStepStr == aStepValAsStr.str()
+                                 ? ModelHighAPI_Integer((int)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;
+}