Salome HOME
Union of validator and filter functionalities.
[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_ID()
33   {
34     static const std::string MY_OBJECT_ID("main_object");
35     return MY_OBJECT_ID;
36   }
37   /// attribute name of tool object
38   inline static const std::string& TOOL_ID()
39   {
40     static const std::string MY_TOOL_ID("tool_object");
41     return MY_TOOL_ID;
42   }
43   /// attribute name of operation type
44   inline static const std::string& TYPE_ID()
45   {
46     static const std::string MY_TYPE_ID("bool_type");
47     return MY_TYPE_ID;
48   }
49
50   enum {
51         BOOL_CUT,
52         BOOL_FUSE,
53     BOOL_COMMON
54   };
55
56   /// Returns the kind of a feature
57   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
58   {
59     static std::string MY_KIND = FeaturesPlugin_Boolean::ID();
60     return MY_KIND;
61   }
62
63   /// Creates a new part document if needed
64   FEATURESPLUGIN_EXPORT virtual void execute();
65
66   /// Request for initialization of data model of the feature: adding all attributes
67   FEATURESPLUGIN_EXPORT virtual void initAttributes();
68
69   /// Use plugin manager for features creation
70   FeaturesPlugin_Boolean();
71
72 private:
73   std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
74   
75   /// Load Naming data structure of the feature to the document
76   void LoadNamingDS(GeomAlgoAPI_Boolean* theFeature, 
77                                         std::shared_ptr<ModelAPI_ResultBody> theResultBody,
78                         std::shared_ptr<GeomAPI_Shape> theObject,
79                         std::shared_ptr<GeomAPI_Shape> theTool,
80                                         int theType);
81 };
82
83 #endif