Salome HOME
a8867530ebcfd4ae193da42a87bff50470676fa0
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Extrusion.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesPlugin_Extrusion.h
4 // Created:     30 May 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef FeaturesPlugin_Extrusion_H_
8 #define FeaturesPlugin_Extrusion_H_
9
10 #include <FeaturesPlugin.h>
11 #include <GeomAlgoAPI_Prism.h>
12
13 #include <FeaturesPlugin_CompositeSketch.h>
14
15 class GeomAPI_Shape;
16 class ModelAPI_ResultBody;
17
18 /**\class FeaturesPlugin_Extrusion
19  * \ingroup Plugins
20  * \brief Feature for creation of extrusion from the planar face.
21  *
22  * Extrusion creates the lateral faces based on edges of the base face and
23  * the top and bottom faces equal to the base face or this faces can be projection on the
24  * bounding planes if they were set. Direction of extrusion is taken from the face
25  * plane or if the bounding faces were set then it will be from the bottom to the top plane.
26  */
27 class FeaturesPlugin_Extrusion : public FeaturesPlugin_CompositeSketch
28 {
29  public:
30   /// Extrusion kind
31   inline static const std::string& ID()
32   {
33     static const std::string MY_EXTRUSION_ID("Extrusion");
34     return MY_EXTRUSION_ID;
35   }
36   /// attribute name of references sketch entities list, it should contain a sketch result or
37   /// a pair a sketch result to sketch face
38   inline static const std::string& LIST_ID()
39   {
40     static const std::string MY_GROUP_LIST_ID("base");
41     return MY_GROUP_LIST_ID;
42   }
43
44   /// attribute name of an object to which the extrusion grows
45   inline static const std::string& AXIS_OBJECT_ID()
46   {
47     static const std::string MY_TO_OBJECT_ID("axis_object");
48     return MY_TO_OBJECT_ID;
49   }
50
51   /// attribute name for creation method
52   inline static const std::string& CREATION_METHOD()
53   {
54     static const std::string METHOD_ATTR("CreationMethod");
55     return METHOD_ATTR;
56   }
57
58   /// attribute name of extrusion size
59   inline static const std::string& TO_SIZE_ID()
60   {
61     static const std::string MY_TO_SIZE_ID("to_size");
62     return MY_TO_SIZE_ID;
63   }
64
65   /// attribute name of extrusion size
66   inline static const std::string& FROM_SIZE_ID()
67   {
68     static const std::string MY_FROM_SIZE_ID("from_size");
69     return MY_FROM_SIZE_ID;
70   }
71
72   /// attribute name of an object to which the extrusion grows
73   inline static const std::string& TO_OBJECT_ID()
74   {
75     static const std::string MY_TO_OBJECT_ID("to_object");
76     return MY_TO_OBJECT_ID;
77   }
78
79   /// attribute name of extrusion offset
80   inline static const std::string& TO_OFFSET_ID()
81   {
82     static const std::string MY_TO_OFFSET_ID("to_offset");
83     return MY_TO_OFFSET_ID;
84   }
85
86   /// attribute name of tool object
87   inline static const std::string& FROM_OBJECT_ID()
88   {
89     static const std::string MY_FROM_OBJECT_ID("from_object");
90     return MY_FROM_OBJECT_ID;
91   }
92
93   /// attribute name of extrusion offset
94   inline static const std::string& FROM_OFFSET_ID()
95   {
96     static const std::string MY_FROM_OFFSET_ID("from_offset");
97     return MY_FROM_OFFSET_ID;
98   }
99
100   /// Returns the kind of a feature
101   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
102   {
103     static std::string MY_KIND = FeaturesPlugin_Extrusion::ID();
104     return MY_KIND;
105   }
106
107   /// Creates a new part document if needed
108   FEATURESPLUGIN_EXPORT virtual void execute();
109
110   /// Request for initialization of data model of the feature: adding all attributes
111   FEATURESPLUGIN_EXPORT virtual void initAttributes();
112
113   /// This method to inform that sub-feature is removed and must be removed from the internal data
114   /// structures of the owner (the remove from the document will be done outside just after)
115   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
116
117   /// Use plugin manager for features creation
118   FeaturesPlugin_Extrusion();
119
120 protected:
121   /// Init attributes for extrusion.
122   virtual void initMakeSolidsAttributes() {};
123
124   /// Create solid from face with extrusion.
125   virtual void makeSolid(const std::shared_ptr<GeomAPI_Shape> theFace,
126                          std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape) {};
127
128 private:
129   /// Load Naming data structure of the feature to the document
130   void loadNamingDS(GeomAlgoAPI_Prism& thePrismAlgo,
131                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
132                     std::shared_ptr<GeomAPI_Shape> theBasis);
133
134   /// Set the sub-object to list of exturusion base.
135   void setSketchObjectToList();
136 };
137
138 #endif