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