[Paraview] Providing block names within .vtm files

Favre Jean jfavre at cscs.ch
Fri Mar 25 08:04:35 EDT 2011


I believe the functionality is missing. I have looked for it for many years.

I just put together a quick hack, which seems to work fine for me. No exhaustive testing was done. It works for my test data, which are multi-blocks of multi-blocks. It could be generalized to multi-pieces too. I'll let a Kitware guru do that. :-)

I modified VTK/IO/vtkXMLMultiBlockDataReader.cxx to get the attribute "name"

    // child is a leaf node, read and insert.
    const char* tagName = childXML->GetName();
    if (strcmp(tagName, "DataSet") == 0)
      {
      vtkSmartPointer<vtkDataSet> childDS;
      const char* name;
      if (this->ShouldReadDataSet(dataSetIndex))
        {
        // Read
        childDS.TakeReference(this->ReadDataset(childXML, filePath));
        name = childXML->GetAttribute("name");
        }
      // insert
      if (mblock)
        {
        mblock->SetBlock(index, childDS);
        mblock->GetMetaData(index)->Set(vtkCompositeDataSet::NAME(), name);
        }
      else if (mpiece)
        {
        mpiece->SetPiece(index, childDS);
        }
      dataSetIndex++;
      }
    // Child is a multiblock dataset itself. Create it.
    else if (mblock != 0
             && strcmp(tagName, "Block") == 0)
      {
      vtkMultiBlockDataSet* childDS = vtkMultiBlockDataSet::New();;
      this->ReadComposite(childXML, childDS, filePath, dataSetIndex);
      const char* name = childXML->GetAttribute("name");
      if (mblock)
        {
        mblock->SetBlock(index, childDS);
        mblock->GetMetaData(index)->Set(vtkCompositeDataSet::NAME(), name);
        }
      else if (mpiece)
        {
        vtkErrorMacro("Multipiece data can't have composite children.");
        return;
        }
      childDS->Delete();
      }


-----------------
Jean M. Favre
Swiss National Supercomputing Center



More information about the ParaView mailing list