点云的凸包是包含所有点的最小凸集
三角网格的凸包是包含所有三角网格的最小凸集
计算点云的凸包并返回三角网格和顶点索引
open3d.geometry.PointCloud.compute_convex_hull()
计算三角网格的凸包并返回三角网格和顶点索引
open3d.geometry.TriangleMesh.compute_convex_hull()
从三角网格创建LineSet
open3d.geometry.LineSet.create_from_triangle_mesh()
import open3d as o3d
if __name__ == "__main__":
print("Displaying pointcloud with convex hull ...")
bunny = o3d.data.BunnyMesh()
mesh = o3d.io.read_triangle_mesh(bunny.path)
mesh.compute_vertex_normals()
o3d.visualization.draw([mesh])
# mesh_ls = o3d.geometry.LineSet.create_from_triangle_mesh(mesh)
# mesh_ls.paint_uniform_color((1, 0, 0))
# o3d.visualization.draw([mesh_ls])
#网格点采样
pcl = mesh.sample_points_poisson_disk(number_of_points=10000)
# 计算点云凸包
hull, _ = pcl.compute_convex_hull()
# 计算网格凸包
#hull, _ = mesh.compute_convex_hull()
#创建线集
hull_ls = o3d.geometry.LineSet.create_from_triangle_mesh(hull)
hull_ls.paint_uniform_color((1, 0, 0))
o3d.visualization.draw([pcl, hull_ls])