DataObjectFilters.cell_centers

Contents

DataObjectFilters.cell_centers#

DataObjectFilters.cell_centers(
vertex: bool = True,
pass_cell_data: bool = True,
progress_bar: bool = False,
)[source]#

Generate points at the center of the cells in this dataset.

These points can be used for placing glyphs or vectors.

Parameters:
vertexbool, default: True

Enable or disable the generation of vertex cells.

pass_cell_databool, default: True

If enabled, pass the input cell data through to the output.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData

Polydata where the points are the cell centers of the original dataset.

Examples

>>> import pyvista as pv
>>> mesh = pv.Plane()
>>> mesh.point_data.clear()
>>> centers = mesh.cell_centers()
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(mesh, show_edges=True)
>>> actor = pl.add_points(
...     centers,
...     render_points_as_spheres=True,
...     color='red',
...     point_size=20,
... )
>>> pl.show()
../../../_images/pyvista-DataObjectFilters-cell_centers-953c188f8560d781_00_00.png

See Extract Cell Centers for more examples using this filter.