Salome HOME
Issue #1692: Explicit send the Create message when external entity appears in the...
[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 protected:
56   enum InitFlags {
57     InitSketchLauncher   = 1 << 0,
58     InitBaseObjectsList  = 1 << 1
59   };
60
61   FeaturesPlugin_CompositeSketch(){};
62
63   /// Initializes composite sketch attributes.
64   void initCompositeSketchAttribtues(const int theInitFlags);
65
66   /// \brief Returns list of base shapes.
67   /// \param[out] theBaseShapesList list of base shapes (warning: list not cleared).
68   /// \param[in] theIsMakeShells if true make shells from faces with shared edges.
69   void getBaseShapes(ListOfShape& theBaseShapesList, const bool theIsMakeShells = true);
70
71   /// Checks make shape algo.
72   bool isMakeShapeValid(const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
73
74   /// Stores result of generation.
75   void storeResult(const GeomShapePtr theBaseShape,
76                    const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
77                    const int theIndex = 0);
78
79   /// Stores generation history.
80   void storeGenerationHistory(ResultBodyPtr theResultBody,
81                               const GeomShapePtr theBaseShape,
82                               const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape,
83                               int& theTag);
84
85   /// Used to store from and to shapes.
86   void storeShapes(ResultBodyPtr theResultBody,
87                    const GeomAPI_Shape::ShapeType theBaseShapeType,
88                    const std::shared_ptr<GeomAPI_DataMapOfShapeShape> theMapOfSubShapes,
89                    const ListOfShape& theShapes,
90                    const std::string theName,
91                    int& theTag);
92
93 };
94
95 #endif