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