Skip to content

Instantly share code, notes, and snippets.

@nicoguaro
Last active May 4, 2018 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicoguaro/43f5676e6985360e59ffe212dd22f460 to your computer and use it in GitHub Desktop.
Save nicoguaro/43f5676e6985360e59ffe212dd22f460 to your computer and use it in GitHub Desktop.
Examples of use of vtkInterface for Scientific Visualization in Python using VTK.
import vtkInterface
from vtkInterface import examples
# Load Grid
grid = vtkInterface.UnstructuredGrid(examples.hexbeamfile)
# scalar demo
plobj = vtkInterface.PlotClass()
plobj.AddMesh(grid, scalars=grid.points[:, 2], colormap='viridis')
plobj.AddScalarBar()
plobj.Plot()
import numpy as np
import vtkInterface
x = np.arange(-10, 10, 0.25)
y = np.arange(-10, 10, 0.25)
z = 0
x, y, z = np.meshgrid(x, y, z)
data = np.column_stack((x.flatten(), y.flatten(), x.flatten()))
grid = vtkInterface.StructuredGrid(x, y, z)
# Add data
grid.AddPointScalars(data, "data")
grid.Write("test.vts")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment