Salome HOME
Make SHAPER STUDY fields exported in SMESH into MED file
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_ExtrusionBoolean.cpp
index 1b16e2aff44b0d798faae5ca0a5b54c0bd01d19b..af4102734031cc1e34379f6061a6b9cfd9292c4e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019  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
 //
 // 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
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include "FeaturesAPI_ExtrusionBoolean.h"
@@ -89,11 +88,7 @@ void FeaturesAPI_ExtrusionBoolean::setSizes(const ModelHighAPI_Double& theToSize
 //==================================================================================================
 void FeaturesAPI_ExtrusionBoolean::setSize(const ModelHighAPI_Double& theSize)
 {
-  fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-  fillAttribute(theSize, mytoSize);
-  fillAttribute(ModelHighAPI_Double(), myfromSize);
-
-  execIfBaseNotEmpty();
+  setSizes(theSize, ModelHighAPI_Double());
 }
 
 //==================================================================================================
@@ -160,6 +155,8 @@ void FeaturesAPI_ExtrusionBoolean::dump(ModelHighAPI_Dumper& theDumper) const
 
     theDumper << ", " << anAttrToObject << ", " << anAttrToOffset <<
       ", " << anAttrFromObject << ", " << anAttrFromOffset;
+  } else {
+    // Through all
   }
 
   AttributeSelectionListPtr anAttrBoolObjects =
@@ -188,6 +185,20 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
   initialize();
 }
 
+//==================================================================================================
+FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+  const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+: FeaturesAPI_ExtrusionBoolean(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_THROUGH_ALL(), mycreationMethod);
+    setBooleanObjects(theBooleanObjects);
+  }
+}
+
 //==================================================================================================
 FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
@@ -198,9 +209,23 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
 {
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theSize, mytoSize);
-    fillAttribute(ModelHighAPI_Double(), myfromSize);
+    setSize(theSize);
+    setBooleanObjects(theBooleanObjects);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+  const ModelHighAPI_Selection& theDirection,
+  const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+: FeaturesAPI_ExtrusionBoolean(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theDirection, mydirection);
+    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_THROUGH_ALL(), mycreationMethod);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -217,9 +242,7 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theDirection, mydirection);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theSize, mytoSize);
-    fillAttribute(ModelHighAPI_Double(), myfromSize);
+    setSize(theSize);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -235,9 +258,7 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
 {
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theToSize, mytoSize);
-    fillAttribute(theFromSize, myfromSize);
+    setSizes(theToSize, theFromSize);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -255,9 +276,7 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theDirection, mydirection);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theToSize, mytoSize);
-    fillAttribute(theFromSize, myfromSize);
+    setSizes(theToSize, theFromSize);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -275,11 +294,7 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
 {
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
-    fillAttribute(theToObject, mytoObject);
-    fillAttribute(theToOffset, mytoOffset);
-    fillAttribute(theFromObject, myfromObject);
-    fillAttribute(theFromOffset, myfromOffset);
+    setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -299,15 +314,22 @@ FeaturesAPI_ExtrusionCut::FeaturesAPI_ExtrusionCut(
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theDirection, mydirection);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
-    fillAttribute(theToObject, mytoObject);
-    fillAttribute(theToOffset, mytoOffset);
-    fillAttribute(theFromObject, myfromObject);
-    fillAttribute(theFromOffset, myfromOffset);
+    setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
     setBooleanObjects(theBooleanObjects);
   }
 }
 
+//==================================================================================================
+ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
+  return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects,
+                                                      theBooleanObjects));
+}
+
 //==================================================================================================
 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
                                 const std::list<ModelHighAPI_Selection>& theBaseObjects,
@@ -320,6 +342,18 @@ ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePar
                                                       theSize, theBooleanObjects));
 }
 
+//==================================================================================================
+ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                const ModelHighAPI_Selection& theDirection,
+                                const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesPlugin_ExtrusionCut::ID());
+  return ExtrusionCutPtr(new FeaturesAPI_ExtrusionCut(aFeature, theBaseObjects, theDirection,
+                                                      theBooleanObjects));
+}
+
 //==================================================================================================
 ExtrusionCutPtr addExtrusionCut(const std::shared_ptr<ModelAPI_Document>& thePart,
                                 const std::list<ModelHighAPI_Selection>& theBaseObjects,
@@ -415,6 +449,20 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
   initialize();
 }
 
+//==================================================================================================
+FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+  const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+: FeaturesAPI_ExtrusionBoolean(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_THROUGH_ALL(), mycreationMethod);
+    setBooleanObjects(theBooleanObjects);
+  }
+}
+
 //==================================================================================================
 FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
   const std::shared_ptr<ModelAPI_Feature>& theFeature,
@@ -425,9 +473,23 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
 {
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theSize, mytoSize);
-    fillAttribute(ModelHighAPI_Double(), myfromSize);
+    setSize(theSize);
+    setBooleanObjects(theBooleanObjects);
+  }
+}
+
+//==================================================================================================
+FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
+  const std::shared_ptr<ModelAPI_Feature>& theFeature,
+  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+  const ModelHighAPI_Selection& theDirection,
+  const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+: FeaturesAPI_ExtrusionBoolean(theFeature)
+{
+  if(initialize()) {
+    fillAttribute(theBaseObjects, mybaseObjects);
+    fillAttribute(theDirection, mydirection);
+    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_THROUGH_ALL(), mycreationMethod);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -444,9 +506,7 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theDirection, mydirection);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theSize, mytoSize);
-    fillAttribute(ModelHighAPI_Double(), myfromSize);
+    setSize(theSize);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -462,9 +522,7 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
 {
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theToSize, mytoSize);
-    fillAttribute(theFromSize, myfromSize);
+    setSizes(theToSize, theFromSize);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -482,9 +540,7 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theDirection, mydirection);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
-    fillAttribute(theToSize, mytoSize);
-    fillAttribute(theFromSize, myfromSize);
+    setSizes(theToSize, theFromSize);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -502,11 +558,7 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
 {
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
-    fillAttribute(theToObject, mytoObject);
-    fillAttribute(theToOffset, mytoOffset);
-    fillAttribute(theFromObject, myfromObject);
-    fillAttribute(theFromOffset, myfromOffset);
+    setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
     setBooleanObjects(theBooleanObjects);
   }
 }
@@ -526,15 +578,22 @@ FeaturesAPI_ExtrusionFuse::FeaturesAPI_ExtrusionFuse(
   if(initialize()) {
     fillAttribute(theBaseObjects, mybaseObjects);
     fillAttribute(theDirection, mydirection);
-    fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
-    fillAttribute(theToObject, mytoObject);
-    fillAttribute(theToOffset, mytoOffset);
-    fillAttribute(theFromObject, myfromObject);
-    fillAttribute(theFromOffset, myfromOffset);
+    setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
     setBooleanObjects(theBooleanObjects);
   }
 }
 
+//==================================================================================================
+ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                  const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
+  return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects,
+                                                        theBooleanObjects));
+}
+
 //==================================================================================================
 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,
@@ -547,6 +606,18 @@ ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& theP
                                                         theSize, theBooleanObjects));
 }
 
+//==================================================================================================
+ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
+                                  const std::list<ModelHighAPI_Selection>& theBaseObjects,
+                                  const ModelHighAPI_Selection& theDirection,
+                                  const std::list<ModelHighAPI_Selection>& theBooleanObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+    thePart->addFeature(FeaturesPlugin_ExtrusionFuse::ID());
+  return ExtrusionFusePtr(new FeaturesAPI_ExtrusionFuse(aFeature, theBaseObjects,
+                                                        theDirection, theBooleanObjects));
+}
+
 //==================================================================================================
 ExtrusionFusePtr addExtrusionFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
                                   const std::list<ModelHighAPI_Selection>& theBaseObjects,