39#define MMG3D_EPSRAD 1.00005
43#define MMG3D_EPSCON 1e-5
44#define MMG3D_LONMAX 4096
56 MMG5_int key,*adja,iadr,jel,mins,maxs;
70 ha = &hash->
item[key];
74 if ( ha->
a == mins && ha->
b == maxs ) {
83 adja[j] = iel*4 + (MMG5_int)i;
87 while ( ha->
nxt && ha->
nxt < hash->
max ) {
89 if ( ha->
a == mins && ha->
b == maxs ) {
98 adja[j] = iel*4 + (MMG5_int)i;
107 ha->
k = iel*4 + (MMG5_int)i;
111 if ( hash->
nxt >= hash->
max ) {
114 for (j=hash->
nxt; j<hash->max; j++) hash->
item[j].
nxt = j+1;
122 ha->
k = iel*4 + (MMG5_int)i;
145 MMG5_int base,*adja,*adjb,iel,jel,old,v[3],iadr;
159 for (k=0; k<ilist; k++) {
162 iadr = (old-1)*4 + 1;
164 vois[0] = adja[0] >> 2;
165 vois[1] = adja[1] >> 2;
166 vois[2] = adja[2] >> 2;
167 vois[3] = adja[3] >> 2;
168 for (i=0; i<4; i++) {
171 for (j=0; j<3; j++) {
182 for (k=0; k<ilist; k++) {
185 for (i=0; i<4; i++) {
191 for (k=0; k<ilist; k++) {
194 for (i=0; i<4; i++) {
199 if ( alert ) {
return 0;}
203 fprintf(stderr,
"\n ## Error: %s: unable to complete mesh.\n",__func__);
209 for (k=1 ; k<=size ; k++) {
214 fprintf(stderr,
"\n ## Error: %s: unable to allocate a"
215 " new element.\n",__func__);
221 for (k=0; k<ilist; k++) {
224 iadrold = (old-1)*4 + 1;
241 for (i=0; i<4; i++) {
247 iel = ielnum[size++];
256 iadr = (iel-1)*4 + 1;
280 "larger xtetra table",
282 fprintf(stderr,
" Exit program.\n");
return -1;);
302 iadr = (jel-1)*4 + 1;
308 for (j=0; j<4; j++) {
327 for (k=0; k<ilist; k++) {
353 int ilist,
int nedep,
double volmin) {
356 double dd,det,nn,eps,eps2,ux,uy,uz,vx,vy,vz,v1,v2,v3;
357 double *ma,*mb,*mc,*md,mm[6],h1,h2,h3;
358 MMG5_int *adja,i,j,iel,iadr,adj,ib,ic,id;
359 MMG5_int base,vois[4];
370 memset(mm,0,6*
sizeof(
double));
377 while ( ipil >= 0 ) {
379 iadr = (iel-1)*4 + 1;
381 vois[0] = adja[0] >> 2;
382 vois[1] = adja[1] >> 2;
383 vois[2] = adja[2] >> 2;
384 vois[3] = adja[3] >> 2;
388 for (i=0; i<4; i++) {
401 ux = p2->
c[0] - p1->
c[0];
402 uy = p2->
c[1] - p1->
c[1];
403 uz = p2->
c[2] - p1->
c[2];
405 vx = p3->
c[0] - p1->
c[0];
406 vy = p3->
c[1] - p1->
c[1];
407 vz = p3->
c[2] - p1->
c[2];
413 dd = v1*(ppt->
c[0]-p1->
c[0]) + v2*(ppt->
c[1]-p1->
c[1]) \
414 + v3*(ppt->
c[2]-p1->
c[2]);
418 h1 = ux*ux + uy*uy + uz*uz;
419 h2 = vx*vx + vy*vy + vz*vz;
420 h3 = (p2->
c[0] - p3->
c[0])*(p2->
c[0] - p3->
c[0]) + (p2->
c[1] - p3->
c[1])*(p2->
c[1] - p3->
c[1])
421 + (p2->
c[2] - p3->
c[2])*(p2->
c[2] - p3->
c[2]);
422 if ( dd < volmin*sqrt(h1*h2*h3) )
break;
429 mm[j] = 0.25 * (ma[j]+mb[j]+mc[j]+md[j]);
431 det = mm[0] * ( mm[3]*mm[5] - mm[4]*mm[4]) \
432 - mm[1] * ( mm[1]*mm[5] - mm[2]*mm[4]) \
433 + mm[2] * ( mm[1]*mm[4] - mm[2]*mm[3]);
438 nn = mm[0]*v1*v1 + mm[3]*v2*v2 + mm[5]*v3*v3 \
439 + 2.0*(mm[1]*v1*v2 + mm[2]*v1*v3 + mm[4]*v2*v3);
441 if ( det*dd*dd < nn * eps2 )
break;
444 if ( i < 4 || pt->tag &
MG_REQ ) {
445 if ( ipil <= nedep ) {
450 list[ipil] = list[--lon];
458 while ( ncor > 0 && lon >= nedep );
482 double dd,nn,eps,eps2,ux,uy,uz,vx,vy,vz,v1,v2,v3;
483 MMG5_int *adja,i,iel,iadr,adj,ib,ic,id;
484 MMG5_int base,vois[4];
497 while ( ipil >= 0 ) {
499 iadr = (iel-1)*4 + 1;
501 vois[0] = adja[0] >> 2;
502 vois[1] = adja[1] >> 2;
503 vois[2] = adja[2] >> 2;
504 vois[3] = adja[3] >> 2;
507 for (i=0; i<4; i++) {
520 ux = p2->
c[0] - p1->
c[0];
521 uy = p2->
c[1] - p1->
c[1];
522 uz = p2->
c[2] - p1->
c[2];
524 vx = p3->
c[0] - p1->
c[0];
525 vy = p3->
c[1] - p1->
c[1];
526 vz = p3->
c[2] - p1->
c[2];
532 dd = v1*(ppt->
c[0]-p1->
c[0]) + v2*(ppt->
c[1]-p1->
c[1]) \
533 + v3*(ppt->
c[2]-p1->
c[2]);
536 if ( dd < volmin )
break;
539 nn = (v1*v1 + v2*v2 + v3*v3);
542 if ( dd*dd < nn * eps2 )
break;
545 if ( i < 4 || pt->tag &
MG_REQ ) {
546 if ( ipil <= nedep ) {
552 list[ipil] = list[--lon];
561 while ( ncor > 0 && lon >= nedep );
584 double c[3],eps,dd,ray,ux,uy,uz,crit;
585 double *mj,*mp,ct[12];
586 MMG5_int *adja,*adjb,adj,adi,ia,jel,iadr;
587 MMG5_int base,vois[4],tref;
588 int k,voy,ilist,ipil,i,j,isreq,l;
590 if ( lon < 1 )
return 0;
598 for (k=0; k<lon; k++) {
616 for (k=0; k<lon; k++)
617 list[k] = list[k] / 6;
628 iadr = (jel-1)*4 + 1;
635 for (i=0; i<4; i++) {
638 if ( !adj )
continue;
645 if ( pt->
flag == base )
continue;
648 for (j=0,l=0; j<4; j++,l+=3) {
649 memcpy(&ct[l],
mesh->
point[pt->
v[j]].
c,3*
sizeof(
double));
656 ux = ppt->
c[0] - c[0];
657 uy = ppt->
c[1] - c[1];
658 uz = ppt->
c[2] - c[2];
659 dd = mp[0]*ux*ux + mp[3]*uy*uy + mp[5]*uz*uz \
660 + 2.0*(mp[1]*ux*uy + mp[2]*ux*uz + mp[4]*uy*uz);
662 if ( dd > crit )
continue;
666 for (j=0; j<4; j++) {
671 ux = ppt->
c[0] - c[0];
672 uy = ppt->
c[1] - c[1];
673 uz = ppt->
c[2] - c[2];
674 dd = mj[0]*ux*ux + mj[3]*uy*uy + mj[5]*uz*uz \
675 + 2.0*(mj[1]*ux*uy + mj[2]*ux*uz + mj[4]*uy*uz);
676 crit += sqrt(dd/ray);
679 if ( crit > 5.0 )
continue;
682 iadr = (adj-1)*4 + 1;
685 for (j=0; j<4; j++) {
686 if ( j == voy )
continue;
689 if ( !adi )
continue;
695 if ( pt1->
flag == base ) {
709 while ( ipil < ilist );
714 if ( isreq ) ilist = -abs(ilist);
744 double c[3],crit,dd,eps,ray,ct[12];
745 MMG5_int *adja,*adjb,adj,adi,jel,iadr;
746 MMG5_int tref,base,vois[4],l;
748 int voy,i,j,k,ipil,ilist;
750 if ( lon < 1 )
return 0;
758 for (k=0; k<lon; k++) {
777 for (k=0; k<lon; k++)
778 list[k] = list[k] / 6;
787 iadr = (jel-1)*4 + 1;
794 for (i=0; i<4; i++) {
796 if ( !adj )
continue;
802 if ( pt->
flag == base )
continue;
805 for (j=0,l=0; j<4; j++,l+=3) {
806 memcpy(&ct[l],
mesh->
point[pt->
v[j]].
c,3*
sizeof(
double));
813 dd = (ppt->
c[0] - c[0]) * (ppt->
c[0] - c[0]) \
814 + (ppt->
c[1] - c[1]) * (ppt->
c[1] - c[1]) \
815 + (ppt->
c[2] - c[2]) * (ppt->
c[2] - c[2]);
816 if ( dd > crit )
continue;
819 iadr = (adj-1)*4 + 1;
822 for (j=0; j<4; j++) {
823 if ( j == voy )
continue;
825 if ( !adi )
continue;
831 if ( pt1->
flag == base )
845 while ( ipil < ilist );
850 if ( isreq ) ilist = -abs(ilist);
MMG5_pMesh MMG5_pSol * sol
if(!ier) exit(EXIT_FAILURE)
int MMG5_cenrad_iso(MMG5_pMesh mesh, double *ct, double *c, double *rad)
int MMG5_cenrad_ani(MMG5_pMesh mesh, double *ct, double *m, double *c, double *rad)
int MMG5_cavity_iso(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int iel, int ip, int64_t *list, int lon, double volmin)
static int MMG5_correction_iso(MMG5_pMesh mesh, int ip, int64_t *list, int ilist, int nedep, double volmin)
int MMG5_hashEdgeDelone(MMG5_pMesh mesh, MMG5_Hash *hash, MMG5_int iel, int i, MMG5_int *v)
static int MMG5_correction_ani(MMG5_pMesh mesh, MMG5_pSol met, int ip, int64_t *list, int ilist, int nedep, double volmin)
int MMG5_delone(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int ip, int64_t *list, int ilist)
int MMG5_cavity_ani(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int iel, int ip, int64_t *list, int lon, double volmin)
int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash, MMG5_int hsiz, MMG5_int hmax)
static double MMG5_orcal(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int iel)
MMG5_int MMG3D_newElt(MMG5_pMesh mesh)
int MMG3D_delElt(MMG5_pMesh mesh, MMG5_int iel)
static const int8_t MMG5_iarf[4][3]
iarf[i]: edges of face opposite to vertex i
static const uint8_t MMG5_ifar[6][2]
ifar[i][]: faces sharing the ith edge of the tetra
#define MMG3D_TETRA_REALLOC(mesh, jel, wantedGap, law)
static const uint8_t MMG5_idir[4][3]
idir[i]: vertices of face opposite to vertex i
#define MMG5_TAB_RECALLOC(mesh, ptr, initSize, wantedGap, type, message, law)
#define MMG5_DEL_MEM(mesh, ptr)
Identic as MMG5_HGeom but use MMG5_hedge to store edges instead of MMG5_hgeom (memory economy).
Structure to store vertices of an MMG mesh.
Structure to store tetrahedra of an MMG mesh.
Used to hash edges (memory economy compared to MMG5_hgeom).
Structure to store additional information for the surface tetrahedra of an MMG mesh.