Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Symmetry.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef FEATURESPLUGIN_SYMMETRY_H_
21 #define FEATURESPLUGIN_SYMMETRY_H_
22
23 #include <FeaturesPlugin.h>
24
25 #include <ModelAPI_Feature.h>
26
27 #include <GeomAlgoAPI_Symmetry.h>
28
29 /** \class FeaturesPlugin_Symmetry
30  *  \ingroup Plugins
31  *  \brief Feature that performs reflection with respect to a point, axis, or plane.
32  */
33 class FeaturesPlugin_Symmetry : public ModelAPI_Feature
34 {
35  public:
36   /// Symmetry kind.
37   inline static const std::string& ID()
38   {
39     static const std::string MY_SYMMETRY_ID("Symmetry");
40     return MY_SYMMETRY_ID;
41   }
42
43   /// Attribute name for creation method.
44   inline static const std::string& CREATION_METHOD()
45   {
46     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
47     return MY_CREATION_METHOD_ID;
48   }
49
50   /// Attribute name for creation method "ByPoint".
51   inline static const std::string& CREATION_METHOD_BY_POINT()
52   {
53     static const std::string MY_CREATION_METHOD_ID("ByPoint");
54     return MY_CREATION_METHOD_ID;
55   }
56
57   /// Attribute name for creation method "ByAxis".
58   inline static const std::string& CREATION_METHOD_BY_AXIS()
59   {
60     static const std::string MY_CREATION_METHOD_ID("ByAxis");
61     return MY_CREATION_METHOD_ID;
62   }
63
64   /// Attribute name for creation method "ByPlane".
65   inline static const std::string& CREATION_METHOD_BY_PLANE()
66   {
67     static const std::string MY_CREATION_METHOD_ID("ByPlane");
68     return MY_CREATION_METHOD_ID;
69   }
70
71   /// Attribute name of referenced objects.
72   inline static const std::string& OBJECTS_LIST_ID()
73   {
74     static const std::string MY_OBJECTS_LIST_ID("main_objects");
75     return MY_OBJECTS_LIST_ID;
76   }
77
78   /// Attribute name of a point.
79   inline static const std::string& POINT_OBJECT_ID()
80   {
81     static const std::string MY_POINT_OBJECT_ID("point_object");
82     return MY_POINT_OBJECT_ID;
83   }
84
85   /// Attribute name of an axis.
86   inline static const std::string& AXIS_OBJECT_ID()
87   {
88     static const std::string MY_AXIS_OBJECT_ID("axis_object");
89     return MY_AXIS_OBJECT_ID;
90   }
91
92   /// Attribute name of a plane.
93   inline static const std::string& PLANE_OBJECT_ID()
94   {
95     static const std::string MY_PLANE_OBJECT_ID("plane_object");
96     return MY_PLANE_OBJECT_ID;
97   }
98
99   /// \return the kind of a feature.
100   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
101   {
102     static std::string MY_KIND = FeaturesPlugin_Symmetry::ID();
103     return MY_KIND;
104   }
105
106   /// Creates a new part document if needed.
107   FEATURESPLUGIN_EXPORT virtual void execute();
108
109   /// Request for initialization of data model of the feature: adding all attributes.
110   FEATURESPLUGIN_EXPORT virtual void initAttributes();
111
112   /// Use plugin manager for features creation.
113   FeaturesPlugin_Symmetry();
114
115 private:
116   /// Perform symmetry with respect to a point.
117   void performSymmetryByPoint();
118
119   /// Perform symmetry with respect to an axis.
120   void performSymmetryByAxis();
121
122   /// Perform symmetry with respect to a plane.
123   void performSymmetryByPlane();
124
125   /// Perform the naming
126   void loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
127                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
128                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
129 };
130
131 #endif // FEATURESPLUGIN_SYMMETRY_H_