static bool recurse_CascadeDoc(TDF_Label label, Handle_XCAFDoc_ShapeTool& shapeTool, TopLoc_Location& parentloc, int level, ChCascadeDoc::callback_CascadeDoc& mcallback) { TDF_LabelSequence child_labels; Standard_Boolean is_assembly; is_assembly = shapeTool->GetComponents(label, child_labels, 0); char mstring[200] = "no name"; Standard_PCharacter mchastr = mstring; // access name Handle_TDataStd_Name N; if (label.FindAttribute(TDataStd_Name::GetID(), N)) { N->Get().ToUTF8CString(mchastr); } TDF_Label reflabel; Standard_Boolean isref = shapeTool->GetReferredShape(label, reflabel); if (isref) // ..maybe it references some shape: the name is stored there... { Handle_TDataStd_Name N; if (reflabel.FindAttribute(TDataStd_Name::GetID(), N)) { N->Get().ToUTF8CString(mchastr); } } TopLoc_Location mloc = shapeTool->GetLocation(label); TopLoc_Location absloc = parentloc.Multiplied(mloc); // access shape and position TopoDS_Shape rShape; rShape = shapeTool->GetShape(label); if (!rShape.IsNull()) { // === call the callback! === if (!mcallback.ForShape(rShape, absloc, mstring, level, label)) return false; // (skip children recursion if returned false) } // Recurse all children !!! if (is_assembly) { for (Standard_Integer j = 1; j <= child_labels.Length(); j++) { TDF_Label clabel = child_labels.Value(j); recurse_CascadeDoc(clabel, shapeTool, absloc, (level + 1), mcallback); } } // If it is a reference, Recurse all children of reference if (isref) { TDF_LabelSequence refchild_labels; Standard_Boolean refis_assembly; refis_assembly = shapeTool->GetComponents(reflabel, refchild_labels, 0); for (Standard_Integer j = 1; j <= refchild_labels.Length(); j++) { TDF_Label clabel = refchild_labels.Value(j); recurse_CascadeDoc(clabel, shapeTool, absloc, (level + 1), mcallback); } } return true; }