General Utilities#

utilities.VtkErrorCatcher([raise_errors, ...])

Context manager to temporarily catch VTK errors.

utilities.set_error_output_file(filename)

Set a file to write out the VTK errors.

utilities.is_inside_bounds(point, bounds)

Check if a point is inside a set of bounds.

utilities.axis_rotation(points, angle[, ...])

Rotate points by angle about an axis.

Object Conversions#

wrap(dataset)

Wrap any given VTK data object to its appropriate PyVista data object.

is_pyvista_dataset(obj)

Return True if the object is a PyVista wrapped dataset.

image_to_texture(image)

Convert vtkImageData (pyvista.UniformGrid) to a vtkTexture.

numpy_to_texture(image)

Convert a NumPy image array to a vtk.vtkTexture.

array_from_vtkmatrix(matrix)

Convert a vtk matrix to an array.

vtkmatrix_from_array(array)

Convert a numpy.ndarray or array-like to a vtk matrix.

cubemap([path, prefix, ext])

Construct a cubemap from 6 images.

File IO#

read(filename[, attrs, force_ext, ...])

Read any file type supported by vtk or meshio.

read_exodus(filename[, animate_mode_shapes, ...])

Read an ExodusII file ('.e' or '.exo').

read_texture(filename[, attrs, progress_bar])

Load a texture from an image file.

read_legacy(filename[, progress_bar])

Use VTK's legacy reader to read a file.

save_meshio(filename, mesh[, file_format])

Save mesh to file using meshio.

Mesh Creation#

lines_from_points(points[, close])

Make a connected line set given an array of points.

vtk_points(points[, deep, force_float])

Convert numpy array or array-like to a vtkPoints object.

vector_poly_data(orig, vec)

Create a pyvista.PolyData object composed of vectors.

fit_plane_to_points(points[, return_meta])

Fit a plane to a set of points using the SVD algorithm.

Array Access#

get_array(mesh, name[, preference, err])

Search point, cell and field data for an array.

convert_array(arr[, name, deep, array_type])

Convert a NumPy array to a vtkDataArray or vice versa.

point_array(obj, name)

Return point array of a pyvista or vtk object.

cell_array(obj, name)

Return cell array of a pyvista or vtk object.

field_array(obj, name)

Return field data of a pyvista or vtk object.

Image Comparison and Regression#

compare_images(im1, im2[, threshold, use_vtk])

Compare two different images of the same size.

Miscellaneous#

Color([color, opacity, default_color, ...])

Helper class to convert between different color representations used in the pyvista library.

color_like

Any object convertible to a Color.

start_xvfb([wait, window_size])

Start the virtual framebuffer Xvfb.

VTK Version Information#

The PyVista library is heavily dependent on VTK and provides an easy way of getting the version of VTK in your environment.

Output the version of VTK.

>>> import pyvista
>>> pyvista.vtk_version_info
VTKVersionInfo(major=9, minor=1, micro=0)

Get the major version of VTK

>>> pyvista.vtk_version_info.major
9