Localized Remesh

Greetings,

In MMGS, is there a way to remesh a subset of the entire mesh using, for example, a mask array?

Thank you,

Patrick

What I’m looking to do is to densify the mesh at particular locations but keep the rest intact.

Perhaps, it is something expensive to do. The other approach would be to keep the same sizing function on all the mesh except the part that I want to densify, but there could be risks­. I’d like to elaborate all the possibilities first.

Thank you!

Hello Patrick,

I have just added this possibility in the develop branch of the Mmg repository:

  • if you start from a file at Medit format (.mesh), you can use the RequiredTriangles field followed by the number of triangles that you don’t want to remesh and the list of the indices of this triangles (see the cube.mesh (9.0 KB)
    file for example: I ask for 2 required triangles, the triangles number 299 and 101 (red triangles in the cube.png picture));

  • If you use Mmg in library mode, you can call the MMGS_Set_requiredTriangle API function (after the triangles setting). For example, to set the triangles of indices 299 and 101 as required:
    if ( !MMGS_Set_requiredTriangle(mmgMesh, 101) ) exit (EXIT_FAILURE);
    if ( !MMGS_Set_requiredTriangle(mmgMesh, 299) ) exit (EXIT_FAILURE);

Two remarks :

  • the gmsh file format doesn’t allow to define required entities (so, this feature of Mmg is not possible starting from a .msh file);
  • to ensure an output mesh of good quality, Mmg erase the size map along the required entities: the size asked along a required edge is replaced by the euclidean edge length. This sizes are propagated to respect a maximal ratio between two adjacent edges. You can disable this feature (but it is not recommended) using the -hgradreq -1 option.

For a better understanding, you can run the 2 following commands and look at their respective outputs (see below):

  • mmgs_O3 cube.mesh -hsiz 0.01
  • mmgs_O3 cube.mesh -hsiz 0.01 -hgradreq -1

Do not hesitate to get back to me if you have other questions.

Regards,
Algiane

1 Like

Wow! That was fast! Many thanks for your help! We can definitely use this. I will report bugs if there is any in the future.

Patrick

I’ve been doing some tests with the algorithm, and it seems to work in most simple cases.

But as soon as I add too many triangles to exclude, some triangles do get remeshed (see image below)

beforeRemesh
afterRemesh

Perhaps, I shouldn’t apply it to triangle strips

I’ve added a second strip of triangles


Observing a similar pattern

I can’t export my mesh into a .mesh. Are there any other standard formats I can use?

Hello,

It remains some bugs in my implementation…
Is it possible to send me a gmsh file? And the parameters used to run Mmg?

Thank you by advance,

Algiane

Hi,

Here is my data. Our implementation does not generate edges in mmg. Can it be a potential problem?

sphere.mesh (29.8 KB)

Parameters are:

MMGS_DPARAM_hmin: 0
MMGS_DPARAM_hmax: 0.1
MMGS_DPARAM_hausd: 0.01
MMGS_DPARAM_angleDetection: 30
MMGS_DPARAM_hgrad: 1.10517
MMGS_IPARAM_noinsert: false
MMGS_IPARAM_noswap: false
MMGS_IPARAM_nomove: false

Patrick

Hi,

The problem was in Mmg (you can provide a mesh without edges): I have made an error in the function that transfers the tags from the edges of one triangle to the neighbour triangles.

It is corrected (develop branch, commit 6c8104771) and seems to work on your example. I hope that there isn’t other hidden bugs.

Regards,
Algiane

Hi,

I can confirm that my example works! I’ve been testing other examples and it doesn’t seem to remesh zones that are required. However, some triangles not required does not get remeshed. Perhaps, my example is a bit unrealistic:

Before:

After:

Mesh File:
sphere2.mesh (32.7 KB)

Parameters:

MMGS_DPARAM_hmin: 0
MMGS_DPARAM_hmax: 0.1
MMGS_DPARAM_hausd: 0.01
MMGS_DPARAM_angleDetection: 30
MMGS_DPARAM_hgrad: 1.10517
MMGS_IPARAM_noinsert: false
MMGS_IPARAM_noswap: false
MMGS_IPARAM_nomove: false

The pattern I’m seeing here is that it needs to have at least 2 triangles close to each other to remesh. I will not get these use cases, but I’m leaving it here if you wish to fix it.

Thank you very much!

Patrick

Hi Patrick,

The non-required triangles that are not remeshed are triangles for which the 3 neighbours are required:

  • If a triangle is required, its 3 boundary edges are required too, and, because we work with conformal meshes, the same edges are required in the neighbour triangles. In the case of a triangle T surrounded by required triangles, it leads to have the 3 edges of T marked as required;

  • the data structure used by Mmg to store triangles doesn’t have any field to mark the triangle as required but it has an array of size 3 associated to the edges of the tria to mark if edges are required. To implement the required triangles I have made the assumption that a triangle with 3 required edges is a required triangle. It is not always true of course but in practice a triangle with 3 required edges is very constrained and, if we remesh it, its quality will degenerate very fast. Moreover, if the gradation linked to the required entities is keeped enabled, it will leads to not remesh such triangles.

I am sorry to not have any solution to propose to keep the possibility to remesh “isolated” non required triangles.

Regards.

1 Like