Salome HOME
Issue #1650: Added option to create axis by plane and point.
[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 first point
60   inline static const std::string& POINT_FIRST()
61   {
62     static const std::string POINT_ATTR_FIRST("FirstPoint");
63     return POINT_ATTR_FIRST;
64   }
65   /// attribute name for second point
66   inline static const std::string& POINT_SECOND()
67   {
68     static const std::string POINT_ATTR_SECOND("SecondPoint");
69     return POINT_ATTR_SECOND;
70   }
71   /// attribute name for second point
72   inline static const std::string& CYLINDRICAL_FACE()
73   {
74     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
75     return CYLINDRICAL_FACE_ATTR;
76   }
77   /// attribute name for the X dimension
78   inline static const std::string& DX()
79   {
80     static const std::string DX_ATTR("DX");
81     return DX_ATTR;
82   }
83   /// attribute name for the Y dimension
84   inline static const std::string& DY()
85   {
86     static const std::string DY_ATTR("DY");
87     return DY_ATTR;
88   }
89   /// attribute name for the Z dimension
90   inline static const std::string& DZ()
91   {
92     static const std::string DZ_ATTR("DZ");
93     return DZ_ATTR;
94   }
95
96   /// attribute name for X direction
97   inline static const std::string& X_DIRECTION()
98   {
99     static const std::string ATTR_X_DIRECTION("X_Direction");
100     return ATTR_X_DIRECTION;
101   }
102
103   /// attribute name for Y direction
104   inline static const std::string& Y_DIRECTION()
105   {
106     static const std::string ATTR_Y_DIRECTION("Y_Direction");
107     return ATTR_Y_DIRECTION;
108   }
109
110   /// attribute name for Y direction
111   inline static const std::string& Z_DIRECTION()
112   {
113     static const std::string ATTR_Z_DIRECTION("Z_Direction");
114     return ATTR_Z_DIRECTION;
115   }
116
117   /// Attribute name for line.
118   inline static const std::string& LINE()
119   {
120     static const std::string ATTR_ID("line");
121     return ATTR_ID;
122   }
123
124   /// Attribute name for plane.
125   inline static const std::string& PLANE()
126   {
127     static const std::string ATTR_ID("plane");
128     return ATTR_ID;
129   }
130
131   /// Attribute name for point.
132   inline static const std::string& POINT()
133   {
134     static const std::string ATTR_ID("point");
135     return ATTR_ID;
136   }
137
138   /// Returns a minimal length for axis
139   inline static const double MINIMAL_LENGTH() { return 1.e-5; }
140
141   /// Creates a new part document if needed
142   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
143
144   /// Request for initialization of data model of the feature: adding all attributes
145   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
146
147   /// Construction result is allways recomuted on the fly
148   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
149
150   /// Use plugin manager for features creation
151   ConstructionPlugin_Axis();
152
153   /// Customize presentation of the feature
154   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
155                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
156
157  protected:
158   /// Creates a new axis by two defined points
159   void createAxisByTwoPoints();
160   /// Creates a new axis using three dimensions
161   void createAxisByDimensions();
162   /// Creates a new axis as copy of cylindrical face axis
163   void createAxisByCylindricalFace();
164   /// Creates a new axis by point and direction
165   void createAxisByPointAndDirection();
166   void createAxisByLine();
167   void createAxisByPlaneAndPoint();
168 };
169
170
171 #endif