Importing VTK data to be displayed as Mesh

Additional requirements for this example: vtk

We will also use K3D's bundled color maps.


In [ ]:
import k3d
import os
import vtk

from k3d.helpers import download

filename = download("https://raw.githubusercontent.com/naucoin/VTKData/master/Data/Quadratic/CylinderQuadratic.vtk")

model_matrix = (
     10.0,  0.0, 0.0, 0.0,
     0.0,  10.0, 0.0, 0.0,
     0.0,  0.0, 10.0, 0.0,
     0.0,  0.0, 0.0, 1.0
)
    
reader = vtk.vtkUnstructuredGridReader()
reader.SetFileName(filename)
reader.Update()

geometryFilter = vtk.vtkGeometryFilter()
geometryFilter.SetInputData(reader.GetOutput())
geometryFilter.Update()

plot = k3d.plot()
cylinder = k3d.vtk_poly_data(geometryFilter.GetOutput(), color_attribute=('pressure', -100, 7200), 
                             color_map=k3d.basic_color_maps.Jet, model_matrix=model_matrix)
plot += cylinder
plot.display()

In [ ]:
cylinder.color_map = k3d.matplotlib_color_maps.Blues

In [ ]:
cylinder.color_map = k3d.paraview_color_maps.Rainbow_Desaturated

In [ ]:
plot.colorbar_object_id = 0 # Disabling colorLegend programmatically

In [ ]: