I encountered scene files that would not load as expected due to two reasons:
- a zip CRC error (probably to be solved by T19315)
- this would keep the reader from loading a single one of a multitude of property list files
- a broken logic in mitk::SceneReaderV1 that was trying to sort nodes according to their "layer" property before adding them to the datastorage.
The second issue is topic of this bug report. A scene file that would reproduce the described behavior will be attached. Screenshots are also attached to demonstrate wrong and correct loading.
The concerned sorting logic was attempting to calculate unique layer numbers (as far as I understood it). This was not working correctly:
- the layer numbers could be non-unique for scenes where layers are identical for multiple nodes or for scenes where layer numbers are not consecutive (I think -- the code seemed just not clear)
- when layer number collided, the loader would assign two parents to a node, would not be able to figure out an order to insert all nodes, and finally (wrongly) insert many nodes as top-level items
I tracked the change down to T11181 (some three years ago). Seemingly, most scenes have not been affected since then. Data for 11181 is not available in Bugzilla, but I'll ask the authors for examples.
In a branch for this bug, I changed the sorting to a more stable version (with slightly less code, too). This solves my problem, but I'll invite others to verify their scenes, too.
One important thing that needs to be known (not mentioned in T11181): SceneIO can under no circumstances guarantee that the node order will correctly be restored as long as Data Manager (or different versions/configurations of Data Manager or similar views) will react to each DataStorage::Add() and re-order nodes/layers! With the current change the default configurations of SceneIO and Data Manager go along with each other, but if someone activates the "insert new nodes on top" for Data Manager's list, this would be broken again.
Another point: this shows that we need more complex tests for SceneIO. I'll add those in T19299.