List of Readers

I’ve been thinking it would be beneficial to compile a list of readers in the VTK library and their respective, typical file extensions. I think this would be awesome to include in the docs somewhere… perhaps on the lorensen GitHub site?

Does anyone know of any lists like this that currently exist? I’ve found the ParaView list but PV’s reader names aren’t exactly the same as the VTK side and this list seems a bit dated ( last modified on 26 January 2016, at 13:06).

I am willing to compile this list as I am hoping to create a dictionary based on file extensions for vtki since many readers can be used in Python with the same routine:

reader = vtk.vtkMyFavoriteReader()
reader.SetFileName(filename)
reader.Update()
output = reader.GetOutputDataObject(0)

Hi Bane,
indeed, they do exist:
https://vtk.org/Wiki/VTK/FAQ#What_image_file_formats_can_VTK_read_and_write.3F
and
https://vtk.org/Wiki/VTK/FAQ#What_3D_file_formats_can_VTK_import_and_export.3F

HTH,
JON HAITZ

1 Like

That page will need to be updated to reflect changes in the vtk module API.

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'})

The VTKExamples https://lorensen.github.io/VTKExamples/site/ show how
to do this in C++. See these examples:

https://lorensen.github.io/VTKExamples/site/Cxx/IO/ReadAllPolyDataTypes/

and

https://lorensen.github.io/VTKExamples/site/Cxx/IO/ReadAllPolyDataTypesDemo/

Bill

1 Like