1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModelAPI_ResultBody_H_
22 #define ModelAPI_ResultBody_H_
24 #include "ModelAPI_Result.h"
25 #include <GeomAPI_Shape.h>
26 #include <GeomAPI_DataMapOfShapeShape.h>
29 class ModelAPI_BodyBuilder;
30 class GeomAlgoAPI_MakeShape;
32 /**\class ModelAPI_ResultBody
34 * \brief The body (shape) result of a feature.
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.
40 class ModelAPI_ResultBody : public ModelAPI_Result
43 MODELAPI_EXPORT virtual ~ModelAPI_ResultBody();
44 /// Returns the group identifier of this result
45 MODELAPI_EXPORT virtual std::string groupName();
47 /// Returns the group identifier of this result
48 inline static std::string group()
50 static std::string MY_GROUP = "Bodies";
54 /// default color for a result body
55 inline static const std::string& DEFAULT_COLOR()
57 static const std::string RESULT_BODY_COLOR("200,200,230");
58 return RESULT_BODY_COLOR;
61 /// default deflection for a result body
62 inline static const std::string DEFAULT_DEFLECTION()
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
73 /// Keeps (not persistently) the connected topology flag
74 ConnectedTopologyFlag myConnect;
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);
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);
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);
91 /// Stores the shape without naming support
92 MODELAPI_EXPORT virtual void storeWithoutNaming(
93 const std::shared_ptr<GeomAPI_Shape>& theShape);
95 /// Returns the shape-result produced by this feature
96 MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
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);
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);
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);
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);
121 /// load deleted shapes
122 MODELAPI_EXPORT virtual void loadDeletedShapes (GeomAlgoAPI_MakeShape* theMS,
123 std::shared_ptr<GeomAPI_Shape> theShapeIn,
124 const int theKindOfShape,
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 const bool theSplitInSubs = false);
133 /// load and orient generated shapes
134 MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes (GeomAlgoAPI_MakeShape* theMS,
135 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
136 const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
138 /// load shapes of the first level (to be used during shape import)
139 MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
140 const std::string& theName, int& theTag);
142 /// load disconnected edges
143 MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
144 const std::string& theName, int& theTag);
146 /// load disconnected vetexes
147 MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
148 const std::string& theName,int& theTag);
150 /// Returns true if the latest modification of this body in the naming history
151 // is equal to the given shape
152 MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
154 /// Returns true is the topology is connected. Cashes this information for the current shape,
155 /// so it is more effective to use this method than directly GeomAPI_Shape.
156 MODELAPI_EXPORT virtual bool isConnectedTopology();
159 /// Default constructor accessible only from Model_Objects
160 MODELAPI_EXPORT ModelAPI_ResultBody();
162 ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape
165 //! Pointer on feature object
166 typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;