Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Revolution.cpp
index a685523e0ed125f56a7424ed9f601dca55f46cf0..4891680fc790d4f4333ec21f0611842baf7955f2 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -52,10 +52,13 @@ FeaturesAPI_Revolution::FeaturesAPI_Revolution(
   const std::list<ModelHighAPI_Selection>& theBaseObjects,
   const ModelHighAPI_Selection& theAxis,
   const ModelHighAPI_Double& theToAngle,
-  const ModelHighAPI_Double& theFromAngle)
+  const ModelHighAPI_Double& theFromAngle,
+  const std::string& theSelectionType)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
+    if (!theSelectionType.empty())
+      mybaseObjects->setSelectionType(theSelectionType);
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theAxis, myaxis);
     setAngles(theToAngle, theFromAngle);
@@ -70,10 +73,13 @@ FeaturesAPI_Revolution::FeaturesAPI_Revolution(
   const ModelHighAPI_Selection& theToObject,
   const ModelHighAPI_Double& theToOffset,
   const ModelHighAPI_Selection& theFromObject,
-  const ModelHighAPI_Double& theFromOffset)
+  const ModelHighAPI_Double& theFromOffset,
+  const std::string& theSelectionType)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
+    if (!theSelectionType.empty())
+      mybaseObjects->setSelectionType(theSelectionType);
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theAxis, myaxis);
     setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
@@ -191,6 +197,18 @@ void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const
       ", " << anAttrFromObject << ", " << anAttrFromOffset;
   }
 
+  // write explicitly the type of selection if it does not correspond
+  // to the type of first selected shape
+  if (!anAttrSketch->isInitialized()) {
+    std::string aListSelType = anAttrObjects->selectionType();
+    AttributeSelectionPtr aFirstSelection = anAttrObjects->value(0);
+    GeomShapePtr aFirstShape = aFirstSelection->value();
+    if (!aFirstShape)
+      aFirstShape = aFirstSelection->context()->shape();
+    if (!aFirstShape || aFirstShape->shapeType() != GeomAPI_Shape::shapeTypeByStr(aListSelType))
+      theDumper << ", \"" << aListSelType << "\"";
+  }
+
   theDumper << ")" << std::endl;
 
   if(anAttrSketch->isInitialized()) {
@@ -221,14 +239,16 @@ RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
                             const ModelHighAPI_Selection& theAxis,
                             const ModelHighAPI_Double& theToAngle,
-                            const ModelHighAPI_Double& theFromAngle)
+                            const ModelHighAPI_Double& theFromAngle,
+                            const std::string& theSelectionType)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
   return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
                                                 theBaseObjects,
                                                 theAxis,
                                                 theToAngle,
-                                                theFromAngle));
+                                                theFromAngle,
+                                                theSelectionType));
 }
 
 //==================================================================================================
@@ -238,7 +258,8 @@ RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
                             const ModelHighAPI_Selection& theToObject,
                             const ModelHighAPI_Double& theToOffset,
                             const ModelHighAPI_Selection& theFromObject,
-                            const ModelHighAPI_Double& theFromOffset)
+                            const ModelHighAPI_Double& theFromOffset,
+                            const std::string& theSelectionType)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
   return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
@@ -247,5 +268,6 @@ RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
                                                 theToObject,
                                                 theToOffset,
                                                 theFromObject,
-                                                theFromOffset));
+                                                theFromOffset,
+                                                theSelectionType));
 }