Salome HOME
updated copyright message
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Revolution.h
1 // Copyright (C) 2014-2023  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 email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef FeaturesPlugin_Revolution_H_
21 #define FeaturesPlugin_Revolution_H_
22
23 #include "FeaturesPlugin.h"
24
25 #include "FeaturesPlugin_CompositeSketch.h"
26
27 #include <GeomAlgoAPI_MakeShape.h>
28
29 /// \class FeaturesPlugin_Revolution
30 /// \ingroup Plugins
31 /// \brief Feature for creation of revolution from the planar face.
32 /// Revolution creates the lateral faces based on edges of the base face and
33 /// the start and end faces and/or start and end angles.
34 class FeaturesPlugin_Revolution: public FeaturesPlugin_CompositeSketch
35 {
36 public:
37   /// Feature kind.
38   inline static const std::string& ID()
39   {
40     static const std::string MY_ID("Revolution");
41     return MY_ID;
42   }
43
44   /// Attribute name for creation method.
45   inline static const std::string& CREATION_METHOD()
46   {
47     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
48     return MY_CREATION_METHOD_ID;
49   }
50
51   /// Attribute name for creation method.
52   inline static const std::string& CREATION_METHOD_THROUGH_ALL()
53   {
54     static const std::string MY_CREATION_METHOD_THROUGH_ALL("ThroughAll");
55     return MY_CREATION_METHOD_THROUGH_ALL;
56   }
57
58   /// Attribute name for creation method.
59   inline static const std::string& CREATION_METHOD_BY_ANGLES()
60   {
61     static const std::string MY_CREATION_METHOD_BY_ANGLES("ByAngles");
62     return MY_CREATION_METHOD_BY_ANGLES;
63   }
64
65   /// Attribute name for creation method.
66   inline static const std::string& CREATION_METHOD_BY_PLANES()
67   {
68     static const std::string MY_CREATION_METHOD_BY_PLANES("ByPlanesAndOffsets");
69     return MY_CREATION_METHOD_BY_PLANES;
70   }
71
72   /// Attribute name of an revolution axis.
73   inline static const std::string& AXIS_OBJECT_ID()
74   {
75     static const std::string MY_AXIS_OBJECT_ID("axis_object");
76     return MY_AXIS_OBJECT_ID;
77   }
78
79   /// Attribute name of revolution to angle.
80   inline static const std::string& TO_ANGLE_ID()
81   {
82     static const std::string MY_TO_ANGLE_ID("to_angle");
83     return MY_TO_ANGLE_ID;
84   }
85
86   /// Attribute name of revolution from angle.
87   inline static const std::string& FROM_ANGLE_ID()
88   {
89     static const std::string MY_FROM_ANGLE_ID("from_angle");
90     return MY_FROM_ANGLE_ID;
91   }
92
93   /// Attribute name of an object to which the revolution grows.
94   inline static const std::string& TO_OBJECT_ID()
95   {
96     static const std::string MY_TO_OBJECT_ID("to_object");
97     return MY_TO_OBJECT_ID;
98   }
99
100   /// Attribute name of revolution offset.
101   inline static const std::string& TO_OFFSET_ID()
102   {
103     static const std::string MY_TO_OFFSET_ID("to_offset");
104     return MY_TO_OFFSET_ID;
105   }
106
107   /// Attribute name of an object from which the revolution grows.
108   inline static const std::string& FROM_OBJECT_ID()
109   {
110     static const std::string MY_FROM_OBJECT_ID("from_object");
111     return MY_FROM_OBJECT_ID;
112   }
113
114   /// Attribute name of revolution offset.
115   inline static const std::string& FROM_OFFSET_ID()
116   {
117     static const std::string MY_FROM_OFFSET_ID("from_offset");
118     return MY_FROM_OFFSET_ID;
119   }
120
121   /// \return the kind of a feature.
122   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
123   {
124     static std::string MY_KIND = FeaturesPlugin_Revolution::ID();
125     return MY_KIND;
126   }
127
128   /// Performs the algorithm and stores results it in the data structure.
129   FEATURESPLUGIN_EXPORT virtual void execute();
130
131   /// Request for initialization of data model of the feature: adding all attributes.
132   FEATURESPLUGIN_EXPORT virtual void initAttributes();
133
134   /// Use plugin manager for features creation.
135   FeaturesPlugin_Revolution();
136
137   protected:
138   /// Generates revolutions.
139   /// \param[out] theBaseShapes list of base shapes.
140   /// \param[out] theMakeShapes list of according algos.
141   /// \return false in case one of algo failed.
142   bool makeRevolutions(ListOfShape& theBaseShapes,
143                        ListOfMakeShape& theMakeShapes);
144 };
145
146 #endif