Salome HOME
Basing on the issue #1757 make extrusion-cut that
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Extrusion.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef FeaturesPlugin_Extrusion_H_
22 #define FeaturesPlugin_Extrusion_H_
23
24 #include "FeaturesPlugin.h"
25
26 #include "FeaturesPlugin_CompositeSketch.h"
27
28 #include <GeomAlgoAPI_MakeShape.h>
29
30 /// \class FeaturesPlugin_Extrusion
31 /// \ingroup Plugins
32 /// \brief Feature for creation of extrusion from the planar face.
33 /// Extrusion creates the lateral faces based on edges of the base face and
34 /// the top and bottom faces equal to the base face or this faces can be projection on the
35 /// bounding planes if they were set. Direction of extrusion is taken from the face
36 /// plane or if the bounding faces were set then it will be from the bottom to the top plane.
37 class FeaturesPlugin_Extrusion: public FeaturesPlugin_CompositeSketch
38 {
39 public:
40   /// Use plugin manager for features creation
41   FeaturesPlugin_Extrusion();
42
43   /// Feature kind.
44   inline static const std::string& ID()
45   {
46     static const std::string MY_ID("Extrusion");
47     return MY_ID;
48   }
49
50   /// Attribute name for creation method.
51   inline static const std::string& CREATION_METHOD()
52   {
53     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
54     return MY_CREATION_METHOD_ID;
55   }
56
57   /// Attribute name for creation method.
58   inline static const std::string& CREATION_METHOD_BY_SIZES()
59   {
60     static const std::string MY_CREATION_METHOD_ID("BySizes");
61     return MY_CREATION_METHOD_ID;
62   }
63
64   /// Attribute name for creation method.
65   inline static const std::string& CREATION_METHOD_BY_PLANES()
66   {
67     static const std::string MY_CREATION_METHOD_ID("ByPlanesAndOffsets");
68     return MY_CREATION_METHOD_ID;
69   }
70
71   /// Attribute name of an object to which the extrusion grows.
72   inline static const std::string& DIRECTION_OBJECT_ID()
73   {
74     static const std::string MY_DIRECTION_OBJECT_ID("direction_object");
75     return MY_DIRECTION_OBJECT_ID;
76   }
77
78   /// Attribute name of extrusion to size.
79   inline static const std::string& TO_SIZE_ID()
80   {
81     static const std::string MY_TO_SIZE_ID("to_size");
82     return MY_TO_SIZE_ID;
83   }
84
85   /// Attribute name of extrusion from size.
86   inline static const std::string& FROM_SIZE_ID()
87   {
88     static const std::string MY_FROM_SIZE_ID("from_size");
89     return MY_FROM_SIZE_ID;
90   }
91
92   /// Attribute name of an object to which the extrusion grows.
93   inline static const std::string& TO_OBJECT_ID()
94   {
95     static const std::string MY_TO_OBJECT_ID("to_object");
96     return MY_TO_OBJECT_ID;
97   }
98
99   /// Attribute name of extrusion offset.
100   inline static const std::string& TO_OFFSET_ID()
101   {
102     static const std::string MY_TO_OFFSET_ID("to_offset");
103     return MY_TO_OFFSET_ID;
104   }
105
106   /// Attribute name of an object from which the extrusion grows.
107   inline static const std::string& FROM_OBJECT_ID()
108   {
109     static const std::string MY_FROM_OBJECT_ID("from_object");
110     return MY_FROM_OBJECT_ID;
111   }
112
113   /// Attribute name of extrusion offset.
114   inline static const std::string& FROM_OFFSET_ID()
115   {
116     static const std::string MY_FROM_OFFSET_ID("from_offset");
117     return MY_FROM_OFFSET_ID;
118   }
119
120   /// \return the kind of a feature.
121   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
122   {
123     static std::string MY_KIND = FeaturesPlugin_Extrusion::ID();
124     return MY_KIND;
125   }
126
127   /// Request for initialization of data model of the feature: adding all attributes.
128   FEATURESPLUGIN_EXPORT virtual void initAttributes();
129
130   /// Creates a new part document if needed.
131   FEATURESPLUGIN_EXPORT virtual void execute();
132
133 protected:
134   /// Generates extrusions.
135   /// \param[out] theBaseShapes list of base shapes.
136   /// \param[out] theMakeShapes list of according algos.
137   /// \return false in case one of algo failed.
138   bool makeExtrusions(ListOfShape& theBaseShapes,
139                       ListOfMakeShape& theMakeShapes);
140 };
141
142 #endif