pyvista.CellArray

Contents

pyvista.CellArray#

class CellArray(
cells: CellsLike | None = None,
n_cells: int | None = None,
deep: bool | None = None,
)[source]#

PyVista wrapping of vtkCellArray.

Provides convenience functions to simplify creating a CellArray from a numpy array or list.

Deprecated since version 0.44.0: The parameters n_cells and deep are deprecated and no longer used.

Parameters:
cellsnp.ndarray or list, optional

Import an array of data with the legacy vtkCellArray layout, e.g. { n0, p0_0, p0_1, ..., p0_n, n1, p1_0, p1_1, ..., p1_n, ... } Where n0 is the number of points in cell 0, and pX_Y is the Y’th point in cell X.

n_cellsint, optional

The number of cells.

deepbool, default: False

Perform a deep copy of the original cell.

Examples

Create a cell array containing two triangles from the traditional interleaved format

>>> from pyvista.core.cell import CellArray
>>> cellarr = CellArray([3, 0, 1, 2, 3, 3, 4, 5])

Create a cell array containing two triangles from separate offsets and connectivity arrays

>>> from pyvista.core.cell import CellArray
>>> offsets = [0, 3, 6]
>>> connectivity = [0, 1, 2, 3, 4, 5]
>>> cellarr = CellArray.from_arrays(offsets, connectivity)

Methods

CellArray.from_arrays(offsets, connectivity)

Construct a CellArray from offsets and connectivity arrays.

CellArray.from_irregular_cells(cells)

Construct a CellArray from a (n_cells, cell_size) array of cell indices.

CellArray.from_regular_cells(cells[, deep])

Construct a CellArray from a (n_cells, cell_size) array of cell indices.

Attributes

CellArray.cells

Return a numpy array of the cells.

CellArray.connectivity_array

Return the array with the point ids that define the cells' connectivity.

CellArray.n_cells

Return the number of cells.

CellArray.offset_array

Return the array used to store cell offsets.

CellArray.regular_cells

Return an array of shape (n_cells, cell_size) of point indices when all faces have the same size.