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