# Examples from pyvista.DataObjectFilters.convex_hull
# ===================================================

# 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()

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
