Last active
May 4, 2018 00:22
-
-
Save nicoguaro/43f5676e6985360e59ffe212dd22f460 to your computer and use it in GitHub Desktop.
Examples of use of vtkInterface for Scientific Visualization in Python using VTK.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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