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, const std::string& theName, const int theTag = 1);
65 /// Records the shape newShape which is a modification of the shape oldShape.
66 /// As an example, consider the case of a face split or merged in a Boolean operation.
67 MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
68 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
70 /// Records the shape oldShape which was deleted from the current label.
71 /// As an example, consider the case of a face removed by a Boolean operation.
72 MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
73 const int theTag = 1);
75 /// load deleted shapes
76 MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
77 std::shared_ptr<GeomAPI_Shape> theShapeIn,
78 const int theKindOfShape,
80 /// load and orient modified shapes
81 MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
82 GeomAlgoAPI_MakeShape* theMS,
83 std::shared_ptr<GeomAPI_Shape> theShapeIn,
84 const int theKindOfShape,
86 const std::string& theName,
87 GeomAPI_DataMapOfShapeShape& theSubShapes,
88 const bool theIsStoreSeparate = false);
89 /// load and orient generated shapes
90 MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
91 GeomAlgoAPI_MakeShape* theMS,
92 std::shared_ptr<GeomAPI_Shape> theShapeIn,
93 const int theKindOfShape,
95 const std::string& theName,
96 GeomAPI_DataMapOfShapeShape& theSubShapes);
98 /// Loads shapes of the first level (to be used during shape import)
99 MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
101 /// Loads disconnected edges
102 MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
104 /// Loads disconnected vetexes
105 MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
107 /// Removes the stored builders
108 MODEL_EXPORT virtual ~Model_BodyBuilder();
110 /// Converts evolution of sub-shapes stored in naming structure to selection
111 /// (theFlag = true) and back (theFlag = false)
112 MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
114 /// Returns true if the latest modification of this body in the naming history
115 // is equal to the given shape
116 MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape);
119 /// Default constructor accessible only by Model_Objects
120 Model_BodyBuilder(ModelAPI_Object* theOwner);
122 /// Removes the stored builders
125 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
126 TNaming_Builder* builder(const int theTag);
129 /// Loads shapes of the next level (to be used during shape import)
130 void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
132 /// builds name for the shape kept at the specified tag
133 void buildName(const int theTag, const std::string& theName);
135 friend class Model_ResultBody;
136 friend class Model_ResultCompSolid;