]> SALOME platform Git repositories - modules/shaper.git/blob - src/FeaturesPlugin/FeaturesPlugin_CompositeBoolean.h
Salome HOME
Issue #1343 Improvement of Extrusion and Revolution operations: extrusion cut.
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeBoolean.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_CompositeBoolean.h
4 // Created:     11 June 2015
5 // Author:      Dmitry Bobylev
6
7 #ifndef FeaturesPlugin_CompositeBoolean_H_
8 #define FeaturesPlugin_CompositeBoolean_H_
9
10 #include <FeaturesPlugin.h>
11
12 #include <ModelAPI_CompositeFeature.h>
13
14 #include <GeomAlgoAPI_Boolean.h>
15
16 /** \class FeaturesPlugin_CompositeBoolean
17  *  \ingroup Plugins
18  *  \brief Interface for the composite boolean feature.
19  */
20 class FeaturesPlugin_CompositeBoolean : public ModelAPI_CompositeFeature
21 {
22  public:
23   /// Attribute name of sketch feature.
24   inline static const std::string& SKETCH_OBJECT_ID()
25   {
26     static const std::string MY_SKETCH_OBJECT_ID("sketch");
27     return MY_SKETCH_OBJECT_ID;
28   }
29
30   /// attribute name of references sketch entities list, it should contain a sketch result or
31   /// a pair a sketch result to sketch face
32   inline static const std::string& LIST_ID()
33   {
34     static const std::string MY_GROUP_LIST_ID("base");
35     return MY_GROUP_LIST_ID;
36   }
37
38   /// Attribute name of sketch feature.
39   inline static const std::string& SKETCH_SELECTION_ID()
40   {
41     static const std::string MY_SKETCH_SELECTION_ID("sketch_selection");
42     return MY_SKETCH_SELECTION_ID;
43   }
44
45   /// Attribute name of objects for boolean operation.
46   inline static const std::string& BOOLEAN_OBJECTS_ID()
47   {
48     static const std::string MY_BOOLEAN_OBJECTS_ID("boolean_objects");
49     return MY_BOOLEAN_OBJECTS_ID;
50   }
51
52   /// Creates a new part document if needed.
53   FEATURESPLUGIN_EXPORT virtual void execute();
54
55   /// Request for initialization of data model of the feature: adding all attributes.
56   FEATURESPLUGIN_EXPORT virtual void initAttributes();
57
58   /// Appends a feature to the sketch sub-elements container.
59   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
60
61   /// \return the number of sub-elements.
62   FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const;
63
64   /// \return the sub-feature by zero-base index.
65   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
66
67   /// \return the sub-feature unique identifier in this composite feature by zero-base index.
68   FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
69
70   /// \return true if feature or reuslt belong to this composite feature as subs.
71   FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
72
73   /// This method to inform that sub-feature is removed and must be removed from the internal data
74   /// structures of the owner (the remove from the document will be done outside just after)
75   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
76
77   /// removes also all sub-sketch
78   FEATURESPLUGIN_EXPORT virtual void erase();
79
80 protected:
81   FeaturesPlugin_CompositeBoolean(){};
82
83   /// Define this function to init attributes for extrusion/revolution.
84   virtual void initMakeSolidsAttributes() = 0;
85
86   /// Define this function to create solids from faces with extrusion/revolution.
87   virtual void makeSolids(const ListOfShape& theFaces,
88                           ListOfShape& theResults,
89                           ListOfMakeShape& theAlgos) = 0;
90
91   /// Results naming.
92   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
93                     const ListOfShape& theShells,
94                     ListOfMakeShape& theSolidsAlgos,
95                     const std::shared_ptr<GeomAPI_Shape> theBaseShape,
96                     const ListOfShape& theTools,
97                     const std::shared_ptr<GeomAPI_Shape> theResultShape,
98                     GeomAlgoAPI_MakeShape& theMakeShape,
99                     GeomAPI_DataMapOfShapeShape& theMapOfShapes);
100
101   /// Set the sub-object to list of exturusion base.
102   void setSketchObjectToList();
103
104 protected:
105   /// Type of boolean operation.
106   GeomAlgoAPI_Boolean::OperationType myBooleanOperationType;
107 };
108
109 #endif