1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef Model_BodyBuilder_H_
21 #define Model_BodyBuilder_H_
24 #include <ModelAPI_BodyBuilder.h>
26 #include <GeomAlgoAPI_MakeShape.h>
27 #include <GeomAPI_DataMapOfShapeShape.h>
30 class TNaming_Builder;
32 /**\class Model_BodyBuilder
34 * \brief Extra API for the ResultBody that allows to work with naming.
36 class Model_BodyBuilder : public ModelAPI_BodyBuilder
38 /// builders that store the naming history: one per label to allow store several shapes to one
39 /// label; index in vector corresponds to the label tag
40 std::map<int, TNaming_Builder*> myBuilders;
42 /// Stores the shape (called by the execution method).
43 MODEL_EXPORT virtual void store(const GeomShapePtr& theShape,
44 const bool theIsStoreSameShapes = true);
46 /// Stores the generated shape (called by the execution method).
47 MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
48 const GeomShapePtr& theToShape);
50 /// Stores the modified shape (called by the execution method).
51 /// \param theOldShape shape that produces result
52 /// \param theNewShape resulting shape
53 /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
54 /// theNewShape is compound of solids, if zero it is not used
55 MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
56 const GeomShapePtr& theNewShape,
57 const bool theIsCleanStored = true) override;
59 /// Returns the shape-result produced by this feature
60 MODEL_EXPORT virtual GeomShapePtr shape();
62 /// Records the subshape newShape which was generated during a topological construction.
63 /// As an example, consider the case of a face generated in construction of a box.
64 /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
65 MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
66 const std::string& theName, const bool theCheckIsInResult = true) override;
68 /// Records the shape newShape which was generated from the shape oldShape during a topological
69 /// construction. As an example, consider the case of a face generated from an edge in
70 /// construction of a prism.
71 MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
72 const GeomShapePtr& theNewShape,
73 const std::string& theName = "") override;
76 /// Records the shape newShape which is a modification of the shape oldShape.
77 /// As an example, consider the case of a face split or merged in a Boolean operation.
78 MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
79 const GeomShapePtr& theNewShape,
80 const std::string& theName = "") override;
82 /// load deleted shapes
84 virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
85 const GeomShapePtr& theOldShape,
86 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
87 const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override;
89 /// load and orient modified shapes
91 virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
92 const GeomShapePtr& theOldShape,
93 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
94 const std::string& theName = "") override;
96 /// load and orient generated shapes
98 virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
99 const GeomShapePtr& theOldShape,
100 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
101 const std::string& theName = "") override;
103 /// Loads shapes of the first level (to be used during shape import)
104 MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
105 const std::string& theName) override;
107 /// Removes the stored builders
108 MODEL_EXPORT virtual ~Model_BodyBuilder();
110 /// Cleans cash related to the already stored elements
111 MODEL_EXPORT virtual void cleanCash() override;
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(GeomShapePtr theShape,
125 const std::string& theName);
127 /// builds name for the shape kept at the specified tag
128 void buildName(const int theTag, const std::string& theName);
133 std::vector<int> tags;
137 int myFreePrimitiveTag;
138 std::map<std::string, IndexTags> myPrimitivesNamesIndexMap;
141 friend class Model_ResultBody;
142 friend class Model_ResultCompSolid;