I am reading a binary TecPlot file in Python. I tried to use vtk.vtkTecplotReader, but this crashes. Instead, I have shifted my approach to use paraview.simple.VisItTecplotBinaryReader.
Ultimately I would like to use VTK filters on this data (for example, vtk.vtkMassProperties())
Is there any way to get from an instance of VisItTecplotBinaryReader directly to a VTK data type such as vtkUnstructuredGrid? Right now I am using paraview.simple.SaveData to write the data to disk and then reloading it via vtkXMLUnstructuredGridReader. This is far from ideal.
from paraview.simple import *
import vtk
r = VisItTecplotBinaryReader(FileName=['data.plt'])
r.MeshStatus = ['Surface']
r.PointArrayStatus = []
SaveData('data.vtm', proxy=r)
r = vtk.vtkXMLUnstructuredGridReader()
r.SetFileName('data/data.i_0_0.vtu')
r.Update()
geom = r.GetOutput()
def iterate(multiblock_dataset):
"""Iterate through a vtkMultiBlockDataset.
Args:
multiblock_dataset (vtkMultiBlockDataSet): Over which we iterate
Yields:
Iterator[vtkDataObject]: A block in the multiblock dataset
"""
iterator = multiblock_dataset.NewIterator()
iterator.InitTraversal()
while not iterator.IsDoneWithTraversal():
block = iterator.GetCurrentDataObject()
yield block
iterator.GoToNextItem()
Then you can use this generator to loop through the unstructured grids in your multiblock dataset:
for grid in iterate(your_multiblock_dataset):
# do sth with the grid