Source code for

# -*- coding: utf-8 -*-
"""Viewer for a vtk file."""
# import os
# os.environ["QT_API"] = "pyqt"
# os.environ["ETS_TOOLKIT"] = "qt4"

    from mayavi import mlab
except ImportError:
    MAYA_AVAIL = False

[docs]def show_vtk(vtkfile, log_scale=False): """ Display a given mesh colored by its material ID. Parameters ---------- vtkfile : :class:`str` Path to the vtk/vtu file to show. log_scale : bool, optional State if the data should be shown in log scale. Default: False Notes ----- This routine needs "mayavi" to display the mesh. (see here: """ # stop if mayavi is not installed if not MAYA_AVAIL: print("Could not import 'mayavi'!") return None # new mayavi scenes mlab.figure() # load the vtk file to mayavi's mlab data_source = # create a surface out of the vtk source surface = mlab.pipeline.surface(data_source) # make the edges visible = False = 1.0 = "flat" # show legend try: surface.parent.scalar_lut_manager.lut_mode = "viridis" surface.parent.scalar_lut_manager.shadow = True surface.parent.scalar_lut_manager.show_scalar_bar = True if log_scale: surface.parent.scalar_lut_manager.lut.scale = "log10" except: pass # give it a name = "VTK-File" # show it return surface