SHAPER  9.12.0
FeaturesPlugin_Symmetry.h
1 // Copyright (C) 2014-2023 CEA, EDF
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
18 //
19 
20 #ifndef FEATURESPLUGIN_SYMMETRY_H_
21 #define FEATURESPLUGIN_SYMMETRY_H_
22 
23 #include <FeaturesPlugin.h>
24 
25 #include <ModelAPI_Feature.h>
26 #include <ModelAPI_Result.h>
27 
28 class GeomAPI_Trsf;
30 
36 {
37  public:
39  inline static const std::string& ID()
40  {
41  static const std::string MY_SYMMETRY_ID("Symmetry");
42  return MY_SYMMETRY_ID;
43  }
44 
46  inline static const std::string& CREATION_METHOD()
47  {
48  static const std::string MY_CREATION_METHOD_ID("CreationMethod");
49  return MY_CREATION_METHOD_ID;
50  }
51 
53  inline static const std::string& CREATION_METHOD_BY_POINT()
54  {
55  static const std::string MY_CREATION_METHOD_ID("ByPoint");
56  return MY_CREATION_METHOD_ID;
57  }
58 
60  inline static const std::string& CREATION_METHOD_BY_AXIS()
61  {
62  static const std::string MY_CREATION_METHOD_ID("ByAxis");
63  return MY_CREATION_METHOD_ID;
64  }
65 
67  inline static const std::string& CREATION_METHOD_BY_PLANE()
68  {
69  static const std::string MY_CREATION_METHOD_ID("ByPlane");
70  return MY_CREATION_METHOD_ID;
71  }
72 
74  inline static const std::string& OBJECTS_LIST_ID()
75  {
76  static const std::string MY_OBJECTS_LIST_ID("main_objects");
77  return MY_OBJECTS_LIST_ID;
78  }
79 
81  inline static const std::string& POINT_OBJECT_ID()
82  {
83  static const std::string MY_POINT_OBJECT_ID("point_object");
84  return MY_POINT_OBJECT_ID;
85  }
86 
88  inline static const std::string& AXIS_OBJECT_ID()
89  {
90  static const std::string MY_AXIS_OBJECT_ID("axis_object");
91  return MY_AXIS_OBJECT_ID;
92  }
93 
95  inline static const std::string& PLANE_OBJECT_ID()
96  {
97  static const std::string MY_PLANE_OBJECT_ID("plane_object");
98  return MY_PLANE_OBJECT_ID;
99  }
100 
102  inline static const std::string& KEEP_ORIGINAL_RESULT()
103  {
104  static const std::string MY_KEEP_ORIGINAL_RESULT_ID("keep_original");
105  return MY_KEEP_ORIGINAL_RESULT_ID;
106  }
107 
109  FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
110  {
111  static std::string MY_KIND = FeaturesPlugin_Symmetry::ID();
112  return MY_KIND;
113  }
114 
116  FEATURESPLUGIN_EXPORT virtual void execute();
117 
119  FEATURESPLUGIN_EXPORT virtual void initAttributes();
120 
123 
124 private:
126  std::shared_ptr<GeomAPI_Trsf> symmetryByPoint();
127 
129  std::shared_ptr<GeomAPI_Trsf> symmetryByAxis();
130 
132  std::shared_ptr<GeomAPI_Trsf> symmetryByPlane();
133 
135  void performSymmetry(std::shared_ptr<GeomAPI_Trsf> theTrsf);
136 
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,
141  int& theResultIndex,
142  const ResultPtr& theTextureSource);
143 
145  void buildResult(std::shared_ptr<ModelAPI_ResultPart> theOriginal,
146  std::shared_ptr<GeomAPI_Trsf> theTrsf,
147  int& theResultIndex);
148 };
149 
150 #endif // FEATURESPLUGIN_SYMMETRY_H_
Feature that performs reflection with respect to a point, axis, or plane.
Definition: FeaturesPlugin_Symmetry.h:36
virtual FEATURESPLUGIN_EXPORT void execute()
Performs the algorithm and stores results it in the data structure.
Definition: FeaturesPlugin_Symmetry.cpp:84
virtual FEATURESPLUGIN_EXPORT const std::string & getKind()
Definition: FeaturesPlugin_Symmetry.h:109
static const std::string & ID()
Symmetry kind.
Definition: FeaturesPlugin_Symmetry.h:39
static const std::string & CREATION_METHOD()
Attribute name for creation method.
Definition: FeaturesPlugin_Symmetry.h:46
static const std::string & AXIS_OBJECT_ID()
Attribute name of an axis.
Definition: FeaturesPlugin_Symmetry.h:88
FeaturesPlugin_Symmetry()
Use plugin manager for features creation.
Definition: FeaturesPlugin_Symmetry.cpp:51
static const std::string & KEEP_ORIGINAL_RESULT()
Attribute name of keeping original shape.
Definition: FeaturesPlugin_Symmetry.h:102
virtual FEATURESPLUGIN_EXPORT void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: FeaturesPlugin_Symmetry.cpp:56
static const std::string & CREATION_METHOD_BY_POINT()
Attribute name for creation method "ByPoint".
Definition: FeaturesPlugin_Symmetry.h:53
static const std::string & POINT_OBJECT_ID()
Attribute name of a point.
Definition: FeaturesPlugin_Symmetry.h:81
static const std::string & OBJECTS_LIST_ID()
Attribute name of referenced objects.
Definition: FeaturesPlugin_Symmetry.h:74
static const std::string & CREATION_METHOD_BY_PLANE()
Attribute name for creation method "ByPlane".
Definition: FeaturesPlugin_Symmetry.h:67
static const std::string & CREATION_METHOD_BY_AXIS()
Attribute name for creation method "ByAxis".
Definition: FeaturesPlugin_Symmetry.h:60
static const std::string & PLANE_OBJECT_ID()
Attribute name of a plane.
Definition: FeaturesPlugin_Symmetry.h:95
Keep the transformation matrix coefficients.
Definition: GeomAPI_Trsf.h:36
List of topological shapes constructions.
Definition: GeomAlgoAPI_MakeShapeList.h:33
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39