Salome HOME
49db67df9ab6e6a2db8f6707e59fcc6daf50ef51
[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 X coordinate.
86   inline static const std::string& X()
87   {
88     static const std::string POINT_ATTR_X("x");
89     return POINT_ATTR_X;
90   }
91
92   /// Attribute name for Y coordinate.
93   inline static const std::string& Y()
94   {
95     static const std::string POINT_ATTR_Y("y");
96     return POINT_ATTR_Y;
97   }
98
99   /// Attribute name for Z coordinate.
100   inline static const std::string& Z()
101   {
102     static const std::string POINT_ATTR_Z("z");
103     return POINT_ATTR_Z;
104   }
105
106   /// Attribute name for selected edge.
107   inline static const std::string& EDGE()
108   {
109     static const std::string ATTR_ID("edge");
110     return ATTR_ID;
111   }
112
113   /// Attribute name for offset type on selected edge.
114   inline static const std::string& OFFSET_TYPE()
115   {
116     static const std::string ATTR_ID("offset_type");
117     return ATTR_ID;
118   }
119
120   /// Attribute name for offset type by distance.
121   inline static const std::string& OFFSET_TYPE_BY_DISTANCE()
122   {
123     static const std::string ATTR_ID("offset_type_by_distance");
124     return ATTR_ID;
125   }
126
127   /// Attribute name for offset type by ratio.
128   inline static const std::string& OFFSET_TYPE_BY_RATIO()
129   {
130     static const std::string ATTR_ID("offset_type_by_ratio");
131     return ATTR_ID;
132   }
133
134   /// Attribute name for distance.
135   inline static const std::string& DISTANCE()
136   {
137     static const std::string ATTR_ID("distance");
138     return ATTR_ID;
139   }
140
141   /// Attribute name for percent flag.
142   inline static const std::string& RATIO()
143   {
144     static const std::string ATTR_ID("ratio");
145     return ATTR_ID;
146   }
147
148   /// Attribute name for reverse flag.
149   inline static const std::string& REVERSE()
150   {
151     static const std::string ATTR_ID("reverse");
152     return ATTR_ID;
153   }
154
155   /// Attribute name for point to projection.
156   inline static const std::string& POINT_TO_PROJECT()
157   {
158     static const std::string ATTR_ID("point_to_project");
159     return ATTR_ID;
160   }
161
162   /// Attribute name for projection type.
163   inline static const std::string& PROJECTION_TYPE()
164   {
165     static const std::string ATTR_ID("projection_type");
166     return ATTR_ID;
167   }
168
169   /// Attribute name for projection type on edge.
170   inline static const std::string& PROJECTION_TYPE_ON_EDGE()
171   {
172     static const std::string ATTR_ID("projection_type_on_edge");
173     return ATTR_ID;
174   }
175
176   /// Attribute name for projection type on face.
177   inline static const std::string& PROJECTION_TYPE_ON_FACE()
178   {
179     static const std::string ATTR_ID("projection_type_on_face");
180     return ATTR_ID;
181   }
182
183   /// Attribute name for edge for point projection.
184   inline static const std::string& EDGE_FOR_POINT_PROJECTION()
185   {
186     static const std::string ATTR_ID("edge_for_point_projection");
187     return ATTR_ID;
188   }
189
190   /// Attribute name for face for point projection.
191   inline static const std::string& FACE_FOR_POINT_PROJECTION()
192   {
193     static const std::string ATTR_ID("face_for_point_projection");
194     return ATTR_ID;
195   }
196
197   /// Attribute name for intersection type.
198   inline static const std::string& INTERSECTION_TYPE()
199   {
200     static const std::string ATTR_ID("intersection_type");
201     return ATTR_ID;
202   }
203
204   /// Attribute name for intersection type by lines.
205   inline static const std::string& INTERSECTION_TYPE_BY_LINES()
206   {
207     static const std::string MY_CREATION_METHOD_ID("intersection_type_by_lines");
208     return MY_CREATION_METHOD_ID;
209   }
210
211   /// Attribute name for intersection type by line and plane.
212   inline static const std::string& INTERSECTION_TYPE_BY_LINE_AND_PLANE()
213   {
214     static const std::string MY_CREATION_METHOD_ID("intersection_type_by_line_and_plane");
215     return MY_CREATION_METHOD_ID;
216   }
217
218   /// Attribute name for intersection type by planes.
219   inline static const std::string& INTERSECTION_TYPE_BY_PLANES()
220   {
221     static const std::string MY_CREATION_METHOD_ID("intersection_type_by_planes");
222     return MY_CREATION_METHOD_ID;
223   }
224
225   /// Attribute name for selected first intersection line.
226   inline static const std::string& INTERSECTION_LINE_1()
227   {
228     static const std::string ATTR_ID("intersection_line_1");
229     return ATTR_ID;
230   }
231
232   /// Attribute name for selected second intersection line.
233   inline static const std::string& INTERSECTION_LINE_2()
234   {
235     static const std::string ATTR_ID("intersection_line_2");
236     return ATTR_ID;
237   }
238
239   /// Attribute name for selected intersection line.
240   inline static const std::string& INTERSECTION_LINE()
241   {
242     static const std::string ATTR_ID("intersection_line");
243     return ATTR_ID;
244   }
245
246   /// Attribute name for selected intersection plane.
247   inline static const std::string& INTERSECTION_PLANE()
248   {
249     static const std::string ATTR_ID("intersection_plane");
250     return ATTR_ID;
251   }
252
253   /// Attribute name for use offset for the intersection plane.
254   inline static const std::string& USE_OFFSET()
255   {
256     static const std::string ATTR_ID("use_offset");
257     return ATTR_ID;
258   }
259
260   /// Attribute name for offset for the intersection plane.
261   inline static const std::string& OFFSET()
262   {
263     static const std::string ATTR_ID("offset");
264     return ATTR_ID;
265   }
266
267   /// Attribute name for reverse offset for the intersection plane.
268   inline static const std::string& REVERSE_OFFSET()
269   {
270     static const std::string ATTR_ID("reverse_offset");
271     return ATTR_ID;
272   }
273
274   /// Attribute name for selected intersection plane.
275   inline static const std::string& INTERSECTION_PLANE_1()
276   {
277     static const std::string ATTR_ID("intersection_plane_1");
278     return ATTR_ID;
279   }
280
281   /// Attribute name for selected intersection plane.
282   inline static const std::string& INTERSECTION_PLANE_2()
283   {
284     static const std::string ATTR_ID("intersection_plane_2");
285     return ATTR_ID;
286   }
287
288   /// Attribute name for selected intersection plane.
289   inline static const std::string& INTERSECTION_PLANE_3()
290   {
291     static const std::string ATTR_ID("intersection_plane_3");
292     return ATTR_ID;
293   }
294
295   /// Creates a new part document if needed.
296   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
297
298   /// Request for initialization of data model of the feature: adding all attributes.
299   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
300
301   /// Construction result is allways recomuted on the fly.
302   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
303
304   /// Use plugin manager for features creation
305   ConstructionPlugin_Point();
306
307   /// Customize presentation of the feature
308   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
309                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
310
311 private:
312   std::shared_ptr<GeomAPI_Vertex> createByXYZ();
313   std::shared_ptr<GeomAPI_Vertex> createByDistanceOnEdge();
314   std::shared_ptr<GeomAPI_Vertex> createByProjectionOnEdge();
315   std::shared_ptr<GeomAPI_Vertex> createByProjectionOnFace();
316   std::shared_ptr<GeomAPI_Vertex> createByLinesIntersection();
317   std::list<std::shared_ptr<GeomAPI_Vertex> > createByLineAndPlaneIntersection();
318   std::shared_ptr<GeomAPI_Vertex> createByPlanesIntersection();
319 };
320
321 #endif