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.
39 * Also provides a conainer of sub-body result in case it is compound or compsolid.
41 class ModelAPI_ResultBody : public ModelAPI_Result
44 /// Iternal enumeration for storage the information of connected topology flag
45 enum ConnectedTopologyFlag {
46 ConnectionNotComputed, ///< not yet computed
47 IsConnected, ///< the topology is connected
48 IsNotConnected ///< the topology is connected
52 /// Keeps (not persistently) the connected topology flag
53 ConnectedTopologyFlag myConnect;
55 ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape
58 MODELAPI_EXPORT virtual ~ModelAPI_ResultBody();
60 /// Returns the group identifier of this result
61 MODELAPI_EXPORT virtual std::string groupName();
63 /// Returns the group identifier of this result
64 inline static std::string group()
66 static std::string MY_GROUP = "Bodies";
70 /// default color for a result body
71 inline static const std::string& DEFAULT_COLOR()
73 static const std::string RESULT_BODY_COLOR("200,200,230");
74 return RESULT_BODY_COLOR;
77 /// default deflection for a result body
78 inline static const std::string DEFAULT_DEFLECTION()
83 /// Returns the number of sub-elements
84 MODELAPI_EXPORT virtual int numberOfSubs(bool forTree = false) const = 0;
86 /// Returns the sub-result by zero-base index
87 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(
88 const int theIndex, bool forTree = false) const = 0;
90 /// Returns true if feature or reuslt belong to this composite feature as subs
91 /// Returns theIndex - zero based index of sub if found
92 MODELAPI_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const = 0;
94 /// \brief Stores the shape (called by the execution method).
95 /// param[in] theShape shape to store.
96 /// param[in] theIsStoreSameShapes if false stores reference to the same shape
97 /// if it is already in document.
98 MODELAPI_EXPORT virtual void store(const std::shared_ptr<GeomAPI_Shape>& theShape,
99 const bool theIsStoreSameShapes = true);
101 /// Stores the generated shape (called by the execution method).
102 MODELAPI_EXPORT virtual void storeGenerated(const std::shared_ptr<GeomAPI_Shape>& theFromShape,
103 const std::shared_ptr<GeomAPI_Shape>& theToShape);
105 /// Stores the modified shape (called by the execution method).
106 MODELAPI_EXPORT virtual void storeModified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
107 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const int theDecomposeSolidsTag = 0);
109 /// Stores the shape without naming support
110 MODELAPI_EXPORT virtual void storeWithoutNaming(
111 const std::shared_ptr<GeomAPI_Shape>& theShape);
113 /// Returns the shape-result produced by this feature
114 MODELAPI_EXPORT virtual std::shared_ptr<GeomAPI_Shape> shape();
116 /// Records the subshape newShape which was generated during a topological construction.
117 /// As an example, consider the case of a face generated in construction of a box.
118 MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theNewShape,
119 const std::string& theName, const int theTag = 1);
121 /// Records the shape newShape which was generated from the shape oldShape during a topological
122 /// construction. As an example, consider the case of a face generated from an edge in
123 /// construction of a prism.
124 MODELAPI_EXPORT virtual void generated(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
125 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
126 const int theTag = 1);
128 /// Records the shape newShape which is a modification of the shape oldShape.
129 /// As an example, consider the case of a face split or merged in a Boolean operation.
130 MODELAPI_EXPORT virtual void modified(const std::shared_ptr<GeomAPI_Shape>& theOldShape,
131 const std::shared_ptr<GeomAPI_Shape>& theNewShape, const std::string& theName,
132 const int theTag = 1);
134 /// Records the shape oldShape which was deleted from the current label.
135 /// As an example, consider the case of a face removed by a Boolean operation.
136 MODELAPI_EXPORT virtual void deleted(
137 const std::shared_ptr<GeomAPI_Shape>& theOldShape, const int theTag = 1);
139 /// load deleted shapes
140 MODELAPI_EXPORT virtual void loadDeletedShapes(GeomAlgoAPI_MakeShape* theMS,
141 std::shared_ptr<GeomAPI_Shape> theShapeIn,
142 const int theKindOfShape,
144 const GeomShapePtr theShapes = GeomShapePtr());
146 /// load and orient modified shapes
147 MODELAPI_EXPORT virtual void loadAndOrientModifiedShapes(GeomAlgoAPI_MakeShape* theMS,
148 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape, const int theTag,
149 const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes,
150 const bool theIsStoreSeparate = false, const bool theIsStoreAsGenerated = false,
151 const bool theSplitInSubs = false);
153 /// load and orient generated shapes
154 MODELAPI_EXPORT virtual void loadAndOrientGeneratedShapes(GeomAlgoAPI_MakeShape* theMS,
155 std::shared_ptr<GeomAPI_Shape> theShapeIn, const int theKindOfShape,
156 const int theTag, const std::string& theName, GeomAPI_DataMapOfShapeShape& theSubShapes);
158 /// load shapes of the first level (to be used during shape import)
159 MODELAPI_EXPORT virtual void loadFirstLevel(std::shared_ptr<GeomAPI_Shape> theShape,
160 const std::string& theName, int& theTag);
162 /// load disconnected edges
163 MODELAPI_EXPORT virtual void loadDisconnectedEdges(std::shared_ptr<GeomAPI_Shape> theShape,
164 const std::string& theName, int& theTag);
166 /// load disconnected vetexes
167 MODELAPI_EXPORT virtual void loadDisconnectedVertexes(std::shared_ptr<GeomAPI_Shape> theShape,
168 const std::string& theName, int& theTag);
170 /// Returns true if the latest modification of this body in the naming history
171 // is equal to the given shape
172 MODELAPI_EXPORT virtual bool isLatestEqual(const std::shared_ptr<GeomAPI_Shape>& theShape) = 0;
174 /// Returns true is the topology is connected.
175 MODELAPI_EXPORT virtual bool isConnectedTopology() = 0;
177 /// Set displayed flag to the result and all sub results
178 /// \param theDisplay a boolean value
179 MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
181 /// Updates the sub-bodies if shape of this object is compsolid or compound
182 MODELAPI_EXPORT virtual void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
183 const bool theShapeChanged = true) = 0;
186 /// Default constructor accessible only from Model_Objects
187 MODELAPI_EXPORT ModelAPI_ResultBody();
191 //! Pointer on feature object
192 typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;