ExplicitStructuredGrid.cast_to_unstructured_grid#
- ExplicitStructuredGrid.cast_to_unstructured_grid() UnstructuredGrid[source]#
Cast to an unstructured grid.
- Returns:
UnstructuredGridAn 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_cellsExtract a subset of a dataset.
pyvista.UnstructuredGrid.cast_to_explicit_structured_gridCast 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#
Download Python source code | Download Jupyter notebook
>>> from pyvista import examples
>>> grid = examples.load_explicit_structured()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
>>> grid = grid.hide_cells(range(80, 120))
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
>>> grid = grid.cast_to_unstructured_grid()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
>>> grid = grid.cast_to_explicit_structured_grid()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)