Searching for subshapes using ShapeTool

Hello!
I am trying to assign custom attributes to a subshape in an xcaf document that was generated by STEPCAFControl_Reader. None of ShapeTool's member functions FindMainShape, Search or SearchUsingMap return a non-null Label for the main shape. I created a map of the subshapes found in the document using TopExp::MapShapes on the shapes returned by ShapeTool::GetShapes. In this map I was able to find the subshape I was looking for.
How can I use ShapeTool to find the main shape or assembly?

Regards,

Dirk

Dirk B's picture

Storing a map of subshape, mainlabel worked to find the mainshape. After setting and initializing an XCAFDoc_ShapeMapTool for each free shape, I could then call XCAFDoc_ShapeTool::AddSubshape( mainlabel, subshape ) and receive a valid subshape label. This only seems to work around some problem. What is going wrong here? What am I missing?

Thanks,

Dirk

Dirk B's picture

FindMainShape considers only main shapes that are not assemblies. Does anybody know the reason for this? Where can I find more information on assemblies? How can I reference a subshape of an assembly?

Thanks,

Dirk

Patrik Mueller's picture

Hi Dirk,

here's a snippet to iterate the subshapes of an assembly:

if (m_pXDEShapes->IsAssembly(tmpLabel))
{
TDF_LabelSequence shapeLabels;
TDF_Label aLabel;
m_pXDEShapes->GetComponents(tmpLabel, shapeLabels);
Standard_Integer nbShapes = shapeLabels.Length();
for (Standard_Integer i = 1; i <= nbShapes; i++)
{
Im_Entity3DPtr tmpEntity = ReadShape(shapeLabels.Value(i));
}

Ignore ReadShape - its one of my methods...

Hope this helps,

Patrik