Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to fix incomplete check of the consistency of edge tag inside tetra
Reminder of Mmg data structures
We don't store the edges in a "unique" way inside an edge array.
Instead, each tetra is able to retrieve, for each of its edges, "geometrical" informations (is the edge a
reference
edge, anon-manifold
one, aridge
one...). These informations are stored under the form of binary tags inside aMMG5_xTetra
structure:MMG5_xTetra
structures stores the edge tags inside itstag
array for each of the 6 tetra edges;xt
field of the tetra stores the position of itsMMG5_xTetra
inside the xtetra array.Thus, for an edge shared by multiple tetras, bugs may lead to inconsistencies (differences) between the tags stored by tetra, while tags should be identical in all the tetra that are sharing the edge as soon as the edge is marked as
MG_BDY
inside the tetra (boundary edge belonging to a boundary face).For illustration, on the attached picture, if we suppose that the edge$4^{th}$ edge of the tetra number $1$ and the $2^d$ edge of the tetra $2$ , as soon as the edge belongs to a boundary face in both tetra (edge marked
p-q
is theMG_BDY
in both tetra) we should have:Debug function
MMG3D_chkmeshedgestags
The
MMG3D_chkmeshedgestag
function is provided for debugging purpose and called by theMMG3D_chkmsh
function at the end of the remeshing process (during the mesh packing) when debug mode is enabled (-d
command line option).Incomplete implementation
Initial implementation calls the
MMG5_hashEdgeTag
function which cumulates the edge tags inside a hash table :16
the first time the edge is hased, the function stores the edge with tag16
and returns16
;1
or17
the second time the edge is hased, then the tag of the edge inside the hash table is updated to17
(acumulation of binary tagstag |= 1
ortag |= 17
) and the function returns17
;16
the third time the edge is hashed, then the tag of the edge inside the hash table stays17
and the function still returns17
.In consequence, if the edge
p-q
is processed first from the tetra 1 in which it has tag16
(MG_BDY
) then from the tetra 2 in which it has tag17
(MG_REF & MG_BDY
), the implementation in thedevelop
branch fails to detect the lack of consistency. If tetra are processed in reverse order, the inconsistency is detected because we store first the tag17
in the hash table, then we compare the tag stored inside the xtetra of tetra 2, which is16
with the value stored in the hash table (17
).Fix
The current PR proposes to replace the call to the
MMG5_hashEdgeTag
function by a call to theMMG5_hGet
function. This function:1
if the edge is founded in the hash table and stores the associated tag (so we can compare it with the tetra edge tag);0
if the edge is not founded: in this case, we call theMMG5_hEdge
function to store the edge and the associated tag.It allows to detect inconsistencies independently of the order in which we process the tetra.