MmgTools / mmg

open source software for bidimensional and tridimensional remeshing
http://www.mmgtools.org
Other
367 stars 118 forks source link

Incorrect Hausdorff distance? #29

Open jdumas opened 6 years ago

jdumas commented 6 years ago

Hi,

I'm observing a weird bulging effect with mmgs's surface remeshing. If I take a unit cube and remesh it with the default option, without angle detection (-nr -hausd 0.01), I get the following result:

2018-09-25-165744_2560x1395_scrot

Measuring the Hausdorff distance with the original cube gives me a value of 0.21, which is super large compared to the requested one (0.01). Any idea what went wrong? How is mmg ensuring the Hausdorff distance during the remeshing?

Algiane commented 6 years ago

Hi Jeremie,

Your initial mesh is a cube mesh with 2 triangles per faces?

In fact, Mmg computes the local Hausdorff (and not the global one):

I think that the 0.21 value is the maximal distance between the faces of the initial cube and the final mesh, so the global Hausdorff distance, am I right?

In your case, because the automatic detection of sharp angles is disabled, Mmg "smooth" the geometry according to the normal at vertices that it computes (from the normal at the triangles sharing the vertex) and as you have very few triangles per cube faces, this normal is far from the normal at the cube faces. With sharp angles, Mmg computes 2 normals per point (one for each surface that the sharp angle delimits) so the cube geometry keeped.

To conclude, in your case, you have 2 solutions:

jdumas commented 6 years ago

Thanks for the detailed explanation.

How can we provide ridges to mmg?

In fact I stumbled upon this issue when trying to remesh the Ford engine model. The cylindrical holes are made of long thin triangles, and I'm seeing bulges inside the holes, even with sharp angle detection enabled. I think mmgs should subdivide triangles until a certain edge length is reached before attempting to remesh using local Hausdorff distance maybe? I mean I could also look into doing this preprocessing myself and see if it helps.

Algiane commented 6 years ago

Because of the coarse initial mesh, the surface reconstruction of Mmg is very sensitive to the ridges detection. To give the ridges to Mmg :

If you know it, you can also provide the normals at vertices to Mmg:

jdumas commented 6 years ago

Ok thanks! Any suggestion how to deal with the long triangles in the cylinders of the ford engine model? Would providing correct ridges and vertex-averaged normals on non-feature vertices would be enough to get a good remeshed surface? How does mmg numbers the edges of the mesh? Do I need to explicitly call MMG3D_Set_edge and then call MMG3D_Set_ridge with the same number? If I provide vertex normals with MMG3D_Set_normalAtVertex, will mmgs recompute one normal per incident triangle for vertices on a ridge?

jdumas commented 6 years ago

Just for reference, here is the result I'm getting if I try to remesh the Ford engine model from Thingiverse, as linked above:

2018-09-26-212311_2560x1395_scrot

I just merged duplicated vertices from the .stl, saved as .mesh, and called mmgs with default parameters on it.

Algiane commented 6 years ago

Hi Jeremie,

You made a good point, in fact, providing the vertex averaged normals on non feature vertices is exactly what Mmg computes so the result will be pretty similar. And for now, Mmg always computes its own normals at ridges points so you don't have any way to provide it. But I think that it can be useful to add it (I am not sure about when it can be done but I add it to my todo list).

Having the suitable ridges will strongly help Mmg (see the attached picture) but it seems to not be sufficient. I am not sure why but Mmg still corrupt the geometry in some specific areas.

capture d ecran 2018-09-27 14 53 34

To provide ridges, yes, you must explicitly call MMG3D_Set_edge and then MMG3D_Set_ridge with the edge index.

jdumas commented 6 years ago

How did you generate the above screenshot then? By changing the angle threshold for ridge detection?

Algiane commented 6 years ago

Oh yes, sorry: I use the increase the sensitivity for the sharp edge detection -ar 15 option (just to check that having all the ridges of the cylinder helps). Of course, in consequences, I have some spurious ridges.

jdumas commented 6 years ago

Ok I see. Not completely satisfactory since it still mess up the geometry somehow. Please let me know if you ever find out why.

jdumas commented 6 years ago

Just a note that -- unsurprisingly -- this problem also happens with mmg3d. Here is an example using default ridges in red. The result is over-refined in region where the ridge detection missed the transition to the flat regions. This creates some unwanted bump, although not as bad as on the previous example.

micro

If you're interested let me know and I can upload the input tet mesh.

Algiane commented 6 years ago

Hi Jeremie,

Thank you for the feedback. Yes, it is not suprising that missing some ridges leads to introduce a bunp in the surface: Mmg thinks that the surface is smooth so it computes the normals at vertices taking into account the 2 surfaces that in fact are shared by a sharp angle.

But I am still not sure of what happens here, because in this case, it seems that we have all the ridges but we still destroy the surface.

Regards,

Algiane

pareshspatel commented 4 years ago

Hi Algiane,

MMGS messes up the geometry and causes bulging effect in curved areas with high aspect ratio triangles. Is there a solution or work around for this issue? What is the root cause of the problem? I can help resolve the issue.

Regards,

Paresh

Algiane commented 4 years ago

Hi Paresh,

The bulging effect may have several causes:

Do note hesitate to create a new post around this issue and to attach your input mesh, I can try to see what happens...

Regards, Algiane

pareshspatel commented 4 years ago

Algiane , thank you for your message. I'll create an issue and attach a simple sample model. Thanks!