Salome HOME
Issue #1343 Fixes for creating extrusion on vertex
[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 <ModelAPI_ResultBody.h>
15
16 /// \class FeaturesPlugin_CompositeSketch
17 /// \ingroup Plugins
18 /// \brief Interface for the composite sketch feature.
19 class FeaturesPlugin_CompositeSketch : public ModelAPI_CompositeFeature
20 {
21 public:
22   /// Attribute name of sketch feature.
23   inline static const std::string& SKETCH_ID()
24   {
25     static const std::string MY_SKETCH_ID("sketch");
26     return MY_SKETCH_ID;
27   }
28
29   /// Attribute name of base objects.
30   inline static const std::string& BASE_OBJECTS_ID()
31   {
32     static const std::string MY_BASE_OBJECTS_ID("base");
33     return MY_BASE_OBJECTS_ID;
34   }
35
36   /// Appends a feature to the sketch sub-elements container.
37   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
38
39   /// \return the number of sub-elements.
40   FEATURESPLUGIN_EXPORT virtual int numberOfSubs(bool forTree = false) const;
41
42   /// \return the sub-feature by zero-base index.
43   FEATURESPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
44
45   /// \return the sub-feature unique identifier in this composite feature by zero-base index.
46   FEATURESPLUGIN_EXPORT virtual int subFeatureId(const int theIndex) const;
47
48   /// \return true if feature or result belong to this composite feature as subs.
49   FEATURESPLUGIN_EXPORT virtual bool isSub(ObjectPtr theObject) const;
50
51   /// This method to inform that sub-feature is removed and must be removed from the internal data
52   /// structures of the owner (the remove from the document will be done outside just after).
53   FEATURESPLUGIN_EXPORT virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature);
54
55   /// Removes also all sub-sketch.
56   FEATURESPLUGIN_EXPORT virtual void erase();
57
58 protected:
59   enum InitFlags {
60     InitSketchLauncher   = 1 << 0,
61     InitBaseObjectsList  = 1 << 1
62   };
63
64   FeaturesPlugin_CompositeSketch(){};
65
66   /// Initializes composite sketch attributes.
67   void initCompositeSketchAttribtues(const int theInitFlags);
68
69   /// Sets the sub-object to list of base.
70   void setSketchObjectToList();
71
72   /// \brief Returns list of base shapes.
73   /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
74   /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
75   void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
76
77   /// Checks make shape algo.
78   bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
79
80   /// Stores result of generation.
81   void storeResult(const GeomShapePtr theBaseShape,
82                    const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
83                    const int theIndex = 0);
84
85   /// Stores generation history.
86   void storeGenerationHistory(ResultBodyPtr theResultBody,
87                               const GeomShapePtr theBaseShape,
88                               const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
89                               int& theTag);
90
91   /// Used to store from and to shapes.
92   void storeShapes(ResultBodyPtr theResultBody,
93                    const GeomAPI_Shape::ShapeType theBaseShapeType,
94                    const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
95                    const ListOfShape& theShapes,
96                    const std::string theName,
97                    int& theTag);
98
99 };
100
101 #endif