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) override;
47 /// Stores the generated shape (called by the execution method).
48 MODEL_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
49 const GeomShapePtr& theToShape,
50 const bool theIsCleanStored = true) override;
52 /// Stores the root generated shapes (called by the execution method).
53 MODEL_EXPORT virtual void storeGenerated(const std::list<GeomShapePtr>& theFromShapes,
54 const GeomShapePtr& theToShape,
55 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape) override;
57 /// Stores the modified shape (called by the execution method).
58 /// \param theOldShape shape that produces result
59 /// \param theNewShape resulting shape
60 /// \param theIsCleanStored erases all previous data structure of this body if true
61 MODEL_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
62 const GeomShapePtr& theNewShape,
63 const bool theIsCleanStored = true) override;
65 /// Stores the root modified shape (called by the execution method).
66 /// \param theOldShapes all shapes that produce result
67 /// \param theNewShape resulting shape
68 /// \param theIsCleanStored erases all previous data structure of this body if true
69 MODEL_EXPORT virtual void storeModified(const std::list<GeomShapePtr>& theOldShapes,
70 const GeomShapePtr& theNewShape,
71 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape) override;
73 /// Returns the shape-result produced by this feature
74 MODEL_EXPORT virtual GeomShapePtr shape();
76 /// Records the subshape newShape which was generated during a topological construction.
77 /// As an example, consider the case of a face generated in construction of a box.
78 /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
79 MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
80 const std::string& theName, const bool theCheckIsInResult = true) override;
82 /// Records the shape newShape which was generated from the shape oldShape during a topological
83 /// construction. As an example, consider the case of a face generated from an edge in
84 /// construction of a prism.
85 MODEL_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
86 const GeomShapePtr& theNewShape,
87 const std::string& theName = "") override;
90 /// Records the shape newShape which is a modification of the shape oldShape.
91 /// As an example, consider the case of a face split or merged in a Boolean operation.
92 MODEL_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
93 const GeomShapePtr& theNewShape,
94 const std::string& theName = "") override;
96 /// load deleted shapes
98 virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
99 const GeomShapePtr& theOldShape,
100 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
101 const GeomShapePtr& theShapesToExclude = GeomShapePtr()) override;
103 /// load and orient modified shapes
105 virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
106 const GeomShapePtr& theOldShape,
107 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
108 const std::string& theName = "") override;
110 /// load and orient generated shapes
112 virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
113 const GeomShapePtr& theOldShape,
114 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
115 const std::string& theName = "") override;
117 /// Loads shapes of the first level (to be used during shape import)
118 MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
119 const std::string& theName) override;
121 /// Removes the stored builders
122 MODEL_EXPORT virtual ~Model_BodyBuilder();
124 /// Cleans cash related to the already stored elements
125 MODEL_EXPORT virtual void cleanCash() override;
127 /// Default constructor accessible only by Model_Objects
128 Model_BodyBuilder(ModelAPI_Object* theOwner);
130 /// Removes the stored builders
133 /// Returns (creates if necessary) the builder created on the needed tag of sub-label
134 TNaming_Builder* builder(const int theTag);
137 /// Loads shapes of the next level (to be used during shape import)
138 void loadNextLevels(GeomShapePtr theShape,
139 const std::string& theName);
141 /// builds name for the shape kept at the specified tag
142 void buildName(const int theTag, const std::string& theName);
147 std::vector<int> tags;
151 int myFreePrimitiveTag;
152 std::map<std::string, IndexTags> myPrimitivesNamesIndexMap;
155 friend class Model_ResultBody;
156 friend class Model_ResultCompSolid;