Refactoring MMG5_chkBdryTria#259
Conversation
| if ( k!=nbl ) { | ||
| pttnew = &mesh->tria[nbl]; | ||
| memcpy(pttnew,ptt,sizeof(MMG5_Tria)); | ||
| } |
There was a problem hiding this comment.
I think that we can remove / extract this from the loop and just delete extra triangles inside the loop.
Then, after the loop (so outside the MMG5_chkbdryTria_deleteExtraBoundaries() func), it should be possible to :
- travel triangles
- detect the deleted tria
- pack the array accordingly
- update the perm array for ParMmg only
There was a problem hiding this comment.
something like that :
nt=0; nbl=1;
for (k=1; k<=mesh->nt; k++) {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) continue;
++nt;
if ( k!=nbl ) {
pttnew = &mesh->tria[nbl];
memcpy(pttnew,ptt,sizeof(MMG5_Tria));
if ( permtria ) {
permtria[k] = nbl;
}
}
}
There was a problem hiding this comment.
Or more elegant but also more error-prone (I am not sure that it works ;-) )
k = 1;
do {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) {
pttnew = &mesh->tria[mesh->nt];
assert( ptt && pttnew && MG_EOK(pttnew) );
memcpy(ptt,pttnew,sizeof(MMG5_Tria));
if ( permtria ) permtria[mesh->nt] = k;
ptt->v[0] = 0;
mesh->nt--;
}
}
while ( ++k < mesh->nt );
| if ( k!=nbl ) { | ||
| pttnew = &mesh->tria[nbl]; | ||
| memcpy(pttnew,ptt,sizeof(MMG5_Tria)); | ||
| } |
There was a problem hiding this comment.
something like that :
nt=0; nbl=1;
for (k=1; k<=mesh->nt; k++) {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) continue;
++nt;
if ( k!=nbl ) {
pttnew = &mesh->tria[nbl];
memcpy(pttnew,ptt,sizeof(MMG5_Tria));
if ( permtria ) {
permtria[k] = nbl;
}
}
}
| } | ||
| else if ( j > 0 ) { | ||
| /* the face already exists in the tria table */ | ||
| continue; |
There was a problem hiding this comment.
I think that here we can insert the tria deletion in order to perform the compression of triangle array outside the loop (see comment where the array is currently packed).
With something like : ptt->v[0] = 0; MG_EOK(ptt) should be false.
| if ( k!=nbl ) { | ||
| pttnew = &mesh->tria[nbl]; | ||
| memcpy(pttnew,ptt,sizeof(MMG5_Tria)); | ||
| } |
There was a problem hiding this comment.
Or more elegant but also more error-prone (I am not sure that it works ;-) )
k = 1;
do {
ptt = &mesh->tria[k];
if ( !MG_EOK(ptt) ) {
pttnew = &mesh->tria[mesh->nt];
assert( ptt && pttnew && MG_EOK(pttnew) );
memcpy(ptt,pttnew,sizeof(MMG5_Tria));
if ( permtria ) permtria[mesh->nt] = k;
ptt->v[0] = 0;
mesh->nt--;
}
}
while ( ++k < mesh->nt );
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #259 +/- ##
===========================================
+ Coverage 43.96% 43.98% +0.01%
===========================================
Files 179 179
Lines 54102 54124 +22
Branches 10249 10252 +3
===========================================
+ Hits 23786 23805 +19
Misses 22599 22599
- Partials 7717 7720 +3 ☔ View full report in Codecov by Sentry. |
This update refactorizes the function
MMG_chkBdryTria. It is now written as a sequence of several sub-functions. It does not modify the behaviour or features of mmg. However, this update is necessary for parmmg, in order to take into account the fact that we pack themesh->triaarray when extra triangles are deleted from it.This update primarily ensures the maintainability of the code and avoids redundancy in mmg and parmmg.