Salome HOME
Added a selection attribute and naming basic mechanisms
[modules/shaper.git] / src / Model / Model_ResultBody.h
1 // File:        Model_ResultBody.h
2 // Created:     08 Jul 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef Model_ResultBody_H_
6 #define Model_ResultBody_H_
7
8 #include "Model.h"
9 #include <ModelAPI_ResultBody.h>
10 #include <vector>
11
12 class TNaming_Builder;
13
14 /**\class ModelAPI_ResultBody
15  * \ingroup DataModel
16  * \brief The body (shape) result of a feature.
17  *
18  * Provides a shape that may be displayed in the viewer.
19  * May provide really huge results, so, working with this kind
20  * of result must be optimized.
21  */
22 class Model_ResultBody : public ModelAPI_ResultBody
23 {
24   boost::shared_ptr<ModelAPI_Feature> myOwner;  ///< owner of this result
25   /// builders that tores the naming history: one per label to allow store several shapes to one 
26   /// label; index in vector corresponds to the label tag
27   std::vector<TNaming_Builder*> myBuilders;
28 public:
29   /// Stores the shape (called by the execution method).
30   MODEL_EXPORT virtual void store(const boost::shared_ptr<GeomAPI_Shape>& theShape);
31   /// Returns the shape-result produced by this feature
32   MODEL_EXPORT virtual boost::shared_ptr<GeomAPI_Shape> shape();
33   /// Returns the source feature of this result
34   MODEL_EXPORT virtual boost::shared_ptr<ModelAPI_Feature> owner();
35
36   /// Records the subshape newShape which was generated during a topological construction.
37   /// As an example, consider the case of a face generated in construction of a box.
38   MODEL_EXPORT virtual void generated(const boost::shared_ptr<GeomAPI_Shape>& theNewShape, 
39     const int theTag = 1);
40
41   /// Records the shape newShape which was generated from the shape oldShape during a topological 
42   /// construction. As an example, consider the case of a face generated from an edge in 
43   /// construction of a prism.
44   MODEL_EXPORT virtual void generated(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
45     const boost::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag = 1);
46
47
48   /// Records the shape newShape which is a modification of the shape oldShape.
49   /// As an example, consider the case of a face split or merged in a Boolean operation.
50   MODEL_EXPORT virtual void modified(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
51     const boost::shared_ptr<GeomAPI_Shape>& theNewShape, const int theTag = 1);
52
53   /// Records the shape oldShape which was deleted from the current label.
54   /// As an example, consider the case of a face removed by a Boolean operation.
55   MODEL_EXPORT virtual void deleted(const boost::shared_ptr<GeomAPI_Shape>& theOldShape,
56     const int theTag = 1);
57
58   /// Removes the stored builders
59   MODEL_EXPORT virtual ~Model_ResultBody();
60
61 protected:
62   /// Makes a body on the given feature
63   Model_ResultBody();
64
65   /// Removes the stored builders
66   void clean();
67
68   /// Returns (creates if necessary) the builder created on the needed tag of sub-label
69   TNaming_Builder* builder(const int theTag);
70
71   friend class Model_Document;
72 };
73
74 #endif