]> SALOME platform Git repositories - modules/shaper.git/blob - src/ConstructionPlugin/ConstructionPlugin_Axis.h
Salome HOME
Issue #1650: Added option to create axis by two planes.
[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_LINE()
47   {
48     static const std::string METHOD_ATTR("by_line");
49     return METHOD_ATTR;
50   }
51
52   /// Attribute name for creation method.
53   inline static const std::string& CREATION_METHOD_BY_PLANE_AND_POINT()
54   {
55     static const std::string METHOD_ATTR("by_plane_and_point");
56     return METHOD_ATTR;
57   }
58
59   /// Attribute name for creation method.
60   inline static const std::string& CREATION_METHOD_BY_TWO_PLANES()
61   {
62     static const std::string METHOD_ATTR("by_two_planes");
63     return METHOD_ATTR;
64   }
65
66   /// attribute name for first point
67   inline static const std::string& POINT_FIRST()
68   {
69     static const std::string POINT_ATTR_FIRST("FirstPoint");
70     return POINT_ATTR_FIRST;
71   }
72   /// attribute name for second point
73   inline static const std::string& POINT_SECOND()
74   {
75     static const std::string POINT_ATTR_SECOND("SecondPoint");
76     return POINT_ATTR_SECOND;
77   }
78   /// attribute name for second point
79   inline static const std::string& CYLINDRICAL_FACE()
80   {
81     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
82     return CYLINDRICAL_FACE_ATTR;
83   }
84   /// attribute name for the X dimension
85   inline static const std::string& DX()
86   {
87     static const std::string DX_ATTR("DX");
88     return DX_ATTR;
89   }
90   /// attribute name for the Y dimension
91   inline static const std::string& DY()
92   {
93     static const std::string DY_ATTR("DY");
94     return DY_ATTR;
95   }
96   /// attribute name for the Z dimension
97   inline static const std::string& DZ()
98   {
99     static const std::string DZ_ATTR("DZ");
100     return DZ_ATTR;
101   }
102
103   /// attribute name for X direction
104   inline static const std::string& X_DIRECTION()
105   {
106     static const std::string ATTR_X_DIRECTION("X_Direction");
107     return ATTR_X_DIRECTION;
108   }
109
110   /// attribute name for Y direction
111   inline static const std::string& Y_DIRECTION()
112   {
113     static const std::string ATTR_Y_DIRECTION("Y_Direction");
114     return ATTR_Y_DIRECTION;
115   }
116
117   /// attribute name for Y direction
118   inline static const std::string& Z_DIRECTION()
119   {
120     static const std::string ATTR_Z_DIRECTION("Z_Direction");
121     return ATTR_Z_DIRECTION;
122   }
123
124   /// Attribute name for line.
125   inline static const std::string& LINE()
126   {
127     static const std::string ATTR_ID("line");
128     return ATTR_ID;
129   }
130
131   /// Attribute name for plane.
132   inline static const std::string& PLANE()
133   {
134     static const std::string ATTR_ID("plane");
135     return ATTR_ID;
136   }
137
138   /// Attribute name for point.
139   inline static const std::string& POINT()
140   {
141     static const std::string ATTR_ID("point");
142     return ATTR_ID;
143   }
144
145   /// Attribute name for plane 1.
146   inline static const std::string& PLANE1()
147   {
148     static const std::string ATTR_ID("plane1");
149     return ATTR_ID;
150   }
151
152   /// Attribute name for use offset for plane 1.
153   inline static const std::string& USE_OFFSET1()
154   {
155     static const std::string ATTR_ID("use_offset1");
156     return ATTR_ID;
157   }
158
159   /// Attribute name for offset for plane 1.
160   inline static const std::string& OFFSET1()
161   {
162     static const std::string ATTR_ID("offset1");
163     return ATTR_ID;
164   }
165
166   /// Attribute name for reverse offset for plane 1.
167   inline static const std::string& REVERSE_OFFSET1()
168   {
169     static const std::string ATTR_ID("reverse_offset1");
170     return ATTR_ID;
171   }
172
173   /// Attribute name for plane 2.
174   inline static const std::string& PLANE2()
175   {
176     static const std::string ATTR_ID("plane2");
177     return ATTR_ID;
178   }
179
180   /// Attribute name for use offset for plane 2.
181   inline static const std::string& USE_OFFSET2()
182   {
183     static const std::string ATTR_ID("use_offset2");
184     return ATTR_ID;
185   }
186
187   /// Attribute name for offset for plane 2.
188   inline static const std::string& OFFSET2()
189   {
190     static const std::string ATTR_ID("offset2");
191     return ATTR_ID;
192   }
193
194   /// Attribute name for reverse offset for plane 2.
195   inline static const std::string& REVERSE_OFFSET2()
196   {
197     static const std::string ATTR_ID("reverse_offset2");
198     return ATTR_ID;
199   }
200
201   /// Returns a minimal length for axis
202   inline static const double MINIMAL_LENGTH() { return 1.e-5; }
203
204   /// Creates a new part document if needed
205   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
206
207   /// Request for initialization of data model of the feature: adding all attributes
208   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
209
210   /// Construction result is allways recomuted on the fly
211   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
212
213   /// Use plugin manager for features creation
214   ConstructionPlugin_Axis();
215
216   /// Customize presentation of the feature
217   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
218                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
219
220  protected:
221   /// Creates a new axis by two defined points
222   void createAxisByTwoPoints();
223   /// Creates a new axis using three dimensions
224   void createAxisByDimensions();
225   /// Creates a new axis as copy of cylindrical face axis
226   void createAxisByCylindricalFace();
227   /// Creates a new axis by point and direction
228   void createAxisByPointAndDirection();
229   void createAxisByLine();
230   void createAxisByPlaneAndPoint();
231   void createAxisByTwoPlanes();
232 };
233
234
235 #endif