SHAPER 9.16.0
Model_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 Model_ResultBody_H_
21#define Model_ResultBody_H_
22
23#include "Model.h"
24#include <ModelAPI_ResultBody.h>
25#include <vector>
26#include <map>
27
28#include <TopTools_DataMapOfShapeListOfShape.hxx>
29
40{
42 std::vector<ResultBodyPtr> mySubs;
44 std::map<ObjectPtr, int> mySubsMap;
46 bool myLastConcealed;
48 std::shared_ptr<GeomAlgoAPI_MakeShape> myAlgo;
50 std::list<GeomShapePtr> myOlds;
52 bool myIsGenerated;
54 TopTools_DataMapOfShapeListOfShape myHistoryCash;
55
56public:
57
59 MODEL_EXPORT virtual ~Model_ResultBody();
60
62 virtual void initAttributes();
63
66 MODEL_EXPORT virtual bool generated(const GeomShapePtr& theNewShape,
67 const std::string& theName, const bool theCheckIsInResult = true) override;
68
70 MODEL_EXPORT
71 virtual void loadGeneratedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
72 const GeomShapePtr& theOldShape,
73 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
74 const std::string& theName = "",
75 const bool theSaveOldIfNotInTree = false) override;
76
78 MODEL_EXPORT
79 virtual void loadModifiedShapes(const std::shared_ptr<GeomAlgoAPI_MakeShape>& theAlgo,
80 const GeomShapePtr& theOldShape,
81 const GeomAPI_Shape::ShapeType theShapeTypeToExplore,
82 const std::string& theName = "") override;
83
85 MODEL_EXPORT virtual void loadFirstLevel(GeomShapePtr theShape, const std::string& theName);
86
88 MODEL_EXPORT virtual int numberOfSubs(bool forTree = false) const;
89
91 MODEL_EXPORT virtual ResultBodyPtr subResult(const int theIndex,
92 bool forTree = false) const;
93
96 MODEL_EXPORT virtual bool isSub(ObjectPtr theObject, int& theIndex) const;
97
99 MODEL_EXPORT virtual void colorConfigInfo(std::string& theSection,
100 std::string& theName,
101 std::string& theDefault);
102
105 MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
106 const bool theFlag);
107
109 MODEL_EXPORT virtual bool isConcealed();
110
112 MODEL_EXPORT virtual void setIsConcealed(const bool theValue, const bool theForced = false);
113
115 MODEL_EXPORT virtual bool isConnectedTopology();
116
118 MODEL_EXPORT virtual void cleanCash() override;
119
121 MODEL_EXPORT virtual bool hasTexture() override;
122
125 MODEL_EXPORT virtual const std::vector<int>& findShapeColor(const std::wstring& theShapeName);
126
128 MODEL_EXPORT virtual void setSubShapeColorIfAny(const std::shared_ptr<ModelAPI_Result> theResult,
129 const std::shared_ptr<GeomAPI_Shape> theShape);
130
131protected:
134
136 void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
137 const bool theShapeChanged = true);
138
140 void updateSubs(
141 const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
142 const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated);
143
145 void updateConcealment();
146
148 void computeOldForSub(const GeomShapePtr& theSub,
149 const std::list<GeomShapePtr>& theAllOlds, std::list<GeomShapePtr>& theOldForSub);
150
151 friend class Model_Objects;
152
154 std::wstring addShapeName(std::shared_ptr<GeomAPI_Shape> theShape,
155 const std::wstring& theName) override;
156
158 void addShapeColor(const std::wstring& theName,
159 std::vector<int>& theColor) override;
160
162 void setSubShapeColor(const std::shared_ptr<ModelAPI_Result> theResult,
163 const std::shared_ptr<GeomAPI_Shape> theShape,
164 const std::vector<int>& theColor);
165
167 void getSubShapeColor(const std::shared_ptr<ModelAPI_Result> theResult,
168 const std::shared_ptr<GeomAPI_Shape> theShape,
169 std::vector<int>& theColor);
170
172 void getColoredSubShapes(const std::shared_ptr<ModelAPI_Result> theResult,
173 std::map<std::shared_ptr<GeomAPI_Shape>, std::vector<int>>& theColoredShapes);
174
176 void removeSubShapeColors(const std::shared_ptr<ModelAPI_Result> theResult);
177
179 void setShapeName(std::map<std::wstring, std::shared_ptr<GeomAPI_Shape>>& theShapeName,
180 std::map<std::wstring, std::vector<int>>& theColorsShape) override;
181
183 MODELAPI_EXPORT virtual std::shared_ptr<ModelAPI_AttributeSelection> selection();
184
186 std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theShape) override;
187
189 void clearShapeNameAndColor() override;
190
192 std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > myNamesOfShapes;
193 int myLastEmptyNameIndex; // performance optimization
194
196 std::map< std::wstring, std::vector<int>> myColorsShape;
197
198};
199
200#endif
ShapeType
Shape type enum.
Definition: GeomAPI_Shape.h:46
The body (shape) result of a feature.
Definition: ModelAPI_ResultBody.h:43
Manager of objects of the document.
Definition: Model_Objects.h:46
The body (shape) result of a feature.
Definition: Model_ResultBody.h:40
std::map< std::wstring, std::shared_ptr< GeomAPI_Shape > > myNamesOfShapes
map with the name read in step file and shape
Definition: Model_ResultBody.h:192
void addShapeColor(const std::wstring &theName, std::vector< int > &theColor) override
Add color for shape Name read shape in step file.
Definition: Model_ResultBody.cpp:259
virtual bool setDisabled(std::shared_ptr< ModelAPI_Result > theThis, const bool theFlag)
Disables the result body: keeps the resulting shape as selection, but erases the underlying naming da...
Definition: Model_ResultBody.cpp:184
virtual bool isConnectedTopology()
Returns true is the topology is connected.
Definition: Model_ResultBody.cpp:529
void updateConcealment()
Checks the state of children and parents to send events of creation/erase when needed.
Definition: Model_ResultBody.cpp:223
void getSubShapeColor(const std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > theShape, std::vector< int > &theColor)
Get color from sub shape.
Definition: Model_ResultBody.cpp:307
void clearShapeNameAndColor() override
Clear the map of name and color read shape in step file.
Definition: Model_ResultBody.cpp:401
virtual bool isConcealed()
The compsolid is concealed if at least one of the sub is concealed.
Definition: Model_ResultBody.cpp:193
void updateSubs(const std::shared_ptr< GeomAPI_Shape > &theThisShape, const bool theShapeChanged=true)
Updates the sub-bodies if shape of this object is composite-solid.
Definition: Model_ResultBody.cpp:406
void getColoredSubShapes(const std::shared_ptr< ModelAPI_Result > theResult, std::map< std::shared_ptr< GeomAPI_Shape >, std::vector< int > > &theColoredShapes)
Get colored shapes from result.
Definition: Model_ResultBody.cpp:321
std::map< std::wstring, std::vector< int > > myColorsShape
map from the construction name to the imported color
Definition: Model_ResultBody.h:196
Model_ResultBody()
Makes a body on the given feature.
Definition: Model_ResultBody.cpp:53
virtual bool generated(const GeomShapePtr &theNewShape, const std::string &theName, const bool theCheckIsInResult=true) override
Records the subshape newShape which was generated during a topological construction.
Definition: Model_ResultBody.cpp:74
void setShapeName(std::map< std::wstring, std::shared_ptr< GeomAPI_Shape > > &theShapeName, std::map< std::wstring, std::vector< int > > &theColorsShape) override
Set the map of name and color read shape in step file.
Definition: Model_ResultBody.cpp:393
virtual void setIsConcealed(const bool theValue, const bool theForced=false)
Sets all subs as concealed in the data tree (referenced by other objects)
Definition: Model_ResultBody.cpp:198
virtual void setSubShapeColorIfAny(const std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > theShape)
Add color to sub shape.
Definition: Model_ResultBody.cpp:266
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) override
load generated shapes
Definition: Model_ResultBody.cpp:94
void computeOldForSub(const GeomShapePtr &theSub, const std::list< GeomShapePtr > &theAllOlds, std::list< GeomShapePtr > &theOldForSub)
Adds to theOldForSub only old shapes that where used for theSub creation.
Definition: Model_ResultBody.cpp:595
std::wstring findShapeName(std::shared_ptr< GeomAPI_Shape > theShape) override
Find the name of shape read in step file.
Definition: Model_ResultBody.cpp:368
virtual const std::vector< int > & findShapeColor(const std::wstring &theShapeName)
Find the imported color by the construction name of a shape.
Definition: Model_ResultBody.cpp:384
virtual ResultBodyPtr subResult(const int theIndex, bool forTree=false) const
Returns the sub-result by zero-base index.
Definition: Model_ResultBody.cpp:159
virtual bool hasTexture() override
sets the texture file
Definition: Model_ResultBody.cpp:558
virtual void loadFirstLevel(GeomShapePtr theShape, const std::string &theName)
load shapes of the first level (to be used during shape import)
Definition: Model_ResultBody.cpp:139
virtual void loadModifiedShapes(const std::shared_ptr< GeomAlgoAPI_MakeShape > &theAlgo, const GeomShapePtr &theOldShape, const GeomAPI_Shape::ShapeType theShapeTypeToExplore, const std::string &theName="") override
load modified shapes for sub-objects
Definition: Model_ResultBody.cpp:115
virtual void cleanCash() override
Cleans cash related to the already stored elements.
Definition: Model_ResultBody.cpp:547
virtual void colorConfigInfo(std::string &theSection, std::string &theName, std::string &theDefault)
Returns the parameters of color definition in the resources configuration manager.
Definition: Model_ResultBody.cpp:176
void setSubShapeColor(const std::shared_ptr< ModelAPI_Result > theResult, const std::shared_ptr< GeomAPI_Shape > theShape, const std::vector< int > &theColor)
Add color to sub shape.
Definition: Model_ResultBody.cpp:295
void removeSubShapeColors(const std::shared_ptr< ModelAPI_Result > theResult)
Forget subshape colors.
Definition: Model_ResultBody.cpp:328
virtual int numberOfSubs(bool forTree=false) const
Returns the number of sub-elements.
Definition: Model_ResultBody.cpp:154
virtual void initAttributes()
Request for initialization of data model of the result body: adding all attributes.
Definition: Model_ResultBody.cpp:67
virtual MODELAPI_EXPORT std::shared_ptr< ModelAPI_AttributeSelection > selection()
Return Attribute selection.
Definition: Model_ResultBody.cpp:334
virtual bool isSub(ObjectPtr theObject, int &theIndex) const
Returns true if feature or result belong to this composite feature as subs Returns theIndex - zero ba...
Definition: Model_ResultBody.cpp:166
virtual ~Model_ResultBody()
Removes the stored builders.
Definition: Model_ResultBody.cpp:61
std::wstring addShapeName(std::shared_ptr< GeomAPI_Shape > theShape, const std::wstring &theName) override
Add shape Name for read shape in step file.
Definition: Model_ResultBody.cpp:341