Doubts between GetShapes and GetFreeShapes.

Hi,

I have a few doubts regarding XCAFDoc_ShapeTool::GetShapes() and XCAFDoc_ShapeTool::GetFreeShapes().

As stated on XDE and XCAFDoc_ShapeTool documentation, GetFreeShapes returns a sequence of all top-level shapes which are free (i.e. not referred by any other).
Does that means that all those top-level shapes won't appear as references of any other shape?

And when GetShapes() documentation says Returns a sequence of all top-level shapes, means that those shapes where added as root but exists the possibility to appear as referenced in other shapes?

In my personal scenario I'm reading a basic primitive (a cube) as a STEP file. And both methods seems to return me the same simple shape. Does the result from GetShapes() also includes the result from GetFreeShapes()?

Regards!

Dmitrii Pasukhin's picture

Hello,

They look the same, but for assembly structure they return different result.

GetShapes collect each chape in 0:1 Label. So, if you have references, you will have a lot of dublicates.

As for a GetFreeShapes, you will recieve a roots.

To be honest, I don't see any reason for using GetShapes. I will initiate a process to make as deprecate this method, then we will remove it in the some release.

Best regards, Dmitrii.

Lorenzo Napl's picture

Hi Dimitrii,

I want to share the differences using GetFreeShapes and GetShapes with you.
My actual scenario is a STEP file that contains two cubes, one of them is rotated (please see atached image).
When I use GetShapes:

Document
|
|__>Assembly
| |__>Ref to purple cube.
| |__>Ref to white cube.
|
|__>Simple Shape from purple cube.
|__> Simple shape from white cube.

Meanwhile when I use GetFreeShapes:

Document
|
|__>Assembly
| |__>Ref to purple cube.
| |__>Ref to white cube.

If you recommend me to use only GetFreeShapes, what should it be the best efficient way to store all the data of a STEP file that contains references?
My main idea was to use GetShapes in order to store the simple shapes that I get from the document. That way I won't need to visit those shapes again whenever I find a reference that its ¿entry? is equal to the simple shape that I have stored.

Best regards, Lorenzo.

Attachments: 
Dmitrii Pasukhin's picture

Well, in this case you need to choose what are you need.

GetShapes returns you root of assembly, top-level reference(with location) and simple shapes. But you will lose parts of assembly(moved shapes).

GetFreeShapes returns only roots(it can be simple shapes, top-level references or assemblies). You will lose any shapes that have reference.

But you can use map of shape-labe - to use ShapeTool natively. It help to find out label by map.

Best regards, Dmitrii.

Lorenzo Napl's picture

Quote:
But you can use map of shape-labe - to use ShapeTool natively. It help to find out label by map.

Please could you elaborate on that?

The previous image that I attached, one cube is a copy of the other. So I would expect that both would share (as a reference) same shape.
I'm using the following methods from TopoDS_Shape but all of them returns false.

shape.IsPartner(secondShape)

shape.IsEqual(secondShape)

shape.IsSame(secondShape)

Any Idea why is that?

Best regards, Lorenzo