Salome HOME
Merge branch 'V9_9_BR'
[modules/shaper.git] / src / PrimitivesPlugin / PrimitivesPlugin_Sphere.h
1 // Copyright (C) 2017-2022  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 // File:        PrimitivesPlugin_Sphere.h
21 // Created:     15 Mar 2017
22 // Author:      Clarisse Genrault (CEA)
23
24 #ifndef PRIMITIVESPLUGIN_SPHERE_H_
25 #define PRIMITIVESPLUGIN_SPHERE_H_
26
27 #include <PrimitivesPlugin.h>
28 #include <ModelAPI_Feature.h>
29 #include <GeomAlgoAPI_Sphere.h>
30
31 /**\class PrimitivesPlugin_Sphere
32  * \ingroup Plugins
33  * \brief Feature for creation of a sphere primitive using various methods.
34  *
35  * It can be built via two methods : using a radius and a center point defaulting to the origin,
36  * or radii (inner and outer) and angle limits (theta and phi).
37  */
38 class PrimitivesPlugin_Sphere : public ModelAPI_Feature
39 {
40  public:
41   /// Sphere kind
42   inline static const std::string& ID()
43   {
44     static const std::string MY_SPHERE_ID("Sphere");
45     return MY_SPHERE_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_BY_PT_RADIUS()
57   {
58     static const std::string MY_CREATION_METHOD_ID("SphereByPointRadius");
59     return MY_CREATION_METHOD_ID;
60   }
61
62   /// Attribute name for creation method
63   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
64   {
65     static const std::string MY_CREATION_METHOD_ID("SphereByDimensions");
66     return MY_CREATION_METHOD_ID;
67   }
68
69   /// Attribute name of the base point
70   inline static const std::string& CENTER_POINT_ID()
71   {
72     static const std::string MY_CENTER_POINT_ID("center_point");
73     return MY_CENTER_POINT_ID;
74   }
75
76   /// Attribute name of the radius
77   inline static const std::string& RADIUS_ID()
78   {
79     static const std::string MY_RADIUS_ID("radius");
80     return MY_RADIUS_ID;
81   }
82
83   /// attribute name of the inner radius
84   inline static const std::string& RMIN_ID()
85   {
86     static const std::string MY_RMIN_ID("rmin");
87     return MY_RMIN_ID;
88   }
89
90   /// attribute name of the outer radius
91   inline static const std::string& RMAX_ID()
92   {
93     static const std::string MY_RMAX_ID("rmax");
94     return MY_RMAX_ID;
95   }
96
97   /// attribute name of the lower phi limit
98   inline static const std::string& PHIMIN_ID()
99   {
100     static const std::string MY_PHIMIN_ID("phimin");
101     return MY_PHIMIN_ID;
102   }
103
104   /// attribute name of the higher phi limit
105   inline static const std::string& PHIMAX_ID()
106   {
107     static const std::string MY_PHIMAX_ID("phimax");
108     return MY_PHIMAX_ID;
109   }
110
111   /// attribute name of the lower theta limit
112   inline static const std::string& THETAMIN_ID()
113   {
114     static const std::string MY_THETAMIN_ID("thetamin");
115     return MY_THETAMIN_ID;
116   }
117
118   /// attribute name of the higher theta limit
119   inline static const std::string& THETAMAX_ID()
120   {
121     static const std::string MY_THETAMAX_ID("thetamax");
122     return MY_THETAMAX_ID;
123   }
124
125   /// Returns the kind of a feature
126   PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind()
127   {
128     static std::string MY_KIND = PrimitivesPlugin_Sphere::ID();
129     return MY_KIND;
130   }
131
132   /// Creates a new part document if needed
133   PRIMITIVESPLUGIN_EXPORT virtual void execute();
134
135   /// Request for initialization of data model of the feature: adding all attributes
136   PRIMITIVESPLUGIN_EXPORT virtual void initAttributes();
137
138   /// Use plugin manager for features creation
139   PrimitivesPlugin_Sphere();
140
141  private:
142   /// Load Naming data structure of the feature to the document
143   void loadNamingDS(std::shared_ptr<GeomAlgoAPI_Sphere> theSphereAlgo,
144                     std::shared_ptr<ModelAPI_ResultBody> theResultSphere);
145
146   /// Perform the creation of the sphere using a point and a radius
147   void createSphereByPtRadius();
148
149   /// Perform the creation of the sphere using radii (inner and outer) and angle limits
150   /// (theta and phi)
151   void createShereByDimensions();
152
153 };
154
155 #endif // PRIMITIVESPLUGIN_SPHERE_H_