pyvista.ExplicitStructuredGrid.cast_to_unstructured_grid

pyvista.ExplicitStructuredGrid.cast_to_unstructured_grid#

ExplicitStructuredGrid.cast_to_unstructured_grid() UnstructuredGrid[source]#

Cast to an unstructured grid.

Returns:
UnstructuredGrid

An unstructured grid. VTK adds the 'BLOCK_I', 'BLOCK_J' and 'BLOCK_K' cell arrays. These arrays are required to restore the explicit structured grid.

See also

pyvista.DataSetFilters.extract_cells

Extract a subset of a dataset.

pyvista.UnstructuredGrid.cast_to_explicit_structured_grid

Cast an unstructured grid to an explicit structured grid.

Notes

The ghost cell array is disabled before casting the unstructured grid in order to allow the original structure and attributes data of the explicit structured grid to be restored. If you don’t need to restore the explicit structured grid later or want to extract an unstructured grid from the visible subgrid, use the extract_cells filter and the cell indices where the ghost cell array is 0.

Examples

>>> from pyvista import examples
>>> grid = examples.load_explicit_structured()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
../../../_images/pyvista-ExplicitStructuredGrid-cast_to_unstructured_grid-1_00_00.png
>>> grid = grid.hide_cells(range(80, 120))
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
../../../_images/pyvista-ExplicitStructuredGrid-cast_to_unstructured_grid-1_01_00.png
>>> grid = grid.cast_to_unstructured_grid()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
../../../_images/pyvista-ExplicitStructuredGrid-cast_to_unstructured_grid-1_02_00.png
>>> grid = grid.cast_to_explicit_structured_grid()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
../../../_images/pyvista-ExplicitStructuredGrid-cast_to_unstructured_grid-1_03_00.png