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 The body (shape) result of a feature.
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);
32 /// Stores the generated shape (called by the execution method).
33 MODEL_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
34 const std::shared_ptr<GeomAPI_Shape>& theToShape);
36 /// Stores the modified shape (called by the execution method).
37 /// \param theOldShape shape that produces result
38 /// \param theNewShape resulting shape
39 /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
40 /// theNewShape is compound of solids, if zero it is not used
41 MODEL_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
42 const std::shared_ptr<GeomAPI_Shape>& theNewShape,
43 const int theDecomposeSolidsTag = 0);
45 /// Returns the shape-result produced by this feature
46 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
48 /// Records the subshape newShape which was generated during a topological construction.
49 /// As an example, consider the case of a face generated in construction of a box.
50 MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
51 const std::string& theName, const int theTag = 1);
53 /// Records the shape newShape which was generated from the shape oldShape during a topological
54 /// construction. As an example, consider the case of a face generated from an edge in
55 /// construction of a prism.
56 MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
57 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
60 /// Records the shape newShape which is a modification of the shape oldShape.
61 /// As an example, consider the case of a face split or merged in a Boolean operation.
62 MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
63 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
65 /// Records the shape oldShape which was deleted from the current label.
66 /// As an example, consider the case of a face removed by a Boolean operation.
67 MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
68 const int theTag = 1);
70 /// load deleted shapes
71 MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
72 std::shared_ptr<GeomAPI_Shape> theShapeIn,
73 const int theKindOfShape,
75 /// load and orient modified shapes
76 MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
77 GeomAlgoAPI_MakeShape* theMS,
78 std::shared_ptr<GeomAPI_Shape> theShapeIn,
79 const int theKindOfShape,
81 const std::string& theName,
82 GeomAPI_DataMapOfShapeShape& theSubShapes);
83 /// load and orient generated shapes
84 MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
85 GeomAlgoAPI_MakeShape* theMS,
86 std::shared_ptr<GeomAPI_Shape> theShapeIn,
87 const int theKindOfShape,
89 const std::string& theName,
90 GeomAPI_DataMapOfShapeShape& theSubShapes);
92 /// Loads shapes of the first level (to be used during shape import)
93 MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
95 /// Loads disconnected edges
96 MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
98 /// Loads disconnected vetexes
99 MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
101 /// Removes the stored builders
102 MODEL_EXPORT virtual ~Model_BodyBuilder();
104 /// Converts evolution of sub-shapes stored in naming structure to selection
105 /// (theFlag = true) and back (theFlag = false)
106 MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
109 Model_BodyBuilder(ModelAPI_Object* theOwner);
111 /// Removes the stored builders
114 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
115 TNaming_Builder* builder(const int theTag);
118 /// Loads shapes of the next level (to be used during shape import)
119 void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
121 /// builds name for the shape kept at the specified tag
122 void buildName(const int theTag, const std::string& theName);
124 friend class Model_ResultBody;
125 friend class Model_ResultCompSolid;