Salome HOME
Redisplay feature event processing
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Extrusion.cpp
1 // File:        ConstructionPlugin_Extrusion.cpp
2 // Created:     30 May 2014
3 // Author:      Vitaly SMETANNIKOV
4
5 #include "ConstructionPlugin_Extrusion.h"
6 #include <ModelAPI_PluginManager.h>
7 #include <ModelAPI_Document.h>
8 #include <ModelAPI_Data.h>
9 #include <ModelAPI_AttributeDouble.h>
10 #include <ModelAPI_AttributeReference.h>
11 #include <ModelAPI_AttributeBoolean.h>
12
13 #include <GeomAlgoAPI_Extrusion.h>
14
15 using namespace std;
16
17 ConstructionPlugin_Extrusion::ConstructionPlugin_Extrusion()
18 {
19 }
20
21 void ConstructionPlugin_Extrusion::initAttributes()
22 {
23   data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type());
24   data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type());
25   data()->addAttribute(EXTRUSION_REVERSE, ModelAPI_AttributeBoolean::type());
26 }
27
28 void ConstructionPlugin_Extrusion::execute()
29 {
30   boost::shared_ptr<ModelAPI_AttributeReference> aFaceRef = 
31     boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(data()->attribute(EXTRUSION_FACE));
32   if (!aFaceRef)
33     return;
34   FeaturePtr aFaceFeature = aFaceRef->value();
35   if (!aFaceFeature)
36     return;
37   boost::shared_ptr<GeomAPI_Shape> aFace = aFaceFeature->data()->shape();
38   if (!aFace)
39     return;
40
41   double aSize = data()->real(EXTRUSION_SIZE)->value();
42   if (data()->boolean(EXTRUSION_REVERSE)->value())
43     aSize = -aSize;
44   data()->store(GeomAlgoAPI_Extrusion::makeExtrusion(aFace, aSize));
45 }