yalezhang2021
yalezhang2021

Reputation: 1

How to export 3d delaunay triangle mesh with python?

I want to use scipy.spatial.delaunay get the triangle mesh from the 3d point cloud. And i use trimesh to save the triangle mesh as .ply form. But the result seems bad. All points play roles as vertices, so it works slowly and bad... how can i get a better mesh output with this delaunay method?

Code:

#pcd is 3d point cloud 
tri = Delaunay(pcd)   
#faces
f = tri.simplices
# Mesh
mesh = trimesh.Trimesh(vertices=pos_combine, faces=f)
# show mesh and export it
mesh.show()
mesh.export(file_obj="mesh.ply")

Upvotes: 0

Views: 1431

Answers (1)

Nico Schlömer
Nico Schlömer

Reputation: 58791

I write meshio for this. Just do

import meshio

meshio.Mesh(pcd, {"triangles": tri.simplices}).write("out.ply")

should do the job.

Upvotes: -1

Related Questions