CellArray.from_irregular_cells

CellArray.from_irregular_cells#

classmethod CellArray.from_irregular_cells(cells: MatrixLike[int]) CellArray[source]#

Construct a CellArray from cells which may have different sizes.

Use this method when the cells have varying numbers of points, e.g. a mix of triangles and quads. The cell offsets are computed from the length of each cell, and the connectivity array is built by concatenating the cells. Use from_regular_cells() instead if all cells have the same size.

Unlike from_regular_cells(), this method has no deep parameter, since building the connectivity array always makes a copy of the input.

Parameters:
cellsSequence[Sequence[int]]

Sequence of length n_cells where each item is a sequence of the point indices for that cell. The cells may have different lengths.

Returns:
pyvista.CellArray

Constructed CellArray.

See also

from_regular_cells

Equivalent method for cells which all have the same size.

offset_array

Offsets marking where each cell begins in the connectivity array.

Examples#

Download Python source code | Download Jupyter notebook

Create a cell array from a triangle and a quad.

>>> import pyvista as pv
>>> cells = pv.CellArray.from_irregular_cells([[0, 1, 2], [1, 2, 3, 4]])
>>> cells.n_cells
2
>>> cells.connectivity_array
array([0, 1, 2, 1, 2, 3, 4]...)
>>> cells.offset_array
array([0, 3, 7]...)