Keep lonely edges

Hi,

I have a 3D mesh and I want to keep some lonely edges (these edges help me define boundary conditions) after ridges-detection/re-meshing. Even if a I put the edges in the RequiredEdges list (in the mesh) mmg3D erase it. Here is a minimal non working example:

mmg3d_O3 -ar 85 -noinsert -noswap -nomove -nosurf -in input.mesh -out outs/output.mesh

But the output mesh always has only 4 vertices !!

using
– MMG3d, Release 5.2.1 (Jan 22, 2017)
Copyright © IMB-LJLL, 2004-
Jul 12 2017 15:54:07

Any ideas ???

Thanks
Felipe

file input.mesh ***************

MeshVersionFormatted 2
Dimension 3
Vertices
5
0 0 0 1
1 0 0 2
0 1 0 3
1 1 0 4
0 0 1 5
Edges
1
2 4 5
Triangles
1
1 2 3 6
Tetrahedra
1
1 2 3 5 7
Corners
0
RequiredVertices
5
1
2
3
4
5
Ridges
0
RequiredEdges
1
1
END

file output.mesh

MeshVersionFormatted 2

Dimension 3

Vertices
4
0 0 0 1
1 0 0 2
0 1 0 3
0 0 1 5

Corners
4
1
2
3
4

RequiredVertices
4
1
2
3
4

Tetrahedra
1
1 2 3 4 7

Triangles
4
2 3 4 7
1 4 3 7
1 2 4 7
1 3 2 6

Edges
6
1 3 0
1 2 0
2 4 0
1 4 0
2 3 0
3 4 0

Ridges
6
1
2
3
4
5
6

End

Hi Felipe,

mmg3d is not able to preserve edges/triangles that doesn’t belong to a tetrahedron:

  • during the mesh analysis, Mmg store the edges/triangles informations inside the tetra structure;
  • then it deletes the edges/tria arrays and deal only with tetrahedra;
  • In a last step, Mmg build the new edges/triangles arrays to send it back to the user.

If you want to be able to recover your edges after calling Mmg you will need to call Mmg in library mode. Thus, I suppose here that you have an application with a mesh in your own format and that you pass your mesh to Mmg and call it to perform the mesh modifications.

You can keep your lonely edges following this procedure :

  • Create an array containing the lonely edges;
  • When giving the mesh to Mmg, associate to the reference of the points that are at your lonely edges extremities their indices and set this points to required (this two things are already done in your input mesh);
  • After the remeshing, get back the Mmg mesh (tetra, edges, points…) at your own format;
  • When getting back the new mesh vertices, you can use the point references (that has not been modified) to find the new indices of your lonely edges extremities and to update your lonely edges array;
  • Add the edges of the lonely edge array to your true edge array.

I hope that it will help.

Regards,

Algiane

Thanks Algiane,

But I use the refs to store information about the topological groups (boundary conditions zones) so I can’t use the refs numbers to store the index of the vertex.

I gonna try to use the mmg in library mode ( or modified the mmg3D exec to fit to my needs)

thanks again,
Felipe

Hi Algiane,

Can you point me in the right direction on how to modified the mmg3D exec to keep my lonely edges.
I tried to modified the file hash_3D.c (around lines 1094-1095) to not delete my edges. I comment these two lines and add some lines hash the original edges but I was unable to keep my lines.

I don’t want to use the library because a use almost all the option (with or without) (ar, noisnert, iso) of the mmg3d_03. And I don’t want to write a new mmg3D from scratch.

Thaks

Hi Felipe,

You can try to apply the following patch (git apply lonelyEdges.patch) to the develop branch of Mmg:
lonelyEdges.patch (5.2 KB)

It seems to work (at least on your small example):

  • I have added a new field in the point structure (the init_index field) that is used to store the intial indices of the points that are at edges extremities. It allows to recover the new numbering of your edges. This field is filled when reading the mesh, thus, my addings donesn’t work in library mode. Besides, this new field cannot be keeped in a stable version of Mmg as it is done now but I will propose another solution in developer meeting (transform the ref integer field into an array of integers. By default this array will be of size 1 but the user will have the possibility to modify this size at compilation time).

  • During the edge hashing, the lonely edges are detected and keeped in the edge array while all the other edges are removed from this array (otherwise the “normal” edges will be present twice in the final mesh).

  • When mmg reconstruct the edges array to send it back to the user, it begins by adding the lonely edges (that are in the edge array) while updating the indices of its extremities with the new node numbering.

Let me know if it works on a more complex case.

Regards,

Algiane

Thanks for the patch, but I was unable to make it work. I get a Segmentation fault during the execution; here is the backtrace.

the execution command line is
/home/fbordeu-weld/bin/mmg3d_debug -ar 80 -noinsert -noswap -nomove -nosurf meshfile -out solution.solb

I have a mesh with tets/tris/and edges. some of the edges are connected by one point to a tet. and some edges are connected to other edges (they don’t share a point with a tet)

Program received signal SIGSEGV, strong textSegmentation fault.
0x0000000000434beb in _MMG5_boulesurfvolp (mesh=0x720010, start=8, ip=0, iface=2, listv=0x7ffffffe8d60, ilistv=0x7ffffffe8d58, lists=0x7fffffff2d70, ilists=0x7ffffffe8d5c, isnm=0)
at /home/fbordeu-weld/APPS/mmg/src/mmg3d/boulep_3d.c:505
505 adj = adja[ iopp ] / 4;
Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.166.el6_7.7.x86_64
(gdb) bt
#0 0x0000000000434beb in _MMG5_boulesurfvolp (mesh=0x720010, start=8, ip=0, iface=2, listv=0x7ffffffe8d60, ilistv=0x7ffffffe8d58, lists=0x7fffffff2d70, ilists=0x7ffffffe8d5c, isnm=0)
at /home/fbordeu-weld/APPS/mmg/src/mmg3d/boulep_3d.c:505
#1 0x00000000004e975e in _MMG3D_defsiz_iso (mesh=0x720010, met=0x7201e0) at /home/fbordeu-weld/APPS/mmg/src/mmg3d/isosiz_3d.c:752
#2 0x0000000000447de7 in _MMG5_mmg3d1_delone (mesh=0x720010, met=0x7201e0) at /home/fbordeu-weld/APPS/mmg/src/mmg3d/mmg3d1_delone.c:1221
#3 0x0000000000412d41 in MMG3D_mmg3dlib (mesh=0x720010, met=0x7201e0) at /home/fbordeu-weld/APPS/mmg/src/mmg3d/libmmg3d.c:694
#4 0x0000000000407dc6 in main (argc=10, argv=0x7fffffffdcb8) at /home/fbordeu-weld/APPS/mmg/src/mmg3d/mmg3d.c:398
(gdb) print mesh->adja
$1 = (int *) 0x0

I think the mesh->adja inside the _MMG5_boulesurfvolp is the problem (the value is equal to zero), this explain the segfault.

Felipe

Hi Felipe,

Thank you for the bug report.
In noinsert mode the adja table was not allocated. It is patched, you can pull the develop branch to get the correction.

Regards,
Algiane

Thank,

the last commit solve the problem.

Felipe