Salome HOME
6d5df99dcd57e3ea257fc553166424c6e43b4538
[modules/shaper.git] / src / ModelAPI / ModelAPI_ResultBody.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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #ifndef ModelAPI_ResultBody_H_
21 #define ModelAPI_ResultBody_H_
22
23 #include "ModelAPI_Result.h"
24 #include <GeomAPI_Shape.h>
25 #include <GeomAPI_DataMapOfShapeShape.h>
26 #include <string>
27
28 class ModelAPI_BodyBuilder;
29 class GeomAlgoAPI_MakeShape;
30
31 /**\class ModelAPI_ResultBody
32 * \ingroup DataModel
33 * \brief The body (shape) result of a feature.
34 *
35 * Provides a shape that may be displayed in the viewer.
36 * May provide really huge results, so, working with this kind
37 * of result must be optimized.
38 */
39 class ModelAPI_ResultBody : public ModelAPI_Result
40 {
41 public:
42   MODELAPI_EXPORT virtual ~ModelAPI_ResultBody();
43   /// Returns the group identifier of this result
44   MODELAPI_EXPORT virtual std::string groupName();
45
46   /// Returns the group identifier of this result
47   inline static std::string group()
48   {
49     static std::string MY_GROUP = "Bodies";
50     return MY_GROUP;
51   }
52
53   /// default color for a result body
54   inline static const std::string& DEFAULT_COLOR()
55   {
56     static const std::string RESULT_BODY_COLOR("200,200,230");
57     return RESULT_BODY_COLOR;
58   }
59
60   /// default deflection for a result body
61   inline static const std::string DEFAULT_DEFLECTION()
62   {
63     return "0.0001";
64   }
65
66   /// Iternal enumeration for storage the information of connected topology flag
67   enum ConnectedTopologyFlag {
68     ConnectionNotComputed, ///< not yet computed
69     IsConnected,           ///< the topology is connected
70     IsNotConnected         ///< the topology is connected
71   };
72   /// Keeps (not persistently) the connected topology flag
73   ConnectedTopologyFlag myConnect;
74
75   /// \brief Stores the shape (called by the execution method).
76   /// param[in] theShape shape to store.
77   /// param[in] theIsStoreSameShapes if false stores reference to the same shape
78   ///                                if it is already in document.
79   MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
80                                      const bool theIsStoreSameShapes = true);
81
82   /// Stores the generated shape (called by the execution method).
83   MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
84     const std::shared_ptr<GeomAPI_Shape>& theToShape);
85
86   /// Stores the modified shape (called by the execution method).
87   MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
88     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
89
90   /// Stores the shape without naming support
91   MODELAPI_EXPORT virtual void storeWithoutNaming(
92     const std::shared_ptr<GeomAPI_Shape>& theShape);
93
94   /// Returns the shape-result produced by this feature
95   MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
96
97   /// Records the subshape newShape which was generated during a topological construction.
98   /// As an example, consider the case of a face generated in construction of a box.
99   MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
100     const std::string& theName, const int theTag = 1);
101
102   /// Records the shape newShape which was generated from the shape oldShape during a topological
103   /// construction. As an example, consider the case of a face generated from an edge in
104   /// construction of a prism.
105   MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
106     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
107     const int theTag = 1);
108
109   /// Records the shape newShape which is a modification of the shape oldShape.
110   /// As an example, consider the case of a face split or merged in a Boolean operation.
111   MODELAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
112     const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
113     const int theTag = 1);
114
115   /// Records the shape oldShape which was deleted from the current label.
116   /// As an example, consider the case of a face removed by a Boolean operation.
117   MODELAPI_EXPORT virtual void deleted(
118     const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
119
120   /// load deleted shapes
121   MODELAPI_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
122                                   std::shared_ptr<GeomAPI_Shape>  theShapeIn,
123                                   const int  theKindOfShape,
124                                   const int  theTag);
125   /// load and orient modified shapes
126   MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes (GeomAlgoAPI_MakeShape* theMS,
127     std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape, const int  theTag,
128     const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
129     const bool theIsStoreSeparate = false,
130     const bool theIsStoreAsGenerated = false);
131   /// load and orient generated shapes
132   MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
133     std::shared_ptr<GeomAPI_Shape>  theShapeIn, const int  theKindOfShape,
134     const int  theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
135
136   /// load shapes of the first level (to be used during shape import)
137   MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
138     const std::string& theName, int&  theTag);
139
140   /// load disconnected edges
141   MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
142     const std::string& theName, int&  theTag);
143
144   /// load disconnected vetexes
145   MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
146     const std::string& theName,int&  theTag);
147
148   /// Returns true if the latest modification of this body in the naming history
149   // is equal to the given shape
150   MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
151
152   /// Returns true is the topology is connected. Cashes this information for the current shape,
153   /// so it is more effective to use this method than directly GeomAPI_Shape.
154   MODELAPI_EXPORT virtual bool isConnectedTopology();
155
156 protected:
157   /// Default constructor accessible only from Model_Objects
158   MODELAPI_EXPORT ModelAPI_ResultBody();
159
160   ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape
161 };
162
163 //! Pointer on feature object
164 typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;
165
166 #endif