Salome HOME
Update copyrights
[modules/shaper.git] / src / ModelAPI / ModelAPI_BodyBuilder.h
1 // Copyright (C) 2014-2019  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ModelAPI_BodyBuilder_H_
21 #define ModelAPI_BodyBuilder_H_
22
23 #include <ModelAPI.h>
24 #include <GeomAPI_Shape.h>
25 #include <GeomAlgoAPI_MakeShape.h>
26 #include <GeomAPI_DataMapOfShapeShape.h>
27 #include <memory>
28 #include <string>
29
30 class ModelAPI_Data;
31 class ModelAPI_Document;
32 class ModelAPI_Object;
33
34 /**\class ModelAPI_BodyBuilder
35 * \ingroup DataModel
36  * \brief Extra API for the ResultBody that allows to work with naming.
37 */
38 class ModelAPI_BodyBuilder
39 {
40 public:
41   MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
42
43   /// Stores the shape (called by the execution method).
44   virtual void store(const GeomShapePtr& theShape,
45                      const bool theIsStoreSameShapes = true) = 0;
46
47   /// Stores the generated shape (called by the execution method).
48   virtual void storeGenerated(const GeomShapePtr& theFromShape,
49                               const GeomShapePtr& theToShape) = 0;
50
51   /// Stores the modified shape (called by the execution method).
52   virtual void storeModified(const GeomShapePtr& theOldShape,
53                              const GeomShapePtr& theNewShape,
54                              const bool theIsCleanStored = true) = 0;
55
56   /// Returns the shape-result produced by this feature
57   virtual GeomShapePtr shape() = 0;
58
59   /// Records the subshape newShape which was generated during a topological construction.
60   /// As an example, consider the case of a face generated in construction of a box.
61   /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
62   virtual bool generated(const GeomShapePtr& theNewShape,
63     const std::string& theName, const bool theCheckIsInResult = true) = 0;
64
65   /// Records the shape newShape which was generated from the shape oldShape during a topological
66   /// construction. As an example, consider the case of a face generated from an edge in
67   /// construction of a prism.
68   virtual void generated(const GeomShapePtr& theOldShape,
69                          const GeomShapePtr& theNewShape,
70                          const std::string& theName = "") = 0;
71
72   /// Records the shape newShape which is a modification of the shape oldShape.
73   /// As an example, consider the case of a face split or merged in a Boolean operation.
74   virtual void modified(const GeomShapePtr& theOldShape,
75                         const GeomShapePtr& theNewShape,
76                         const std::string& theName = "") = 0;
77
78   /// load deleted shapes
79   virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
80                                  const GeomShapePtr& theOldShape,
81                                  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
82                                  const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0;
83
84   /// load and orient modified shapes
85   virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
86                                   const GeomShapePtr& theOldShape,
87                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
88                                   const std::string& theName = "") = 0;
89
90   /// load and orient generated shapes
91   virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
92                                    const GeomShapePtr& theOldShape,
93                                    const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
94                                    const std::string& theName = "") = 0;
95
96   /// load shapes of the first level (to be used during shape import)
97   virtual void loadFirstLevel(GeomShapePtr theShape,
98                               const std::string& theName) = 0;
99
100   /// Cleans cash related to the already stored elements
101   MODELAPI_EXPORT virtual void cleanCash() = 0;
102
103 protected:
104   /// Returns the data manager of this object: attributes
105   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
106
107   /// Returns document this feature belongs to
108   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
109
110 protected:
111   /// Default constructor accessible only from Model_Object
112   MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
113
114   ModelAPI_Object* myOwner; ///< the owner object this builder belongs to
115 };
116
117 //! Pointer on feature object
118 typedef std::shared_ptr<ModelAPI_BodyBuilder> BodyBuilderPtr;
119
120 #endif