44 int8_t iedg,int64_t *list,
int ilist,int8_t typchk) {
47 double calold,calnew,caltmp,ll,lon;
57 if ( typchk == 2 && met->
m ) {
66 calold = calnew = DBL_MAX;
67 for (j=0; j<ilist; j++) {
73 for (jj=0; jj<4; jj++)
if ( pt->
v[jj] == nq )
break;
74 if ( jj < 4 )
continue;
83 for (jj=0; jj<3; jj++) {
97 for (jj=0; jj<3; jj++) {
103 assert ( 0 &&
"Uncomment this test, it is not useless");
113 if ( met->
size==6 ) {
118 for (jj=0; jj<3; jj++) {
132 for (jj=0; jj<3; jj++) {
140 assert ( 0 &&
"Uncomment this test, it is not useless");
151 if ( typchk==1 && met->
m && met->
size > 1 )
157 calnew =
MG_MIN(calnew,caltmp);
159 if ( typchk == 2 && met->
m ) {
160 for (jj=0; jj<6; jj++) {
168 ll = MMG5_lenedgspl(
mesh,met,jj,pt0);
169 if ( (!ll) || (ll > lon) )
174 if ( calold <
MMG5_EPSOK && calnew <= calold )
return 0;
175 else if ( calnew <
MMG5_EPSOK || calnew < 0.3*calold )
return 0;
198 MMG5_int *iel,int8_t *iopp) {
201 int8_t i,ipiv,isface;
231 while ( adj && ( adj != end ) && !isface );
259 double n0[3],n1[3],devnew;
260 MMG5_int nump,numq,iel,jel,jel1,nap,nbp,naq,nbq,nro;
261 int8_t ip,iq,iopp,i,j,j1,jface,jface1;
275 jface = lists[1] % 4;
278 for (j=0; j<3; j++) {
280 if ( pt->
v[i] != nump && pt->
v[i] != nro )
break;
292 else if ( nap == naq ) {
296 assert (
mesh->
tetra[k].
xt &&
"initial tetra is not boundary");
307 devnew = n0[0]*n1[0] + n0[1]*n1[1] + n0[2]*n1[2];
308 if ( devnew < mesh->
info.
dhd )
return 0;
312 jel1 = lists[ilists-1] / 4;
313 jface1 = lists[ilists-1] % 4;
315 for (j1=0; j1<3; j1++) {
317 if ( pt->
v[i] != nump && pt->
v[i] != numq )
break;
322 jel = lists[ilists-2] / 4;
323 jface = lists[ilists-2] % 4;
325 for (j=0; j<3; j++) {
327 if ( pt->
v[i] != nump && pt->
v[i] != nro )
break;
339 else if ( nbp == nbq ) {
353 devnew = n0[0]*n1[0] + n0[1]*n1[1] + n0[2]*n1[2];
354 if ( devnew < mesh->
info.
dhd )
return 0;
382 uint16_t *tag,MMG5_int *ref, MMG5_int piv,MMG5_int adj,
390 while ( adj && (adj != start) ) {
442 MMG5_int piv,na,nb,adj,*adja;
447 assert( start >= 1 &&
MG_EOK(pt) );
457 *tag |= pxt->
tag[ia];
477 assert ( (adj == start) || filled );
480 else if ( adj < 0 )
return 0;
491 if ( adj < 0 )
return 0;
528 int8_t iedg,int64_t *listv,
int ilistv,MMG5_int *lists,
int ilists,
529 MMG5_int refmin,MMG5_int refplus, int8_t typchk,
int isnm,int8_t isnmint) {
534 double calold,calnew,caltmp,nadja[3],nprvold[3],nprvnew[3],ncurold[3],ncurnew[3];
535 double ps,devold,devnew,hmax,hausd;
536 MMG5_int nump,numq,ndepmin,ndepplus,l,kk,iel;
537 int nr,nbbdy,isloc,iedgeOpp,ipp;
539 int8_t iopp,iopp2,ia,ip,i,iq,i0,i1,
ier,isminp,isplp;
557 nprvold[0] = nprvold[1] = nprvold[2] = 0.;
558 ncurold[0] = ncurold[1] = ncurold[2] = 0.;
559 nprvnew[0] = nprvnew[1] = nprvnew[2] = 0.;
560 ncurnew[0] = ncurnew[1] = ncurnew[2] = 0.;
563 ndepmin = ndepplus = 0;
573 if ( ilists <= 2 )
return 0;
580 calold = calnew = DBL_MAX;
581 for (l=0; l<ilistv; l++) {
584 assert(iel && ipp >=0 && ipp < 4 &&
"unexpected tetra or local vertex idx");
589 if ( pt->
ref == refmin ) isminp = 1;
590 else if ( pt->
ref == refplus ) isplp = 1;
594 for (iq=0; iq<4; iq++)
595 if ( pt->
v[iq] == numq )
break;
603 for (i=0; i<4; i++) {
611 else if ( nbbdy == 3 ) {
628 for (i=0; i<4; i++) {
629 if ( i==ipp || i==iq ) {
638 uint16_t tag0,tag1,tag2;
639 MMG5_int ref0,ref1,ref2;
641 tag0 = tag1 = tag2 = 0;
642 ref0 = ref1 = ref2 = 0;
645 fprintf(stderr,
"\n ## Error: %s: 0. unable to get edge info.\n",__func__);
649 fprintf(stderr,
"\n ## Error: %s: 1. unable to get edge info.\n",__func__);
653 fprintf(stderr,
"\n ## Error: %s: 2. unable to get edge info.\n",__func__);
668 if ( (!ndepmin) && (pt->
ref == refmin) ) {
671 else if ( (!ndepplus) && (pt->
ref == refplus) ) {
678 if ( met && met->
m && met->
size == 6 ) {
682 for (iq=0; iq<3; iq++) {
689 if ( nr==3 )
return 0;
697 if ( typchk==1 && met->
m && met->
size > 1 )
703 calnew =
MG_MIN(calnew,caltmp);
705 if ( calold <
MMG5_EPSOK && calnew <= calold )
return 0;
706 else if ( calnew <
MMG5_EPSOK || calnew < 0.3*calold )
return 0;
713 for (l=1; l<ilists-1; l++) {
716 assert(iel && iopp >=0 && iopp < 4 &&
"unexpected tetra or local vertex idx");
723 for (ip=0; ip<4; ip++)
724 if ( pt->
v[ip] == nump )
break;
727 if ( ip==4 )
return 0;
736 ps = ncurold[0]*ncurnew[0] + ncurold[1]*ncurnew[1] + ncurold[2]*ncurnew[2];
737 if ( ps < 0.0 )
return 0;
747 if (
ier < 0 )
return -1;
748 else if (!
ier )
return 0;
750 devnew = nadja[0]*ncurnew[0] + nadja[1]*ncurnew[1] + nadja[2]*ncurnew[2];
752 if ( devnew < mesh->
info.
dhd )
return 0;
761 iopp2 = lists[0] % 4;
766 for (ipp=0; ipp<3; ipp++)
767 if ( pt1->
v[
MMG5_idir[iopp2][ipp]] == nump )
break;
775 if (
ier < 0 )
return -1;
776 else if ( !
ier )
return 0;
778 devnew = nadja[0]*ncurnew[0] + nadja[1]*ncurnew[1] + nadja[2]*ncurnew[2];
779 if ( devnew < mesh->
info.
dhd ) {
790 devold = nprvold[0]*ncurold[0] + nprvold[1]*ncurold[1] + nprvold[2]*ncurold[2];
791 devnew = nprvnew[0]*ncurnew[0] + nprvnew[1]*ncurnew[1] + nprvnew[2]*ncurnew[2];
794 if ( devnew < devold ) {
807 for (i=0; i<3; i++) {
808 if ( tt.
v[i] == nump )
break;
812 if ( i==3 )
return 0;
820 else if ( l == ilists-2 ) {
821 for (i=0; i<3; i++) {
822 if ( tt.
v[i] == nump )
break;
832 for (i=0; i<3; i++) {
833 if ( tt.
v[i] == nump )
break;
836 if ( i==3 )
return 0;
849 if ( par->
ref != pt->
ref )
continue;
863 if ( par->
ref != tt.
ref )
continue;
875 if ( par->
ref != tt.
ref )
continue;
888 memcpy(nprvold,ncurold,3*
sizeof(
double));
889 memcpy(nprvnew,ncurnew,3*
sizeof(
double));
896 kk = lists[ilists-1] / 4;
897 iopp2 = lists[ilists-1] % 4;
902 for (ipp=0; ipp<3; ipp++)
903 if ( pt1->
v[
MMG5_idir[iopp2][ipp]] == nump )
break;
911 if (
ier < 0 )
return -1;
912 else if ( !
ier )
return 0;
914 devnew = nadja[0]*ncurnew[0] + nadja[1]*ncurnew[1] + nadja[2]*ncurnew[2];
916 if ( devnew < mesh->
info.
dhd ) {
923 if ( !
ier )
return 0;
928 if (
ier<0 )
return -1;
929 else if ( !
ier )
return 0;
960 for ( j=0; j<3; j++ ) {
964 if ( pxt->
tag[ia] ) {
965 for ( i=0; i<3; i++ ) {
984 tag1 = pxt1->
tag[iav];
986 pxt1->
tag[iav] |= pxt->
tag[ia];
989 pxt1->
tag[iav] &= ~MG_NOSURF;
1013 uint16_t tag,MMG5_int ref, MMG5_int piv,MMG5_int adj) {
1020 assert ( tag &
MG_BDY &&
"Unexpected non boundary tag");
1022 while ( adj && (adj != start) ) {
1038 if ( xtag == tag && pxt->
edg[i] == ref ) {
1047 pxt->
tag[i] &= ~MG_NOSURF;
1080 MMG5_int piv,na,nb,adj,*adja;
1085 assert( start >= 1 &&
MG_EOK(pt) &&
"invalid tetra" );
1086 assert ( tag &
MG_BDY &&
"Unexpected non boundary tag");
1101 if ( xtag == tag && pxt->
edg[ia] == ref ) {
1106 pxt->
tag[ia] |= tag;
1109 pxt->
tag[ia] &= ~MG_NOSURF;
1121 if ( adj == start )
return 1;
1122 else if ( adj < 0 )
return 0;
1133 if ( adj < 0 )
return 0;
1158 MMG5_int iel,jel,pel,qel,k,np,nq,*adja;
1159 uint8_t ip,iq,j,voy,voyp,voyq;
1172 const int8_t MMG5_coledge[6][4] = {
1173 {1,3,2,4}, {0,3,2,5}, {0,4,1,5},{0,1,4,5}, {0,2,3,5}, {4,3,2,1} };
1182 for (k=0; k<ilist; k++) {
1187 for (j=0; j<3; j++) {
1189 if ( pt->
v[iq] == nq ) {
1198 for (k=0; k<ilist; k++) {
1200 if ( list[k] < 0 )
continue;
1207 if ( !jel )
continue;
1212 if (pt->
v[voy] == nq) {
1222 for (k=0; k<ilist; k++) {
1224 if ( list[k] > 0 )
continue;
1230 for (j=0; j<3; j++) {
1232 if ( pt->
v[iq] == nq ) {
1242 const int8_t *coled;
1246 coled = MMG5_coledge[0];
1250 coled = MMG5_coledge[1];
1254 coled = MMG5_coledge[2];
1258 coled = MMG5_coledge[3];
1262 coled = MMG5_coledge[4];
1266 coled = MMG5_coledge[5];
1269 assert ( 0 &&
"Unexpected collapse configuration");
1273 for ( l=0; l<3; l+=2 ) {
1278 int iped = coled[l+0];
1279 int iqed = coled[l+1];
1287 fprintf(stderr,
"\n ## Error: %s: 1. unable to get edge info.\n",__func__);
1291 fprintf(stderr,
"\n ## Error: %s: 2. unable to get edge info.\n",__func__);
1295 if ( (tagip != tagiq) || (refip != refiq) ) {
1298 refip = (refip > refiq )? refip : refiq;
1304 fprintf(stderr,
"\n ## Error: %s: 1. unable to update edge info.\n",__func__);
1308 fprintf(stderr,
"\n ## Error: %s: 1. unable to update edge info.\n",__func__);
1314 assert ( tagip == tagiq && refip == refiq );
1325 for (k=0; k<ilist; k++) {
1326 if ( list[k] > 0 )
continue;
1327 iel = (-list[k]) / 4;
1328 ip = (-list[k]) % 4;
1332 for (j=0; j<3; j++) {
1333 if ( pt->
v[iq] == nq )
break;
1343 voyp = adja[iq] % 4;
1345 voyq = adja[ip] % 4;
1350 adja[voyp] = 4*qel+voyq;
1354 adja[voyq] = 4*pel+voyp;
1364 if ( pt1->
xt > 0 ) {
1403 pxt1->
ref[voyp] = pxt->
ref[ip];
1422 if ( pt1->
xt > 0 ) {
1424 pxt1->
ref[voyp] = 0;
1425 pxt1->
ftag[voyp] = 0;
1434 if ( pt1->
xt > 0 ) {
1474 pxt1->
ref[voyq] = pxt->
ref[iq];
1486 "larger xtetra table",
1500 if ( pt1->
xt > 0 ) {
1502 pxt1->
ref[voyq] = 0;
1503 pxt1->
ftag[voyq] = 0;
1515 if ( pt1->
xt > 0 ) {
1517 pxt1->
ref[voyq] = pxt->
ref[iq];
1528 pxt1->
ref[voyq] = pxt->
ref[iq];
1547 for (k=0; k<ilist; k++) {
1548 if ( list[k] < 0 )
continue;
1553 if ( typchk==1 && met->
m && met->
size > 1 )
int MMG3D_findEdge(MMG5_pMesh mesh, MMG5_pTetra pt, MMG5_int k, MMG5_int na, MMG5_int nb, int error, int8_t *mmgWarn, int8_t *ia)
int MMG3D_chk_shellEdgeTag(MMG5_pMesh mesh, MMG5_int start, int8_t ia, uint16_t tag, MMG5_int ref)
static void MMG3D_update_edgeTag(MMG5_pTetra pt, MMG5_pxTetra pxt, MMG5_int np, MMG5_int nq, uint8_t ip, MMG5_pTetra pt1, MMG5_pxTetra pxt1, uint8_t voyp)
static MMG5_int MMG3D_update_shellEdgeTag_oneDir(MMG5_pMesh mesh, MMG5_int start, MMG5_int na, MMG5_int nb, uint16_t tag, MMG5_int ref, MMG5_int piv, MMG5_int adj)
static int MMG5_topchkcol_bdy(MMG5_pMesh mesh, MMG5_int k, int iface, int8_t iedg, MMG5_int *lists, int ilists)
static int MMG3D_update_shellEdgeTag(MMG5_pMesh mesh, MMG5_int start, int8_t ia, uint16_t tag, MMG5_int ref)
int MMG3D_get_shellEdgeTag(MMG5_pMesh mesh, MMG5_int start, int8_t ia, uint16_t *tag, MMG5_int *ref)
static int MMG3D_get_shellEdgeTag_oneDir(MMG5_pMesh mesh, MMG5_int start, MMG5_int na, MMG5_int nb, uint16_t *tag, MMG5_int *ref, MMG5_int piv, MMG5_int adj, int8_t *filled)
MMG5_int MMG5_colver(MMG5_pMesh mesh, MMG5_pSol met, int64_t *list, int ilist, int8_t indq, int8_t typchk)
int MMG5_chkcol_int(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t iface, int8_t iedg, int64_t *list, int ilist, int8_t typchk)
int MMG5_chkcol_bdy(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int8_t iface, int8_t iedg, int64_t *listv, int ilistv, MMG5_int *lists, int ilists, MMG5_int refmin, MMG5_int refplus, int8_t typchk, int isnm, int8_t isnmint)
static MMG5_int MMG3D_unfold_shell(MMG5_pMesh mesh, MMG5_int start, MMG5_int end, MMG5_int na, MMG5_int nb, MMG5_int piv, MMG5_int *iel, int8_t *iopp)
static double MMG5_orcal(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int iel)
static const int8_t MMG5_idirinv[4][4]
int MMG3D_normalAdjaTri(MMG5_pMesh, MMG5_int, int8_t, int, double n[3])
int MMG5_startedgsurfball(MMG5_pMesh mesh, MMG5_int nump, MMG5_int numq, MMG5_int *list, int ilist)
int MMG3D_chkmanicoll(MMG5_pMesh, MMG5_int, int, int, MMG5_int, MMG5_int, MMG5_int, MMG5_int, int8_t, int8_t)
int MMG3D_delElt(MMG5_pMesh mesh, MMG5_int iel)
int8_t MMG5_chkedg(MMG5_pMesh mesh, MMG5_Tria *pt, int8_t ori, double, double, int)
static const int8_t MMG5_iarf[4][3]
iarf[i]: edges of face opposite to vertex i
double MMG5_caltet33_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_pTetra pt)
static const uint8_t MMG5_iare[6][2]
vertices of extremities of the edges of the tetra
static const uint8_t MMG5_ifar[6][2]
ifar[i][]: faces sharing the ith edge of the tetra
void MMG5_tet2tri(MMG5_pMesh mesh, MMG5_int k, int8_t ie, MMG5_Tria *ptt)
static const uint8_t MMG5_inxt3[7]
next vertex of tetra: {1,2,3,0,1,2,3}
int MMG5_norface(MMG5_pMesh mesh, MMG5_int k, int iface, double v[3])
static const uint8_t MMG5_idir[4][3]
idir[i]: vertices of face opposite to vertex i
#define MG_CLR(flag, bit)
static const uint8_t MMG5_iprv2[3]
#define MMG5_TAB_RECALLOC(mesh, ptr, initSize, wantedGap, type, message, law)
#define MG_GEO_OR_NOM(tag)
#define MG_GET(flag, bit)
static const uint8_t MMG5_inxt2[6]
#define MG_SIN_OR_NOM(tag)
int MMG5_norpts(MMG5_pMesh, MMG5_int, MMG5_int, MMG5_int, double *)
#define MG_SET(flag, bit)
Local parameters for a specific entity and reference.
Structure to store vertices of an MMG mesh.
Structure to store tetrahedra of an MMG mesh.
Structure to store triangles of a MMG mesh.
Structure to store additional information for the surface tetrahedra of an MMG mesh.