STEP assembly file bug?

Hello again,

Consider the following code:

STEPControlStd_Reader reader; int numRoots = reader.NbRootsForTransfer();

I have what I think is a bug in the STEP file reader class.

If I read a STEP file with one geometrical object (no children), then the function, NbRootsForTransfer(), returns 1.

If the STEP file contains two geometrical objects (no children) then the function returns 2.

If the STEP file contains two geometrical objects where one object is a child of the other, the function returns 2.

If the STEP file contains four geometrical objects with three of them being children of the fourth then the function returns 4.

So far so good, but now if a STEP file contains 5 children with the first three being children of entity number 4 and entity number 5 is an orphan object then NbRootsForTransfer returns 2!

Is this what should be returned? If so, it would seem that this function is only telling me the number of roots at the top level. If this is the case, then how can I access children at a lower level? In the example above, how can I access the three children of the assembly?

Thanks for your help,

-- Shaun

Andrey Betenev's picture

Hello Shaun,

There is nothing wrong in this behaviour. Function NbRootsForTransfer() returns number of root objects (on the top level, you are right, this is the meaning of the term "root" here) in the STEP file that can be translated (while, not necessarily with some result). For assembly, it returns only root shape of assembly, all components are treated as non-roots.

If you want to iterate by components of assembly, you can start with root shape (eg. SHAPE_DEFINITION_REPRESENTATION entity) of the whole assembly, and then iterate by its children references to find all components. The iteration could be done by CONTEXT_DEPENDENT_SHAPE_REPRESENTATION or NEXT_ASSEMBLY_USAGE_OCCURENCE entities. You can find example of this in the class StepControlStd_ActorRead::TransferShape (just search for the phrase "process subcomponents of assembly")

Best Regards,