OCAF - XCAFDoc_ShapeTool - shape, components and subshapes

Hi all,
using XCAFDoc_ShapeTool I'm able to add only top level shapes using AddShape, but with child I've not found any way to use XCAFDoc_ShapeTool.
Someone can explain me the difference and the use cases for
- AddComponent
- AddSubShape
Thanks

Rob Bachrach's picture

This is my understanding...

If you are creating the CAD equivalent of an assembly with parts, the parts would be "components" of the assembly. This is how you create your parent->child relationships.

A subshape allows you to assign specific properties (like layer or color) to a subshape of another shape. For example, if you want one face of a solid to have a different color, you assign that subshape to a label with that color property.

In my code, when creating a parent->child relationship, I do the following:

Use AddShape (with "true" for the makeAssembly argument) to add the parent as a top level item.
Use AddShape (with "false" for the makeAssembly argument) to add the child as a top level item, unless it too is an assembly.
Use AddComponent to add the child to the parent.

Remember, OCC does not necessarily consider a "top level item" as a parentless item in the component tree. It is simply a shape that can be referenced directly. And can be included as multiple components with different locations. It is the CAD equivalent of a base part. Parentless items in the component tree are actually referred to as "free shapes".

Marco Matt's picture

I've done some tests based on your information, but with no success.

I want to create a hierarchical structure, but I didn't find a way to do it.

ASSEMBLY (Compound3 with boxD and Compound2)
|---> SHAPE (boxD)
|---> ASSEMBLY (Compound2 with boxC and Compound1)
.........|------>SHAPE (boxC)
.........|------>ASSEMBLY (Compound1 with boxA and boxB)
....................|------>SHAPE (boxA)
....................|------>SHAPE (boxB)

Some suggestion?

Marco Matt's picture

To build the hierarchical structure as above I made a compound for each assembly and than I had only to AddShape the high level compound.