pyvista.Cell

Contents

pyvista.Cell#

class Cell(*args, **kwargs)[source]#

Wrapping of vtkCell.

This class provides the capability to access a given cell topology and can be useful when walking through a cell’s individual faces or investigating cell properties.

Parameters:
vtk_cellvtk.vtkCell, optional

The vtk object to wrap as Cell, that must be of vtk.vtkCell type.

cell_typeint, optional

VTK cell type. Determined from vtk_cell if not input.

deepbool, default: False

Perform a deep copy of the original cell.

Notes

Accessing individual cells from a pyvista.DataSet using this class will be much slower than accessing bulk data from the pyvista.PolyData.faces or pyvista.UnstructuredGrid.cells attributes.

Also note that the cell object is a deep copy of the original cell and is unassociated with the original cell. Changing any data of that cell (for example, pyvista.Cell.points) will not change the original dataset.

Examples

Get the 0-th cell from a pyvista.PolyData.

>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> cell = mesh.get_cell(0)
>>> cell  
Cell (0x7fa760075a10)
  Type:       <CellType.TRIANGLE: 5>
  Linear:     True
  Dimension:  2
  N Points:   3
  N Faces:    0
  N Edges:    3
  X Bounds:   -5.406e-02, -5.551e-17
  Y Bounds:   0.000e+00, 1.124e-02
  Z Bounds:   -5.000e-01, -4.971e-01

Get the 0-th cell from a pyvista.UnstructuredGrid.

>>> from pyvista import examples
>>> mesh = examples.load_hexbeam()
>>> cell = mesh.get_cell(0)
>>> cell  
Cell (0x7fdc71a3c210)
  Type:       <CellType.HEXAHEDRON: 12>
  Linear:     True
  Dimension:  3
  N Points:   8
  N Faces:    6
  N Edges:    12
  X Bounds:   0.000e+00, 5.000e-01
  Y Bounds:   0.000e+00, 5.000e-01
  Z Bounds:   0.000e+00, 5.000e-01

Methods

Cell.cast_to_polydata()

Cast this cell to PolyData.

Cell.cast_to_unstructured_grid()

Cast this cell to an unstructured grid.

Cell.copy([deep])

Return a copy of the cell.

Cell.get_edge(index)

Get the i-th edge composing the cell.

Cell.get_face(index)

Get the i-th face composing the cell.

Cell.plot(**kwargs)

Plot this cell.

Attributes

Cell.bounds

Get the cell bounds in (x_min, x_max, y_min, y_max, z_min, z_max).

Cell.center

Get the center of the cell.

Cell.dimension

Return the cell dimension.

Cell.edges

Return a list of edges composing the cell.

Cell.faces

Return a list of faces composing the cell.

Cell.is_linear

Return if the cell is linear.

Cell.n_edges

Get the number of edges composing the cell.

Cell.n_faces

Get the number of faces composing the cell.

Cell.n_points

Get the number of points composing the cell.

Cell.point_ids

Get the point IDs composing the cell.

Cell.points

Get the point coordinates of the cell.

Cell.type

Get the cell type from the enum pyvista.CellType.