<div dir="ltr"><div><div><div><div><div>Dear vtk users,<br><br></div>I am trying to write MetaData in vtm serial files with the following code:<br></div><pre style="color:rgb(0,0,0);background:rgb(255,255,255) none repeat scroll 0% 0%"><span style="color:rgb(105,105,105)"> // lenght of object array with multiple unstructuredgrids</span>
<span style="color:rgb(128,0,0);font-weight:bold">int</span> noBlocks <span style="color:rgb(128,128,48)">=</span> UGs<span style="color:rgb(128,128,48)">.</span>Length<span style="color:rgb(128,0,128)">;</span>
vtkMultiBlockDataSet mbset <span style="color:rgb(128,128,48)">=</span> vtkMultiBlockDataSet<span style="color:rgb(128,128,48)">.</span>New<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
mbset<span style="color:rgb(128,128,48)">.</span>SetNumberOfBlocks<span style="color:rgb(128,128,48)">(</span>noBlocks<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(128,0,0);font-weight:bold">for</span> <span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,0,0);font-weight:bold">uint</span> i <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,0,128)">;</span> i <span style="color:rgb(128,128,48)"><</span> noBlocks<span style="color:rgb(128,0,128)">;</span> i<span style="color:rgb(128,128,48)">+</span><span style="color:rgb(128,128,48)">+</span><span style="color:rgb(128,128,48)">)</span>
<span style="color:rgb(128,0,128)">{</span>
domainName <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(128,0,0)">"</span><span style="color:rgb(0,0,230)">MultiBlock_0</span><span style="color:rgb(128,0,0)">"</span> <span style="color:rgb(128,128,48)">+</span> i<span style="color:rgb(128,128,48)">.</span>ToString<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
mbset<span style="color:rgb(128,128,48)">.</span>SetBlock<span style="color:rgb(128,128,48)">(</span>i<span style="color:rgb(128,128,48)">,</span> <span style="color:rgb(128,128,48)">(</span>vtkUnstructuredGrid<span style="color:rgb(128,128,48)">)</span>UGrids<span style="color:rgb(128,128,48)">[</span>i<span style="color:rgb(128,128,48)">]</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
mbset<span style="color:rgb(128,128,48)">.</span>GetMetaData<span style="color:rgb(128,128,48)">(</span>i<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">.</span>Set<span style="color:rgb(128,128,48)">(</span>vtkCompositeDataSet<span style="color:rgb(128,128,48)">.</span>NAME<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">,</span> domainName<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(105,105,105)">// the following, prints the desired names of the blocks</span>
<span style="color:rgb(128,0,0);font-weight:bold">string</span> nameOfBlock <span style="color:rgb(128,128,48)">=</span> mbset<span style="color:rgb(128,128,48)">.</span>GetMetaData<span style="color:rgb(128,128,48)">(</span>i<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">.</span>Get<span style="color:rgb(128,128,48)">(</span>vtkCompositeDataSet<span style="color:rgb(128,128,48)">.</span>NAME<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
Debug<span style="color:rgb(128,128,48)">.</span>Print<span style="color:rgb(128,128,48)">(</span>nameOfBlock<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(128,0,128)">}</span>
<span style="color:rgb(128,0,0);font-weight:bold">string</span> fileDir <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(128,0,0)">@"</span><span style="color:rgb(0,0,230)">C:\\gitRepositories\\vtkActiViz\\</span><span style="color:rgb(128,0,0)">"</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(128,0,0);font-weight:bold">string</span> filename <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(128,0,0)">"</span><span style="color:rgb(0,0,230)">multiblock_increment01.vtm</span><span style="color:rgb(128,0,0)">"</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(105,105,105)">// write a vtm file with the multi-block</span>
vtkXMLMultiBlockDataWriter writerMultiBlock <span style="color:rgb(128,128,48)">=</span> vtkXMLMultiBlockDataWriter<span style="color:rgb(128,128,48)">.</span>New<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
writerMultiBlock<span style="color:rgb(128,128,48)">.</span>SetFileName<span style="color:rgb(128,128,48)">(</span>fileDir <span style="color:rgb(128,128,48)">+</span> filename<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
writerMultiBlock<span style="color:rgb(128,128,48)">.</span>SetInput<span style="color:rgb(128,128,48)">(</span>mbset<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
writerMultiBlock<span style="color:rgb(128,128,48)">.</span>Update<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
writerMultiBlock<span style="color:rgb(128,128,48)">.</span>UpdateInformation<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
writerMultiBlock<span style="color:rgb(128,128,48)">.</span>Write<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;<br></span></pre><pre style="color:rgb(0,0,0);background:rgb(255,255,255) none repeat scroll 0% 0%"><span style="color:rgb(128,0,128)"><font color="#000000"><font face="arial,helvetica,sans-serif">However, when opening the .vtm file, the names are not written and the .vtu files are written as </font></font>multiblock_increment01_0.vtu <font color="#000000"><font face="arial,helvetica,sans-serif">instead of </font></font></span><span style="color:rgb(128,0,128)"><br><span style="color:rgb(128,0,128)">multiblock_increment01_Multiblock_00.vtu.<br></span></span></pre><div style="text-align:left"><pre style="color:rgb(0,0,0);background:rgb(255,255,255) none repeat scroll 0% 0%"><span style="font-family:arial,helvetica,sans-serif">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:</span><br><br><span style="font-family:arial,helvetica,sans-serif"><span style="color:rgb(128,0,0);font-weight:bold"> string</span> domainName<span style="color:rgb(128,0,128)">;</span>
vtkInformation info <span style="color:rgb(128,128,48)">=</span> <span style="color:rgb(128,0,0);font-weight:bold">null</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(105,105,105)">// read multi-block</span>
</span><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,helvetica,sans-serif">vtkXMLMultiBlockDataReader<span style="color:rgb(128,128,48)"> </span></span>readerMB <span style="color:rgb(128,128,48)">=</span> vtkXMLMultiBlockDataReader<span style="color:rgb(128,128,48)">.</span>New<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
readerMB<span style="color:rgb(128,128,48)">.</span>SetFileName<span style="color:rgb(128,128,48)">(</span>filename<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
readerMB<span style="color:rgb(128,128,48)">.</span>Update<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
readerMB<span style="color:rgb(128,128,48)">.</span>UpdateInformation<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(105,105,105)">//multiBlock = vtkMultiBlockDataSet.New();</span>
</span><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,helvetica,sans-serif">vtkMultiBlockDataSet<span style="color:rgb(128,128,48)"> </span></span>multiBlock <span style="color:rgb(128,128,48)">=</span> vtkMultiBlockDataSet<span style="color:rgb(128,128,48)">.</span>SafeDownCast<span style="color:rgb(128,128,48)">(</span>readerMB<span style="color:rgb(128,128,48)">.</span>GetOutput<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(105,105,105)">//multiBlock = (vtkMultiBlockDataSet)readerMB.GetOutput();</span>
multiBlock<span style="color:rgb(128,128,48)">.</span>Update<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
multiBlock<span style="color:rgb(128,128,48)">.</span>UpdateData<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
multiBlock<span style="color:rgb(128,128,48)">.</span>UpdateInformation<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(105,105,105)">// get the number of blocks</span>
noBlocks <span style="color:rgb(128,128,48)">=</span> multiBlock<span style="color:rgb(128,128,48)">.</span>GetNumberOfBlocks<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
Debug<span style="color:rgb(128,128,48)">.</span>Print<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,0,0)">"</span><span style="color:rgb(0,0,230)">The number of blocks is: </span><span style="color:rgb(128,0,0)">"</span> <span style="color:rgb(128,128,48)">+</span> noBlocks<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
info <span style="color:rgb(128,128,48)">=</span> vtkInformation<span style="color:rgb(128,128,48)">.</span>New<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
info <span style="color:rgb(128,128,48)">=</span> multiBlock<span style="color:rgb(128,128,48)">.</span>GetMetaData<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
<span style="color:rgb(128,0,0);font-weight:bold">int</span> hasMD <span style="color:rgb(128,128,48)">=</span> multiBlock<span style="color:rgb(128,128,48)">.</span>HasMetaData<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(0,140,0)">0</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
Debug<span style="color:rgb(128,128,48)">.</span>Print<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,0,0)">"</span><span style="color:rgb(0,0,230)">The vtkInformation is: </span><span style="color:rgb(128,0,0)">"</span> <span style="color:rgb(128,128,48)">+</span> info<span style="color:rgb(128,128,48)">.</span>ToString<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
// </span><span style="font-family:arial,helvetica,sans-serif"><span style="font-family:arial,helvetica,sans-serif"><span style="color:rgb(105,105,105)">the following, prints 1<br></span></span> Debug<span style="color:rgb(128,128,48)">.</span>Print<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,0,0)">"</span><span style="color:rgb(0,0,230)">Does this block have metadata ? </span><span style="color:rgb(128,0,0)">"</span> <span style="color:rgb(128,128,48)">+</span> hasMD<span style="color:rgb(128,128,48)">.</span>ToString<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
domainName <span style="color:rgb(128,128,48)">=</span> info<span style="color:rgb(128,128,48)">.</span>Get<span style="color:rgb(128,128,48)">(</span>vtkCompositeDataSet<span style="color:rgb(128,128,48)">.</span>NAME<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span>
Debug<span style="color:rgb(128,128,48)">.</span>Print<span style="color:rgb(128,128,48)">(</span><span style="color:rgb(128,0,0)">"</span><span style="color:rgb(0,0,230)">The name of the muliblock is :</span><span style="color:rgb(128,0,0)">"</span> <span style="color:rgb(128,128,48)">+</span> domainName<span style="color:rgb(128,128,48)">)</span><span style="color:rgb(128,0,128)">;</span><br><br></span></pre><pre style="color:rgb(0,0,0);background:rgb(255,255,255) none repeat scroll 0% 0%"><span style="font-family:arial,helvetica,sans-serif">The keys NAMES are not accessible. Do I have to upgrade to a new ActiViz version? What am I doing wrong? <br></span></pre></div></div></div></div></div>