SHAPER 9.16.0
ModelAPI_ResultBody.h
1// Copyright (C) 2014-2026 CEA, EDF
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
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#include <map>
28#include <vector>
29
32
43{
44public:
50 };
51
52protected:
55
57
58public:
59 MODELAPI_EXPORT virtual ~ModelAPI_ResultBody();
60
62 inline static const std::string& IMAGE_ID()
63 {
64 static const std::string MY_IMAGE_ID("Image");
65 return MY_IMAGE_ID;
66 }
67
69 MODELAPI_EXPORT virtual std::string groupName();
70
72 inline static std::string group()
73 {
74 static std::string MY_GROUP = "Bodies";
75 return MY_GROUP;
76 }
77
79 inline static const std::string& DEFAULT_COLOR()
80 {
81 static const std::string RESULT_BODY_COLOR("200,200,230");
82 return RESULT_BODY_COLOR;
83 }
84
86 inline static const std::string DEFAULT_DEFLECTION()
87 {
88 return "0.0001";
89 }
90
92 MODELAPI_EXPORT virtual int numberOfSubs(bool forTree = false) const = 0;
93
95 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> subResult(
96 const int theIndex, bool forTree = false) const = 0;
97
100 MODELAPI_EXPORT virtual bool isSub(ObjectPtr theResult, int& theIndex) const = 0;
101
106 MODELAPI_EXPORT virtual void store(const GeomShapePtr& theShape,
107 const bool theIsStoreSameShapes = true);
108
110 MODELAPI_EXPORT virtual void storeGenerated(const GeomShapePtr& theFromShape,
111 const GeomShapePtr& theToShape);
112
114 MODELAPI_EXPORT virtual void storeGenerated(
115 const std::list<GeomShapePtr>& theFromShapes, const GeomShapePtr& theToShape,
116 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
117
119 MODELAPI_EXPORT virtual void storeModified(const GeomShapePtr& theOldShape,
120 const GeomShapePtr& theNewShape,
121 const bool theIsCleanStored = true);
122
124 MODELAPI_EXPORT virtual void storeModified(
125 const std::list<GeomShapePtr>& theOldShapes, const GeomShapePtr& theNewShape,
126 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape);
127
129 MODELAPI_EXPORT virtual GeomShapePtr shape();
130
134 MODELAPI_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
135 const std::string& theName, const bool theCheckIsInResult = true) = 0;
136
140 MODELAPI_EXPORT virtual void generated(const GeomShapePtr& theOldShape,
141 const GeomShapePtr& theNewShape,
142 const std::string& theName = "");
143
146 MODELAPI_EXPORT virtual void modified(const GeomShapePtr& theOldShape,
147 const GeomShapePtr& theNewShape,
148 const std::string& theName = "");
149
151 MODELAPI_EXPORT
152 virtual void loadDeletedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
153 const GeomShapePtr& theOldShape,
154 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
155 const GeomShapePtr& theShapesToExclude = GeomShapePtr());
156
158 MODELAPI_EXPORT
159 virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
160 const GeomShapePtr& theOldShape,
161 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
162 const std::string& theName = "") = 0;
163
165 MODELAPI_EXPORT
166 virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
167 const GeomShapePtr& theOldShape,
168 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
169 const std::string& theName = "",
170 const bool theSaveOldIfNotInTree = false) = 0;
171
173 MODELAPI_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape,
174 const std::string& theName) = 0;
175
177 MODELAPI_EXPORT virtual bool isConnectedTopology() = 0;
178
181 MODELAPI_EXPORT virtual void setDisplayed(const bool theDisplay);
182
184 MODELAPI_EXPORT virtual void updateSubs(const GeomShapePtr& theThisShape,
185 const bool theShapeChanged = true) = 0;
186
188 MODELAPI_EXPORT virtual void updateSubs(
189 const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
190 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated) = 0;
191
193 MODELAPI_EXPORT virtual void cleanCash() = 0;
194
196 MODELAPI_EXPORT virtual std::wstring addShapeName
197 (std::shared_ptr<GeomAPI_Shape> theShape,
198 const std::wstring& theName) = 0;
199
201 MODELAPI_EXPORT virtual void addShapeColor
202 (const std::wstring& theName,
203 std::vector<int>& theColor) = 0;
204
206 MODELAPI_EXPORT virtual void setSubShapeColor(const std::shared_ptr<ModelAPI_Result> theResult,
207 const std::shared_ptr<GeomAPI_Shape> theShape,
208 const std::vector<int>& theColor) = 0;
209
211 MODELAPI_EXPORT virtual void getSubShapeColor(const std::shared_ptr<ModelAPI_Result> theResult,
212 const std::shared_ptr<GeomAPI_Shape> theShape,
213 std::vector<int>& theColor) = 0;
214
216 MODELAPI_EXPORT virtual void getColoredSubShapes(const std::shared_ptr<ModelAPI_Result> theResult,
217 std::map<std::shared_ptr<GeomAPI_Shape>, std::vector<int>>& theColoredShapes) = 0;
218
220 MODELAPI_EXPORT virtual void removeSubShapeColors(const std::shared_ptr<ModelAPI_Result> theResult) = 0;
221
223 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_AttributeSelection> selection() = 0;
224
226 MODELAPI_EXPORT virtual void setShapeName
227 (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theShapeName,
228 std::map< std::wstring, std::vector<int>> & theColorsShape) = 0;
229
231 MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0;
232
234 MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theShape) = 0;
235
238 MODELAPI_EXPORT virtual const std::vector<int>& findShapeColor(
239 const std::wstring& theShapeName) = 0;
240
242 MODELAPI_EXPORT virtual void setSubShapeColorIfAny(const std::shared_ptr<ModelAPI_Result> theResult,
243 const std::shared_ptr<GeomAPI_Shape> theShape) = 0;
244
245
246protected:
248 MODELAPI_EXPORT ModelAPI_ResultBody();
249
250};
251
253typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;
254
255#endif
ShapeType
Shape type enum.
Definition: GeomAPI_Shape.h:46
Interface to the root class of all topological shapes constructions.
Definition: GeomAlgoAPI_MakeShape.h:35
Extra API for the ResultBody that allows to work with naming.
Definition: ModelAPI_BodyBuilder.h:39
The body (shape) result of a feature.
Definition: ModelAPI_ResultBody.h:43
virtual std::wstring addShapeName(std::shared_ptr< GeomAPI_Shape > theShape, const std::wstring &theName)=0
Add shape Name for read shape in step file.
virtual std::shared_ptr< ModelAPI_AttributeSelection > selection()=0
Return Attribute selection.
virtual void updateSubs(const GeomShapePtr &theThisShape, const bool theShapeChanged=true)=0
Updates the sub-bodies if shape of this object is compsolid or compound.
static const std::string DEFAULT_DEFLECTION()
default deflection for a result body
Definition: ModelAPI_ResultBody.h:86
virtual bool isSub(ObjectPtr theResult, int &theIndex) const =0
Returns true if theResult belong to this composite result as sub.
virtual std::wstring findShapeName(std::shared_ptr< GeomAPI_Shape > theShape)=0
Find the name of shape read in step file.
static const std::string & DEFAULT_COLOR()
default color for a result body
Definition: ModelAPI_ResultBody.h:79
virtual void removeSubShapeColors(const std::shared_ptr< ModelAPI_Result > theResult)=0
Forget subshape colors.
virtual void loadFirstLevel(GeomShapePtr theShape, const std::string &theName)=0
load shapes of the first level (to be used during shape import)
virtual bool generated(const GeomShapePtr &theNewShape, const std::string &theName, const bool theCheckIsInResult=true)=0
Records the subshape newShape which was generated during a topological construction.
ModelAPI_BodyBuilder * myBuilder
provides the body processing in naming shape
Definition: ModelAPI_ResultBody.h:56
virtual void getColoredSubShapes(const std::shared_ptr< ModelAPI_Result > theResult, std::map< std::shared_ptr< GeomAPI_Shape >, std::vector< int > > &theColoredShapes)=0
Get colored shapes from result.
virtual void updateSubs(const GeomShapePtr &theThisShape, const std::list< GeomShapePtr > &theOlds, const std::shared_ptr< GeomAlgoAPI_MakeShape > theMakeShape, const bool isGenerated)=0
Updates the sub-bodies in accordance to the algorithm history information.
ConnectedTopologyFlag myConnect
Keeps (not persistently) the connected topology flag.
Definition: ModelAPI_ResultBody.h:54
virtual bool isConnectedTopology()=0
Returns true is the topology is connected.
Definition: ModelAPI_ResultBody.cpp:143
virtual void loadGeneratedShapes(const std::shared_ptr< GeomAlgoAPI_MakeShape > &theAlgo, const GeomShapePtr &theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, const std::string &theName="", const bool theSaveOldIfNotInTree=false)=0
load and orient generated shapes
virtual void setSubShapeColorIfAny(const std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > theShape)=0
Add color to sub shape.
static std::string group()
Returns the group identifier of this result.
Definition: ModelAPI_ResultBody.h:72
virtual void addShapeColor(const std::wstring &theName, std::vector< int > &theColor)=0
Add color for shape Name read shape in step file.
virtual void store(const GeomShapePtr &theShape, const bool theIsStoreSameShapes=true)
Stores the shape (called by the execution method).
Definition: ModelAPI_ResultBody.cpp:41
virtual void storeModified(const GeomShapePtr &theOldShape, const GeomShapePtr &theNewShape, const bool theIsCleanStored=true)
Stores the modified shape (called by the execution method).
Definition: ModelAPI_ResultBody.cpp:84
virtual void getSubShapeColor(const std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > theShape, std::vector< int > &theColor)=0
Get color from sub shape.
virtual std::string groupName()
Returns the group identifier of this result.
Definition: ModelAPI_ResultBody.cpp:36
virtual void cleanCash()=0
Cleans cash related to the already stored elements.
virtual std::shared_ptr< ModelAPI_ResultBody > subResult(const int theIndex, bool forTree=false) const =0
Returns the sub-result by zero-base index.
virtual void setSubShapeColor(const std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > theShape, const std::vector< int > &theColor)=0
Add color to sub shape.
virtual void loadDeletedShapes(const std::shared_ptr< GeomAlgoAPI_MakeShape > &theAlgo, const GeomShapePtr &theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, const GeomShapePtr &theShapesToExclude=GeomShapePtr())
load deleted shapes
Definition: ModelAPI_ResultBody.cpp:134
virtual void setDisplayed(const bool theDisplay)
Set displayed flag to the result and all sub results.
Definition: ModelAPI_ResultBody.cpp:151
virtual const std::vector< int > & findShapeColor(const std::wstring &theShapeName)=0
Find the imported color by the construction name of a shape.
virtual void storeGenerated(const GeomShapePtr &theFromShape, const GeomShapePtr &theToShape)
Stores the generated shape (called by the execution method).
Definition: ModelAPI_ResultBody.cpp:55
virtual void modified(const GeomShapePtr &theOldShape, const GeomShapePtr &theNewShape, const std::string &theName="")
Records the shape newShape which is a modification of the shape oldShape.
Definition: ModelAPI_ResultBody.cpp:126
virtual void loadModifiedShapes(const std::shared_ptr< GeomAlgoAPI_MakeShape > &theAlgo, const GeomShapePtr &theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, const std::string &theName="")=0
load and orient modified shapes
virtual void clearShapeNameAndColor()=0
Clear the map of name and color read shape in step file.
static const std::string & IMAGE_ID()
Reference to the image attribute of the result body.
Definition: ModelAPI_ResultBody.h:62
ConnectedTopologyFlag
Internal enumeration for storage the information of connected topology flag.
Definition: ModelAPI_ResultBody.h:46
@ IsConnected
the topology is connected
Definition: ModelAPI_ResultBody.h:48
@ IsNotConnected
the topology is connected
Definition: ModelAPI_ResultBody.h:49
@ ConnectionNotComputed
not yet computed
Definition: ModelAPI_ResultBody.h:47
virtual int numberOfSubs(bool forTree=false) const =0
Returns the number of sub-elements.
ModelAPI_ResultBody()
Default constructor accessible only from Model_Objects.
Definition: ModelAPI_ResultBody.cpp:26
virtual void setShapeName(std::map< std::wstring, std::shared_ptr< GeomAPI_Shape > > &theShapeName, std::map< std::wstring, std::vector< int > > &theColorsShape)=0
Set the map of name and color read shape in step file.
virtual GeomShapePtr shape()
Returns the shape-result produced by this feature.
Definition: ModelAPI_ResultBody.cpp:114
The result of a feature.
Definition: ModelAPI_Result.h:37