Salome HOME
Issue #2593: CEA 2018-2 Geometrical Naming
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Placement.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_Placement_H_
22 #define FeaturesPlugin_Placement_H_
23
24 #include "FeaturesPlugin.h"
25 #include <ModelAPI_Feature.h>
26 #include <GeomAlgoAPI_Placement.h>
27 #include <GeomAlgoAPI_Transform.h>
28
29 class ModelAPI_ResultBody;
30 class GeomAPI_Shape;
31
32 /**\class FeaturesPlugin_Placement
33  * \ingroup Plugins
34  * \brief Feature for applying of placement operation: relative movement of Solid.
35  *
36  * Locates the selected placement_attractable_object (face, edge, vertex) of the solid into 
37  * the selected placement_base_object. Faces must be planar, edges must be linear.
38  * Orientation of the placed solid depends on the underlied planes of both faces.
39  */
40 class FeaturesPlugin_Placement : public ModelAPI_Feature
41 {
42  public:
43   /// Placement kind
44   inline static const std::string& ID()
45   {
46     static const std::string MY_PLACEMENT_ID("Placement");
47     return MY_PLACEMENT_ID;
48   }
49
50   /// attribute name of references sketch entities list, it should contain a sketch result or
51   /// a pair a sketch result to sketch face
52   inline static const std::string& OBJECTS_LIST_ID()
53   {
54     static const std::string MY_OBJECTS_LIST_ID("placement_objects_list");
55     return MY_OBJECTS_LIST_ID;
56   }
57
58   /// attribute name of referenced object
59   inline static const std::string& START_SHAPE_ID()
60   {
61     static const std::string MY_START_SHAPE_ID("placement_start_shape");
62     return MY_START_SHAPE_ID;
63   }
64   /// attribute name of attractable face
65   inline static const std::string& END_SHAPE_ID()
66   {
67     static const std::string MY_END_SHAPE_ID("placement_end_shape");
68     return MY_END_SHAPE_ID;
69   }
70   /// attribute name of flag of reverse direction
71   inline static const std::string& REVERSE_ID()
72   {
73     static const std::string MY_REVERSE_ID("placement_reverse_direction");
74     return MY_REVERSE_ID;
75   }
76   /// attribute name of flag of centering position
77   inline static const std::string& CENTERING_ID()
78   {
79     static const std::string MY_CENTERING_ID("placement_centering");
80     return MY_CENTERING_ID;
81   }
82
83   /// Returns the kind of a feature
84   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
85   {
86     static std::string MY_KIND = FeaturesPlugin_Placement::ID();
87     return MY_KIND;
88   }
89
90   /// Creates a new part document if needed
91   FEATURESPLUGIN_EXPORT virtual void execute();
92
93   /// Request for initialization of data model of the feature: adding all attributes
94   FEATURESPLUGIN_EXPORT virtual void initAttributes();
95
96   /// Use plugin manager for features creation
97   FeaturesPlugin_Placement();
98 private:
99   /// Checks validity of passed shape.
100   bool isShapeValid(GeomShapePtr theShape);
101
102   /// Load Naming data structure of the feature to the document
103   void loadNamingDS(GeomAlgoAPI_Transform& theTransformAlgo,
104                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
105                     std::shared_ptr<GeomAPI_Shape> theBaseShape);
106 };
107
108 #endif