Salome HOME
Update of documentation in the Model package
[modules/shaper.git] / src / Model / Model_BodyBuilder.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_ResultBody.h
4 // Created:     08 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_BodyBuilder_H_
8 #define Model_BodyBuilder_H_
9
10 #include "Model.h"
11 #include <ModelAPI_BodyBuilder.h>
12
13 #include <GeomAlgoAPI_MakeShape.h>
14 #include <GeomAPI_DataMapOfShapeShape.h>
15 #include <vector>
16
17 class TNaming_Builder;
18
19 /**\class Model_BodyBuilder
20  * \ingroup DataModel
21  * \brief The body (shape) result of a feature.
22  */
23 class Model_BodyBuilder : public ModelAPI_BodyBuilder
24 {
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 std::shared_ptr<GeomAPI_Shape>& theShape);
31
32   /// Stores the generated shape (called by the execution method).
33   MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
34                                                const std::shared_ptr<GeomAPI_Shape>& theToShape);
35
36   /// Stores the modified shape (called by the execution method).
37   /// \param theOldShape shape that produces result
38   /// \param theNewShape resulting shape
39   /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case 
40   ///          theNewShape is compound of solids, if zero it is not used
41   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
42                                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
43                                           const int theDecomposeSolidsTag = 0);
44
45   /// Stores the shape without naming support
46   /// \param theShape shape to store
47   MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape);
48
49   /// Returns the shape-result produced by this feature
50   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
51
52   /// Records the subshape newShape which was generated during a topological construction.
53   /// As an example, consider the case of a face generated in construction of a box.
54   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape, 
55     const std::string& theName, const int theTag = 1);
56
57   /// Records the shape newShape which was generated from the shape oldShape during a topological 
58   /// construction. As an example, consider the case of a face generated from an edge in 
59   /// construction of a prism.
60   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
61     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
62
63
64   /// Records the shape newShape which is a modification of the shape oldShape.
65   /// As an example, consider the case of a face split or merged in a Boolean operation.
66   MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
67     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
68
69   /// Records the shape oldShape which was deleted from the current label.
70   /// As an example, consider the case of a face removed by a Boolean operation.
71   MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
72     const int theTag = 1);
73
74   /// load deleted shapes
75   MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
76                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
77                                                const int  theKindOfShape,
78                                                const int  theTag);
79   /// load and orient modified shapes
80   MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
81                                                    GeomAlgoAPI_MakeShape* theMS,
82                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
83                                                const int  theKindOfShape,
84                                                const int  theTag,
85                                                                                            const std::string& theName,
86                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
87    /// load and orient generated shapes
88   MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
89                                                    GeomAlgoAPI_MakeShape* theMS,
90                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
91                                                const int  theKindOfShape,
92                                                const int  theTag,
93                                                                                            const std::string& theName,
94                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
95   
96   /// Loads shapes of the first level (to be used during shape import)
97   MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
98   
99   /// Loads disconnected edges
100   MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
101
102   /// Loads disconnected vetexes
103   MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
104
105   /// Removes the stored builders
106   MODEL_EXPORT virtual ~Model_BodyBuilder();
107
108   /// Converts evolution of sub-shapes stored in naming structure to selection 
109   /// (theFlag = true) and back (theFlag = false)
110   MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
111
112 protected:
113   /// Default constructor accessible only by Model_Objects
114   Model_BodyBuilder(ModelAPI_Object* theOwner);
115
116   /// Removes the stored builders
117   void clean();
118
119   /// Returns (creates if necessary) the builder created on the needed tag of sub-label
120   TNaming_Builder* builder(const int theTag);
121
122 private:
123   /// Loads shapes of the next level (to be used during shape import)
124   void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
125
126   /// builds name for the shape kept at the specified tag 
127   void buildName(const int theTag, const std::string& theName);
128
129   friend class Model_ResultBody;
130   friend class Model_ResultCompSolid;
131 };
132
133 #endif