UnstructuredGrid.cells_dict#
- property UnstructuredGrid.cells_dict: dict[np.uint8, NumpyArray[int] | list[NumpyArray[int]]][source]#
Return a dictionary that contains all cells mapped from cell types.
This function returns a
numpy.ndarrayfor each cell type in an ordered fashion. For a cell type whose cells all have the same number of points the value is a single[N, D]array; for a cell type with a data-defined number of points whose cells differ in size (e.g.POLYGON) the value is instead a list ofN1D arrays, one per cell.Changed in version 0.46: An empty dict
{}is returned instead ofNoneif the input is empty.Changed in version 0.49: Cell types with a data-defined number of points are now supported (previously this raised a
ValueError).- Returns:
dictA dictionary mapping containing all cells of this unstructured grid. Structure: vtk_enum_type (int) -> cells (
numpy.ndarray).
See also
Examples
Return the cells dictionary of the sample hex beam. Note how there is only one key/value pair as the hex beam example is composed of only all hexahedral cells, which is
CellType.HEXAHEDRON, which evaluates to 12.Also note how there is no padding for the cell array. This approach may be more helpful than the
cellsproperty when extracting cells.>>> import pyvista as pv >>> from pyvista import examples >>> hex_beam = pv.read(examples.hexbeamfile) >>> hex_beam.cells_dict {12: array([[ 0, 2, 8, 7, 27, 36, 90, 81], [ 2, 1, 4, 8, 36, 18, 54, 90], [ 7, 8, 6, 5, 81, 90, 72, 63], ... [44, 26, 62, 98, 11, 10, 13, 17], [89, 98, 80, 71, 16, 17, 15, 14], [98, 62, 53, 80, 17, 13, 12, 15]])}