]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesPlugin/FeaturesPlugin_Symmetry.h
Salome HOME
Task 2.6. Behavior of the Symmetry feature
[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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef FEATURESPLUGIN_SYMMETRY_H_
22 #define FEATURESPLUGIN_SYMMETRY_H_
23
24 #include <FeaturesPlugin.h>
25
26 #include <ModelAPI_Feature.h>
27
28 #include <GeomAlgoAPI_Symmetry.h>
29
30 class GeomAPI_Trsf;
31
32 /** \class FeaturesPlugin_Symmetry
33  *  \ingroup Plugins
34  *  \brief Feature that performs reflection with respect to a point, axis, or plane.
35  */
36 class FeaturesPlugin_Symmetry : public ModelAPI_Feature
37 {
38  public:
39   /// Symmetry kind.
40   inline static const std::string& ID()
41   {
42     static const std::string MY_SYMMETRY_ID("MirrorCopy");
43     return MY_SYMMETRY_ID;
44   }
45
46   /// Attribute name for creation method.
47   inline static const std::string& CREATION_METHOD()
48   {
49     static const std::string MY_CREATION_METHOD_ID("CreationMethod");
50     return MY_CREATION_METHOD_ID;
51   }
52
53   /// Attribute name for creation method "ByPoint".
54   inline static const std::string& CREATION_METHOD_BY_POINT()
55   {
56     static const std::string MY_CREATION_METHOD_ID("ByPoint");
57     return MY_CREATION_METHOD_ID;
58   }
59
60   /// Attribute name for creation method "ByAxis".
61   inline static const std::string& CREATION_METHOD_BY_AXIS()
62   {
63     static const std::string MY_CREATION_METHOD_ID("ByAxis");
64     return MY_CREATION_METHOD_ID;
65   }
66
67   /// Attribute name for creation method "ByPlane".
68   inline static const std::string& CREATION_METHOD_BY_PLANE()
69   {
70     static const std::string MY_CREATION_METHOD_ID("ByPlane");
71     return MY_CREATION_METHOD_ID;
72   }
73
74   /// Attribute name of referenced objects.
75   inline static const std::string& OBJECTS_LIST_ID()
76   {
77     static const std::string MY_OBJECTS_LIST_ID("main_objects");
78     return MY_OBJECTS_LIST_ID;
79   }
80
81   /// Attribute name of a point.
82   inline static const std::string& POINT_OBJECT_ID()
83   {
84     static const std::string MY_POINT_OBJECT_ID("point_object");
85     return MY_POINT_OBJECT_ID;
86   }
87
88   /// Attribute name of an axis.
89   inline static const std::string& AXIS_OBJECT_ID()
90   {
91     static const std::string MY_AXIS_OBJECT_ID("axis_object");
92     return MY_AXIS_OBJECT_ID;
93   }
94
95   /// Attribute name of a plane.
96   inline static const std::string& PLANE_OBJECT_ID()
97   {
98     static const std::string MY_PLANE_OBJECT_ID("plane_object");
99     return MY_PLANE_OBJECT_ID;
100   }
101
102   /// \return the kind of a feature.
103   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
104   {
105     static std::string MY_KIND = FeaturesPlugin_Symmetry::ID();
106     return MY_KIND;
107   }
108
109   /// Creates a new part document if needed.
110   FEATURESPLUGIN_EXPORT virtual void execute();
111
112   /// Request for initialization of data model of the feature: adding all attributes.
113   FEATURESPLUGIN_EXPORT virtual void initAttributes();
114
115   /// Use plugin manager for features creation.
116   FeaturesPlugin_Symmetry();
117
118 private:
119   /// Obtain list of source objects of the mirror
120   bool collectSourceObjects(ListOfShape& theSourceShapes,
121                             std::list<std::shared_ptr<ModelAPI_Result>>& theSourceResults);
122
123   /// Perform symmetry with respect to a point.
124   void performSymmetryByPoint();
125
126   /// Perform symmetry with respect to an axis.
127   void performSymmetryByAxis();
128
129   /// Perform symmetry with respect to a plane.
130   void performSymmetryByPlane();
131
132   /// Perform the naming
133   void loadNamingDS(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
134                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
135                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
136
137   /// Create new result on given shapes and the index of result
138   void buildResult(GeomAlgoAPI_Symmetry& theSymmetryAlgo,
139                    std::shared_ptr<GeomAPI_Shape> theBaseShape,
140                    int theResultIndex);
141
142   /// Create new result for the given part and transformation
143   void buildResult(std::shared_ptr<ModelAPI_ResultPart> theOriginal,
144                    std::shared_ptr<GeomAPI_Trsf> theTrsf,
145                    int& theResultIndex);
146 };
147
148 #endif // FEATURESPLUGIN_SYMMETRY_H_