Salome HOME
df9065b25fcc609de4bf909427f3af470e279f79
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_Boolean.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesPlugin_Boolean.h
4 // Created:     02 Sept 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef FeaturesPlugin_Cut_H_
8 #define FeaturesPlugin_Cut_H_
9
10 #include "FeaturesPlugin.h"
11 #include <ModelAPI_Feature.h>
12
13 #include <GeomAlgoAPI_Boolean.h>
14
15 class GeomAlgoAPI_MakeShapeList;
16
17 /**\class FeaturesPlugin_Boolean
18  * \ingroup Plugins
19  * \brief Feature for applying of Boolean operations on Solids.
20  *
21  * Supports three kinds of Boolean operations: Cut, Fuse and Common.
22  * For all of them requires two Solids: object and tool.
23  */
24 class FeaturesPlugin_Boolean : public ModelAPI_Feature
25 {
26 public:
27   /// Extrusion kind
28   inline static const std::string& ID()
29   {
30     static const std::string MY_ID("Boolean");
31     return MY_ID;
32   }
33   /// attribute name of referenced object
34   inline static const std::string& OBJECT_LIST_ID()
35   {
36     static const std::string MY_OBJECT_LIST_ID("main_objects");
37     return MY_OBJECT_LIST_ID;
38   }
39   /// attribute name of referenced object
40   inline static const std::string& OBJECT_ID()
41   {
42     static const std::string MY_OBJECT_ID("main_object");
43     return MY_OBJECT_ID;
44   }
45   /// attribute name of tool object
46   inline static const std::string& TOOL_ID()
47   {
48     static const std::string MY_TOOL_ID("tool_object");
49     return MY_TOOL_ID;
50   }
51   /// attribute name of tool object
52   inline static const std::string& TOOL_LIST_ID()
53   {
54     static const std::string MY_TOOL_LIST_ID("tool_objects");
55     return MY_TOOL_LIST_ID;
56   }
57   /// attribute name of operation type
58   inline static const std::string& TYPE_ID()
59   {
60     static const std::string MY_TYPE_ID("bool_type");
61     return MY_TYPE_ID;
62   }
63
64   enum {
65     BOOL_CUT,
66     BOOL_FUSE,
67     BOOL_COMMON
68   };
69
70   /// Returns the kind of a feature
71   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
72   {
73     static std::string MY_KIND = FeaturesPlugin_Boolean::ID();
74     return MY_KIND;
75   }
76
77   /// Creates a new part document if needed
78   FEATURESPLUGIN_EXPORT virtual void execute();
79
80   /// Request for initialization of data model of the feature: adding all attributes
81   FEATURESPLUGIN_EXPORT virtual void initAttributes();
82
83   /// Use plugin manager for features creation
84   FeaturesPlugin_Boolean();
85
86 private:
87   std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
88
89   /// Load Naming data structure of the feature to the document
90   void LoadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
91                     const std::shared_ptr<GeomAPI_Shape>& theBaseObject,
92                     const ListOfShape& theTools,
93                     const GeomAlgoAPI_Boolean& theAlgo);
94 };
95
96 #endif