I’ve created a big list of readers for vtki
in this pull request. This PR sets up a common way to read any supported file with a VTK reader chosen by the file extension.
Please take a look at the dictionary mapping the extensions to the proper VTK reader classes in vtki/readers.py
and either let me know if something is incorrect or create a pull request to add new ones!
In vtki
, any VTK reader can now be used with the following code which will return a vtki
wrapped VTK data object. Note that vtki
simply provides a layer of wrappings on top of the VTK object so the returned object could be passed to any VTK Python routine.
import vtki
filename = 'path/to/my/file.ext'
data = vtki.read(filename)
Perhaps you need some flexibility with what the reader performs and need to call several setters/options on the reader - then simply pass a dictionary of function names and parameters to pass:
import vtki
filename = 'path/to/my/file.ext'
data = vtki.read(filename, attrs={'DebugOn':None, 'SetScalarsName':'foo'})