Salome HOME
Issue #1860: fix end lines with spaces
[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 Extra API for the ResultBody that allows to work with naming.
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                                   const bool theIsStoreSameShapes = true);
32
33   /// Stores the generated shape (called by the execution method).
34   MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
35                                                const std::shared_ptr<GeomAPI_Shape>& theToShape);
36
37   /// Stores the modified shape (called by the execution method).
38   /// \param theOldShape shape that produces result
39   /// \param theNewShape resulting shape
40   /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
41   ///          theNewShape is compound of solids, if zero it is not used
42   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
43                                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
44                                           const int theDecomposeSolidsTag = 0);
45
46   /// Stores the shape without naming support
47   /// \param theShape shape to store
48   MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape);
49
50   /// Returns the shape-result produced by this feature
51   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
52
53   /// Records the subshape newShape which was generated during a topological construction.
54   /// As an example, consider the case of a face generated in construction of a box.
55   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
56     const std::string& theName, const int theTag = 1);
57
58   /// Records the shape newShape which was generated from the shape oldShape during a topological
59   /// construction. As an example, consider the case of a face generated from an edge in
60   /// construction of a prism.
61   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
62     const std::shared_ptr<GeomAPI_Shape>& theNewShape,
63     const std::string& theName, const int theTag = 1);
64
65
66   /// Records the shape newShape which is a modification of the shape oldShape.
67   /// As an example, consider the case of a face split or merged in a Boolean operation.
68   MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
69     const std::shared_ptr<GeomAPI_Shape>& theNewShape,
70     const std::string& theName, const int theTag = 1);
71
72   /// Records the shape oldShape which was deleted from the current label.
73   /// As an example, consider the case of a face removed by a Boolean operation.
74   MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
75     const int theTag = 1);
76
77   /// load deleted shapes
78   MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
79                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
80                                                const int  theKindOfShape,
81                                                const int  theTag);
82   /// load and orient modified shapes
83   MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
84                                                    GeomAlgoAPI_MakeShape* theMS,
85                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
86                                                const int  theKindOfShape,
87                                                const int  theTag,
88                                                                                            const std::string& theName,
89                                                GeomAPI_DataMapOfShapeShape& theSubShapes,
90                                                const bool theIsStoreSeparate = false);
91    /// load and orient generated shapes
92   MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
93                                                    GeomAlgoAPI_MakeShape* theMS,
94                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
95                                                const int  theKindOfShape,
96                                                const int  theTag,
97                                                                                            const std::string& theName,
98                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
99
100   /// Loads shapes of the first level (to be used during shape import)
101   MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
102                                            const std::string& theName, int&  theTag);
103
104   /// Loads disconnected edges
105   MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
106                                                   const std::string& theName, int&  theTag);
107
108   /// Loads disconnected vetexes
109   MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
110                                                      const std::string& theName, int&  theTag);
111
112   /// Removes the stored builders
113   MODEL_EXPORT virtual ~Model_BodyBuilder();
114
115   /// Converts evolution of sub-shapes stored in naming structure to selection
116   /// (theFlag = true) and back (theFlag = false)
117   MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
118
119   /// Returns true if the latest modification of this body in the naming history
120   // is equal to the given shape
121   MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
122
123 protected:
124   /// Default constructor accessible only by Model_Objects
125   Model_BodyBuilder(ModelAPI_Object* theOwner);
126
127   /// Removes the stored builders
128   void clean();
129
130   /// Returns (creates if necessary) the builder created on the needed tag of sub-label
131   TNaming_Builder* builder(const int theTag);
132
133 private:
134   /// Loads shapes of the next level (to be used during shape import)
135   void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
136                       const std::string& theName, int&  theTag);
137
138   /// builds name for the shape kept at the specified tag
139   void buildName(const int theTag, const std::string& theName);
140
141   friend class Model_ResultBody;
142   friend class Model_ResultCompSolid;
143 };
144
145 #endif