1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_ResultBody.h
4 // Created: 08 Jul 2014
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_ResultBody_H_
8 #define Model_ResultBody_H_
11 #include <ModelAPI_ResultBody.h>
12 #include <GeomAlgoAPI_MakeShape.h>
13 #include <GeomAPI_DataMapOfShapeShape.h>
16 class TNaming_Builder;
18 /**\class Model_ResultBody
20 * \brief The body (shape) result of a feature.
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.
26 class Model_ResultBody : public ModelAPI_ResultBody
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;
32 /// Request for initialization of data model of the result: adding all attributes
33 virtual void initAttributes();
35 /// Stores the shape (called by the execution method).
36 MODEL_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape);
38 /// Stores the generated shape (called by the execution method).
39 MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
40 const std::shared_ptr<GeomAPI_Shape>& theToShape);
42 /// Stores the modified shape (called by the execution method).
43 MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
44 const std::shared_ptr<GeomAPI_Shape>& theNewShape);
46 /// Returns the shape-result produced by this feature
47 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
49 /// Records the subshape newShape which was generated during a topological construction.
50 /// As an example, consider the case of a face generated in construction of a box.
51 MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
52 const std::string& theName, const int theTag = 1);
54 /// Records the shape newShape which was generated from the shape oldShape during a topological
55 /// construction. As an example, consider the case of a face generated from an edge in
56 /// construction of a prism.
57 MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
58 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
61 /// Records the shape newShape which is a modification of the shape oldShape.
62 /// As an example, consider the case of a face split or merged in a Boolean operation.
63 MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
64 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
66 /// Records the shape oldShape which was deleted from the current label.
67 /// As an example, consider the case of a face removed by a Boolean operation.
68 MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
69 const int theTag = 1);
71 /// load deleted shapes
72 MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
73 std::shared_ptr<GeomAPI_Shape> theShapeIn,
74 const int theKindOfShape,
76 /// load and orient modified shapes
77 MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
78 GeomAlgoAPI_MakeShape* theMS,
79 std::shared_ptr<GeomAPI_Shape> theShapeIn,
80 const int theKindOfShape,
82 const std::string& theName,
83 GeomAPI_DataMapOfShapeShape& theSubShapes);
84 /// load and orient generated shapes
85 MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
86 GeomAlgoAPI_MakeShape* theMS,
87 std::shared_ptr<GeomAPI_Shape> theShapeIn,
88 const int theKindOfShape,
90 const std::string& theName,
91 GeomAPI_DataMapOfShapeShape& theSubShapes);
93 /// Loads shapes of the first level (to be used during shape import)
94 MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
96 /// Loads disconnected edges
97 MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
99 /// Loads disconnected vetexes
100 MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
102 /// Removes the stored builders
103 MODEL_EXPORT virtual ~Model_ResultBody();
106 /// Makes a body on the given feature
109 /// Removes the stored builders
112 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
113 TNaming_Builder* builder(const int theTag);
116 /// Loads shapes of the next level (to be used during shape import)
117 void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
119 /// builds name for the shape kept at the specified tag
120 void buildName(const int theTag, const std::string& theName);
122 friend class Model_Document;