1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef Model_BodyBuilder_H_
22 #define Model_BodyBuilder_H_
25 #include <ModelAPI_BodyBuilder.h>
27 #include <GeomAlgoAPI_MakeShape.h>
28 #include <GeomAPI_DataMapOfShapeShape.h>
31 class TNaming_Builder;
33 /**\class Model_BodyBuilder
35 * \brief Extra API for the ResultBody that allows to work with naming.
37 class Model_BodyBuilder : public ModelAPI_BodyBuilder
39 /// builders that store the naming history: one per label to allow store several shapes to one
40 /// label; index in vector corresponds to the label tag
41 std::map<int, TNaming_Builder*> myBuilders;
43 /// Stores the shape (called by the execution method).
44 MODEL_EXPORT virtual void store(const GeomShapePtr& theShape,
45 const bool theIsStoreSameShapes = true);
47 /// Stores the generated shape (called by the execution method).
48 MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
49 const GeomShapePtr& theToShape);
51 /// Stores the modified shape (called by the execution method).
52 /// \param theOldShape shape that produces result
53 /// \param theNewShape resulting shape
54 /// \param theDecomposeSolidsTag tag for starting of solids sub-elements placement in case
55 /// theNewShape is compound of solids, if zero it is not used
56 MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
57 const GeomShapePtr& theNewShape,
58 const bool theIsCleanStored = true) override;
60 /// Stores the shape without naming support
61 /// \param theShape shape to store
62 MODEL_EXPORT virtual void storeWithoutNaming(const GeomShapePtr& theShape);
64 /// Returns the shape-result produced by this feature
65 MODEL_EXPORT virtual GeomShapePtr shape();
67 /// Records the subshape newShape which was generated during a topological construction.
68 /// As an example, consider the case of a face generated in construction of a box.
69 /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
70 MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
71 const std::string& theName, const bool theCheckIsInResult = true) override;
73 /// Records the shape newShape which was generated from the shape oldShape during a topological
74 /// construction. As an example, consider the case of a face generated from an edge in
75 /// construction of a prism.
76 MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
77 const GeomShapePtr& theNewShape,
78 const std::string& theName = "") override;
81 /// Records the shape newShape which is a modification of the shape oldShape.
82 /// As an example, consider the case of a face split or merged in a Boolean operation.
83 MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
84 const GeomShapePtr& theNewShape,
85 const std::string& theName = "") override;
87 /// Records the shape oldShape which was deleted from the current label.
88 /// As an example, consider the case of a face removed by a Boolean operation.
89 MODEL_EXPORT virtual void deleted(const GeomShapePtr& theOldShape) override;
91 /// load deleted shapes
93 virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
94 const GeomShapePtr& theOldShape,
95 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
96 const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override;
98 /// load and orient modified shapes
100 virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
101 const GeomShapePtr& theOldShape,
102 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
103 const std::string& theName = "") override;
105 /// load and orient generated shapes
107 virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
108 const GeomShapePtr& theOldShape,
109 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
110 const std::string& theName = "") override;
112 /// Loads shapes of the first level (to be used during shape import)
113 MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
114 const std::string& theName) override;
116 /// Loads disconnected edges
117 MODEL_EXPORT virtual void loadDisconnectedEdges(GeomShapePtr theShape,
118 const std::string& theName) override;
120 /// Loads disconnected vetexes
121 MODEL_EXPORT virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
122 const std::string& theName) override;
124 /// Removes the stored builders
125 MODEL_EXPORT virtual ~Model_BodyBuilder();
127 /// Returns true if the latest modification of this body in the naming history
128 // is equal to the given shape
129 MODEL_EXPORT virtual bool isLatestEqual(const GeomShapePtr& theShape);
132 /// Default constructor accessible only by Model_Objects
133 Model_BodyBuilder(ModelAPI_Object* theOwner);
135 /// Removes the stored builders
138 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
139 TNaming_Builder* builder(const int theTag);
142 /// Loads shapes of the next level (to be used during shape import)
143 void loadNextLevels(GeomShapePtr theShape,
144 const std::string& theName);
146 /// builds name for the shape kept at the specified tag
147 void buildName(const int theTag, const std::string& theName);
152 std::vector<int> tags;
156 int myFreePrimitiveTag;
157 std::map<std::string, IndexTags> myPrimitivesNamesIndexMap;
160 friend class Model_ResultBody;
161 friend class Model_ResultCompSolid;