]> SALOME platform Git repositories - modules/shaper.git/blob - src/Model/Model_ResultBody.h
Salome HOME
Fix for the issue #686: now compounds produced by the Boolean operations can be corre...
[modules/shaper.git] / src / Model / Model_ResultBody.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_ResultBody_H_
8 #define Model_ResultBody_H_
9
10 #include "Model.h"
11 #include <ModelAPI_ResultBody.h>
12 #include <GeomAlgoAPI_MakeShape.h>
13 #include <GeomAPI_DataMapOfShapeShape.h>
14 #include <vector>
15
16 class TNaming_Builder;
17
18 /**\class Model_ResultBody
19  * \ingroup DataModel
20  * \brief The body (shape) result of a feature.
21  *
22  * Provides a shape that may be displayed in the viewer.
23  * May provide really huge results, so, working with this kind
24  * of result must be optimized.
25  */
26 class Model_ResultBody : public ModelAPI_ResultBody
27 {
28   /// builders that tores the naming history: one per label to allow store several shapes to one 
29   /// label; index in vector corresponds to the label tag
30   std::vector<TNaming_Builder*> myBuilders;
31 public:
32   /// default color for a result body
33   inline static const std::string& DEFAULT_COLOR()
34   {
35     static const std::string RESULT_BODY_COLOR("150,150,180");
36     return RESULT_BODY_COLOR;
37   }
38
39   /// Request for initialization of data model of the result: adding all attributes
40   virtual void initAttributes();
41
42   /// Returns the parameters of color definition in the resources config manager
43   MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
44                                             std::string& theDefault);
45
46   /// Disables the result body: keeps the resulting shape as selection, but erases the underlaying
47   /// naming data structure if theFlag if false. Or restores everything on theFlag is true.
48   MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
49     const bool theFlag);
50
51   /// Stores the shape (called by the execution method).
52   MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
53
54   /// Stores the generated shape (called by the execution method).
55   MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
56                                                const std::shared_ptr<GeomAPI_Shape>& theToShape);
57
58   /// Stores the modified shape (called by the execution method).
59   /// \param theOldShape shape that produces result
60   /// \param theNewShape resulting shape
61   /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case 
62   ///          theNewShape is compound of solids, if zero it is not used
63   MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
64                                                 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
65                                           const int theDecomposeSolidsTag = 0);
66
67   /// Returns the shape-result produced by this feature
68   MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
69
70   /// Records the subshape newShape which was generated during a topological construction.
71   /// As an example, consider the case of a face generated in construction of a box.
72   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape, 
73     const std::string& theName, const int theTag = 1);
74
75   /// Records the shape newShape which was generated from the shape oldShape during a topological 
76   /// construction. As an example, consider the case of a face generated from an edge in 
77   /// construction of a prism.
78   MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
79     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
80
81
82   /// Records the shape newShape which is a modification of the shape oldShape.
83   /// As an example, consider the case of a face split or merged in a Boolean operation.
84   MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
85     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
86
87   /// Records the shape oldShape which was deleted from the current label.
88   /// As an example, consider the case of a face removed by a Boolean operation.
89   MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
90     const int theTag = 1);
91
92   /// load deleted shapes
93   MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
94                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
95                                                const int  theKindOfShape,
96                                                const int  theTag);
97   /// load and orient modified shapes
98   MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
99                                                    GeomAlgoAPI_MakeShape* theMS,
100                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
101                                                const int  theKindOfShape,
102                                                const int  theTag,
103                                                                                            const std::string& theName,
104                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
105    /// load and orient generated shapes
106   MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
107                                                    GeomAlgoAPI_MakeShape* theMS,
108                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
109                                                const int  theKindOfShape,
110                                                const int  theTag,
111                                                                                            const std::string& theName,
112                                                GeomAPI_DataMapOfShapeShape& theSubShapes);
113   
114   /// Loads shapes of the first level (to be used during shape import)
115   MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
116   
117   /// Loads disconnected edges
118   MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
119
120   /// Loads disconnected vetexes
121   MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
122
123   /// Removes the stored builders
124   MODEL_EXPORT virtual ~Model_ResultBody();
125
126 protected:
127   /// Makes a body on the given feature
128   Model_ResultBody();
129
130   /// Removes the stored builders
131   void clean();
132
133   /// Returns (creates if necessary) the builder created on the needed tag of sub-label
134   TNaming_Builder* builder(const int theTag);
135
136 private:
137   /// Loads shapes of the next level (to be used during shape import)
138   void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag);
139
140   /// builds name for the shape kept at the specified tag 
141   void buildName(const int theTag, const std::string& theName);
142
143   friend class Model_Objects;
144 };
145
146 #endif