DataObjectFilters.convex_hull#
- DataObjectFilters.convex_hull(
- *,
- dimensionality: Literal[1, 2, 3, 'auto'] = 3,
- progress_bar: bool = False,
Compute the convex hull from this mesh’s points.
With
vtk>=9.7, this uses vtkConvexHull. With older VTK,scipy(Qhull) is used instead fordimensionality=2or3;dimensionality=1requiresvtk>=9.7.Added in version 0.49.
- Parameters:
- dimensionality
int| ‘auto’, default: 3 The dimensionality of the hull. If
'auto', the dimensionality is set to this mesh’sdimensionality, that is, points are not assumed to span all three dimensions. Auto-detection has a computational cost and is not enabled by default. Note that a 2D hull is computed from points projected onto this mesh’s best-fit plane, so requestingdimensionality=2(or an auto-detected2) for points that are not coplanar will discard information.- progress_barbool, default:
False Display a progress bar to indicate progress.
- dimensionality
- Returns:
pyvista.PolyDataSurface mesh of the grid.
Examples#
Download Python source code | Download Jupyter notebook
Compute the convex hull of a 3D mesh.
>>> import pyvista as pv
>>> from pyvista import examples
>>> mesh = examples.download_cow_head()
>>> hull = mesh.convex_hull()
Plot the hull with the original input.
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh, color='red')
>>> _ = pl.add_mesh(hull, opacity=0.5, show_edges=True)
>>> cpos = pv.CameraPosition(
... position=(9.159, 1.892, -4.015),
... focal_point=(4.500, 1.731, -0.1015),
... viewup=(0.08577, 0.9861, 0.1426),
... )
>>> pl.camera_position = cpos
>>> pl.show()
Compute the convex hull of two circle meshes comprising a MultiBlock.
>>> circle1 = pv.Circle(radius=0.5)
>>> circle2 = pv.Circle(radius=0.25).translate((1.0, 0.0, 0.0))
>>> mesh = pv.MultiBlock([circle1, circle2])
>>> hull = mesh.convex_hull(dimensionality=2)
Plot the hull with the original input.
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh, color='red')
>>> _ = pl.add_mesh(hull, opacity=0.5, show_edges=True)
>>> pl.view_xy()
>>> pl.show()
Used In#
Gallery Examples