Salome HOME
424f9857b5f43558c8b430e160c6cdbe92d4acf5
[modules/shaper.git] / src / ModelAPI / ModelAPI_BodyBuilder.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_BodyBuilder.hxx
4 // Created:     07 Jul 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ModelAPI_BodyBuilder_H_
8 #define ModelAPI_BodyBuilder_H_
9
10 #include <ModelAPI.h>
11 #include <GeomAPI_Shape.h>
12 #include <GeomAlgoAPI_MakeShape.h>
13 #include <GeomAPI_DataMapOfShapeShape.h>
14 #include <memory>
15 #include <string>
16
17 class ModelAPI_Data;
18 class ModelAPI_Document;
19 class ModelAPI_Object;
20
21 /**\class ModelAPI_BodyBuilder
22 * \ingroup DataModel
23  * \brief Extra API for the ResultBody that allows to work with naming.
24 */
25 class ModelAPI_BodyBuilder
26 {
27 public:
28   MODELAPI_EXPORT virtual ~ModelAPI_BodyBuilder() {};
29
30   /// Stores the shape (called by the execution method).
31   virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
32
33   /// Stores the generated shape (called by the execution method).
34   virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
35                                   const std::shared_ptr<GeomAPI_Shape>& theToShape) = 0;
36
37   /// Stores the modified shape (called by the execution method).
38   virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
39                                   const std::shared_ptr<GeomAPI_Shape>& theNewShape,
40                             const int theDecomposeSolidsTag = 0) = 0;
41
42   /// Stores the shape without naming support
43   virtual void storeWithoutNaming(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
44
45   /// Returns the shape-result produced by this feature
46   virtual std::shared_ptr<GeomAPI_Shape> shape() = 0;
47
48   /// Records the subshape newShape which was generated during a topological construction.
49   /// As an example, consider the case of a face generated in construction of a box.
50   virtual void generated(
51     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
52
53   /// Records the shape newShape which was generated from the shape oldShape during a topological 
54   /// construction. As an example, consider the case of a face generated from an edge in 
55   /// construction of a prism.
56   virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
57     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
58
59   /// Records the shape newShape which is a modification of the shape oldShape.
60   /// As an example, consider the case of a face split or merged in a Boolean operation.
61   virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
62     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName, const int theTag = 1) = 0;
63
64   /// Records the shape oldShape which was deleted from the current label.
65   /// As an example, consider the case of a face removed by a Boolean operation.
66   virtual void deleted(
67     const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1) = 0;
68   
69   /// load deleted shapes
70   virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
71                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
72                                                const int  theKindOfShape,
73                                                const int  theTag) = 0;
74   /// load and orient modified shapes
75   virtual void loadAndOrientModifiedShapes (
76                                                    GeomAlgoAPI_MakeShape* theMS,
77                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
78                                                const int  theKindOfShape,
79                                                const int  theTag,
80                                                                                            const std::string& theName,
81                                                GeomAPI_DataMapOfShapeShape& theSubShapes,
82                                                const bool theIsStoreSeparate = false) = 0;
83   /// load and orient generated shapes
84   virtual void loadAndOrientGeneratedShapes (
85                                                    GeomAlgoAPI_MakeShape* theMS,
86                                                std::shared_ptr<GeomAPI_Shape>  theShapeIn,
87                                                const int  theKindOfShape,
88                                                const int  theTag,
89                                                                                            const std::string& theName,
90                                                GeomAPI_DataMapOfShapeShape& theSubShapes) = 0;
91
92   /// load shapes of the first level (to be used during shape import)
93   virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag) = 0;
94   
95   /// load disconnected edges
96   virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName, int&  theTag) = 0;
97
98   /// load disconnected vetexes
99   virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape, const std::string& theName,int&  theTag) = 0;
100
101   /// Converts evolution of sub-shapes stored in naming structure to selection 
102   /// (theFlag = true) and back (theFlag = false)
103   virtual void evolutionToSelection(const bool theFlag) = 0;
104
105   /// Returns true if the latest modification of this body in the naming history
106   // is equal to the given shape
107   virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
108
109 protected:
110   /// Returns the data manager of this object: attributes
111   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Data> data() const;
112
113   /// Returns document this feature belongs to
114   MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_Document> document() const;
115
116 protected:
117   /// Deafult constructor accessible only from Model_Object
118   MODELAPI_EXPORT ModelAPI_BodyBuilder(ModelAPI_Object* theOwner);
119
120   ModelAPI_Object* myOwner; ///< the owner object this builder belongs to
121 };
122
123 //! Pointer on feature object
124 typedef std::shared_ptr<ModelAPI_BodyBuilder> BodyBuilderPtr;
125
126 #endif