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 container of sub-body result in case it is compound or compsolid.
41 class ModelAPI_ResultBody : public ModelAPI_Result
44 /// Internal 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 result 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 GeomShapePtr& theShape,
99 const bool theIsStoreSameShapes = true);
101 /// Stores the generated shape (called by the execution method).
102 MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
103 const GeomShapePtr& theToShape);
105 /// Stores the modified shape (called by the execution method).
106 MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
107 const GeomShapePtr& theNewShape,
108 const bool theIsCleanStored = true);
110 /// Returns the shape-result produced by this feature
111 MODELAPI_EXPORT virtual GeomShapePtr shape();
113 /// Records the subshape newShape which was generated during a topological construction.
114 /// As an example, consider the case of a face generated in construction of a box.
115 /// Returns true if it is stored correctly (the final shape contains this new sub-shape)
116 MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
117 const std::string& theName, const bool theCheckIsInResult = true) = 0;
119 /// Records the shape newShape which was generated from the shape oldShape during a topological
120 /// construction. As an example, consider the case of a face generated from an edge in
121 /// construction of a prism.
122 MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
123 const GeomShapePtr& theNewShape,
124 const std::string& theName = "");
126 /// Records the shape newShape which is a modification of the shape oldShape.
127 /// As an example, consider the case of a face split or merged in a Boolean operation.
128 MODELAPI_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
129 const GeomShapePtr& theNewShape,
130 const std::string& theName = "");
132 /// load deleted shapes
134 virtual void loadDeletedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
135 const GeomShapePtr& theOldShape,
136 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
137 const GeomShapePtr& theShapesToExclude = GeomShapePtr());
139 /// load and orient modified shapes
141 virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
142 const GeomShapePtr& theOldShape,
143 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
144 const std::string& theName = "") = 0;
146 /// load and orient generated shapes
148 virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
149 const GeomShapePtr& theOldShape,
150 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
151 const std::string& theName = "") = 0;
153 /// load shapes of the first level (to be used during shape import)
154 MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
155 const std::string& theName);
157 /// Returns true is the topology is connected.
158 MODELAPI_EXPORT virtual bool isConnectedTopology() = 0;
160 /// Set displayed flag to the result and all sub results
161 /// \param theDisplay a boolean value
162 MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
164 /// Updates the sub-bodies if shape of this object is compsolid or compound
165 MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape,
166 const bool theShapeChanged = true) = 0;
168 /// Cleans cash related to the already stored elements
169 MODELAPI_EXPORT virtual void cleanCash() = 0;
172 /// Default constructor accessible only from Model_Objects
173 MODELAPI_EXPORT ModelAPI_ResultBody();
177 //! Pointer on feature object
178 typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;