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