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 ModelAPI_BodyBuilder_H_
22 #define ModelAPI_BodyBuilder_H_
25 #include <GeomAPI_Shape.h>
26 #include <GeomAlgoAPI_MakeShape.h>
27 #include <GeomAPI_DataMapOfShapeShape.h>
32 class ModelAPI_Document;
33 class ModelAPI_Object;
35 /**\class ModelAPI_BodyBuilder
37 * \brief Extra API for the ResultBody that allows to work with naming.
39 class ModelAPI_BodyBuilder
42 MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
44 /// Stores the shape (called by the execution method).
45 virtual void store(const GeomShapePtr& theShape,
46 const bool theIsStoreSameShapes = true) = 0;
48 /// Stores the generated shape (called by the execution method).
49 virtual void storeGenerated(const GeomShapePtr& theFromShape,
50 const GeomShapePtr& theToShape,
51 const bool theIsCleanStored = true) = 0;
53 /// Stores the root generated shapes (called by the execution method).
54 virtual void storeGenerated(const std::list<GeomShapePtr>& theFromShapes,
55 const GeomShapePtr& theToShape, const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape) = 0;
57 /// Stores the modified shape (called by the execution method).
58 virtual void storeModified(const GeomShapePtr& theOldShape,
59 const GeomShapePtr& theNewShape,
60 const bool theIsCleanStored = true) = 0;
62 /// Stores the root modified shapes (called by the execution method).
63 virtual void storeModified(const std::list<GeomShapePtr>& theOldShapes,
64 const GeomShapePtr& theNewShape, const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape)=0;
66 /// Returns the shape-result produced by this feature
67 virtual GeomShapePtr shape() = 0;
69 /// Records the subshape newShape which was generated during a topological construction.
70 /// As an example, consider the case of a face generated in construction of a box.
71 /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
72 virtual bool generated(const GeomShapePtr& theNewShape,
73 const std::string& theName, const bool theCheckIsInResult = true) = 0;
75 /// Records the shape newShape which was generated from the shape oldShape during a topological
76 /// construction. As an example, consider the case of a face generated from an edge in
77 /// construction of a prism.
78 virtual void generated(const GeomShapePtr& theOldShape,
79 const GeomShapePtr& theNewShape,
80 const std::string& theName = "") = 0;
82 /// Records the shape newShape which is a modification of the shape oldShape.
83 /// As an example, consider the case of a face split or merged in a Boolean operation.
84 virtual void modified(const GeomShapePtr& theOldShape,
85 const GeomShapePtr& theNewShape,
86 const std::string& theName = "") = 0;
88 /// load deleted shapes
89 virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
90 const GeomShapePtr& theOldShape,
91 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
92 const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0;
94 /// load and orient modified shapes
95 virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
96 const GeomShapePtr& theOldShape,
97 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
98 const std::string& theName = "") = 0;
100 /// load and orient generated shapes
101 virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
102 const GeomShapePtr& theOldShape,
103 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
104 const std::string& theName = "",
105 const bool theSaveOldIfNotInTree = false) = 0;
107 /// load shapes of the first level (to be used during shape import)
108 virtual void loadFirstLevel(GeomShapePtr theShape,
109 const std::string& theName) = 0;
111 /// Cleans cash related to the already stored elements
112 MODELAPI_EXPORT virtual void cleanCash() = 0;
115 /// Returns the data manager of this object: attributes
116 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
118 /// Returns document this feature belongs to
119 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
122 /// Default constructor accessible only from Model_Object
123 MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
125 ModelAPI_Object* myOwner; ///< the owner object this builder belongs to
128 //! Pointer on feature object
129 typedef std::shared_ptr<ModelAPI_BodyBuilder> BodyBuilderPtr;