Salome HOME
multi selector controls for boolean feature
[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 #include <GeomAPI_Shape.h>
13 #include <GeomAlgoAPI_Boolean.h>
14
15 /**\class FeaturesPlugin_Boolean
16  * \ingroup Plugins
17  * \brief Feature for applying of Boolean operations on Solids.
18  *
19  * Supports three kinds of Boolean operations: Cut, Fuse and Common.
20  * For all of them requires two Solids: object and tool.
21  */
22 class FeaturesPlugin_Boolean : public ModelAPI_Feature
23 {
24 public:
25   /// Extrusion kind
26   inline static const std::string& ID()
27   {
28     static const std::string MY_ID("Boolean");
29     return MY_ID;
30   }
31   /// attribute name of referenced object
32   inline static const std::string& OBJECT_LIST_ID()
33   {
34     static const std::string MY_OBJECT_LIST_ID("main_objects");
35     return MY_OBJECT_LIST_ID;
36   }
37   /// attribute name of referenced object
38   inline static const std::string& OBJECT_ID()
39   {
40     static const std::string MY_OBJECT_ID("main_object");
41     return MY_OBJECT_ID;
42   }
43   /// attribute name of tool object
44   inline static const std::string& TOOL_ID()
45   {
46     static const std::string MY_TOOL_ID("tool_object");
47     return MY_TOOL_ID;
48   }
49   /// attribute name of tool object
50   inline static const std::string& TOOL_LIST_ID()
51   {
52     static const std::string MY_TOOL_LIST_ID("tool_objects");
53     return MY_TOOL_LIST_ID;
54   }
55   /// attribute name of operation type
56   inline static const std::string& TYPE_ID()
57   {
58     static const std::string MY_TYPE_ID("bool_type");
59     return MY_TYPE_ID;
60   }
61
62   enum {
63         BOOL_CUT,
64         BOOL_FUSE,
65     BOOL_COMMON
66   };
67
68   /// Returns the kind of a feature
69   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
70   {
71     static std::string MY_KIND = FeaturesPlugin_Boolean::ID();
72     return MY_KIND;
73   }
74
75   /// Creates a new part document if needed
76   FEATURESPLUGIN_EXPORT virtual void execute();
77
78   /// Request for initialization of data model of the feature: adding all attributes
79   FEATURESPLUGIN_EXPORT virtual void initAttributes();
80
81   /// Use plugin manager for features creation
82   FeaturesPlugin_Boolean();
83
84 private:
85   std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
86   
87   /// Load Naming data structure of the feature to the document
88   void LoadNamingDS(GeomAlgoAPI_Boolean* theFeature, 
89                                         std::shared_ptr<ModelAPI_ResultBody> theResultBody,
90                         std::shared_ptr<GeomAPI_Shape> theObject,
91                         std::shared_ptr<GeomAPI_Shape> theTool,
92                                         int theType);
93 };
94
95 #endif