Hello. I am using python with the vtk library. I need to add to vtkMultiBlockDataSet a block consisting of at least one separate polyData (vtp) element. And then I want to write the result using the vtkXMLMultiBlockDataWriter class.
So it should look like this in the vtm file:
<?xml version='1.0'?>
<VTKFile type='vtkMultiBlockDataSet' version='1.0' byte_order='LittleEndian' header_type='UInt64'>
<vtkMultiBlockDataSet>
<DataSet name='internal' file='result/internal.vtu' />
<Block name='boundary'>
<DataSet name='wall' file='result/boundary/wall.vtp' />
<DataSet name='outlet' file='result/boundary/outlet.vtp' />
<DataSet name='inlet' file='result/boundary/inlet.vtp' />
</Block>
</vtkMultiBlockDataSet>
</VTKFile>
However, I couldn’t find how to combine multiple vtp files and add them as a single block to the vtkMultiBlockDataSet class object.
This is currently done as follows:
from vtk import *
...
result = vtkMultiBlockDataSet()
result.SetNumberOfBlocks(4)
result.SetBlock(0, myVtkUnstructuredGrid)
result.SetBlock(1, myVtkPolyData1)
result.SetBlock(2, myVtkPolyData2)
result.SetBlock(3, myVtkPolyData3)
writer = vtkXMLMultiBlockDataWriter()
writer.SetFileName("result.vtm")
writer.SetInputData(result)
writer.Write()
And this produces the following result in the vtm file:
<?xml version="1.0"?>
<VTKFile type="vtkMultiBlockDataSet" version="1.0" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<vtkMultiBlockDataSet>
<DataSet index="0" file="result/result_0.vtu"/>
<DataSet index="1" file="result/result_1.vtp"/>
<DataSet index="2" file="result/result_2.vtp"/>
<DataSet index="3" file="result/result_3.vtp"/>
</vtkMultiBlockDataSet>
</VTKFile>
I tried using vtkMultiBlockDataGroupFilter, vtkMultiBlockMergeFilter, and vtkPartitionedDataSetCollection, but all to no avail.
Could you please advise me on the best way to implement this?