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_BodyBuilder_H_
8 #define Model_BodyBuilder_H_
11 #include <ModelAPI_BodyBuilder.h>
13 #include <GeomAlgoAPI_MakeShape.h>
14 #include <GeomAPI_DataMapOfShapeShape.h>
17 class TNaming_Builder;
19 /**\class Model_BodyBuilder
21 * \brief Extra API for the ResultBody that allows to work with naming.
23 class Model_BodyBuilder : public ModelAPI_BodyBuilder
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;
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);
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);
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);
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);
50 /// Returns the shape-result produced by this feature
51 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
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);
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);
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);
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);
77 /// load deleted shapes
78 MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
79 std::shared_ptr<GeomAPI_Shape> theShapeIn,
80 const int theKindOfShape,
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,
88 const std::string& theName,
89 GeomAPI_DataMapOfShapeShape& theSubShapes,
90 const bool theIsStoreSeparate = false,
91 const bool theIsStoreAsGenerated = false);
92 /// load and orient generated shapes
93 MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
94 GeomAlgoAPI_MakeShape* theMS,
95 std::shared_ptr<GeomAPI_Shape> theShapeIn,
96 const int theKindOfShape,
98 const std::string& theName,
99 GeomAPI_DataMapOfShapeShape& theSubShapes);
101 /// Loads shapes of the first level (to be used during shape import)
102 MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
103 const std::string& theName, int& theTag);
105 /// Loads disconnected edges
106 MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
107 const std::string& theName, int& theTag);
109 /// Loads disconnected vetexes
110 MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
111 const std::string& theName, int& theTag);
113 /// Removes the stored builders
114 MODEL_EXPORT virtual ~Model_BodyBuilder();
116 /// Converts evolution of sub-shapes stored in naming structure to selection
117 /// (theFlag = true) and back (theFlag = false)
118 MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
120 /// Returns true if the latest modification of this body in the naming history
121 // is equal to the given shape
122 MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
125 /// Default constructor accessible only by Model_Objects
126 Model_BodyBuilder(ModelAPI_Object* theOwner);
128 /// Removes the stored builders
131 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
132 TNaming_Builder* builder(const int theTag);
135 /// Loads shapes of the next level (to be used during shape import)
136 void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape,
137 const std::string& theName, int& theTag);
139 /// builds name for the shape kept at the specified tag
140 void buildName(const int theTag, const std::string& theName);
142 friend class Model_ResultBody;
143 friend class Model_ResultCompSolid;