47 return (ref - pim->
offset);
72 return (pim->
lookup[key] / 4 - 1);
88 return (pim->
lookup[key] % 4);
99 return pim->
lookup[key] ? 0 : 1;
112 fprintf(stderr,
"\n ## Warning: Overwrite material reference %d"
113 " (from LSReferences line %d) with another entry from LSReferences line %d."
115 fprintf(stderr,
"\n Check your LSReferences table: if possible,"
116 " each material reference should be unique,\n"
117 " if not possible, you may"
118 " encounter unexpected issues (wrong domain mapping or erroneous"
119 " detection of non-manifold level-set)!\n");
186 fprintf(stderr,
"\n ## Warning: %s: material %" MMG5_PRId
" not found in table.\n",
188 fprintf(stderr,
" Please ensure that you provide all mesh"
189 " references in the material map\n"
190 " (that is, the whole list of"
191 " surface materials in lssurf mode,\n"
192 " and the whole list of domain"
193 " materials in ls mode).\n" );
244 printf(
"%" MMG5_PRId
" (%" MMG5_PRId
"): %" MMG5_PRId
" %d\n",ref,
330 MMG5_int refmax,refmin;
337 fprintf(stderr,
"\n ## Error: %s: Only %d materials out of %d have been set.\n",
348 if (
sizeof(MMG5_int) == 8 ) {
359 if( pm->
ref > refmax ) refmax = pm->
ref;
360 if( pm->
ref < refmin ) refmin = pm->
ref;
361 if( !pm->
dospl )
continue;
363 if( pm->
rin > refmax ) refmax = pm->
rin;
364 if( pm->
rin < refmin ) refmin = pm->
rin;
366 if( pm->
rex > refmax ) refmax = pm->
rex;
367 if( pm->
rex < refmin ) refmin = pm->
rex;
374 for ( k=1; k<=
mesh->
ne; ++k ) {
378 for ( k=1; k<=
mesh->
nt; ++k ) {
382 for ( k=1; k<=
mesh->
na; ++k ) {
389 pim->
size = refmax - refmin + 1;
390 assert( pim->
size > 0 );
479 int8_t found0,found1;
512 MMG5_int k,kk,iel,ns,nc,ip,ip1,ip2,npl,nmn;
519 fprintf(stderr,
" Exit program.\n");
524 for (k=1; k<=
mesh->
np; k++)
529 for (k=1; k<=
mesh->
np; k++) {
531 if ( !
MG_VOK(p0) )
continue;
541 for (k=1; k<=
mesh->
nt; k++) {
543 if ( !
MG_EOK(pt) )
continue;
544 for (i=0; i<3; i++) {
560 if ( p0->
flag && !smsgn ) {
574 for (k=1; k<=
mesh->
nt; k++) {
576 if ( !
MG_EOK(pt) )
continue;
577 for (i=0; i<3; i++) {
583 for(kk=0; kk<ilist; kk++) {
598 if ( npl == 1 && nmn == 0 )
600 else if ( npl == 0 && nmn == 1 )
606 fprintf(stdout,
" %8" MMG5_PRId
" points snapped, %" MMG5_PRId
" corrected\n",ns,nc);
631 MMG5_int refstart,*adja,k,ip1,ip2,end1;
633 static int8_t mmgWarn=0;
675 while ( smsgn && (k != start) );
723 while ( smsgn && (k != start) );
733 fprintf(stderr,
"\n ## Warning: %s: unsnap at least 1 point "
734 "(point %" MMG5_PRId
" in tri %" MMG5_PRId
").\n",__func__,
761 vol = (p1->
c[0]-p0->
c[0])*(p2->
c[1]-p0->
c[1]) - (p1->
c[1]-p0->
c[1])*(p2->
c[0]-p0->
c[0]);
783 double v[3],vfp,vfm,lam,area,eps,o1[2],o2[2];
784 MMG5_int ip[3],nplus,nminus,nzero;
785 int8_t i,i0,i1,i2,imin1,iplus1,iz;
798 v[0] =
sol->m[ip[0]];
799 v[1] =
sol->m[ip[1]];
800 v[2] =
sol->m[ip[2]];
803 nplus = nminus = nzero = 0;
804 imin1 = iplus1 = iz = -1;
806 for (i=0; i<3; i++) {
807 if ( fabs(v[i]) < eps ) {
809 if ( iz < 0 ) iz = i;
811 else if ( v[i] >= eps ) {
813 if ( iplus1 < 0 ) iplus1 = i;
817 if ( imin1 < 0 ) imin1 = i;
822 if ( nzero == 3 )
return 0.0;
826 vfp = (ppt[1]->
c[0]-ppt[0]->
c[0])*(ppt[2]->c[1]-ppt[0]->c[1]) - (ppt[1]->
c[1]-ppt[0]->
c[1])*(ppt[2]->c[0]-ppt[0]->c[0]);
828 if ( pm == 1 )
return vfp;
834 vfm = (ppt[1]->
c[0]-ppt[0]->
c[0])*(ppt[2]->c[1]-ppt[0]->c[1]) - (ppt[1]->
c[1]-ppt[0]->
c[1])*(ppt[2]->c[0]-ppt[0]->c[0]);
836 if ( pm == -1 )
return vfm;
846 lam = v[i0] / (v[i0]-v[i1]);
847 o1[0] = ppt[i0]->
c[0] + lam*(ppt[i1]->
c[0]-ppt[i0]->
c[0]);
848 o1[1] = ppt[i0]->
c[1] + lam*(ppt[i1]->
c[1]-ppt[i0]->
c[1]);
850 lam = v[i0] / (v[i0]-v[i2]);
851 o2[0] = ppt[i0]->
c[0] + lam*(ppt[i2]->
c[0]-ppt[i0]->
c[0]);
852 o2[1] = ppt[i0]->
c[1] + lam*(ppt[i2]->
c[1]-ppt[i0]->
c[1]);
854 vfm = (o1[0]-ppt[i0]->
c[0])*(o2[1]-ppt[i0]->c[1]) - (o1[1]-ppt[i0]->
c[1])*(o2[0]-ppt[i0]->c[0]);
857 if ( pm == -1 )
return vfm;
859 area = (ppt[1]->
c[0]-ppt[0]->
c[0])*(ppt[2]->c[1]-ppt[0]->c[1]) - (ppt[1]->
c[1]-ppt[0]->
c[1])*(ppt[2]->c[0]-ppt[0]->c[0]);
860 area = 0.5*fabs(area);
872 lam = v[i0] / (v[i0]-v[i1]);
873 o1[0] = ppt[i0]->
c[0] + lam*(ppt[i1]->
c[0]-ppt[i0]->
c[0]);
874 o1[1] = ppt[i0]->
c[1] + lam*(ppt[i1]->
c[1]-ppt[i0]->
c[1]);
876 lam = v[i0] / (v[i0]-v[i2]);
877 o2[0] = ppt[i0]->
c[0] + lam*(ppt[i2]->
c[0]-ppt[i0]->
c[0]);
878 o2[1] = ppt[i0]->
c[1] + lam*(ppt[i2]->
c[1]-ppt[i0]->
c[1]);
880 vfp = (o1[0]-ppt[i0]->
c[0])*(o2[1]-ppt[i0]->c[1]) - (o1[1]-ppt[i0]->
c[1])*(o2[0]-ppt[i0]->c[0]);
883 if ( pm == 1 )
return vfp;
885 area = (ppt[1]->
c[0]-ppt[0]->
c[0])*(ppt[2]->c[1]-ppt[0]->c[1]) - (ppt[1]->
c[1]-ppt[0]->
c[1])*(ppt[2]->c[0]-ppt[0]->c[0]);
886 area = 0.5*fabs(area);
919 double volc,voltot,v0,v1,v2;
920 MMG5_int k,kk,l,ll,ncp,ncm,ip0,ip1,ip2,cur,ipile,*pile,*adja,base;
931 for (k=1; k<=
mesh->
nt; k++) {
933 if ( !
MG_EOK(pt) )
continue;
942 printf(
" Exit program.\n");
949 for (k=1; k<=
mesh->
nt; k++) {
953 if ( !
MG_EOK(pt) )
continue;
954 if ( pt->
flag == base )
continue;
965 if ( v0 <= 0.0 && v1 <= 0.0 && v2 <= 0.0 )
continue;
972 fprintf(stderr,
"\n ## Problem in length of pile; function rmc.\n"
973 " Check that the level-set intersect the mesh.\n"
990 for (i=0; i<3; i++) {
992 if (
sol->m[ip0] <= 0.0 )
continue;
1001 if ( pt2->
flag != base ) {
1005 if ( ipile >
mesh->
nt ) {
1006 fprintf(stderr,
"\n ## Problem in length of pile; function rmc. Exit program.\n");
1016 if ( pt2->
flag != base ) {
1020 if ( ipile >
mesh->
nt ) {
1021 fprintf(stderr,
"\n ## Problem in length of pile; function rmc. Exit program.\n");
1028 while ( ++cur < ipile );
1031 if ( volc < mesh->
info.
rmc*voltot ) {
1032 for (l=0; l<ipile; l++) {
1034 for (i=0; i<3; i++) {
1047 for (k=1; k<=
mesh->
nt; k++) {
1051 if ( !
MG_EOK(pt) )
continue;
1052 if ( pt->
flag == base )
continue;
1063 if ( v0 >= 0.0 && v1 >= 0.0 && v2 >= 0.0 )
continue;
1069 if ( ipile >
mesh->
nt ) {
1070 fprintf(stderr,
"\n ## Problem in length of pile; function rmc. Exit program.\n");
1084 for (i=0; i<3; i++) {
1086 if (
sol->m[ip0] >= 0.0 )
continue;
1095 if ( pt2->
flag != base ) {
1099 if ( ipile >
mesh->
nt ) {
1100 fprintf(stderr,
"\n ## Problem in length of pile; function rmc. Exit program.\n");
1110 if ( pt2->
flag != base ) {
1114 if ( ipile >
mesh->
nt ) {
1115 fprintf(stderr,
"\n ## Problem in length of pile; function rmc. Exit program.\n");
1123 while ( ++cur < ipile );
1126 if ( volc < mesh->
info.
rmc*voltot ) {
1127 for (l=0; l<ipile; l++) {
1129 for (i=0; i<3; i++) {
1140 for (l=0; l<ipile; l++) {
1142 for (i=0; i<3; i++) {
1147 if (
sol->m[ip1] < 0.0 ) {
1152 if (
sol->m[ip2] < 0.0 ) {
1162 for (l=0; l<ipile; l++) {
1164 for (i=0; i<3; i++) {
1182 printf(
"\n *** Removed %" MMG5_PRId
" positive parasitic bubbles and %" MMG5_PRId
" negative parasitic bubbles\n",ncp,ncm);
1200 for (k=1; k<=
mesh->
nt; k++) {
1202 if ( !pt->
v[0] )
continue;
1204 for (i=0; i<3; i++) {
1212 for (k=1; k<=
mesh->
nt; k++) {
1214 if ( !pt->
v[0] )
continue;
1234 MMG5_int k,ip,ip1,ref,refint,refext;
1235 int8_t i,i1,i2,nmn,npl,nz;
1237 for (k=1; k<=
mesh->
nt; k++) {
1239 if ( !
MG_EOK(pt) )
continue;
1243 for (i=0; i<3; i++) {
1277 for (i=0; i<3; i++) {
1282 if ( v == 0.0 && v1 == 0.0) {
1310 MMG5_int refstart,*adja,k;
1362 if ( k == 0 )
return 1;
1434 static int8_t mmgWarn = 0;
1437 for (k=1; k<=
mesh->
nt; k++) {
1439 if ( !
MG_EOK(pt) )
continue;
1443 for (i=0; i<3; i++) {
1455 if ( pt1->
ref != pt->
ref ) cnt++;
1466 fprintf(stderr,
"\n ## Warning: %s: at least 1 triangle with 3 boundary"
1467 " edges.\n",__func__);
1475 for (k=1; k<=
mesh->
nt; k++) {
1477 if ( !
MG_EOK(pt) )
continue;
1479 for (i=0; i<3; i++) {
1483 if (! iel )
continue;
1497 fprintf(stderr,
" *** Topological problem\n");
1498 fprintf(stderr,
" non manifold curve at point %" MMG5_PRId
"\n",pt->
v[i1]);
1499 fprintf(stderr,
" non manifold curve at tria %" MMG5_PRId
" (ip %d)\n", MMG5_indElt(
mesh,k),i1);
1506 fprintf(stdout,
" *** Manifold implicit surface.\n");
MMG5_pMesh MMG5_pSol * sol
int MMG5_boulet(MMG5_pMesh mesh, MMG5_int start, int ip, MMG5_int *list, int8_t s, int8_t *opn)
static int MMG5_InvMat_code(int k, int attr)
static void MMG5_InvMat_error(MMG5_pInvMat pim, int ref, int k)
int MMG5_rmc(MMG5_pMesh mesh, MMG5_pSol sol)
static int MMG5_InvMat_check(MMG5_pInvMat pim, int key)
int MMG5_isLevelSet(MMG5_pMesh mesh, MMG5_int ref0, MMG5_int ref1)
int MMG5_isNotSplit(MMG5_pMesh mesh, MMG5_int ref)
int MMG5_ismaniball(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int start, int8_t istart)
static int MMG5_isbr(MMG5_pMesh mesh, MMG5_int ref)
static int MMG5_InvMat_getParent(MMG5_pMesh mesh, MMG5_pInvMat pim, MMG5_int ref, MMG5_int *pref)
static MMG5_int MMG5_InvMat_key(MMG5_pInvMat pim, int ref)
static int MMG5_InvMat_getAttrib(MMG5_pInvMat pim, int ref)
int MMG5_snpval_ls(MMG5_pMesh mesh, MMG5_pSol sol)
int MMG5_isSplit(MMG5_pMesh mesh, MMG5_int ref, MMG5_int *refint, MMG5_int *refext)
static int MMG5_InvMat_set(MMG5_pMesh mesh, MMG5_pInvMat pim, int k)
static void MMG5_InvMat_print(MMG5_pMesh mesh, MMG5_pInvMat pim)
static double MMG5_voltri(MMG5_pMesh mesh, MMG5_int ip0, MMG5_int ip1, MMG5_int ip2)
int MMG5_MultiMat_init(MMG5_pMesh mesh)
int MMG5_getStartRef(MMG5_pMesh mesh, MMG5_int ref, MMG5_int *pref)
static double MMG5_vfrac(MMG5_pMesh mesh, MMG5_pSol sol, MMG5_int k, int pm)
int MMG5_resetRef_ls(MMG5_pMesh mesh)
int MMG5_chkmaniball(MMG5_pMesh mesh, MMG5_int start, int8_t istart)
int MMG5_chkmanimesh(MMG5_pMesh mesh)
static int MMG5_InvMat_getIndex(MMG5_pInvMat pim, int ref)
int MMG5_setref_ls(MMG5_pMesh mesh, MMG5_pSol sol)
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_ADD_MEM(mesh, size, message, law)
static const uint8_t MMG5_iprv2[3]
static const uint8_t MMG5_inxt2[6]
#define MMG5_DEL_MEM(mesh, ptr)
To store lookup table for references in the mesh (useful in LS mode)
To store user-defined references in the mesh (useful in LS mode)
Structure to store points of a MMG mesh.