SHAPER  9.12.0
Model_ResultBody.h
1 // Copyright (C) 2014-2023 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 
56 public:
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, std::string& theName,
100  std::string& theDefault);
101 
104  MODEL_EXPORT virtual bool setDisabled(std::shared_ptr<ModelAPI_Result> theThis,
105  const bool theFlag);
106 
108  MODEL_EXPORT virtual bool isConcealed();
109 
111  MODEL_EXPORT virtual void setIsConcealed(const bool theValue, const bool theForced = false);
112 
114  MODEL_EXPORT virtual bool isConnectedTopology();
115 
117  MODEL_EXPORT virtual void cleanCash() override;
118 
120  MODEL_EXPORT virtual bool hasTexture() override;
121 
124  MODEL_EXPORT virtual const std::vector<int>& findShapeColor(const std::wstring& theShapeName);
125 
126 protected:
129 
131  void updateSubs(const std::shared_ptr<GeomAPI_Shape>& theThisShape,
132  const bool theShapeChanged = true);
133 
135  void updateSubs(
136  const GeomShapePtr& theThisShape, const std::list<GeomShapePtr>& theOlds,
137  const std::shared_ptr<GeomAlgoAPI_MakeShape> theMakeShape, const bool isGenerated);
138 
140  void updateConcealment();
141 
143  void computeOldForSub(const GeomShapePtr& theSub,
144  const std::list<GeomShapePtr>& theAllOlds, std::list<GeomShapePtr>& theOldForSub);
145 
146  friend class Model_Objects;
147 
149  std::wstring addShapeName(std::shared_ptr<GeomAPI_Shape>,const std::wstring& theName) override;
150 
152  void addShapeColor( const std::wstring& theName,std::vector<int>& color) override;
153 
155  void setShapeName(std::map< std::wstring,
156  std::shared_ptr<GeomAPI_Shape>>& theShapeName,
157  std::map< std::wstring,
158  std::vector<int>>& theColorsShape) override;
159 
161  std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theShape) override;
162 
164  void clearShapeNameAndColor() override;
165 
167  std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > myNamesShape;
168 
170  std::map< std::wstring, std::vector<int>> myColorsShape;
171 
172 };
173 
174 #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 > > myNamesShape
map with the name read in step file and shape
Definition: Model_ResultBody.h:167
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 underlaying naming d...
Definition: Model_ResultBody.cpp:171
virtual bool isConnectedTopology()
Returns true is the topology is connected.
Definition: Model_ResultBody.cpp:428
void updateConcealment()
Checks the state of children and parents to send events of creation/erase when needed.
Definition: Model_ResultBody.cpp:210
void clearShapeNameAndColor() override
Clear the map of name and color read shape in step file.
Definition: Model_ResultBody.cpp:301
virtual bool isConcealed()
The compsolid is concealed if at least one of the sub is concealed.
Definition: Model_ResultBody.cpp:180
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:306
std::map< std::wstring, std::vector< int > > myColorsShape
map from the construction name to the imported color
Definition: Model_ResultBody.h:170
Model_ResultBody()
Makes a body on the given feature.
Definition: Model_ResultBody.cpp:47
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:67
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:293
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:185
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:87
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:494
std::wstring findShapeName(std::shared_ptr< GeomAPI_Shape > theShape) override
Find the name of shape read in step file.
Definition: Model_ResultBody.cpp:268
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:284
virtual ResultBodyPtr subResult(const int theIndex, bool forTree=false) const
Returns the sub-result by zero-base index.
Definition: Model_ResultBody.cpp:146
virtual bool hasTexture() override
sets the texture file
Definition: Model_ResultBody.cpp:457
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:126
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:108
virtual void cleanCash() override
Cleans cash related to the already stored elements.
Definition: Model_ResultBody.cpp:446
void addShapeColor(const std::wstring &theName, std::vector< int > &color) override
Add color for shape Name read shape in step file.
Definition: Model_ResultBody.cpp:246
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:163
virtual int numberOfSubs(bool forTree=false) const
Returns the number of sub-elements.
Definition: Model_ResultBody.cpp:141
std::wstring addShapeName(std::shared_ptr< GeomAPI_Shape >, const std::wstring &theName) override
Add shape Name for read shape in step file.
Definition: Model_ResultBody.cpp:252
virtual void initAttributes()
Request for initialization of data model of the result body: adding all attributes.
Definition: Model_ResultBody.cpp:60
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:153
virtual ~Model_ResultBody()
Removes the stored builders.
Definition: Model_ResultBody.cpp:54