Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Boolean.cpp
index 220b4144c6e05edfdfe87eb12124309be7ea5e4f..3161b31c22e9cd1978659f88834d512b6ce8dc9c 100644 (file)
@@ -7,6 +7,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_ResultBody.h>
 #include <GeomAlgoAPI_Boolean.h>
 
@@ -18,7 +19,7 @@ FeaturesPlugin_Boolean::FeaturesPlugin_Boolean()
 
 void FeaturesPlugin_Boolean::initAttributes()
 {
-  data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeReference::type());
+  data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeInteger::type());
   data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
   data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
 }
@@ -39,6 +40,12 @@ boost::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Boolean::getShape(const std::str
 
 void FeaturesPlugin_Boolean::execute()
 {
+  boost::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = boost::dynamic_pointer_cast<
+      ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID()));
+  if (!aTypeAttr)
+    return;
+  int aType = aTypeAttr->value();
+
   boost::shared_ptr<GeomAPI_Shape> aObject = this->getShape(FeaturesPlugin_Boolean::OBJECT_ID());
   if (!aObject)
     return;
@@ -48,6 +55,16 @@ void FeaturesPlugin_Boolean::execute()
     return;
 
   boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
-  aResult->store(GeomAlgoAPI_Boolean::makeCut(aObject, aTool));
+  switch (aType) {
+  case BOOL_CUT:
+    aResult->store(GeomAlgoAPI_Boolean::makeCut(aObject, aTool));
+    break;
+  case BOOL_FUSE:
+    aResult->store(GeomAlgoAPI_Boolean::makeFuse(aObject, aTool));
+    break;
+  case BOOL_COMMON:
+    aResult->store(GeomAlgoAPI_Boolean::makeCommon(aObject, aTool));
+    break;
+  }
   setResult(aResult);
 }
\ No newline at end of file