Salome HOME
Compsolids: initial implementation of sub-results of results on the data model level.
[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   /// Returns the shape-result produced by this feature
46   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
47
48   /// Records the subshape newShape which was generated during a topological construction.
49   /// As an example, consider the case of a face generated in construction of a box.
50   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape, 
51     const std::string& theName, const int theTag = 1);
52
53   /// Records the shape newShape which was generated from the shape oldShape during a topological 
54   /// construction. As an example, consider the case of a face generated from an edge in 
55   /// construction of a prism.
56   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
57     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
58
59
60   /// Records the shape newShape which is a modification of the shape oldShape.
61   /// As an example, consider the case of a face split or merged in a Boolean operation.
62   MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
63     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
64
65   /// Records the shape oldShape which was deleted from the current label.
66   /// As an example, consider the case of a face removed by a Boolean operation.
67   MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
68     const int theTag = 1);
69
70   /// load deleted shapes
71   MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
72                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
73                                                const int  theKindOfShape,
74                                                const int  theTag);
75   /// load and orient modified shapes
76   MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
77                                                    GeomAlgoAPI_MakeShape* theMS,
78                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
79                                                const int  theKindOfShape,
80                                                const int  theTag,
81                                                                                            const std::string& theName,
82                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
83    /// load and orient generated shapes
84   MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
85                                                    GeomAlgoAPI_MakeShape* theMS,
86                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
87                                                const int  theKindOfShape,
88                                                const int  theTag,
89                                                                                            const std::string& theName,
90                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
91   
92   /// Loads shapes of the first level (to be used during shape import)
93   MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
94   
95   /// Loads disconnected edges
96   MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
97
98   /// Loads disconnected vetexes
99   MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
100
101   /// Removes the stored builders
102   MODEL_EXPORT virtual ~Model_BodyBuilder();
103
104   /// Converts evolution of sub-shapes stored in naming structure to selection 
105   /// (theFlag = true) and back (theFlag = false)
106   MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
107
108 protected:
109   Model_BodyBuilder(ModelAPI_Object* theOwner);
110
111   /// Removes the stored builders
112   void clean();
113
114   /// Returns (creates if necessary) the builder created on the needed tag of sub-label
115   TNaming_Builder* builder(const int theTag);
116
117 private:
118   /// Loads shapes of the next level (to be used during shape import)
119   void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
120
121   /// builds name for the shape kept at the specified tag 
122   void buildName(const int theTag, const std::string& theName);
123
124   friend class Model_ResultBody;
125   friend class Model_ResultCompSolid;
126 };
127
128 #endif