#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeInteger.h>
#include <ModelAPI_ResultBody.h>
#include <GeomAlgoAPI_Boolean.h>
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());
}
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;
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