Salome HOME
Fix for the problem if disappeared sketch elements (on Apply) inside of sketch in...
[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
12 #include <GeomAlgoAPI_MakeShape.h>
13
14 #include <ModelAPI_Feature.h>
15
16 /// \class FeaturesPlugin_Boolean
17 /// \ingroup Plugins
18 /// \brief Feature for applying of Boolean operations on Solids.
19 /// Supports four kinds of Boolean operations: Cut, Fuse, Common and Smash.
20 class FeaturesPlugin_Boolean : public ModelAPI_Feature
21 {
22 public:
23   enum OperationType {
24     BOOL_CUT,
25     BOOL_FUSE,
26     BOOL_COMMON,
27     BOOL_SMASH
28   };
29
30   /// Feature kind.
31   inline static const std::string& ID()
32   {
33     static const std::string MY_ID("Boolean");
34     return MY_ID;
35   }
36
37   /// Attribute name of main objects.
38   inline static const std::string& OBJECT_LIST_ID()
39   {
40     static const std::string MY_OBJECT_LIST_ID("main_objects");
41     return MY_OBJECT_LIST_ID;
42   }
43
44   /// Attribute name of tool objects.
45   inline static const std::string& TOOL_LIST_ID()
46   {
47     static const std::string MY_TOOL_LIST_ID("tool_objects");
48     return MY_TOOL_LIST_ID;
49   }
50
51   /// Attribute name of operation type.
52   inline static const std::string& TYPE_ID()
53   {
54     static const std::string MY_TYPE_ID("bool_type");
55     return MY_TYPE_ID;
56   }
57
58   /// \return the kind of a feature.
59   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
60   {
61     static std::string MY_KIND = FeaturesPlugin_Boolean::ID();
62     return MY_KIND;
63   }
64
65   /// Creates a new part document if needed.
66   FEATURESPLUGIN_EXPORT virtual void execute();
67
68   /// Request for initialization of data model of the feature: adding all attributes.
69   FEATURESPLUGIN_EXPORT virtual void initAttributes();
70
71   /// Use plugin manager for features creation.
72   FeaturesPlugin_Boolean();
73
74 private:
75   std::shared_ptr<GeomAPI_Shape> getShape(const std::string& theAttrName);
76
77   /// Load Naming data structure of the feature to the document
78   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
79                     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
80                     const ListOfShape& theTools,
81                     const std::shared_ptr<GeomAPI_Shape> theResultShape,
82                     GeomAlgoAPI_MakeShape& theMakeShape,
83                     GeomAPI_DataMapOfShapeShape& theMapOfShapes);
84 };
85
86 #endif