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