Step conversion problem - additional shapes at assemly


I am writing a program, which reads STEP and I need to get the individual elements in the assembly.

I'm using STEPCAFControl_Reader and XCAFApp_Application, get a root and analize a structure by my own recuration function:

WcdIt(XCAFDoc_DocumentTool::ShapeTool(doc->Main()) ,doc->GetData()->Root());

void WcdIt(Handle (XCAFDoc_ShapeTool) l_ShapeTool ,TDF_Label label)
TopoDS_Shape l_Shape = l_ShapeTool->GetShape(label);

int cd=label.NbChildren();

if (cd>0)
for (int i=0;i WcdIt(l_ShapeTool,label.FindChild(i+1,Standard_False));

So MyShapeAnalize analize a last childs in the tree. At MyShapeAnalize I'm looking for edges by aEdgeExplorer.

My problem:
In many cases I have more call MyShapeAnalize like shoud be: I found that this additional shapes are same from real model, but in another position.

I think that I should find unnecessary branches. But I do not know how to identify them.

Thanks for any suggestions

Thnx in advance

Roman Lygin's picture

Hi Aleksander,

Not sure if I fully get your need but looking at your code, I guess it just does wrong thing.

You seem to recursively iterate directly on document labels starting from the root
(label "0"). Instead you should rather rely on XCAFDoc_ShapeTool which frees you from knowing the exact structure of your OCAF tree.

I'd encourage you to read CDL and XDE User's Guide to check which methods you need. Likely the following:

XCAFDoc_ShapeTool::GetFreeShapes() will return you a list of labels containing free root
shapes in tree. Then you could iterate over these labels and ask for assembly components with XCAFDoc_ShapeTool::GetComponents(). Calling the latter with Standard_True will do recursion for you.

Hope this helps.

--- - blog on Open CASCADE