SHAPER  9.12.0
ModelAPI_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 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 {
44 public:
50  };
51 
52 protected:
55 
57 
58 public:
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>, const std::wstring& theName) = 0;
198 
200  MODELAPI_EXPORT virtual void addShapeColor
201  (const std::wstring& theName, std::vector<int>& theColor) = 0;
202 
204  MODELAPI_EXPORT virtual void setShapeName
205  (std::map< std::wstring, std::shared_ptr<GeomAPI_Shape> > &theShapeName,
206  std::map< std::wstring, std::vector<int>> & theColorsShape) = 0;
207 
209  MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0;
210 
212  MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr<GeomAPI_Shape> theShape) = 0;
213 
216  MODELAPI_EXPORT virtual const std::vector<int>& findShapeColor(
217  const std::wstring& theShapeName) = 0;
218 
219 
220 protected:
222  MODELAPI_EXPORT ModelAPI_ResultBody();
223 
224 };
225 
227 typedef std::shared_ptr<ModelAPI_ResultBody> ResultBodyPtr;
228 
229 #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 void updateSubs(const GeomShapePtr &theThisShape, const bool theShapeChanged=true)=0
Updates the sub-bodies if shape of this object is compsolid or compound.
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.
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.
virtual std::shared_ptr< ModelAPI_ResultBody > subResult(const int theIndex, bool forTree=false) const =0
Returns the sub-result by zero-base index.
static const std::string & IMAGE_ID()
Reference to the image attribute of the result body.
Definition: ModelAPI_ResultBody.h:62
static const std::string & DEFAULT_COLOR()
default color for a result body
Definition: ModelAPI_ResultBody.h:79
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 const std::vector< int > & findShapeColor(const std::wstring &theShapeName)=0
Find the imported color by the construction name of a shape.
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 std::wstring addShapeName(std::shared_ptr< GeomAPI_Shape >, const std::wstring &theName)=0
Add shape Name for read shape in step file.
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
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 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 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 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.
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 GeomShapePtr shape()
Returns the shape-result produced by this feature.
Definition: ModelAPI_ResultBody.cpp:114
The result of a feature.
Definition: ModelAPI_Result.h:35