Salome HOME
Fix for the issue #1794: can't create a plane by a vertex and an axis if the vertex...
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Plane.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ConstructionPlugin_Plane.h
4 // Created:     12 Dec 2014
5 // Author:      Vitaly Smetannikov
6
7 #ifndef ConstructionPlugin_Plane_H
8 #define ConstructionPlugin_Plane_H
9
10 #include "ConstructionPlugin.h"
11
12 #include <ModelAPI_Feature.h>
13 #include <ModelAPI_Result.h>
14 #include <GeomAPI_ICustomPrs.h>
15
16 /// \class ConstructionPlugin_Plane
17 /// \ingroup Plugins
18 /// \brief Feature for creation of the new planar surface in PartSet.
19 class ConstructionPlugin_Plane: public ModelAPI_Feature, public GeomAPI_ICustomPrs
20 {
21 public:
22   /// \return the kind of a feature.
23   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
24   {
25     static std::string MY_KIND = ConstructionPlugin_Plane::ID();
26     return MY_KIND;
27   }
28
29   /// Default color for a plane.
30   inline static const std::string& DEFAULT_COLOR()
31   {
32     static const std::string CONSTRUCTION_PLANE_COLOR("150,150,180");
33     return CONSTRUCTION_PLANE_COLOR;
34   }
35
36   /// Plane kind.
37   inline static const std::string& ID()
38   {
39     static const std::string CONSTRUCTION_PLANE_KIND("Plane");
40     return CONSTRUCTION_PLANE_KIND;
41   }
42
43   /// Attribute name for creation method.
44   inline static const std::string& CREATION_METHOD()
45   {
46     static const std::string MY_CREATION_METHOD_ID("creation_method");
47     return MY_CREATION_METHOD_ID;
48   }
49
50   /// Attribute name for creation method.
51   inline static const std::string& CREATION_METHOD_BY_GENERAL_EQUATION()
52   {
53     static const std::string MY_CREATION_METHOD_ID("by_general_equation");
54     return MY_CREATION_METHOD_ID;
55   }
56
57   /// Attribute name for creation method.
58   inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
59   {
60     static const std::string MY_CREATION_METHOD_ID("by_three_points");
61     return MY_CREATION_METHOD_ID;
62   }
63
64   /// Attribute name for creation method.
65   inline static const std::string& CREATION_METHOD_BY_LINE_AND_POINT()
66   {
67     static const std::string MY_CREATION_METHOD_ID("by_line_and_point");
68     return MY_CREATION_METHOD_ID;
69   }
70
71   /// Attribute name for creation method.
72   inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE()
73   {
74     static const std::string MY_CREATION_METHOD_ID("by_other_plane");
75     return MY_CREATION_METHOD_ID;
76   }
77
78   /// Attribute name for creation method.
79   inline static const std::string& CREATION_METHOD_BY_OTHER_PLANE_OPTION()
80   {
81     static const std::string MY_CREATION_METHOD_ID("by_other_plane_option");
82     return MY_CREATION_METHOD_ID;
83   }
84
85   /// Attribute name for creation method.
86   inline static const std::string& CREATION_METHOD_BY_DISTANCE_FROM_OTHER()
87   {
88     static const std::string MY_CREATION_METHOD_ID("by_distance_from_other");
89     return MY_CREATION_METHOD_ID;
90   }
91
92   /// Attribute name for creation method.
93   inline static const std::string& CREATION_METHOD_BY_COINCIDENT_TO_POINT()
94   {
95     static const std::string MY_CREATION_METHOD_ID("by_coincident_to_point");
96     return MY_CREATION_METHOD_ID;
97   }
98
99   /// Attribute name for creation method.
100   inline static const std::string& CREATION_METHOD_BY_ROTATION()
101   {
102     static const std::string MY_CREATION_METHOD_ID("by_rotation");
103     return MY_CREATION_METHOD_ID;
104   }
105
106   /// Attribute name for creation method.
107   inline static const std::string& CREATION_METHOD_BY_TWO_PARALLEL_PLANES()
108   {
109     static const std::string MY_CREATION_METHOD_ID("by_two_parallel_planes");
110     return MY_CREATION_METHOD_ID;
111   }
112
113   /// Attribute name for first point.
114   inline static const std::string& POINT1()
115   {
116     static const std::string ATTR_ID("point1");
117     return ATTR_ID;
118   }
119
120   /// Attribute name for second point.
121   inline static const std::string& POINT2()
122   {
123     static const std::string ATTR_ID("point2");
124     return ATTR_ID;
125   }
126
127   /// Attribute name for third point.
128   inline static const std::string& POINT3()
129   {
130     static const std::string ATTR_ID("point3");
131     return ATTR_ID;
132   }
133
134   /// Attribute name for line.
135   inline static const std::string& LINE()
136   {
137     static const std::string ATTR_ID("line");
138     return ATTR_ID;
139   }
140
141   /// Attribute name for point.
142   inline static const std::string& POINT()
143   {
144     static const std::string ATTR_ID("point");
145     return ATTR_ID;
146   }
147
148   /// Attribute name for perpendicular flag.
149   inline static const std::string& PERPENDICULAR()
150   {
151     static const std::string ATTR_ID("perpendicular");
152     return ATTR_ID;
153   }
154
155   /// Attribute name for selected plane.
156   inline static const std::string& PLANE()
157   {
158     static const std::string ATTR_ID("plane");
159     return ATTR_ID;
160   }
161
162   /// Attribute name for distance.
163   inline static const std::string& DISTANCE()
164   {
165     static const std::string ATTR_ID("distance");
166     return ATTR_ID;
167   }
168
169   /// Attribute name for reverse flag.
170   inline static const std::string& REVERSE()
171   {
172     static const std::string ATTR_ID("reverse");
173     return ATTR_ID;
174   }
175
176   /// Attribute name for coincident point.
177   inline static const std::string& COINCIDENT_POINT()
178   {
179     static const std::string ATTR_ID("coincident_point");
180     return ATTR_ID;
181   }
182
183   /// Attribute name for axis.
184   inline static const std::string& AXIS()
185   {
186     static const std::string ATTR_ID("axis");
187     return ATTR_ID;
188   }
189
190   /// Attribute name for angle.
191   inline static const std::string& ANGLE()
192   {
193     static const std::string ATTR_ID("angle");
194     return ATTR_ID;
195   }
196
197   inline static const std::string& PLANE1()
198   {
199     static const std::string ATTR_ID("plane1");
200     return ATTR_ID;
201   }
202
203   inline static const std::string& PLANE2()
204   {
205     static const std::string ATTR_ID("plane2");
206     return ATTR_ID;
207   }
208
209
210   /// Attribute name for a parameter for the general equation of a plane (ax+by+cz+d=0)
211   inline static const std::string& A()
212   {
213     static const std::string ATTR_ID("A");
214     return ATTR_ID;
215   }
216   /// Attribute name for b parameter for the general equation of a plane (ax+by+cz+d=0)
217   inline static const std::string& B()
218   {
219     static const std::string ATTR_ID("B");
220     return ATTR_ID;
221   }
222   /// Attribute name for c parameter for the general equation of a plane (ax+by+cz+d=0)
223   inline static const std::string& C()
224   {
225     static const std::string ATTR_ID("C");
226     return ATTR_ID;
227   }
228   /// Attribute name for d parameter for the general equation of a plane (ax+by+cz+d=0)
229   inline static const std::string& D()
230   {
231     static const std::string ATTR_ID("D");
232     return ATTR_ID;
233   }
234
235   /// Creates a new part document if needed
236   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
237
238   /// Request for initialization of data model of the feature: adding all attributes
239   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
240
241   /// Construction result is always recomputed on the fly
242   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
243
244   /// Use plugin manager for features creation
245   ConstructionPlugin_Plane();
246
247   /// Customize presentation of the feature
248   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
249                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
250
251 protected:
252   /// Creates a new plane by general equation.
253   std::shared_ptr<GeomAPI_Shape> createByGeneralEquation();
254   std::shared_ptr<GeomAPI_Shape> createByThreePoints();
255   std::shared_ptr<GeomAPI_Shape> createByLineAndPoint();
256   std::shared_ptr<GeomAPI_Shape> createByCoincidentPoint();
257   std::shared_ptr<GeomAPI_Shape> createByRotation();
258   std::shared_ptr<GeomAPI_Shape> createByTwoParallelPlanes();
259   /// Creates a new plane by copy of face plane with translation along the normal
260   /// to the specified distance.
261   std::shared_ptr<GeomAPI_Shape> createByDistanceFromOther();
262 };
263
264 #endif