1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef FEATURESPLUGIN_SYMMETRY_H_
21 #define FEATURESPLUGIN_SYMMETRY_H_
23 #include <FeaturesPlugin.h>
25 #include <ModelAPI_Feature.h>
28 class GeomAlgoAPI_MakeShapeList;
30 /** \class FeaturesPlugin_Symmetry
32 * \brief Feature that performs reflection with respect to a point, axis, or plane.
34 class FeaturesPlugin_Symmetry : public ModelAPI_Feature
38 inline static const std::string& ID()
40 static const std::string MY_SYMMETRY_ID("Symmetry");
41 return MY_SYMMETRY_ID;
44 /// Attribute name for creation method.
45 inline static const std::string& CREATION_METHOD()
47 static const std::string MY_CREATION_METHOD_ID("CreationMethod");
48 return MY_CREATION_METHOD_ID;
51 /// Attribute name for creation method "ByPoint".
52 inline static const std::string& CREATION_METHOD_BY_POINT()
54 static const std::string MY_CREATION_METHOD_ID("ByPoint");
55 return MY_CREATION_METHOD_ID;
58 /// Attribute name for creation method "ByAxis".
59 inline static const std::string& CREATION_METHOD_BY_AXIS()
61 static const std::string MY_CREATION_METHOD_ID("ByAxis");
62 return MY_CREATION_METHOD_ID;
65 /// Attribute name for creation method "ByPlane".
66 inline static const std::string& CREATION_METHOD_BY_PLANE()
68 static const std::string MY_CREATION_METHOD_ID("ByPlane");
69 return MY_CREATION_METHOD_ID;
72 /// Attribute name of referenced objects.
73 inline static const std::string& OBJECTS_LIST_ID()
75 static const std::string MY_OBJECTS_LIST_ID("main_objects");
76 return MY_OBJECTS_LIST_ID;
79 /// Attribute name of a point.
80 inline static const std::string& POINT_OBJECT_ID()
82 static const std::string MY_POINT_OBJECT_ID("point_object");
83 return MY_POINT_OBJECT_ID;
86 /// Attribute name of an axis.
87 inline static const std::string& AXIS_OBJECT_ID()
89 static const std::string MY_AXIS_OBJECT_ID("axis_object");
90 return MY_AXIS_OBJECT_ID;
93 /// Attribute name of a plane.
94 inline static const std::string& PLANE_OBJECT_ID()
96 static const std::string MY_PLANE_OBJECT_ID("plane_object");
97 return MY_PLANE_OBJECT_ID;
100 /// Attribute name of keeping original shape.
101 inline static const std::string& KEEP_ORIGINAL_RESULT()
103 static const std::string MY_KEEP_ORIGINAL_RESULT_ID("keep_original");
104 return MY_KEEP_ORIGINAL_RESULT_ID;
107 /// \return the kind of a feature.
108 FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
110 static std::string MY_KIND = FeaturesPlugin_Symmetry::ID();
114 /// Performs the algorithm and stores results it in the data structure.
115 FEATURESPLUGIN_EXPORT virtual void execute();
117 /// Request for initialization of data model of the feature: adding all attributes.
118 FEATURESPLUGIN_EXPORT virtual void initAttributes();
120 /// Use plugin manager for features creation.
121 FeaturesPlugin_Symmetry();
124 /// Calculate symmetry with respect to a point.
125 std::shared_ptr<GeomAPI_Trsf> symmetryByPoint();
127 /// Calculate symmetry with respect to an axis.
128 std::shared_ptr<GeomAPI_Trsf> symmetryByAxis();
130 /// Calculate symmetry with respect to a plane.
131 std::shared_ptr<GeomAPI_Trsf> symmetryByPlane();
133 /// Perform the transformation
134 void performSymmetry(std::shared_ptr<GeomAPI_Trsf> theTrsf);
136 /// Create new result on given shapes and the index of result
137 void buildResult(const std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theAlgo,
138 const std::list<std::shared_ptr<GeomAPI_Shape> >& theOriginalShapes,
139 std::shared_ptr<GeomAPI_Shape> theTargetShape,
140 int& theResultIndex);
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);
148 #endif // FEATURESPLUGIN_SYMMETRY_H_