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

How to save converted watertight mesh on local ? #65

Open
HripsimeS opened this issue May 16, 2023 · 7 comments
Open

How to save converted watertight mesh on local ? #65

HripsimeS opened this issue May 16, 2023 · 7 comments

Comments

@HripsimeS
Copy link

@fwilliams @clbarnes @eltociear @maurock @Layer3 Hello

I used point clouds to do create mesh and saved it as .obj file. You can find below the link to the mesh.
https://drive.google.com/file/d/1dPqnw84VP-L4GQFf6MYoAEHHEKTCfEoV/view?usp=share_link

As this mesh is not watertight, I used your library to convert it watertight
https://www.fwilliams.info/point-cloud-utils/sections/watertight_manifold/

import point_cloud_utils as pcu
v, f = pcu.load_mesh_vf("laptop.obj")
resolution = 50_000
vw, fw = pcu.make_mesh_watertight(v, f, resolution)

It worked without errors, but then it is not clear how I can save the converted watertight mesh.
Can you please help to see how save it on local directory somewhere "C:\Users\Me\Desktop\laptop.obj". Thanks in advance!

@HripsimeS
Copy link
Author

I found how to save a converted watertight mesh pcu.save_mesh_vf("C:/Users/Me/Desktop/watertight.obj", vw, fw)
Next step was to check if the converted watertight mesh is really watertight. I used the code below to check it

import open3d as o3d
mesh = o3d.io.read_triangle_mesh("C:/Users/Me/Desktop/watertight.obj")
is_watertight = mesh.is_watertight()
if is_watertight:
print("The mesh is watertight.")
else:
print("The mesh is not watertight.")

Unfortunately the result was "The mesh is not watertight". Do you know how to fix this issue?

@fwilliams
Copy link
Owner

Hi, thanks for bringing this up!

Yes to save a mesh you can use pcu.save_mesh_* where * denotes what attributes you wan to save. (Documentation Here).

Looking at the definition here of is_manifold in open3D it seems that there are three check that determine whether a mesh is manifold.

  1. is_self_intersecting
  2. is_vertex_manifold
  3. is_edge_manifold
    Could you print all of these on your mesh?

Any chance you could also upload the offending input and ouput meshes?

@HripsimeS
Copy link
Author

@fwilliams thanks for your quick reply. Below link is the input mesh and then I just use the code above to convert and save.
https://drive.google.com/file/d/1dPqnw84VP-L4GQFf6MYoAEHHEKTCfEoV/view?usp=share_link

I used the converted mesh and checked with Open3D if it is manifold. The outputs are below.

self_intersecting: True
vertex_manifold: True
edge_manifold: True
watertight: False

I also used Open3D function to compute cubic metre volume mesh.get_volume() and it said the mesh is not watertight. So I don't know if the issue comes from point-cloud-utils converting process or from Open3D library.

@fwilliams
Copy link
Owner

fwilliams commented May 18, 2023 via email

@HripsimeS
Copy link
Author

@fwilliams below you can find the links for input and output meshes, also the code I used to convert to watertight mesh.

https://drive.google.com/file/d/1dPqnw84VP-L4GQFf6MYoAEHHEKTCfEoV/view?usp=share_link Input mesh
https://drive.google.com/file/d/1lOAbaIO8XBG3utwW2aVtJzvyRl0_gf4t/view?usp=share_link Output mesh

import point_cloud_utils as pcu
v, f = pcu.load_mesh_vf("C:/Users/Me/Desktop/laptop.obj")
resolution = 50_000
vw, fw = pcu.make_mesh_watertight(v, f, resolution)
pcu.save_mesh_vf("C:/Users/Me/Desktop/watertight.obj", vw, fw)

@fwilliams
Copy link
Owner

Just took a look.

Indeed it seems like there are self intersections in some very small triangles. These are likely due to numerical errors. The input mesh is low quality which makes this a challenging case.

That said, the mesh is watertight, so if that's all you need then this might be good enough. If not, you can try remeshing or removing the self intersections (meshlab has some tools). Could you elaborate a bit more on your application?

@fwilliams
Copy link
Owner

Any updates on this? Anything I can help with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants