Cannot get subshapes from shape_tool

Hi,
while trying to read an IGES (in the attachment) file using OCAF I get a Compound from the first label.
When I try to get the subshapes it fails.

I am using Clion and can see that there are at least 13 subshapes in
shape_tool->mySubShapes->mySize=13, but for some reason the shape_tool function GetSubShapes is not returning them.

My code:
TDF_LabelSequence labels;
TDF_LabelSequence sub_shape_labels;
Handle_XCAFDoc_ShapeTool const shape_tool = XCAFDoc_DocumentTool::ShapeTool(doc->Main());
Handle_XCAFDoc_ColorTool const color_tool = XCAFDoc_DocumentTool::ColorTool(doc->Main());
shape_tool->GetFreeShapes(labels);
shape_tool->GetSubShapes(labels.Value(1), sub_shape_labels);

Is there another way to get these shapes using shape_tool?

Just to clarify, it works if I use the IGESControl_Reader function:
Handle(TColStd_HSequenceOfTransient) my_list = reader.GiveList("iges-faces");
but, I want to understand why it is not working with the shape_tool, and how I can get the listed shapes listed in Clion.

Attachments: 
Dmitrii Pasukhin's picture

Hello. XCAFDoc_* working with XCAF entities. GetSubShapes() in this case will return only SubShape labels. In debug mode you saw SubShapes map that helps to internal storage validate input data. You can't use this map externally. But this map filled up just by TopExp_Iterator. So, if you would like to iterate through subShapes as TopoDS object use Iterator on extracted Shape. If you would iterate on Sublabeles - use XCAFDoc_ShapeTool.

SubShape had own label only in case when it has own attributes.

Best regards, Dmitrii.