|Description||RWMesh_CafReader::addShapeIntoDoc() (and JTCAFControl_Reader::addShapeIntoDoc()) incorrectly implements recursion while assigning attributes to sub-shapes:|
Standard_Boolean RWMesh_CafReader::addShapeIntoDoc (const TopoDS_Shape& theShape,
const TDF_Label& theLabel,
const TCollection_AsciiString& theParentName)
// add shape as sub-shape
aNewLabel = aShapeTool->AddSubShape (theLabel, theShape);
Handle(XCAFDoc_ShapeMapTool) aShapeMapTool = XCAFDoc_ShapeMapTool::Set (aNewLabel);
// store sub-shapes (iterator is set to ignore Location)
for (TopoDS_Iterator aSubShapeIter (theShape, Standard_True, Standard_False); aSubShapeIter.More();
addShapeIntoDoc (aSubShapeIter.Value(), aNewRefLabel, aDummyName);
so that when sub-shape also has sub-shapes, the method tries adding them as sub-shape to parent shape.
Based on description from XCAF team, this is incorrect - sub-shapes should be added as plain list of Component, not recursively on labels of sub-shapes; so that addShapeIntoDoc() should be called with Component label and not Sub-shape parent shape label.
In addition, it is desired NOT adding dedicated sub-shape labels in case, when it has no special attribute (color, name, metadata) to avoid redundant information in XCAF document.
Note that existing RWMesh_CafReader implementations RWGltf_CafReader and RWObj_CafReader fill the document with hierarchy of Compounds with Faces - so that the issue with sub-shapes and lost attributes should not practically happen. But this might become an issue in future - hence, should be fixed.
JTCAFControl_Reader contains code duplication of RWMesh_CafReader, so it might be worth sub-classing and revising JTCAFControl_Reader in scope of this or another issue.