Salome HOME
ed3f32437c4fee474c1ac717cc25c7130d86118a
[modules/shaper.git] / src / FeaturesPlugin / FeaturesPlugin_CompositeSketch.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        FeaturesPlugin_CompositeSketch.h
4 // Created:     11 September 2015
5 // Author:      Dmitry Bobylev
6
7 #ifndef FeaturesPlugin_CompositeSketch_H_
8 #define FeaturesPlugin_CompositeSketch_H_
9
10 #include <FeaturesPlugin.h>
11
12 #include <ModelAPI_CompositeFeature.h>
13
14 #include <GeomAlgoAPI_Boolean.h>
15
16 /** \class FeaturesPlugin_CompositeSketch
17  *  \ingroup Plugins
18  */
19 class FeaturesPlugin_CompositeSketch : public ModelAPI_CompositeFeature
20 {
21  public:
22   /// Attribute name of sketch feature.
23   inline static const std::string& SKETCH_OBJECT_ID()
24   {
25     static const std::string MY_SKETCH_OBJECT_ID("sketch");
26     return MY_SKETCH_OBJECT_ID;
27   }
28
29   /// Attribute name of sketch feature.
30   inline static const std::string& SKETCH_SELECTION_ID()
31   {
32     static const std::string MY_SKETCH_SELECTION_ID("sketch_selection");
33     return MY_SKETCH_SELECTION_ID;
34   }
35
36   /// Creates a new part document if needed.
37   FEATURESPLUGIN_EXPORT virtual void execute();
38
39   /// Request for initialization of data model of the feature: adding all attributes.
40   FEATURESPLUGIN_EXPORT virtual void initAttributes();
41
42   /// Appends a feature to the sketch sub-elements container.
43   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
44
45   /// \return the number of sub-elements.
46   FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const;
47
48   /// \return the sub-feature by zero-base index.
49   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
50
51   /// \return the sub-feature unique identifier in this composite feature by zero-base index.
52   FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
53
54   /// \return true if feature or reuslt belong to this composite feature as subs.
55   FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
56
57   /// This method to inform that sub-feature is removed and must be removed from the internal data
58   /// structures of the owner (the remove from the document will be done outside just after)
59   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
60
61   /// removes also all sub-sketch
62   FEATURESPLUGIN_EXPORT virtual void erase();
63
64 protected:
65   FeaturesPlugin_CompositeSketch(){};
66
67   /// Define this function to init attributes for extrusion/revolution.
68   virtual void initMakeSolidsAttributes() = 0;
69
70   /// Define this function to create solids from faces with extrusion/revolution.
71   virtual void makeSolid(const std::shared_ptr<GeomAPI_Shape> theFace,
72                          std::shared_ptr<GeomAPI_Shape>& theResult,
73                          ListOfShape& theFromFaces,
74                          ListOfShape& theToFaces,
75                          std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
76                          std::shared_ptr<GeomAPI_DataMapOfShapeShape>& theDataMap) = 0;
77
78   void loadNamingDS(std::shared_ptr<ModelAPI_ResultBody> theResultBody,
79                     const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
80                     const std::shared_ptr<GeomAPI_Shape>& theResult,
81                     const ListOfShape& theFromFaces,
82                     const ListOfShape& theToFaces,
83                     const std::shared_ptr<GeomAlgoAPI_MakeShape>& theMakeShape,
84                     const std::shared_ptr<GeomAPI_DataMapOfShapeShape>& theDataMap);
85 };
86
87 #endif