52 for (k=1; k<=
mesh->
nt; k++) {
110 MMG5_int *adja,*adjb,adji1,adji2,*pile,iad,ipil,ip1,ip2,gen;
111 MMG5_int k,kk,iel,jel,nvf,nf,nr,nm,nt,nre,nreq,ncc,ned,ref;
113 int8_t i,ii,i1,i2,ii1,ii2,voy;
115 nvf = nf = ncc = ned = 0;
129 if ( !
MG_EOK(pt) )
continue;
132 for (i=0; i<3; i++) {
188 if ( MMG5_abs(pt1->
ref) != MMG5_abs(pt->
ref) ) {
204 if ( pt1->
v[ii1] == ip1 ) {
205 assert ( pt1->
base );
207 if ( pt1->
base < 0 ) {
208 fprintf(stderr,
"\n ## Error: %s: Triangle orientation problem (1):"
209 " Moebius strip?\n",__func__);
229 pt1->
tag[ii1] = pt1->
tag[ii2];
232 pt1->
edg[ii1] = pt1->
edg[ii2];
239 mesh->
adjt[3*(iel-1)+1+voy] = 3*kk + ii1;
244 mesh->
adjt[3*(iel-1)+1+voy] = 3*kk + ii2;
260 for (kk=1; kk<=
mesh->
nt; kk++) {
272 nr = nm = nre = nreq = nt = 0;
273 for (k=1; k<=
mesh->
nt; k++) {
275 if ( !
MG_EOK(pt) )
continue;
278 for (i=0; i<3; i++) {
282 if ( !jel || jel > k ) {
292 fprintf(stdout,
" a- ridges: %" MMG5_PRId
" found.\n",nr);
293 fprintf(stdout,
" a- nm : %" MMG5_PRId
" found.\n",nm);
294 fprintf(stdout,
" a- requir: %" MMG5_PRId
" found.\n",nreq);
295 fprintf(stdout,
" a- connex: %" MMG5_PRId
" connected component(s)\n",ncc);
296 fprintf(stdout,
" a- orient: %" MMG5_PRId
" flipped\n",nf);
299 gen = (2 - nvf + ned - nt) / 2;
300 fprintf(stdout,
" Connected component: %" MMG5_PRId
", genus: %" MMG5_PRId
", reoriented: %" MMG5_PRId
"\n",ncc,gen,nf);
301 fprintf(stdout,
" Edges: %" MMG5_PRId
", tagged: %" MMG5_PRId
", ridges: %" MMG5_PRId
", required: %" MMG5_PRId
", refs: %" MMG5_PRId
"\n",
302 ned,nr+nre+nreq,nr,nreq,nre);
312 double n1[3],n2[3],dhd;
313 MMG5_int *adja,k,kk,ne,nr,nrrm;
315 static int8_t warn=0;
324 for (k=1; k<=
mesh->
nt; k++) {
326 if ( !
MG_EOK(pt) )
continue;
331 for (i=0; i<3; i++) {
350 if ( kk && k < kk ) {
354 dhd = n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2];
360 pt->
tag[i] &= ~MG_GEO;
361 pt1->
tag[ii] &= ~MG_GEO;
368 fprintf(stdout,
"\n ## Warning: %s: at least one ridge along flat angle.\n"
369 " Ridge tag will be removed from edges but vertices can"
370 " still have tags that interfer with remeshing.\n\n",
383 for (k=1; k<=
mesh->
nt; k++) {
385 if ( !
MG_EOK(pt) )
continue;
390 for (i=0; i<3; i++) {
409 if ( kk && k < kk ) {
417 if ( pt1->
ref != pt->
ref ) {
429 dhd = n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2];
454 fprintf(stdout,
" %" MMG5_PRId
" ridges, %" MMG5_PRId
" edges added\n",nr,ne);
457 fprintf(stdout,
" %" MMG5_PRId
" ridges removed\n",nrrm);
480 static int8_t mmgWarn = 0;
482 for (k=1; k<=
mesh->
np; k++) {
490 for (k=1; k<=
mesh->
ne; k++) {
492 if ( !
MG_EOK(pt) )
continue;
494 for (i=0; i<4; i++) {
499 for (k=1; k<=
mesh->
ne; k++) {
501 if ( !
MG_EOK(pt) )
continue;
504 for (i=0; i<4; i++) {
505 for (j=0; j<3; j++) {
519 if (
mesh->
adja[4*(k-1)+1+i] )
continue;
524 if (
ier != 1 && !mmgWarn ) {
526 printf(
" ## Warning: %s: unable to check that we don't have"
527 " non-connected domains.\n",__func__);
530 if(ilistv != ppt->
s) {
547 double ux,uy,uz,vx,vy,vz,dd;
553 for (k=1; k<=
mesh->
nt; k++) {
555 if ( !
MG_EOK(pt) )
continue;
557 for (i=0; i<3; i++) {
569 ppt->
tag &= ~MG_NOSURF;
573 else if ( (xp == 1) && (nr == 1) ) {
575 ppt->
tag &= ~MG_NOSURF;
578 else if ( xp == 1 && !nr ){
580 ppt->
tag &= ~MG_NOSURF;
584 else if ( nr == 1 && !xp ){
586 ppt->
tag &= ~MG_NOSURF;
594 ux = p1->
c[0] - ppt->
c[0];
595 uy = p1->
c[1] - ppt->
c[1];
596 uz = p1->
c[2] - ppt->
c[2];
597 vx = p2->
c[0] - ppt->
c[0];
598 vy = p2->
c[1] - ppt->
c[1];
599 vz = p2->
c[2] - ppt->
c[2];
600 dd = (ux*ux + uy*uy + uz*uz) * (vx*vx + vy*vy + vz*vz);
602 dd = (ux*vx + uy*vy + uz*vz) / sqrt(dd);
614 fprintf(stdout,
" %" MMG5_PRId
" corners, %" MMG5_PRId
" singular points detected\n",nc,nre);
643 MMG5_int *adja,k,kk,ng,nn,nt,nf,nnr;
649 fprintf(stdout,
" ## Warning: %s: no research of boundary points"
650 " and normals of mesh. mesh->xpoint must be freed to enforce"
651 " analysis.\n",__func__);
660 for (k=1; k<=
mesh->
nt; k++) {
662 if ( !
MG_EOK(pt) )
continue;
664 for (i=0; i<3; i++) {
671 if ( ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1] + ppt->
n[2]*ppt->
n[2] > 0 ) {
694 nn = ng = nt = nf = 0;
697 for (k=1; k<=
mesh->
nt; k++) {
699 if ( !
MG_EOK(pt) )
continue;
702 for (i=0; i<3; i++) {
725 "larger xpoint table",
730 memcpy(pxp->
n1,ppt->
n,3*
sizeof(
double));
731 ppt->
n[0] = ppt->
n[1] = ppt->
n[2] = 0.;
743 assert ( (!(
MG_NOM & pt->
tag[i1])) &&
"Unexpected non-manifold edge" );
752 "larger xpoint table",
757 memcpy(pxp->
n1,n,3*
sizeof(
double));
759 if ( (pt->
tag[i1] &
MG_GEO) && adja[i1] > 0 ) {
767 memcpy(pxp->
n2,n,3*
sizeof(
double));
770 ppt->
n[0] = pxp->
n1[1]*pxp->
n2[2] - pxp->
n1[2]*pxp->
n2[1];
771 ppt->
n[1] = pxp->
n1[2]*pxp->
n2[0] - pxp->
n1[0]*pxp->
n2[2];
772 ppt->
n[2] = pxp->
n1[0]*pxp->
n2[1] - pxp->
n1[1]*pxp->
n2[0];
773 dd = ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1] + ppt->
n[2]*ppt->
n[2];
792 dd = pxp->
n1[0]*ppt->
n[0] + pxp->
n1[1]*ppt->
n[1] + pxp->
n1[2]*ppt->
n[2];
793 ppt->
n[0] -= dd*pxp->
n1[0];
794 ppt->
n[1] -= dd*pxp->
n1[1];
795 ppt->
n[2] -= dd*pxp->
n1[2];
796 dd = ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1] + ppt->
n[2]*ppt->
n[2];
809 fprintf(stdout,
" %" MMG5_PRId
" input normals ignored\n",nnr);
810 fprintf(stdout,
" %" MMG5_PRId
" normals, %" MMG5_PRId
" tangents updated (%" MMG5_PRId
" failed)\n",nn,nt,nf);
831 double to,tp,t,nnew[3],p[3],o[3],result;
832 int it,maxit,pos,
ier;
861 if ( result <= 0.0 ) {
874 while ( ++it < maxit );
898 double p[3],o[3],vol,to,tp,t;
940 while ( ++it < maxit );
961 double *tabl,c[3],n[3],nnew[3],*cptr,lm1,lm2,cx,cy,cz,res0,res,result;
962 int i,ii,it,nit,ilist,noupdate;
967 for (k=1; k<=
mesh->
nt; k++) {
969 if ( !
MG_EOK(pt) )
continue;
970 for (i=0; i<3; i++) {
972 if ( !ppt->
s ) ppt->
s = k;
976 for (k=1; k<=
mesh->
np; k++) {
981 for (k=1; k<=
mesh->
ne; k++) {
983 if ( !
MG_EOK(ptet) )
continue;
984 for (i=0; i<4; i++) {
1001 while ( it++ < nit ) {
1003 for (k=1; k<=
mesh->
np; k++) {
1007 tabl[iad+0] = ppt->
c[0];
1008 tabl[iad+1] = ppt->
c[1];
1009 tabl[iad+2] = ppt->
c[2];
1010 if ( !
MG_VOK(ppt) )
continue;
1014 if ( !iel )
continue;
1018 if ( pt->
v[1] == k ) i = 1;
1019 else if ( pt->
v[2] == k ) i = 2;
1025 for (i=1; i<=ilist; i++) {
1039 tabl[iad+0] = cptr[0] + lm1 * (cx - cptr[0]);
1040 tabl[iad+1] = cptr[1] + lm1 * (cy - cptr[1]);
1041 tabl[iad+2] = cptr[2] + lm1 * (cz - cptr[2]);
1047 for (k=1; k<=
mesh->
np; k++) {
1050 if ( !
MG_VOK(ppt) )
continue;
1054 if ( !iel )
continue;
1058 if ( pt->
v[1] == k ) i = 1;
1059 else if ( pt->
v[2] == k ) i = 2;
1065 for (i=1; i<=ilist; i++) {
1066 iad = 3*(list[i]-1) + 1;
1077 c[0] = tabl[iad+0] - lm2 * (cx - tabl[iad+0]);
1078 c[1] = tabl[iad+1] - lm2 * (cy - tabl[iad+1]);
1079 c[2] = tabl[iad+2] - lm2 * (cz - tabl[iad+2]);
1089 for (kt = 0 ; kt<ilist ; kt++) {
1092 if ( !
MG_EOK(pt) )
continue;
1097 tnew.
v[i] = pt->
v[i];
1101 if ( pt->
v[1] == k ) i = 1;
1102 if ( pt->
v[2] == k ) i = 2;
1108 if ( result < 0.0 ) {
1120 if ( !
MG_EOK(ptet) )
continue;
1123 if ( ptet->
v[1] == k ) i = 1;
1124 else if ( ptet->
v[2] == k ) i = 2;
1125 else if ( ptet->
v[3] == k ) i = 3;
1128 for( kt=0 ; kt<ilist ; kt++ ) {
1129 iel = tetlist[kt] / 4;
1130 i = tetlist[kt] % 4;
1133 for ( ii=0 ; ii<4 ; ii++ ) {
1134 v[ii] = ptet->
v[ii];
1139 if ( result <= 0.0 ) {
1147 res += (cptr[0]-c[0])*(cptr[0]-c[0]) + (cptr[1]-c[1])*(cptr[1]-c[1]) + (cptr[2]-c[2])*(cptr[2]-c[2]);
1154 if ( it == 1 ) res0 = res;
1155 if ( res0 >
MMG5_EPSD ) res = res / res0;
1157 fprintf(stdout,
" iter %5d res %.3E\r",it,res);
1160 if ( it > 1 && res <
MMG5_EPS )
break;
1163 for (k=1; k<=
mesh->
np; ++k) {
1171 fprintf(stdout,
" %" MMG5_PRId
" coordinates regularized: %.3e\n",nn,res);
1203 MMG5_int *adja,base;
1208 for (k=1; k<=
mesh->
ne; k++) {
1210 if( !
MG_EOK(pt) )
continue;
1212 for (i=0; i<4; i++) {
1213 if ( adja[i] )
continue;
1214 for (j=0; j<3; j++) {
1217 if ( p0->
flag == base )
continue;
1229 p0->
tag &= ~MG_NOSURF;
1236 "larger xpoint table",
1238 fprintf(stderr,
" Exit program.\n");
return 0;);
1243 memcpy(pxp->
n1,n,3*
sizeof(
double));
1244 memcpy(p0->
n,t,3*
sizeof(
double));
1251 for (k=1; k<=
mesh->
ne; k++) {
1253 if( !
MG_EOK(pt) )
continue;
1255 for (i=0; i<4; i++) {
1274 "larger xpoint table",
1276 fprintf(stderr,
" Exit program.\n");
return 0;);
1280 memcpy(p0->
n,t,3*
sizeof(
double));
1285 p0->
tag &= ~MG_NOSURF;
1330 fprintf(stdout,
"\n ** SURFACE ANALYSIS\n");
1334 fprintf(stderr,
"\n ## Hashing problem (1). Exit program.\n");
1341 fprintf(stderr,
"\n ## Problem when updating the xtetra data after ls discretization."
1342 " Exit program.\n");
1349 fprintf(stderr,
"\n ## Prism hashing problem. Exit program.\n");
1355 fprintf(stderr,
"\n ## Boundary orientation problem. Exit program.\n");
1361 fprintf(stderr,
"\n ## Boundary problem. Exit program.\n");
1372 memset ( &hash, 0x0,
sizeof(
MMG5_Hash));
1375 fprintf(stderr,
"\n ## Hashing problem (2). Exit program.\n");
1381 fprintf(stderr,
"\n ## Hashing problem (0). Exit program.\n");
1389 fprintf(stdout,
" ** SETTING TOPOLOGY\n");
1394 fprintf(stderr,
"\n ## Topology problem. Exit program.\n");
1401 fprintf(stderr,
"\n ## Geometry problem. Exit program.\n");
1408 fprintf(stderr,
"\n ## MMG5_Singularity problem. Exit program.\n");
1414 fprintf(stdout,
" ** DEFINING GEOMETRY\n");
1418 fprintf(stderr,
"\n ## Coordinates regularization problem. Exit program.\n");
1424 fprintf(stderr,
"\n ## Normal problem. Exit program.\n");
1429 fprintf(stderr,
"\n ## Normal regularization problem. Exit program.\n");
1435 fprintf(stderr,
"\n ## Boundary problem. Exit program.\n");
1443 fprintf(stdout,
" ** UPDATING TOPOLOGY AT NON-MANIFOLD POINTS\n");
1446 fprintf(stderr,
"\n ## Non-manifold topology problem. Exit program.\n");
1458 fprintf(stderr,
"\n ## Hashing problem (0). Exit program.\n");
1466 fprintf(stderr,
"\n ## Boundary problem. Exit program.\n");
1481 for( ip = 1; ip <=
mesh->
np; ip++ )
int MMG5_regnor(MMG5_pMesh mesh)
void MMG3D_set_reqBoundaries(MMG5_pMesh mesh)
int MMG3D_analys(MMG5_pMesh mesh)
int MMG5_setdhd(MMG5_pMesh mesh)
int MMG5_norver(MMG5_pMesh mesh)
static int MMG3D_dichotomytetra(MMG5_pMesh mesh, MMG5_int *v, MMG5_int k, double *c)
int MMG3D_regver(MMG5_pMesh mesh)
static int MMG3D_dichotomytria(MMG5_pMesh mesh, MMG5_pTria pt, MMG5_int k, double *c, double *n)
int MMG5_setadj(MMG5_pMesh mesh)
int MMG5_chkVertexConnectedDomains(MMG5_pMesh mesh)
int MMG5_singul(MMG5_pMesh mesh)
int MMG3D_nmgeom(MMG5_pMesh mesh)
int MMG5_boulec(MMG5_pMesh mesh, MMG5_int *adjt, MMG5_int start, int ip, double *tt)
int MMG5_boulep(MMG5_pMesh mesh, MMG5_int start, int ip, MMG5_int *adja, MMG5_int *list, MMG5_int *tlist)
int MMG5_bouler(MMG5_pMesh mesh, MMG5_int *adjt, MMG5_int start, int ip, MMG5_int *list, MMG5_int *listref, int *ng, int *nr, int lmax)
int MMG5_boulen(MMG5_pMesh mesh, MMG5_int *adjt, MMG5_int start, int ip, double *nn)
int MMG5_boulevolp(MMG5_pMesh mesh, MMG5_int start, int ip, int64_t *list)
Given a vertex and a tetrahedron, find all tetrahedra in the ball of this vertex.
int MMG5_boulesurfvolp(MMG5_pMesh mesh, MMG5_int start, int ip, int iface, int64_t *listv, int *ilistv, MMG5_int *lists, int *ilists, int isnm)
int MMG5_boulenm(MMG5_pMesh mesh, MMG5_int start, int ip, int iface, double n[3], double t[3])
int MMG5_boulenmInt(MMG5_pMesh mesh, MMG5_int start, int ip, double t[3])
void MMG3D_chkfacetags(MMG5_pMesh mesh)
int MMG3D_hashTetra(MMG5_pMesh mesh, int pack)
Create array of adjacency.
int MMG5_hGeom(MMG5_pMesh mesh)
int MMG3D_hashPrism(MMG5_pMesh mesh)
int MMG5_chkBdryTria(MMG5_pMesh mesh)
int MMG5_bdrySet(MMG5_pMesh mesh)
int MMG5_bdryUpdate(MMG5_pMesh mesh)
int MMG5_setNmTag(MMG5_pMesh mesh, MMG5_Hash *hash)
int MMG3D_hashTria(MMG5_pMesh mesh, MMG5_Hash *hash)
int MMG5_bdryPerm(MMG5_pMesh mesh)
API headers and documentation for the mmg3d library, for volumetric meshes in 3D.
int MMG3D_update_xtetra(MMG5_pMesh mesh)
void MMG5_freeXPrisms(MMG5_pMesh mesh)
void MMG5_freeXTets(MMG5_pMesh mesh)
static const uint8_t MMG5_idir[4][3]
idir[i]: vertices of face opposite to vertex i
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_ADD_MEM(mesh, size, message, law)
static const uint8_t MMG5_iprv2[3]
#define MG_EDG_OR_NOM(tag)
#define MMG5_TAB_RECALLOC(mesh, ptr, initSize, wantedGap, type, message, law)
static const uint8_t MMG5_inxt2[6]
void MMG5_dotprod(int8_t dim, double *a, double *b, double *result)
int MMG5_nortri(MMG5_pMesh mesh, MMG5_pTria pt, double *n)
double MMG5_orvol(MMG5_pPoint point, MMG5_int *v)
#define MMG5_SAFE_MALLOC(ptr, size, type, law)
#define MMG5_SAFE_FREE(ptr)
#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.
Structure to store triangles of a MMG mesh.
Structure to store surface vertices of an MMG mesh.
Structure to store additional information for the surface tetrahedra of an MMG mesh.