[vtkusers] ActiViz.NET-5.8.0- Cannot write/read multiblock MetaData in/from .vtm files

Giorgos Ragkousis giorgosragos at gmail.com
Tue Feb 2 09:32:45 EST 2016


Dear vtk users,

I am trying to write MetaData in vtm serial files with the following code:

            // lenght of object array with multiple unstructuredgrids
            int noBlocks = UGs.Length;
            vtkMultiBlockDataSet mbset = vtkMultiBlockDataSet.New();
            mbset.SetNumberOfBlocks(noBlocks);
            for (uint i = 0; i < noBlocks; i++)
            {
                domainName = "MultiBlock_0" + i.ToString();
                mbset.SetBlock(i, (vtkUnstructuredGrid)UGrids[i]);
                mbset.GetMetaData(i).Set(vtkCompositeDataSet.NAME(),
domainName);
                // the following, prints the desired names of the blocks
                string nameOfBlock =
mbset.GetMetaData(i).Get(vtkCompositeDataSet.NAME());
                Debug.Print(nameOfBlock);
            }
            string fileDir = @"C:\\gitRepositories\\vtkActiViz\\";
            string filename = "multiblock_increment01.vtm";
            // write a vtm file with the multi-block
            vtkXMLMultiBlockDataWriter writerMultiBlock =
vtkXMLMultiBlockDataWriter.New();
            writerMultiBlock.SetFileName(fileDir + filename);
            writerMultiBlock.SetInput(mbset);
            writerMultiBlock.Update();
            writerMultiBlock.UpdateInformation();
            writerMultiBlock.Write();

However, when opening the .vtm file, the names are not written and the
.vtu files are written as multiblock_increment01_0.vtu instead of
multiblock_increment01_Multiblock_00.vtu.

I wrote the above script in vtk python, as well and, the names are
written successfully. However, when I try to read the generated file
(written in python) with:

                        string domainName;
                        vtkInformation info = null;
                        // read multi-block
                        vtkXMLMultiBlockDataReader readerMB =
vtkXMLMultiBlockDataReader.New();
                        readerMB.SetFileName(filename);
                        readerMB.Update();
                        readerMB.UpdateInformation();
                        //multiBlock = vtkMultiBlockDataSet.New();
                        vtkMultiBlockDataSet multiBlock =
vtkMultiBlockDataSet.SafeDownCast(readerMB.GetOutput());
                        //multiBlock =
(vtkMultiBlockDataSet)readerMB.GetOutput();
                        multiBlock.Update();
                        multiBlock.UpdateData();
                        multiBlock.UpdateInformation();
                        // get the number of blocks
                        noBlocks = multiBlock.GetNumberOfBlocks();
                        Debug.Print("The number of blocks is: " + noBlocks);
                        info = vtkInformation.New();
                        info = multiBlock.GetMetaData(0);
                        int hasMD = multiBlock.HasMetaData(0);
                        Debug.Print("The vtkInformation is: " +
info.ToString());
                        // the following, prints 1
                        Debug.Print("Does this block have metadata ? "
+ hasMD.ToString());
                        domainName = info.Get(vtkCompositeDataSet.NAME());
                        Debug.Print("The name of the muliblock is :" +
domainName);

The keys NAMES are not accessible. Do I have to upgrade to a new
ActiViz version? What am I doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160202/7977f238/attachment.html>


More information about the vtkusers mailing list