CellArray.from_irregular_cells#
- classmethod CellArray.from_irregular_cells(cells: MatrixLike[int]) CellArray[source]#
Construct a
CellArrayfrom 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 nodeepparameter, since building the connectivity array always makes a copy of the input.- Parameters:
- cells
Sequence[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.
- cells
- Returns:
pyvista.CellArrayConstructed
CellArray.
See also
from_regular_cellsEquivalent method for cells which all have the same size.
offset_arrayOffsets 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]...)