Salome HOME
Dump Python in the High Level Parameterized Geometry API (issue #1648)
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Boolean.cpp
index 6f68890cfaab05cf5a2222c0f0b734cc0c46477f..062731c89972585ea13c405c912139ac57f46f68 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "FeaturesAPI_Boolean.h"
 
+#include <ModelHighAPI_Dumper.h>
 #include <ModelHighAPI_Integer.h>
 #include <ModelHighAPI_Selection.h>
 #include <ModelHighAPI_Tools.h>
@@ -25,9 +26,11 @@ FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
-    setBoolType(theBoolType);
-    setMainObjects(theMainObjects);
-    setToolObjects(theToolObjects);
+    fillAttribute(theBoolType, myboolType);
+    fillAttribute(theMainObjects, mymainObjects);
+    fillAttribute(theToolObjects, mytoolObjects);
+
+    execute();
   }
 }
 
@@ -61,7 +64,31 @@ void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>
   execute();
 }
 
-// TODO(spo): make add* as static functions of the class
+//==================================================================================================
+void FeaturesAPI_Boolean::dump(ModelHighAPI_Dumper& theDumper) const
+{
+  FeaturePtr aBase = feature();
+
+  FeaturesPlugin_Boolean::OperationType aType =
+      (FeaturesPlugin_Boolean::OperationType)aBase->integer(FeaturesPlugin_Boolean::TYPE_ID())->value();
+
+  theDumper << aBase << " = model.add";
+
+  switch(aType) {
+    case FeaturesPlugin_Boolean::BOOL_CUT:    theDumper << "Cut";    break;
+    case FeaturesPlugin_Boolean::BOOL_FUSE:   theDumper << "Fuse";   break;
+    case FeaturesPlugin_Boolean::BOOL_COMMON: theDumper << "Common"; break;
+    case FeaturesPlugin_Boolean::BOOL_FILL:   theDumper << "Fill";   break;
+    case FeaturesPlugin_Boolean::BOOL_SMASH:  theDumper << "Smash";  break;
+  }
+
+  const std::string& aDocName = theDumper.name(aBase->document());
+  AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
+  AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
+
+  theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
+}
+
 //==================================================================================================
 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const std::list<ModelHighAPI_Selection>& theMainObjects,
@@ -109,3 +136,27 @@ BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
                                             theMainObjects,
                                             theToolObjects));
 }
+
+//==================================================================================================
+BooleanPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
+                    const std::list<ModelHighAPI_Selection>& theMainObjects,
+                    const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+  return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+                                            FeaturesPlugin_Boolean::BOOL_SMASH,
+                                            theMainObjects,
+                                            theToolObjects));
+}
+
+//==================================================================================================
+BooleanPtr addFill(const std::shared_ptr<ModelAPI_Document>& thePart,
+                   const std::list<ModelHighAPI_Selection>& theMainObjects,
+                   const std::list<ModelHighAPI_Selection>& theToolObjects)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
+  return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
+                                            FeaturesPlugin_Boolean::BOOL_FILL,
+                                            theMainObjects,
+                                            theToolObjects));
+}