Salome HOME
afd1e45fc6b793277fc7cf64d72a30bbf97976a0
[modules/shaper.git] / src / ConstructionPlugin / ConstructionPlugin_Axis.h
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D
2
3 // File:        ConstructionPlugin_Axis.h
4 // Created:     12 Dec 2014
5 // Author:      Vitaly Smetannikov
6
7 // Modified by CEA (delegation to Alyotech) : 29 Mar 2016 
8
9 #ifndef ConstructionPlugin_Axis_H
10 #define ConstructionPlugin_Axis_H
11
12 #include "ConstructionPlugin.h"
13 #include <ModelAPI_Feature.h>
14 #include <ModelAPI_Result.h>
15 #include <GeomAPI_ICustomPrs.h>
16
17 /**\class ConstructionPlugin_Axis
18  * \ingroup Plugins
19  * \brief Feature for creation of the new axis in PartSet.
20  */
21 class ConstructionPlugin_Axis : public ModelAPI_Feature, public GeomAPI_ICustomPrs
22 {
23  public:
24   /// Returns the kind of a feature
25   CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind()
26   {
27     static std::string MY_KIND = ConstructionPlugin_Axis::ID();
28     return MY_KIND;
29   }
30
31   /// Axis kind
32   inline static const std::string& ID()
33   {
34     static const std::string CONSTRUCTION_AXIS_KIND("Axis");
35     return CONSTRUCTION_AXIS_KIND;
36   }
37
38   /// attribute name for first point
39   inline static const std::string& METHOD()
40   {
41     static const std::string METHOD_ATTR("CreationMethod");
42     return METHOD_ATTR;
43   }
44
45   /// Attribute name for creation method.
46   inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
47   {
48     static const std::string METHOD_ATTR("AxisByPointsCase");
49     return METHOD_ATTR;
50   }
51
52   /// Attribute name for creation method.
53   inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
54   {
55     static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
56     return METHOD_ATTR;
57   }
58
59   /// Attribute name for creation method.
60   inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
61   {
62     static const std::string METHOD_ATTR("AxisByPointAndDirection");
63     return METHOD_ATTR;
64   }
65
66   /// Attribute name for creation method.
67   inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
68   {
69     static const std::string METHOD_ATTR("AxisByDimensionsCase");
70     return METHOD_ATTR;
71   }
72
73   /// Attribute name for creation method.
74   inline static const std::string& CREATION_METHOD_BY_LINE()
75   {
76     static const std::string METHOD_ATTR("by_line");
77     return METHOD_ATTR;
78   }
79
80   /// Attribute name for creation method.
81   inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
82   {
83     static const std::string METHOD_ATTR("by_plane_and_point");
84     return METHOD_ATTR;
85   }
86
87   /// Attribute name for creation method.
88   inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
89   {
90     static const std::string METHOD_ATTR("by_two_planes");
91     return METHOD_ATTR;
92   }
93
94   /// attribute name for first point
95   inline static const std::string& POINT_FIRST()
96   {
97     static const std::string POINT_ATTR_FIRST("FirstPoint");
98     return POINT_ATTR_FIRST;
99   }
100   /// attribute name for second point
101   inline static const std::string& POINT_SECOND()
102   {
103     static const std::string POINT_ATTR_SECOND("SecondPoint");
104     return POINT_ATTR_SECOND;
105   }
106   /// attribute name for second point
107   inline static const std::string& CYLINDRICAL_FACE()
108   {
109     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
110     return CYLINDRICAL_FACE_ATTR;
111   }
112   /// attribute name for the X dimension
113   inline static const std::string& DX()
114   {
115     static const std::string DX_ATTR("DX");
116     return DX_ATTR;
117   }
118   /// attribute name for the Y dimension
119   inline static const std::string& DY()
120   {
121     static const std::string DY_ATTR("DY");
122     return DY_ATTR;
123   }
124   /// attribute name for the Z dimension
125   inline static const std::string& DZ()
126   {
127     static const std::string DZ_ATTR("DZ");
128     return DZ_ATTR;
129   }
130
131   /// attribute name for X direction
132   inline static const std::string& X_DIRECTION()
133   {
134     static const std::string ATTR_X_DIRECTION("X_Direction");
135     return ATTR_X_DIRECTION;
136   }
137
138   /// attribute name for Y direction
139   inline static const std::string& Y_DIRECTION()
140   {
141     static const std::string ATTR_Y_DIRECTION("Y_Direction");
142     return ATTR_Y_DIRECTION;
143   }
144
145   /// attribute name for Y direction
146   inline static const std::string& Z_DIRECTION()
147   {
148     static const std::string ATTR_Z_DIRECTION("Z_Direction");
149     return ATTR_Z_DIRECTION;
150   }
151
152   /// Attribute name for line.
153   inline static const std::string& LINE()
154   {
155     static const std::string ATTR_ID("line");
156     return ATTR_ID;
157   }
158
159   /// Attribute name for plane.
160   inline static const std::string& PLANE()
161   {
162     static const std::string ATTR_ID("plane");
163     return ATTR_ID;
164   }
165
166   /// Attribute name for point.
167   inline static const std::string& POINT()
168   {
169     static const std::string ATTR_ID("point");
170     return ATTR_ID;
171   }
172
173   /// Attribute name for plane 1.
174   inline static const std::string& PLANE1()
175   {
176     static const std::string ATTR_ID("plane1");
177     return ATTR_ID;
178   }
179
180   /// Attribute name for use offset for plane 1.
181   inline static const std::string& USE_OFFSET1()
182   {
183     static const std::string ATTR_ID("use_offset1");
184     return ATTR_ID;
185   }
186
187   /// Attribute name for offset for plane 1.
188   inline static const std::string& OFFSET1()
189   {
190     static const std::string ATTR_ID("offset1");
191     return ATTR_ID;
192   }
193
194   /// Attribute name for reverse offset for plane 1.
195   inline static const std::string& REVERSE_OFFSET1()
196   {
197     static const std::string ATTR_ID("reverse_offset1");
198     return ATTR_ID;
199   }
200
201   /// Attribute name for plane 2.
202   inline static const std::string& PLANE2()
203   {
204     static const std::string ATTR_ID("plane2");
205     return ATTR_ID;
206   }
207
208   /// Attribute name for use offset for plane 2.
209   inline static const std::string& USE_OFFSET2()
210   {
211     static const std::string ATTR_ID("use_offset2");
212     return ATTR_ID;
213   }
214
215   /// Attribute name for offset for plane 2.
216   inline static const std::string& OFFSET2()
217   {
218     static const std::string ATTR_ID("offset2");
219     return ATTR_ID;
220   }
221
222   /// Attribute name for reverse offset for plane 2.
223   inline static const std::string& REVERSE_OFFSET2()
224   {
225     static const std::string ATTR_ID("reverse_offset2");
226     return ATTR_ID;
227   }
228
229   /// Returns a minimal length for axis
230   inline static const double MINIMAL_LENGTH() { return 1.e-5; }
231
232   /// Creates a new part document if needed
233   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
234
235   /// Request for initialization of data model of the feature: adding all attributes
236   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
237
238   /// Construction result is allways recomuted on the fly
239   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
240
241   /// Use plugin manager for features creation
242   ConstructionPlugin_Axis();
243
244   /// Customize presentation of the feature
245   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
246                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
247
248  protected:
249   /// Creates a new axis by two defined points
250   void createAxisByTwoPoints();
251   /// Creates a new axis using three dimensions
252   void createAxisByDimensions();
253   /// Creates a new axis as copy of cylindrical face axis
254   void createAxisByCylindricalFace();
255   /// Creates a new axis by point and direction
256   void createAxisByPointAndDirection();
257   void createAxisByLine();
258   void createAxisByPlaneAndPoint();
259   void createAxisByTwoPlanes();
260 };
261
262
263 #endif