CellArray.from_regular_cells

CellArray.from_regular_cells#

classmethod CellArray.from_regular_cells(cells: MatrixLike[int], deep: bool = False) CellArray[source]#

Construct a CellArray from cells which all have the same size.

Use this method when every cell has the same number of points, e.g. an array of triangles or an array of quads. The cell offsets are computed directly from the cell size, and the input array is used as the connectivity array. Use from_irregular_cells() instead if the cells have varying sizes.

Parameters:
cellsnumpy.ndarray or list[list[int]]

Cell array of shape (n_cells, cell_size) where all cells have the same cell_size.

deepbool, default: False

Whether to deep copy the cell array data into the vtk connectivity array. If False, the returned cell array may share memory with cells.

Returns:
pyvista.CellArray

Constructed CellArray.

See also

from_irregular_cells

Equivalent method for cells with varying sizes.

regular_cells

Read the cells back as a (n_cells, cell_size) array.

Examples#

Download Python source code | Download Jupyter notebook

Create a cell array of two triangles.

>>> import pyvista as pv
>>> cells = pv.CellArray.from_regular_cells([[0, 1, 2], [1, 2, 3]])
>>> cells.n_cells
2
>>> cells.regular_cells
array([[0, 1, 2],
       [1, 2, 3]]...)