DataSet.cast_to_unstructured_grid

DataSet.cast_to_unstructured_grid#

DataSet.cast_to_unstructured_grid() pv.UnstructuredGrid[source]#

Get a new representation of this object as a UnstructuredGrid.

Note

Casting preserves the cell type(s) of the input. This means that any PIXEL and VOXEL cells from ImageData or RectilinearGrid are preserved. Use to_quads or to_hexahedra instead to convert the cell type for these cases.

Returns:
pyvista.UnstructuredGrid

Dataset cast into a pyvista.UnstructuredGrid.

Examples

Cast a pyvista.PolyData to a pyvista.UnstructuredGrid.

>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> type(mesh)
<class 'pyvista.core.pointset.PolyData'>
>>> grid = mesh.cast_to_unstructured_grid()
>>> type(grid)
<class 'pyvista.core.pointset.UnstructuredGrid'>