node->CreateDefaultDisplayNodes() does return “vtkMRMLScalarVolumeNode::CreateDefaultDisplayNodes failed: scene is invalid” as well if I don’t do a set scene.
But the maybe it’s connected to my issue about loading dicom. With a regular 4.10.2 slicer i’m not able to load a dicom series. It result in one black slice. Sample nrrd are working.
I can load a Dicom serie using the add Data function. But i can’t load it using the DCM database , i see the series in the database, i can check metadata, but i cant examine them (button does nothing) and i can’t load them either.
if i use AddNewNodeByClass instead of AddNode it throw “scene invalid” and it does not work
CreateDisplayDefaultNodes throw a warning :
Warning: In /home/raphaelbahegne/Dev/Slicer/Libs/MRML/Core/vtkMRMLSubjectHierarchyNode.cxx, line 718
vtkSubjectHierarchyItem (0x562fd3c5c650): FindChildByID: Item cache does not contain requested ID 140486651064064
HasItemAttribute: Failed to find subject hierarchy item by ID 140486651064064
this->GetMRMLScene()->AddNewNodeByClass("vtkMRMLScalarVolumeNode", "dicomNode") creates a new node by the name “dicomnode”. The new node has nothing to do with the other node that you created previously. That previously created node is not added to the scene, that’s why you got the error that the scene was invalid.
You can use to use scene->AddNewNodeByClass(...) instead of vtkNew<...> node; scene->AddNode(node). AddNewNodeByClass is simpler (just one method calls instead of two) and it creates the new node with default properties stored in the scene (for volume nodes there is not much to customize but for display or storage nodes the user may have set some non-default values).
Most likely this warning is a false alarm. Do you use latest master version of Slicer?