- std::shared_ptr<ModelAPI_AttributeInteger> aTypeAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeInteger>(data()->attribute(FeaturesPlugin_Boolean::TYPE_ID()));
- if (!aTypeAttr)
- return;
- int aType = aTypeAttr->value();
-
- std::shared_ptr<GeomAPI_Shape> anObject = this->getShape(FeaturesPlugin_Boolean::OBJECT_ID());
- if (!anObject)
- return;
-
- std::shared_ptr<GeomAPI_Shape> aTool = this->getShape(FeaturesPlugin_Boolean::TOOL_ID());
- if (!aTool)
- return;
-
- std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
-
- GeomAlgoAPI_Boolean* aFeature = new GeomAlgoAPI_Boolean(anObject, aTool, aType);
- if(aFeature && !aFeature->isDone()) {
- static const std::string aFeatureError = "Boolean feature: algorithm failed";
- setError(aFeatureError);
- return;
- }
- // Check if shape is valid
- if (aFeature->shape()->isNull()) {
- static const std::string aShapeError = "Boolean feature: resulting shape is Null";
- setError(aShapeError);
- return;
- }
- if(!aFeature->isValid()) {
- static const std::string aFeatureError = "Boolean feature: resulting shape is not valid";
- setError(aFeatureError);
- return;
- }
- // if result of Boolean operation is same as was before it means that Boolean operation has no sence
- // and naming provides no result, so, generate an error in this case
- if (anObject->isEqual(aFeature->shape())) {
- static const std::string aFeatureError = "Boolean feature: operation was not performed";
- setError(aFeatureError);