Salome HOME
90bd71015870b9742f476b8ae146db4bf30f9818
[modules/shaper.git] / src / ModelAPI / ModelAPI_BodyBuilder.h
1 // Copyright (C) 2014-2017  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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModelAPI_BodyBuilder_H_
22 #define ModelAPI_BodyBuilder_H_
23
24 #include <ModelAPI.h>
25 #include <GeomAPI_Shape.h>
26 #include <GeomAlgoAPI_MakeShape.h>
27 #include <GeomAPI_DataMapOfShapeShape.h>
28 #include <memory>
29 #include <string>
30
31 class ModelAPI_Data;
32 class ModelAPI_Document;
33 class ModelAPI_Object;
34
35 /**\class ModelAPI_BodyBuilder
36 * \ingroup DataModel
37  * \brief Extra API for the ResultBody that allows to work with naming.
38 */
39 class ModelAPI_BodyBuilder
40 {
41 public:
42   MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
43
44   /// Stores the shape (called by the execution method).
45   virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
46                      const bool theIsStoreSameShapes = true) = 0;
47
48   /// Stores the generated shape (called by the execution method).
49   virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
50                                   const std::shared_ptr<GeomAPI_Shape>& theToShape) = 0;
51
52   /// Stores the modified shape (called by the execution method).
53   virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
54                                   const std::shared_ptr<GeomAPI_Shape>& theNewShape,
55                             const int theDecomposeSolidsTag = 0) = 0;
56
57   /// Stores the shape without naming support
58   virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
59
60   /// Returns the shape-result produced by this feature
61   virtual std::shared_ptr<GeomAPI_Shape> shape() = 0;
62
63   /// Records the subshape newShape which was generated during a topological construction.
64   /// As an example, consider the case of a face generated in construction of a box.
65   virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
66                          const std::string& theName) = 0;
67
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   virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
72     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
73     const int theTag = 1) = 0;
74
75   /// Records the shape newShape which is a modification of the shape oldShape.
76   /// As an example, consider the case of a face split or merged in a Boolean operation.
77   virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
78     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
79     const int theTag = 1) = 0;
80
81   /// Records the shape oldShape which was deleted from the current label.
82   /// As an example, consider the case of a face removed by a Boolean operation.
83   virtual void deleted(
84     const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
85
86   /// load deleted shapes
87   virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
88                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
89                                                const int  theKindOfShape,
90                                                const int  theTag,
91                                                const GeomShapePtr theShapes = GeomShapePtr()) = 0;
92   /// load and orient modified shapes
93   virtual void loadAndOrientModifiedShapes (
94                                                    GeomAlgoAPI_MakeShape* theMS,
95                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
96                                                const int  theKindOfShape,
97                                                const int  theTag,
98                                                                                            const std::string& theName,
99                                                GeomAPI_DataMapOfShapeShape& theSubShapes,
100                                                const bool theIsStoreSeparate = false,
101                                                const bool theIsStoreAsGenerated = false) = 0;
102   /// load and orient generated shapes
103   virtual void loadAndOrientGeneratedShapes (
104                                                    GeomAlgoAPI_MakeShape* theMS,
105                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
106                                                const int  theKindOfShape,
107                                                const int  theTag,
108                                                                                            const std::string& theName,
109                                                GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
110
111   /// load shapes of the first level (to be used during shape import)
112   virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
113                               const std::string& theName, int&  theTag) = 0;
114
115   /// load disconnected edges
116   virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
117                                      const std::string& theName, int&  theTag) = 0;
118
119   /// load disconnected vetexes
120   virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
121                                         const std::string& theName,int&  theTag) = 0;
122
123   /// Converts evolution of sub-shapes stored in naming structure to selection
124   /// (theFlag = true) and back (theFlag = false)
125   virtual void evolutionToSelection(const bool theFlag) = 0;
126
127   /// Returns true if the latest modification of this body in the naming history
128   // is equal to the given shape
129   virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
130
131 protected:
132   /// Returns the data manager of this object: attributes
133   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
134
135   /// Returns document this feature belongs to
136   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
137
138 protected:
139   /// Deafult constructor accessible only from Model_Object
140   MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
141
142   ModelAPI_Object* myOwner; ///< the owner object this builder belongs to
143 };
144
145 //! Pointer on feature object
146 typedef std::shared_ptr<ModelAPI_BodyBuilder> BodyBuilderPtr;
147
148 #endif