1 // Copyright (C) 2014-2022 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>
26 #include <ModelAPI_Result.h>
29 class GeomAlgoAPI_MakeShapeList;
31 /** \class FeaturesPlugin_Symmetry
33 * \brief Feature that performs reflection with respect to a point, axis, or plane.
35 class FeaturesPlugin_Symmetry : public ModelAPI_Feature
39 inline static const std::string& ID()
41 static const std::string MY_SYMMETRY_ID("Symmetry");
42 return MY_SYMMETRY_ID;
45 /// Attribute name for creation method.
46 inline static const std::string& CREATION_METHOD()
48 static const std::string MY_CREATION_METHOD_ID("CreationMethod");
49 return MY_CREATION_METHOD_ID;
52 /// Attribute name for creation method "ByPoint".
53 inline static const std::string& CREATION_METHOD_BY_POINT()
55 static const std::string MY_CREATION_METHOD_ID("ByPoint");
56 return MY_CREATION_METHOD_ID;
59 /// Attribute name for creation method "ByAxis".
60 inline static const std::string& CREATION_METHOD_BY_AXIS()
62 static const std::string MY_CREATION_METHOD_ID("ByAxis");
63 return MY_CREATION_METHOD_ID;
66 /// Attribute name for creation method "ByPlane".
67 inline static const std::string& CREATION_METHOD_BY_PLANE()
69 static const std::string MY_CREATION_METHOD_ID("ByPlane");
70 return MY_CREATION_METHOD_ID;
73 /// Attribute name of referenced objects.
74 inline static const std::string& OBJECTS_LIST_ID()
76 static const std::string MY_OBJECTS_LIST_ID("main_objects");
77 return MY_OBJECTS_LIST_ID;
80 /// Attribute name of a point.
81 inline static const std::string& POINT_OBJECT_ID()
83 static const std::string MY_POINT_OBJECT_ID("point_object");
84 return MY_POINT_OBJECT_ID;
87 /// Attribute name of an axis.
88 inline static const std::string& AXIS_OBJECT_ID()
90 static const std::string MY_AXIS_OBJECT_ID("axis_object");
91 return MY_AXIS_OBJECT_ID;
94 /// Attribute name of a plane.
95 inline static const std::string& PLANE_OBJECT_ID()
97 static const std::string MY_PLANE_OBJECT_ID("plane_object");
98 return MY_PLANE_OBJECT_ID;
101 /// Attribute name of keeping original shape.
102 inline static const std::string& KEEP_ORIGINAL_RESULT()
104 static const std::string MY_KEEP_ORIGINAL_RESULT_ID("keep_original");
105 return MY_KEEP_ORIGINAL_RESULT_ID;
108 /// \return the kind of a feature.
109 FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
111 static std::string MY_KIND = FeaturesPlugin_Symmetry::ID();
115 /// Performs the algorithm and stores results it in the data structure.
116 FEATURESPLUGIN_EXPORT virtual void execute();
118 /// Request for initialization of data model of the feature: adding all attributes.
119 FEATURESPLUGIN_EXPORT virtual void initAttributes();
121 /// Use plugin manager for features creation.
122 FeaturesPlugin_Symmetry();
125 /// Calculate symmetry with respect to a point.
126 std::shared_ptr<GeomAPI_Trsf> symmetryByPoint();
128 /// Calculate symmetry with respect to an axis.
129 std::shared_ptr<GeomAPI_Trsf> symmetryByAxis();
131 /// Calculate symmetry with respect to a plane.
132 std::shared_ptr<GeomAPI_Trsf> symmetryByPlane();
134 /// Perform the transformation
135 void performSymmetry(std::shared_ptr<GeomAPI_Trsf> theTrsf);
137 /// Create new result on given shapes and the index of result
138 void buildResult(const std::shared_ptr<GeomAlgoAPI_MakeShapeList>& theAlgo,
139 const std::list<std::shared_ptr<GeomAPI_Shape> >& theOriginalShapes,
140 std::shared_ptr<GeomAPI_Shape> theTargetShape,
142 const ResultPtr& theTextureSource);
144 /// Create new result for the given part and transformation
145 void buildResult(std::shared_ptr<ModelAPI_ResultPart> theOriginal,
146 std::shared_ptr<GeomAPI_Trsf> theTrsf,
147 int& theResultIndex);
150 #endif // FEATURESPLUGIN_SYMMETRY_H_