1 // File: FeaturesPlugin_Boolean.cpp
2 // Created: 02 Sept 2014
3 // Author: Vitaly SMETANNIKOV
5 #include "FeaturesPlugin_Boolean.h"
7 #include <ModelAPI_Data.h>
8 #include <ModelAPI_Document.h>
9 #include <ModelAPI_AttributeReference.h>
10 #include <ModelAPI_ResultBody.h>
11 #include <GeomAlgoAPI_Boolean.h>
15 FeaturesPlugin_Boolean::FeaturesPlugin_Boolean()
19 void FeaturesPlugin_Boolean::initAttributes()
21 data()->addAttribute(FeaturesPlugin_Boolean::TYPE_ID(), ModelAPI_AttributeReference::type());
22 data()->addAttribute(FeaturesPlugin_Boolean::OBJECT_ID(), ModelAPI_AttributeReference::type());
23 data()->addAttribute(FeaturesPlugin_Boolean::TOOL_ID(), ModelAPI_AttributeReference::type());
26 boost::shared_ptr<GeomAPI_Shape> FeaturesPlugin_Boolean::getShape(const std::string& theAttrName)
28 boost::shared_ptr<ModelAPI_AttributeReference> aObjRef = boost::dynamic_pointer_cast<
29 ModelAPI_AttributeReference>(data()->attribute(theAttrName));
31 boost::shared_ptr<ModelAPI_ResultBody> aConstr = boost::dynamic_pointer_cast<
32 ModelAPI_ResultBody>(aObjRef->value());
34 return aConstr->shape();
36 return boost::shared_ptr<GeomAPI_Shape>();
40 void FeaturesPlugin_Boolean::execute()
42 boost::shared_ptr<GeomAPI_Shape> aObject = this->getShape(FeaturesPlugin_Boolean::OBJECT_ID());
46 boost::shared_ptr<GeomAPI_Shape> aTool = this->getShape(FeaturesPlugin_Boolean::TOOL_ID());
50 boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
51 aResult->store(GeomAlgoAPI_Boolean::makeCut(aObject, aTool));