Closed AlbertoMQ closed 4 years ago
I need an MWE to reproduce.
My code. Still happens without all the remove functions. 5mm-groove-0.5mm-scan-mm-cropped-2.zip
import numpy as np
import open3d as o3d
import optimesh
myfile = "above file ^"
mesh = o3d.io.read_triangle_mesh(myfile)
mesh = mesh.remove_duplicated_vertices()
mesh = mesh.remove_unreferenced_vertices()
mesh = mesh.remove_duplicated_triangles()
mesh = mesh.remove_degenerate_triangles()
xyz = np.asarray(mesh.vertices)
faces = np.asarray(mesh.triangles)
mymesh, cells = optimesh.odt.fixed_point_uniform(xyz, faces, 1.0e-4, 100)
This code is not complete.
Just added the import statements. Everything else should be there
Yeah, seems like the imports were missing. For me, it was impossible to tell it really was only imports though, so thanks for adding them.
Unfortunately, I still can't run the code. I'm using Python 3.8 which isn't supported by open3d yet. Is it possible to create an MWE without open3d? Otherwise let's just wait.
I can do with pymesh as well. Not sure if it works in 3.8. I know it works for 3.6. There are probably other ways to import the data.
import numpy as np
import pymesh
import optimesh
myfile = "above file ^"
mesh = pymesh.load_mesh(myfile)
xyz = np.copy(np.asarray(mesh.vertices))
faces = np.copy(np.asarray(mesh.faces))
mymesh, cells = optimesh.odt.fixed_point_uniform(xyz, faces, 1.0e-4, 100)
This doesn't work. Error:
AttributeError: module 'pymesh' has no attribute 'load_mesh'
Ah that might have to do with how pymesh was installed, looks like the pip version only takes in .sty and .obj files. I installed using anaconda. conda install -c conda-forge pymesh2
Thanks for trying. I can try and find another package that will load .ply files
https://github.com/nschloe/meshio does. Edit: Fixing a PLY read bug in meshio right now.
I'm getting an error with meshio. Wonder if it has to do with that read bug
AttributeError: 'NoneType' object has no attribute 'groups'
in
line 96, in read_buffer types = m.groups()[:2]
That's what I'm talking about.
I can also load
import trimesh
mesh = trimesh.load(filename)
xyz = np.asarray(mesh.vertices)
faces = np.asarray(mesh.faces)
mymesh, cells = optimesh.odt.fixed_point_uniform(xyz, faces, 1.0e-4, 100)
meshio 4.0.9 can now read it:
import meshio
import optimesh
mesh = meshio.read("5mm-groove-0.5mm-scan-mm-cropped-2.ply")
xyz = mesh.points
faces = mesh.get_cells_type("triangle")
mymesh, cells = optimesh.odt.fixed_point_uniform(xyz, faces, 1.0e-4, 100)
This gives the error
AssertionError: Degenerate cell.
Looking into it.
Okay, that was easy. It seems that you have a proper 3D surface: But since this is a scan, there is no implicit surface as it is here https://github.com/nschloe/optimesh#surface-mesh-smoothing. optimesh is bound to fail then; in your case, after an iteration or so, it produces a degenerate triangle.
I see, so the optimal shape and its gradient needs to be know in order to smooth the mesh.
Indeed. If this is not provided, it may be possible to invent some heuristics, but this is outside the scope of optimesh.
Using Optimesh 0.6.3
Identified degenerate triangle of area 0 with the following vertices which do not give an area of 0.
[ 80.45627594 -37.35506439 -34.14894485] [ 80.27935791 -37.60939026 -34.39572525] [ 80.77883911 -37.62064743 -34.39271545]