# Examples from pyvista.UnstructuredGrid.cells
# ============================================

# Return the indices of the first two cells from the example hex
# beam. Note how the cells have "padding" indicating the number
# of points per cell.
import pyvista as pv
from pyvista import examples
grid = examples.load_hexbeam()
grid.cells[:18]

# While you cannot change the array inplace, you can overwrite it. For example:
grid.cells = [8, 0, 1, 2, 3, 4, 5, 6, 7]

# Create a grid with a single tetrahedron defined as a polyhedron. The cells
# only contain its four points and not its faces.
points = [[0, 0, 0], [1, 0, 0], [0.5, 0.5, 0], [0, 0, 1]]
faces = [4, 3, 0, 1, 2, 3, 0, 1, 3, 3, 0, 2, 3, 3, 1, 2, 3]
grid = pv.UnstructuredGrid(
    [len(faces), *faces], [pv.CellType.POLYHEDRON], points
)
grid.cells

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
