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);
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 /// Stores the shape without naming support
46 /// \param theShape shape to store
47 MODEL_EXPORT virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape);
49 /// Returns the shape-result produced by this feature
50 MODEL_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
52 /// Records the subshape newShape which was generated during a topological construction.
53 /// As an example, consider the case of a face generated in construction of a box.
54 MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
55 const std::string& theName, const int theTag = 1);
57 /// Records the shape newShape which was generated from the shape oldShape during a topological
58 /// construction. As an example, consider the case of a face generated from an edge in
59 /// construction of a prism.
60 MODEL_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
61 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
64 /// Records the shape newShape which is a modification of the shape oldShape.
65 /// As an example, consider the case of a face split or merged in a Boolean operation.
66 MODEL_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
67 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1);
69 /// Records the shape oldShape which was deleted from the current label.
70 /// As an example, consider the case of a face removed by a Boolean operation.
71 MODEL_EXPORT virtual void deleted(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
72 const int theTag = 1);
74 /// load deleted shapes
75 MODEL_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
76 std::shared_ptr<GeomAPI_Shape> theShapeIn,
77 const int theKindOfShape,
79 /// load and orient modified shapes
80 MODEL_EXPORT virtual void loadAndOrientModifiedShapes (
81 GeomAlgoAPI_MakeShape* theMS,
82 std::shared_ptr<GeomAPI_Shape> theShapeIn,
83 const int theKindOfShape,
85 const std::string& theName,
86 GeomAPI_DataMapOfShapeShape& theSubShapes);
87 /// load and orient generated shapes
88 MODEL_EXPORT virtual void loadAndOrientGeneratedShapes (
89 GeomAlgoAPI_MakeShape* theMS,
90 std::shared_ptr<GeomAPI_Shape> theShapeIn,
91 const int theKindOfShape,
93 const std::string& theName,
94 GeomAPI_DataMapOfShapeShape& theSubShapes);
96 /// Loads shapes of the first level (to be used during shape import)
97 MODEL_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
99 /// Loads disconnected edges
100 MODEL_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
102 /// Loads disconnected vetexes
103 MODEL_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
105 /// Removes the stored builders
106 MODEL_EXPORT virtual ~Model_BodyBuilder();
108 /// Converts evolution of sub-shapes stored in naming structure to selection
109 /// (theFlag = true) and back (theFlag = false)
110 MODEL_EXPORT virtual void evolutionToSelection(const bool theFlag);
113 /// Default constructor accessible only by Model_Objects
114 Model_BodyBuilder(ModelAPI_Object* theOwner);
116 /// Removes the stored builders
119 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
120 TNaming_Builder* builder(const int theTag);
123 /// Loads shapes of the next level (to be used during shape import)
124 void loadNextLevels(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int& theTag);
126 /// builds name for the shape kept at the specified tag
127 void buildName(const int theTag, const std::string& theName);
129 friend class Model_ResultBody;
130 friend class Model_ResultCompSolid;