vtkXMLMultiBlockDataWriter does not write names for leaf nodes of the multiblock dataset
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
The following code will assign the name for 0 block, but will not write this name into vtu file:
vtkNew ugrid; vtkNew mb; mb->SetNumberOfBlocks( 1 ); mb->SetBlock( 0, ugrid.GetPointer() ); mb->GetMetaData( 0 )->Set(vtkCompositeDataSet::NAME(), "My Material 1"); mb->GetMetaData( 0 )->Print( std::cout ); // for debuggin to see the name vtkXMLMultiBlockDataWriter *writer = vtkXMLMultiBlockDataWriter::New(); writer->SetInput( mb.GetPointer() ); writer->SetFileName("test.vtm"); writer->Write();
The problem is inside vtkXMLMultiBlockDataWriter.cxx, int vtkXMLMultiBlockDataWriter::WriteComposite method iterates over multiblock data set items, and writes names only for vtkCompositeDataSet datasets.
The fix looks easy, I am attaching the fixed file.
VTK Reader & Paraview support reading of leaf dataset names correctly, so the problem is only in writer.
Thanks, Nikolay