Salome HOME
Fix for the issue #2808 : Documentation on the "Groups" panel. Added description...
[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 GeomShapePtr& theShape,
46                      const bool theIsStoreSameShapes = true) = 0;
47
48   /// Stores the generated shape (called by the execution method).
49   virtual void storeGenerated(const GeomShapePtr& theFromShape,
50                               const GeomShapePtr& theToShape) = 0;
51
52   /// Stores the modified shape (called by the execution method).
53   virtual void storeModified(const GeomShapePtr& theOldShape,
54                              const GeomShapePtr& theNewShape,
55                              const bool theIsCleanStored = true) = 0;
56
57   /// Stores the shape without naming support
58   virtual void storeWithoutNaming(const GeomShapePtr& theShape) = 0;
59
60   /// Returns the shape-result produced by this feature
61   virtual GeomShapePtr 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   /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
66   virtual bool generated(const GeomShapePtr& theNewShape,
67     const std::string& theName, const bool theCheckIsInResult = true) = 0;
68
69   /// Records the shape newShape which was generated from the shape oldShape during a topological
70   /// construction. As an example, consider the case of a face generated from an edge in
71   /// construction of a prism.
72   virtual void generated(const GeomShapePtr& theOldShape,
73                          const GeomShapePtr& theNewShape,
74                          const std::string& theName = "") = 0;
75
76   /// Records the shape newShape which is a modification of the shape oldShape.
77   /// As an example, consider the case of a face split or merged in a Boolean operation.
78   virtual void modified(const GeomShapePtr& theOldShape,
79                         const GeomShapePtr& theNewShape,
80                         const std::string& theName = "") = 0;
81
82   /// Records the shape oldShape which was deleted from the current label.
83   /// As an example, consider the case of a face removed by a Boolean operation.
84   virtual void deleted(const GeomShapePtr& theOldShape) = 0;
85
86   /// load deleted shapes
87   virtual void loadDeletedShapes(const GeomMakeShapePtr& theAlgo,
88                                  const GeomShapePtr& theOldShape,
89                                  const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
90                                  const GeomShapePtr& theShapesToAvoid = GeomShapePtr()) = 0;
91
92   /// load and orient modified shapes
93   virtual void loadModifiedShapes(const GeomMakeShapePtr& theAlgo,
94                                   const GeomShapePtr& theOldShape,
95                                   const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
96                                   const std::string& theName = "") = 0;
97
98   /// load and orient generated shapes
99   virtual void loadGeneratedShapes(const GeomMakeShapePtr& theAlgo,
100                                    const GeomShapePtr& theOldShape,
101                                    const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
102                                    const std::string& theName = "") = 0;
103
104   /// load shapes of the first level (to be used during shape import)
105   virtual void loadFirstLevel(GeomShapePtr theShape,
106                               const std::string& theName) = 0;
107
108   /// load disconnected edges
109   virtual void loadDisconnectedEdges(GeomShapePtr theShape,
110                                      const std::string& theName) = 0;
111
112   /// load disconnected vetexes
113   virtual void loadDisconnectedVertexes(GeomShapePtr theShape,
114                                         const std::string& theName) = 0;
115
116   /// Returns true if the latest modification of this body in the naming history
117   // is equal to the given shape
118   virtual bool isLatestEqual(const GeomShapePtr& theShape) = 0;
119
120 protected:
121   /// Returns the data manager of this object: attributes
122   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
123
124   /// Returns document this feature belongs to
125   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
126
127 protected:
128   /// Deafult constructor accessible only from Model_Object
129   MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
130
131   ModelAPI_Object* myOwner; ///< the owner object this builder belongs to
132 };
133
134 //! Pointer on feature object
135 typedef std::shared_ptr<ModelAPI_BodyBuilder> BodyBuilderPtr;
136
137 #endif