Create a 3D ply file with faces and vertices from numpy array containing vertices
I have the following set of vertices and i would like to create a 3D ply file that have lines and vertices(it would be great to also have faces)
vertices =
[[ 2.304688 -1.882748 -2.1874995]
[-3.007812 1.6 -2.1875005]
[-3.007812 -1.882748 -2.1875005]
[ 2.304688 -1.882748 -2.1874995]
[ 2.304688 1.6 -2.1874995]
[-3.007812 1.6 -2.1875005]
[-3.007812 -1.882748 -2.1875005]
[-3.007813 1.6 2.9687495]
[-3.007813 -1.882748 2.9687495]
[-3.007812 -1.882748 -2.1875005]
[-3.007812 1.6 -2.1875005]
[-3.007813 1.6 2.9687495]
[-3.007813 -1.882748 2.9687495]
[ 2.304687 1.6 2.9687505]
[ 2.304687 -1.882748 2.9687505]
[-3.007813 -1.882748 2.9687495]
[-3.007813 1.6 2.9687495]
[ 2.304687 1.6 2.9687505]
[ 2.304687 -1.882748 2.9687505]
[ 2.304688 1.6 -2.1874995]
[ 2.304688 -1.882748 -2.1874995]
[ 2.304687 -1.882748 2.9687505]
[ 2.304687 1.6 2.9687505]
[ 2.304688 1.6 -2.1874995]
[ 2.304687 1.6 2.9687505]
[-3.007813 1.6 2.9687495]
[-3.007812 1.6 -2.1875005]
[-3.007812 1.6 -2.1875005]
[ 2.304688 1.6 -2.1874995]
[ 2.304687 1.6 2.9687505]]
Right now I can create a a ply file containing the vertices using the following:
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(vertices)
o3d.visualization.draw_geometries([pcd])
When I display it in Open3D i can obviously only see the vertices. I would like to be able to see also the lines and the faces if it is possible.
How can I do that?
It's not possible to restruct a mesh from its vertices only. What you can do is create mesh of the convex hull of the points. Check out SciPy's Delaunay.
For writing PLY files (and many other formats), you can use meshio. (Disclaimer: I wrote meshio.)