Salome HOME
Adding a new type of axis creation : by 3 dimensions.
[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   /// attribute name for first point
45   inline static const std::string& POINT_FIRST()
46   {
47     static const std::string POINT_ATTR_FIRST("FirstPoint");
48     return POINT_ATTR_FIRST;
49   }
50   /// attribute name for second point
51   inline static const std::string& POINT_SECOND()
52   {
53     static const std::string POINT_ATTR_SECOND("SecondPoint");
54     return POINT_ATTR_SECOND;
55   }
56   /// attribute name for second point
57   inline static const std::string& CYLINDRICAL_FACE()
58   {
59     static const std::string CYLINDRICAL_FACE_ATTR("CylindricalFace");
60     return CYLINDRICAL_FACE_ATTR;
61   }
62   /// attribute name for the X dimension
63   inline static const std::string& DX()
64   {
65     static const std::string DX_ATTR("DX");
66     return DX_ATTR;
67   }
68   /// attribute name for the Y dimension
69   inline static const std::string& DY()
70   {
71     static const std::string DY_ATTR("DY");
72     return DY_ATTR;
73   }
74   /// attribute name for the Z dimension
75   inline static const std::string& DZ()
76   {
77     static const std::string DZ_ATTR("DZ");
78     return DZ_ATTR;
79   }
80
81   /// attribute name for X direction
82   inline static const std::string& X_DIRECTION()
83   {
84     static const std::string ATTR_X_DIRECTION("X_Direction");
85     return ATTR_X_DIRECTION;
86   }
87
88   /// attribute name for Y direction
89   inline static const std::string& Y_DIRECTION()
90   {
91     static const std::string ATTR_Y_DIRECTION("Y_Direction");
92     return ATTR_Y_DIRECTION;
93   }
94
95   /// attribute name for Y direction
96   inline static const std::string& Z_DIRECTION()
97   {
98     static const std::string ATTR_Z_DIRECTION("Z_Direction");
99     return ATTR_Z_DIRECTION;
100   }
101
102   /// Returns a minimal length for axis
103   inline static const double MINIMAL_LENGTH() { return 1.e-5; }
104
105   /// Creates a new part document if needed
106   CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
107
108   /// Request for initialization of data model of the feature: adding all attributes
109   CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
110
111   /// Construction result is allways recomuted on the fly
112   CONSTRUCTIONPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
113
114   /// Use plugin manager for features creation
115   ConstructionPlugin_Axis();
116
117   /// Customize presentation of the feature
118   virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
119                                      std::shared_ptr<GeomAPI_ICustomPrs> theDefaultPrs);
120
121  protected:
122   /// Creates a new axis by two defined points
123   void createAxisByTwoPoints();
124   /// Creates a new axis using three dimensions
125   void createAxisByDimensions();
126   /// Creates a new axis as copy of cylindrical face axis
127   void createAxisByCylindricalFace();
128   /// Creates a new axis by point and direction
129   void createAxisByPointAndDirection();
130 };
131
132
133 #endif