// Author: Vitaly SMETANNIKOV
#include "FeaturesPlugin_Extrusion.h"
-#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Session.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Data.h>
+#include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultBody.h>
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_AttributeReference.h>
#include <ModelAPI_AttributeBoolean.h>
void FeaturesPlugin_Extrusion::execute()
{
- boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef =
- boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
+ boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = boost::dynamic_pointer_cast<
+ ModelAPI_AttributeReference>(data()->attribute(FeaturesPlugin_Extrusion::FACE_ID()));
if (!aFaceRef)
return;
- FeaturePtr aFaceFeature = aFaceRef->value();
- if (!aFaceFeature)
- return;
- boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
- if (!aFace)
+ boost::shared_ptr<GeomAPI_Shape> aFace;
+ boost::shared_ptr<ModelAPI_ResultConstruction> aConstr = boost::dynamic_pointer_cast<
+ ModelAPI_ResultConstruction>(aFaceRef->value());
+ if (aConstr) {
+ aFace = aConstr->shape();
+ }
+ if (!aFace) {
+ // Check for body
+ boost::shared_ptr<ModelAPI_ResultBody> aBody = boost::dynamic_pointer_cast<
+ ModelAPI_ResultBody>(aFaceRef->value());
+ if (aBody)
+ aFace = aBody->shape();
+ }
+ if (!aFace)
return;
double aSize = data()->real(FeaturesPlugin_Extrusion::SIZE_ID())->value();
if (data()->boolean(FeaturesPlugin_Extrusion::REVERSE_ID())->value())
aSize = -aSize;
- data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+ boost::shared_ptr<ModelAPI_ResultBody> aResult = document()->createBody(data());
+ aResult->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
+ setResult(aResult);
}