Salome HOME
85b34d0aa01b2823285ebc727df9aa7a1dd43865
[modules/shaper.git] / src / PrimitivesPlugin / PrimitivesPlugin_Cylinder.h
1 // Copyright (C) 2014-2021  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 PRIMITIVESPLUGIN_CYLINDER_H_
21 #define PRIMITIVESPLUGIN_CYLINDER_H_
22
23 #include <PrimitivesPlugin.h>
24 #include <ModelAPI_Feature.h>
25 #include <GeomAlgoAPI_Cylinder.h>
26
27 class GeomAPI_Shape;
28 class ModelAPI_ResultBody;
29
30 /**\class PrimitivesPlugin_Cylinder
31  * \ingroup Plugins
32  * \brief Feature for creation of a cylinder.
33  *
34  * Creates a cylinder from a radius, a height, an angle, a center point defaulting to
35  * the origin and an axis defaulting to OZ
36  */
37 class PrimitivesPlugin_Cylinder : public ModelAPI_Feature
38 {
39  public:
40   /// Cylinder kind
41   inline static const std::string& ID()
42   {
43     static const std::string MY_CYLINDER_ID("Cylinder");
44     return MY_CYLINDER_ID;
45   }
46
47   /// Attribute name for creation method
48   inline static const std::string& CREATION_METHOD()
49   {
50     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
51     return MY_CREATION_METHOD_ID;
52   }
53
54   /// Attribute name for creation method
55   inline static const std::string& CREATION_METHOD_CYLINDER()
56   {
57     static const std::string MY_CREATION_METHOD_ID("Cylinder");
58     return MY_CREATION_METHOD_ID;
59   }
60
61   /// Attribute name for creation method
62   inline static const std::string& CREATION_METHOD_CYLINDER_PORTION()
63   {
64     static const std::string MY_CREATION_METHOD_ID("CylinderPortion");
65     return MY_CREATION_METHOD_ID;
66   }
67
68   /// Attribute name of the base point
69   inline static const std::string& BASE_POINT_ID()
70   {
71     static const std::string MY_BASE_POINT_ID("base_point");
72     return MY_BASE_POINT_ID;
73   }
74
75   /// Attribute name of the axis
76   inline static const std::string& AXIS_ID()
77   {
78     static const std::string MY_AXIS_ID("axis");
79     return MY_AXIS_ID;
80   }
81
82   /// Attribute name of the radius
83   inline static const std::string& RADIUS_ID()
84   {
85     static const std::string MY_RADIUS_ID("radius");
86     return MY_RADIUS_ID;
87   }
88
89   /// Attribute name of the height
90   inline static const std::string& HEIGHT_ID()
91   {
92     static const std::string MY_HEIGHT_ID("height");
93     return MY_HEIGHT_ID;
94   }
95
96   /// Attribute name of the angle
97   inline static const std::string& ANGLE_ID()
98   {
99     static const std::string MY_ANGLE_ID("angle");
100     return MY_ANGLE_ID;
101   }
102
103   /// Returns the kind of a feature
104   PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
105   {
106     static std::string MY_KIND = PrimitivesPlugin_Cylinder::ID();
107     return MY_KIND;
108   }
109
110   /// Creates a new part document if needed
111   PRIMITIVESPLUGIN_EXPORT virtual void execute();
112
113   /// Request for initialization of data model of the feature: adding all attributes
114   PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
115
116   /// Use plugin manager for features creation
117   PrimitivesPlugin_Cylinder();
118
119  private:
120   /// Load Naming data structure of the feature to the document
121   void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Cylinder> theCylinderAlgo,
122                     std::shared_ptr<ModelAPI_ResultBody> theResultCylinder);
123
124   ///Perform the creation of a cylinder
125   void createCylinder(bool withAngle);
126
127 };
128
129 #endif // PRIMITIVESPLUGIN_CYLINDER_H_