fwilliams / point-cloud-utils

An easy-to-use Python library for processing and manipulating 3D point clouds and meshes.
https://www.fwilliams.info/point-cloud-utils/
MIT License
1.35k stars 107 forks source link

How to save converted watertight mesh on local ? #65

Open HripsimeS opened 1 year ago

HripsimeS commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

Is this mesh the output of the manifold process?

Could you also send the input?

On Wed, May 17, 2023 at 10:45 AM Hripsime Snkhchyan < @.***> wrote:

@fwilliams https://github.com/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() http://url 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.

— Reply to this email directly, view it on GitHub https://github.com/fwilliams/point-cloud-utils/issues/65#issuecomment-1551536596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKH6AFSRONBRVNIGD7IW7TXGTQBBANCNFSM6AAAAAAYDQ5YNE . You are receiving this because you were mentioned.Message ID: @.***>

-- Sent from my Commodore 64.

HripsimeS commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

Any updates on this? Anything I can help with?