Fri, 09/17/2021 - 15:51
I have an TopoDS_Shape attribute in a label of the document{Handle(TDocStd_Document) doc}.
when the document is in session, I use the following code to retrieve it
Handle(TNaming_NamedShape) attrib;
m_root.FindAttribute(TNaming_NamedShape::GetID(), attrib)
attrib->Get(); //Get() returns by value
will this create a duplicate of the TopoDS_shape attribute as it returns by value? If yes then my memory cannot handle 2 large TopoDS_shapes,
is it possible to get a reference to the TopoDS_ Shape attribute from document to avoid duplication?
Fri, 09/17/2021 - 17:05
TopoDS_ Shape is a special class in OCCT implementing an implicit smart-pointer behavior. This class stores a combination of Handle(TopoDS_ TShape), TopLoc_Location and Orientation flag. So that making a simple TopoDS_ Shape copy via C++ assignment wouldn't duplicate an underlying geometry - it will keep a reference to it. No worry in memory usage explosion here.
Fri, 09/17/2021 - 17:10
Dear Kavin,
TopoDS_Shape is just a simple interface, similar to smart pointer. The large data of the shape is concealed inside, in TopoDS_TShape and don't copied in this case.
Also, IsEqual method for two shapes created by two "Get" calls will return true.
Mikhail.
Tue, 09/21/2021 - 09:58
Thanks Mikhail and thanks Kirill Gavrilov, it helped a lot