Salome HOME
Added rotation by three points.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Rotation.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_Rotation.h
4 // Created:     12 May 2015
5 // Author:      Dmitry Bobylev
6
7 #ifndef FeaturesPlugin_Rotation_H_
8 #define FeaturesPlugin_Rotation_H_
9
10 #include <FeaturesPlugin.h>
11
12 #include <ModelAPI_Feature.h>
13
14 #include <GeomAlgoAPI_Rotation.h>
15
16 /// \class FeaturesPlugin_Rotation
17 /// \ingroup Plugins
18 /// \brief Feature for rotation objects around the axis.
19 class FeaturesPlugin_Rotation : public ModelAPI_Feature
20 {
21  public:
22   /// Rotation kind.
23   inline static const std::string& ID()
24   {
25     static const std::string MY_ROTATION_ID("Rotation");
26     return MY_ROTATION_ID;
27   }
28
29   /// Attribute name for creation method.
30   inline static const std::string& CREATION_METHOD()
31   {
32     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
33     return MY_CREATION_METHOD_ID;
34   }
35
36   /// Attribute name for creation method "ByAxisAndAngle".
37   inline static const std::string& CREATION_METHOD_BY_ANGLE()
38   {
39     static const std::string MY_CREATION_METHOD_ID("ByAxisAndAngle");
40     return MY_CREATION_METHOD_ID;
41   }
42
43   /// Attribute name for creation method "ByThreePoints".
44   inline static const std::string& CREATION_METHOD_BY_THREE_POINTS()
45   {
46     static const std::string MY_CREATION_METHOD_ID("ByThreePoints");
47     return MY_CREATION_METHOD_ID;
48   }
49
50   /// Attribute name of referenced objects.
51   inline static const std::string& OBJECTS_LIST_ID()
52   {
53     static const std::string MY_OBJECTS_LIST_ID("main_objects");
54     return MY_OBJECTS_LIST_ID;
55   }
56
57   /// Attribute name of an axis.
58   inline static const std::string& AXIS_OBJECT_ID()
59   {
60     static const std::string MY_AXIS_OBJECT_ID("axis_object");
61     return MY_AXIS_OBJECT_ID;
62   }
63
64   /// Attribute name of angle.
65   inline static const std::string& ANGLE_ID()
66   {
67     static const std::string MY_ANGLE_ID("angle");
68     return MY_ANGLE_ID;
69   }
70
71   /// Attribute name of a center point.
72   inline static const std::string& CENTER_POINT_ID()
73   {
74     static const std::string MY_CENTER_POINT_ID("center_point");
75     return MY_CENTER_POINT_ID;
76   }
77
78   /// Attribute name of a center point.
79   inline static const std::string& START_POINT_ID()
80   {
81     static const std::string MY_START_POINT_ID("start_point");
82     return MY_START_POINT_ID;
83   }
84
85   /// Attribute name of a center point.
86   inline static const std::string& END_POINT_ID()
87   {
88     static const std::string MY_END_POINT_ID("end_point");
89     return MY_END_POINT_ID;
90   }
91
92   /// \return the kind of a feature.
93   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
94   {
95     static std::string MY_KIND = FeaturesPlugin_Rotation::ID();
96     return MY_KIND;
97   }
98
99   /// Creates a new part document if needed.
100   FEATURESPLUGIN_EXPORT virtual void execute();
101
102   /// Request for initialization of data model of the feature: adding all attributes.
103   FEATURESPLUGIN_EXPORT virtual void initAttributes();
104
105   /// Use plugin manager for features creation.
106   FeaturesPlugin_Rotation();
107
108 private:
109   ///Perform the rotation using an axis and an angle.
110   void performTranslationByAxisAndAngle();
111
112   ///Perform the rotation using a center and two points.
113   void performTranslationByThreePoints();
114
115   void loadNamingDS(GeomAlgoAPI_Rotation& theRotaionAlgo,
116                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
117                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
118 };
119
120 #endif