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_cellvtkCell, optional

The vtk object to wrap as Cell, that must be of 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#

Download Python source code | Download Jupyter notebook

Get cell 0 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 cell 0 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

See Also#

pyvista.CellType

Inheritance#

Inherited members are documented on _BoundsSizeMixin, DataObject.

See them all under Inherited Attributes and Inherited Methods.

Wraps vtkGenericCell.

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.

Inherited Attributes#

DataObject.actual_memory_size

Return the actual size of the dataset object.

_BoundsSizeMixin.bounds_size

Return the size of each axis of the object’s bounding box.

DataObject.field_data

Return FieldData as DataSetAttributes.

DataObject.is_empty

Return True if the object is empty.

DataObject.memory_address

Get address of the underlying VTK C++ object.

DataObject.user_dict

Set or return a user-specified data dictionary.

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 edge at index composing the cell.

Cell.get_face(index)

Get the face at index composing the cell.

Cell.plot(**kwargs)

Plot this cell.

Inherited Methods#

DataObject.add_field_data

Add field data.

DataObject.cast_to_multiblock

Convert this DataObject to a MultiBlock.

DataObject.clear_field_data

Remove all field data.

DataObject.copy_attributes

Copy the data attributes of the input dataset object.

DataObject.copy_meta_from

Copy pyvista meta data onto this object from another object.

DataObject.copy_structure

Copy the structure (geometry and topology) of the input dataset object.

DataObject.deep_copy

Overwrite this data object with another data object as a deep copy.

DataObject.get_data_range

Get the non-NaN min and max of a named array.

DataObject.head

Return the header stats of this dataset.

DataObject.save

Save this vtk object to file.

DataObject.shallow_copy

Shallow copy the given mesh to this mesh.