UnstructuredGrid.cell_offsets

UnstructuredGrid.cell_offsets#

property UnstructuredGrid.cell_offsets: NumpyArray[int][source]#

Return the offsets array.

The offsets array has n_cells + 1 values and stores the index into cell_connectivity at which each cell begins. The point ids of cell i are cell_connectivity[cell_offsets[i]:cell_offsets[i + 1]].

Added in version 0.49.

Returns:
numpy.ndarray

Array of cell offsets with n_cells + 1 values.

Notes#

The returned array is read-only and cannot be modified in place. To change the offsets, assign a new array to this property. The number of cells must not change, since celltypes must stay in sync; to change the number of cells, assign to cells or build a new grid. See the examples below.

Examples#

Download Python source code | Download Jupyter notebook

Return the cell offset array. Since this mesh is composed of all hexahedral cells, note how each cell starts at 8 greater than the prior cell.

>>> import pyvista as pv
>>> from pyvista import examples
>>> hex_beam = pv.read(examples.hexbeamfile)
>>> hex_beam.cell_offsets
array([  0,   8,  16,  24,  32,  40,  48,  56,  64,  72,  80,  88,  96,
       104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200,
       208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304,
       312, 320]...)

The array is read-only and writing to it raises a ValueError.

>>> hex_beam.cell_offsets.flags['WRITEABLE']
False

See Also#

cell_connectivity

Point ids that define the cells.

cells

Cells in the legacy padded format.

celltypes

Cell type of each cell.

pyvista.PolyData.face_offsets

Equivalent property for the faces of a polygonal mesh.

polyhedron_face_offsets

Offsets for the faces of polyhedral cells, which VTK stores separately from the cell offsets.