Salome HOME
Update copyrights
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Point.h
1 // Copyright (C) 2014-2019  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_Point_H_
21 #define ConstructionPlugin_Point_H_
22
23 #include "ConstructionPlugin.h"
24
25 #include <GeomAPI_ICustomPrs.h>
26 #include <ModelAPI_Feature.h>
27 #include <ModelAPI_Result.h>
28
29 #include <math.h>
30
31 class GeomAPI_Vertex;
32
33 /// \class ConstructionPlugin_Point
34 /// \ingroup Plugins
35 /// \brief Feature for creation of the new part in PartSet.
36 class ConstructionPlugin_Point: public ModelAPI_Feature, public GeomAPI_ICustomPrs
37 {
38 public:
39   /// Returns the kind of a feature.
40   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind();
41
42   /// Point kind.
43   inline static const std::string& ID()
44   {
45     static const std::string CONSTRUCTION_POINT_KIND("Point");
46     return CONSTRUCTION_POINT_KIND;
47   }
48
49   /// Attribute name for creation method.
50   inline static const std::string& CREATION_METHOD()
51   {
52     static const std::string MY_CREATION_METHOD_ID("creation_method");
53     return MY_CREATION_METHOD_ID;
54   }
55
56   /// Attribute name for creation method.
57   inline static const std::string& CREATION_METHOD_BY_XYZ()
58   {
59     static const std::string MY_CREATION_METHOD_ID("by_xyz");
60     return MY_CREATION_METHOD_ID;
61   }
62
63   /// Attribute name for creation method.
64   inline static const std::string& CREATION_METHOD_BY_DISTANCE_ON_EDGE()
65   {
66     static const std::string MY_CREATION_METHOD_ID("by_distance_on_edge");
67     return MY_CREATION_METHOD_ID;
68   }
69
70   /// Attribute name for creation method.
71   inline static const std::string& CREATION_METHOD_BY_PROJECTION()
72   {
73     static const std::string MY_CREATION_METHOD_ID("by_projection");
74     return MY_CREATION_METHOD_ID;
75   }
76
77   /// Attribute name for creation method.
78   inline static const std::string& CREATION_METHOD_BY_INTERSECTION()
79   {
80     static const std::string MY_CREATION_METHOD_ID("by_intersection");
81     return MY_CREATION_METHOD_ID;
82   }
83
84   /// Attribute name for creation method.
85   inline static const std::string& CREATION_METHOD_BY_GEOMETRICAL_PROPERTY()
86   {
87     static const std::string MY_CREATION_METHOD_ID("by_geometrical_property");
88     return MY_CREATION_METHOD_ID;
89   }
90
91   inline static const std::string& POINT3D()
92   {
93     static const std::string POINT_ATTR("point3d");
94     return POINT_ATTR;
95   }
96
97   /// Attribute name for selected edge.
98   inline static const std::string& EDGE()
99   {
100     static const std::string ATTR_ID("edge");
101     return ATTR_ID;
102   }
103
104   /// Attribute name for offset type on selected edge.
105   inline static const std::string& OFFSET_TYPE()
106   {
107     static const std::string ATTR_ID("offset_type");
108     return ATTR_ID;
109   }
110
111   /// Attribute name for offset type by distance.
112   inline static const std::string& OFFSET_TYPE_BY_DISTANCE()
113   {
114     static const std::string ATTR_ID("offset_type_by_distance");
115     return ATTR_ID;
116   }
117
118   /// Attribute name for offset type by ratio.
119   inline static const std::string& OFFSET_TYPE_BY_RATIO()
120   {
121     static const std::string ATTR_ID("offset_type_by_ratio");
122     return ATTR_ID;
123   }
124
125   /// Attribute name for distance.
126   inline static const std::string& DISTANCE()
127   {
128     static const std::string ATTR_ID("distance");
129     return ATTR_ID;
130   }
131
132   /// Attribute name for percent flag.
133   inline static const std::string& RATIO()
134   {
135     static const std::string ATTR_ID("ratio");
136     return ATTR_ID;
137   }
138
139   /// Attribute name for reverse flag.
140   inline static const std::string& REVERSE()
141   {
142     static const std::string ATTR_ID("reverse");
143     return ATTR_ID;
144   }
145
146   /// Attribute name for point to projection.
147   inline static const std::string& POINT_TO_PROJECT()
148   {
149     static const std::string ATTR_ID("point_to_project");
150     return ATTR_ID;
151   }
152
153   /// Attribute name for projection type.
154   inline static const std::string& PROJECTION_TYPE()
155   {
156     static const std::string ATTR_ID("projection_type");
157     return ATTR_ID;
158   }
159
160   /// Attribute name for projection type on edge.
161   inline static const std::string& PROJECTION_TYPE_ON_EDGE()
162   {
163     static const std::string ATTR_ID("projection_type_on_edge");
164     return ATTR_ID;
165   }
166
167   /// Attribute name for projection type on face.
168   inline static const std::string& PROJECTION_TYPE_ON_FACE()
169   {
170     static const std::string ATTR_ID("projection_type_on_face");
171     return ATTR_ID;
172   }
173
174   /// Attribute name for edge for point projection.
175   inline static const std::string& EDGE_FOR_POINT_PROJECTION()
176   {
177     static const std::string ATTR_ID("edge_for_point_projection");
178     return ATTR_ID;
179   }
180
181   /// Attribute name for face for point projection.
182   inline static const std::string& FACE_FOR_POINT_PROJECTION()
183   {
184     static const std::string ATTR_ID("face_for_point_projection");
185     return ATTR_ID;
186   }
187
188   /// Attribute name for intersection type.
189   inline static const std::string& INTERSECTION_TYPE()
190   {
191     static const std::string ATTR_ID("intersection_type");
192     return ATTR_ID;
193   }
194
195   /// Attribute name for intersection type by lines.
196   inline static const std::string& INTERSECTION_TYPE_BY_LINES()
197   {
198     static const std::string MY_CREATION_METHOD_ID("intersection_type_by_lines");
199     return MY_CREATION_METHOD_ID;
200   }
201
202   /// Attribute name for intersection type by line and plane.
203   inline static const std::string& INTERSECTION_TYPE_BY_LINE_AND_PLANE()
204   {
205     static const std::string MY_CREATION_METHOD_ID("intersection_type_by_line_and_plane");
206     return MY_CREATION_METHOD_ID;
207   }
208
209   /// Attribute name for intersection type by planes.
210   inline static const std::string& INTERSECTION_TYPE_BY_PLANES()
211   {
212     static const std::string MY_CREATION_METHOD_ID("intersection_type_by_planes");
213     return MY_CREATION_METHOD_ID;
214   }
215
216   /// Attribute name for selected first intersection line.
217   inline static const std::string& INTERSECTION_LINE_1()
218   {
219     static const std::string ATTR_ID("intersection_line_1");
220     return ATTR_ID;
221   }
222
223   /// Attribute name for selected second intersection line.
224   inline static const std::string& INTERSECTION_LINE_2()
225   {
226     static const std::string ATTR_ID("intersection_line_2");
227     return ATTR_ID;
228   }
229
230   /// Attribute name for selected intersection line.
231   inline static const std::string& INTERSECTION_LINE()
232   {
233     static const std::string ATTR_ID("intersection_line");
234     return ATTR_ID;
235   }
236
237   /// Attribute name for selected intersection plane.
238   inline static const std::string& INTERSECTION_PLANE()
239   {
240     static const std::string ATTR_ID("intersection_plane");
241     return ATTR_ID;
242   }
243
244   /// Attribute name for use offset for the intersection plane.
245   inline static const std::string& USE_OFFSET()
246   {
247     static const std::string ATTR_ID("use_offset");
248     return ATTR_ID;
249   }
250
251   /// Attribute name for offset for the intersection plane.
252   inline static const std::string& OFFSET()
253   {
254     static const std::string ATTR_ID("offset");
255     return ATTR_ID;
256   }
257
258   /// Attribute name for reverse offset for the intersection plane.
259   inline static const std::string& REVERSE_OFFSET()
260   {
261     static const std::string ATTR_ID("reverse_offset");
262     return ATTR_ID;
263   }
264
265   /// Attribute name for selected intersection plane.
266   inline static const std::string& INTERSECTION_PLANE_1()
267   {
268     static const std::string ATTR_ID("intersection_plane_1");
269     return ATTR_ID;
270   }
271
272   /// Attribute name for selected intersection plane.
273   inline static const std::string& INTERSECTION_PLANE_2()
274   {
275     static const std::string ATTR_ID("intersection_plane_2");
276     return ATTR_ID;
277   }
278
279   /// Attribute name for selected intersection plane.
280   inline static const std::string& INTERSECTION_PLANE_3()
281   {
282     static const std::string ATTR_ID("intersection_plane_3");
283     return ATTR_ID;
284   }
285
286   /// Attribute name for property type.
287   inline static const std::string& GEOMETRICAL_PROPERTY_TYPE()
288   {
289     static const std::string ATTR_ID("geometrical_property_type");
290     return ATTR_ID;
291   }
292
293   /// Attribute name for property type by center of gravity.
294   inline static const std::string& GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_GRAVITY()
295   {
296     static const std::string PROPERTY_TYPE("geometrical_property_type_by_center_of_gravity");
297     return PROPERTY_TYPE;
298   }
299
300   /// Attribute name for property type by center of circle.
301   inline static const std::string& GEOMETRICAL_PROPERTY_TYPE_BY_CENTER_OF_CIRCLE()
302   {
303     static const std::string PROPERTY_TYPE("geometrical_property_type_by_center_of_circle");
304     return PROPERTY_TYPE;
305   }
306
307   /// Attribute name for selected object for center of gravity.
308   inline static const std::string& OBJECT_FOR_CENTER_OF_GRAVITY()
309   {
310     static const std::string ATTR_ID("object_for_center_of_gravity");
311     return ATTR_ID;
312   }
313
314   /// Attribute name for selected object for center of cricle.
315   inline static const std::string& OBJECT_FOR_CENTER_OF_CIRCLE()
316   {
317     static const std::string ATTR_ID("object_for_center_of_circle");
318     return ATTR_ID;
319   }
320
321   /// Creates a new part document if needed.
322   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
323
324   /// Request for initialization of data model of the feature: adding all attributes.
325   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
326
327   /// Construction result is allways recomuted on the fly.
328   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
329
330   /// Use plugin manager for features creation
331   ConstructionPlugin_Point();
332
333   /// Customize presentation of the feature
334   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
335                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
336
337 private:
338   std::shared_ptr<GeomAPI_Vertex> createByXYZ();
339   std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
340   std::shared_ptr<GeomAPI_Vertex> createByProjectionOnEdge();
341   std::shared_ptr<GeomAPI_Vertex> createByProjectionOnFace();
342   std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();
343   std::list<std::shared_ptr<GeomAPI_Vertex> > createByLineAndPlaneIntersection();
344   std::shared_ptr<GeomAPI_Vertex> createByPlanesIntersection();
345   std::shared_ptr<GeomAPI_Vertex> createByCenterOfGravity();
346   std::shared_ptr<GeomAPI_Vertex> createByCenterOfCircle();
347 };
348
349 #endif