DataObjectFilters.triangulate

DataObjectFilters.triangulate#

DataObjectFilters.triangulate(
*,
inplace: bool = False,
progress_bar: bool = False,
) → UnstructuredGrid | MultiBlock[source]#

Return an all triangle mesh.

More complex polygons will be broken down into triangles.

Parameters:
inplacebool, default: False

Updates mesh in-place. Only a PolyData or UnstructuredGrid input can be updated in place.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.UnstructuredGrid | pyvista.MultiBlock

Mesh containing only linear cells. A dataset gives an UnstructuredGrid, and a MultiBlock gives a MultiBlock whose blocks each take the path for their own type, nested blocks included, so a PolyData block gives a PolyData through triangulate().

Examples#

Download Python source code | Download Jupyter notebook

Generate a mesh with quadrilateral faces.

>>> import pyvista as pv
>>> plane = pv.Plane()
>>> plane.point_data.clear()
>>> plane.plot(show_edges=True, line_width=5)
../../../_images/pyvista-DataObjectFilters-triangulate-d68b7708d160f8da_00_00.png

Convert it to an all triangle mesh.

>>> mesh = plane.triangulate()
>>> mesh.plot(show_edges=True, line_width=5)
../../../_images/pyvista-DataObjectFilters-triangulate-d68b7708d160f8da_01_00.png