Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converting pointcloud to watertight mesh #170

Open
RohanChacko opened this issue May 27, 2020 · 13 comments
Open

Converting pointcloud to watertight mesh #170

RohanChacko opened this issue May 27, 2020 · 13 comments
Labels
help-wanted Nice question! Extra attention is needed

Comments

@RohanChacko
Copy link

Hi

I am pretty new to pyvista and was looking to convert a numpy (n,3) array to a watertight mesh. I have a pointcloud like this (zoomed in):
pointcloud

And I convert it to a mesh by:

poly = pv.PolyData(points)
shell = poly.delaunay_3d(alpha=0.005, progress_bar=True)
shell = shell.extract_geometry().triangulate()

But this is the result I end up with. There are significant holes in the reconstructed mesh:
image

I tried using pymeshfix as pointed out in the other issues but was not able to fill the holes in the mesh. It looks like delaunay_3d creates triangles that overlap? Is there a way to reconstruct a watertight mesh for the same?

The pointcloud and mesh are in: mesh_repair.zip

@akaszynski
Copy link
Member

@RohanChacko, I played around with this dataset and wasn't able to get delaunay_3d to give me an acceptable mesh to input into pymeshfix. @banesullivan, can you think of any other tools that might be able to perform a reasonable 3D triangulation of a point cloud?

@banesullivan banesullivan added the help-wanted Nice question! Extra attention is needed label May 28, 2020
@banesullivan
Copy link
Member

The delaunay_3d filter is all we really have to offer in PyVista for this and unfortuneatley, I could not get it to work with this dataset either. PyntCloud would be my next go to for this sort of point cloud to mesh problem which has a nice interface to PyVista

@banesullivan
Copy link
Member

If you do find a solution down the road, please be sure to report back so we can know for future reference!

@RohanChacko
Copy link
Author

Hi,
PyntCloud also seems to have Delaunay3D. Is it the same implementation or is there some other solution I should be using?

@banesullivan
Copy link
Member

It isn't the same implementation, but I would be surprised if the results are any different

@banesullivan
Copy link
Member

Actually, it'd be worth trying their Delaunay 3D structure or the Voxel grid structure as your data seems to have some sort of regularness to it

@ttsesm
Copy link

ttsesm commented Jun 3, 2020

@RohanChacko you could try the open3d lib they support some nice surface reconstruction algorithms http://www.open3d.org/docs/release/tutorial/Advanced/surface_reconstruction.html https://towardsdatascience.com/5-step-guide-to-generate-3d-meshes-from-point-clouds-with-python-36bad397d8ba and it is quite easy to jump from pyvista to it and vice versa.

@banesullivan
Copy link
Member

Ah yes, I totally forgot about open3d. In the past, I had used this for some meshing of point clouds.

Here's a function I made at the time but I don't know if it's too relevant/helpful here:

import open3d as o3d

def poisson_mesh(pc, depth=8, width=0, scale=1.1, linear_fit=False):
    """`pc` is a `pyvista.PolyData` point cloud. The default arguments are abitrary"""
    cloud = o3d.geometry.PointCloud()
    cloud.points = o3d.utility.Vector3dVector(pc.points)
    cloud.normals = o3d.utility.Vector3dVector(pc["norms"])
    trimesh, _ = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(cloud, depth=depth, width=width, scale=scale, linear_fit=linear_fit)
    v = np.asarray(trimesh.vertices)
    f = np.array(trimesh.triangles)
    f = np.c_[np.full(len(f), 3), f]
    mesh = pv.PolyData(v, f)
    return mesh.clean()

Basically I was taking point clouds like:

2020-06-04 21 54 26

and creating meshed surfaces:

download

not exactly the same thing as creating water tight meshes, but hopefully this helps you see the logic of working between PyVista and open3d

@bluetyson
Copy link

Interesting example, anyway!

@adam-grant-hendry
Copy link

adam-grant-hendry commented Sep 9, 2021

@akaszynski and @banesullivan What about GaussianSplatting? Would that work and does pyvista support it? I know VTK has it (see SplatFace). Though I do like the BallPivoting algorithm in open3d!

@akaszynski
Copy link
Member

Surface reconstruction is an open issue that we've only partially resolved with Surface Reconstruction. If we want to support ball pivoting or additional algorithms, a PR would be really helpful as I'm swamped (though we all are)...

@PyCody
Copy link

PyCody commented Feb 8, 2023

Hi,

I am using pyvista's reconstruct_surface to generate a mesh from a 3D point cloud. The visual result is impressive but something looks wrong with the curvature.

By mesh.plot_curvature I observe very similar values (for mean curvature) in both flat and more curved regions. I also computed the mean curvature values with a custom algorithm for the discrete Laplace-Beltrami operator and I still had a very little variance in curvatures.

Then I guess this depends on the definition of the mesh/ connection between points.

Have you already faced this problem? Can you help me?

Thank you in advance!

@banesullivan
Copy link
Member

This support forum is now closed. Please open a new discussion topic here: https://github.com/pyvista/pyvista/discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Nice question! Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants