49 MMG5_int *adja,*adjb,adji1,adji2,*pile,iad,ipil,ip1,ip2,gen;
50 MMG5_int k,kk,iel,jel,nvf,nf,nr,nt,nre,nreq,ncc,ned,ref;
52 int8_t i,ii,i1,i2,ii1,ii2,voy;
55 fprintf(stdout,
" ** SETTING TOPOLOGY\n");
57 nvf = nf = ncc = ned = 0;
71 if ( !
MG_EOK(pt) )
continue;
107 pt1->
tag[ii] = pt->
tag[i];
108 pt1->
edg[ii] = pt->
edg[i];
114 pt->
tag[i] = pt1->
tag[ii];
115 pt->
edg[i] = pt1->
edg[ii];
121 if ( MMG5_abs(pt1->
ref) != MMG5_abs(pt->
ref) ) {
142 if ( pt1->
v[ii1] == ip1 ) {
144 assert ( pt1->
base );
145 if ( pt1->
base < 0 ) {
146 pt1->
ref = -MMG5_abs(pt1->
ref);
168 pt1->
tag[ii1] = pt1->
tag[ii2];
171 pt1->
edg[ii1] = pt1->
edg[ii2];
178 mesh->
adja[3*(iel-1)+1+voy] = 3*kk + ii1;
183 mesh->
adja[3*(iel-1)+1+voy] = 3*kk + ii2;
199 for (kk=1; kk<=
mesh->
nt; kk++) {
201 if (
MG_EOK(pt) && (pt->
cc == 0) ) {
211 nr = nre = nreq = nt = 0;
212 for (k=1; k<=
mesh->
nt; k++) {
214 if ( !
MG_EOK(pt) )
continue;
217 for (i=0; i<3; i++) {
221 if ( !jel || jel > k ) {
230 fprintf(stdout,
" a- ridges: %" MMG5_PRId
" found.\n",nr);
231 fprintf(stdout,
" a- requir: %" MMG5_PRId
" found.\n",nreq);
232 fprintf(stdout,
" a- connex: %" MMG5_PRId
" connected component(s)\n",ncc);
233 fprintf(stdout,
" a- orient: %" MMG5_PRId
" flipped\n",nf);
236 gen = (2 - nvf + ned - nt) / 2;
237 fprintf(stdout,
" Connected component: %" MMG5_PRId
", genus: %" MMG5_PRId
", reoriented: %" MMG5_PRId
"\n",ncc,gen,nf);
238 fprintf(stdout,
" Edges: %" MMG5_PRId
", tagged: %" MMG5_PRId
", ridges: %" MMG5_PRId
", required: %" MMG5_PRId
", refs: %" MMG5_PRId
"\n",
239 ned,nr+nre+nreq,nr,nreq,nre);
256 MMG5_int k,np,numt,iel,jel,nmp,*adja;
261 for (k=1; k<=
mesh->
np; k++)
264 for (k=1; k<=
mesh->
nt; k++) {
266 if ( !
MG_EOK(pt) )
continue;
268 for (i=0; i<3; i++) {
271 if ( !p0->
s ) p0->
s = k;
275 for (k=1; k<=
mesh->
nt; k++) {
277 if ( !
MG_EOK(pt) )
continue;
279 for (i=0; i<3; i++) {
283 if ( k == numt )
continue;
297 while ( jel && (jel != numt) && (jel !=k) );
310 else if ( jel == numt )
326 while ( jel && (jel != numt));
338 for (k=1; k<=
mesh->
np; k++)
342 fprintf(stdout,
" ## %" MMG5_PRId
" non manifold points detected\n",nmp);
447 double n1[3],n2[3],dhd;
448 MMG5_int *adja,k,kk,nr;
452 for (k=1; k<=
mesh->
nt; k++) {
454 if ( !
MG_EOK(pt) )
continue;
459 for (i=0; i<3; i++) {
468 dhd = n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2];
483 fprintf(stdout,
" %" MMG5_PRId
" ridges updated\n",nr);
499 double ux,uy,uz,vx,vy,vz,dd;
505 for (k=1; k<=
mesh->
nt; k++) {
507 if ( !
MG_EOK(pt) )
continue;
509 for (i=0; i<3; i++) {
522 else if ( (xp == 1) && (nr == 1) ) {
526 else if ( xp == 1 && !nr ){
531 else if ( nr == 1 && !xp ){
540 ux = p1->
c[0] - ppt->
c[0];
541 uy = p1->
c[1] - ppt->
c[1];
542 uz = p1->
c[2] - ppt->
c[2];
543 vx = p2->
c[0] - ppt->
c[0];
544 vy = p2->
c[1] - ppt->
c[1];
545 vz = p2->
c[2] - ppt->
c[2];
546 dd = (ux*ux + uy*uy + uz*uz) * (vx*vx + vy*vy + vz*vz);
548 dd = (ux*vx + uy*vy + uz*vz) / sqrt(dd);
560 for (k=1; k<=
mesh->
nt; k++) {
562 if ( !
MG_EOK(pt) )
continue;
563 for (i=0; i<3; i++) {
565 if ( !ppt->
s )
continue;
568 if ( nr != ppt->
s ) {
577 for (k=1; k<=
mesh->
np; ++k) {
582 fprintf(stdout,
" %" MMG5_PRId
" corners, %" MMG5_PRId
" singular points detected\n",nc,nre);
604 MMG5_int *adja,k,kk,
ier,xp,nn,nt,nf,nnr;
608 fprintf(stdout,
" ** DEFINING GEOMETRY\n");
611 nn = xp = nt = nf = nnr = 0;
613 for (k=1; k<=
mesh->
nt; k++) {
615 if ( !
MG_EOK(pt) )
continue;
617 for (i=0; i<3; i++) {
622 if ( ppt->
n[0]*ppt->
n[0]+ppt->
n[1]*ppt->
n[1]+ppt->
n[2]*ppt->
n[2] > 0 )
632 if ( ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1] + ppt->
n[2]*ppt->
n[2] > 0 )
655 for (k=1; k<=
mesh->
nt; k++) {
657 if ( !
MG_EOK(pt) )
continue;
660 for (i=0; i<3; i++) {
665 else if ( !
MG_EDG(pt->
tag[i1]) )
continue;
668 assert ( (!(
MG_NOM & pt->
tag[i1])) &&
"Unexpected non-manifold edge" );
671 if ( !
ier )
continue;
676 "larger xpoint table",
682 memcpy(go->
n1,n,3*
sizeof(
double));
692 if ( !
ier )
continue;
693 memcpy(go->
n2,n,3*
sizeof(
double));
696 ppt->
n[0] = go->
n1[1]*go->
n2[2] - go->
n1[2]*go->
n2[1];
697 ppt->
n[1] = go->
n1[2]*go->
n2[0] - go->
n1[0]*go->
n2[2];
698 ppt->
n[2] = go->
n1[0]*go->
n2[1] - go->
n1[1]*go->
n2[0];
700 dd = ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1] + ppt->
n[2]*ppt->
n[2];
714 if ( !
ier )
continue;
715 dd = go->
n1[0]*ppt->
n[0] + go->
n1[1]*ppt->
n[1] + go->
n1[2]*ppt->
n[2];
716 ppt->
n[0] -= dd*go->
n1[0];
717 ppt->
n[1] -= dd*go->
n1[1];
718 ppt->
n[2] -= dd*go->
n1[2];
719 dd = ppt->
n[0]*ppt->
n[0] + ppt->
n[1]*ppt->
n[1] + ppt->
n[2]*ppt->
n[2];
734 fprintf(stdout,
" %" MMG5_PRId
" input normals ignored\n",nnr);
735 fprintf(stdout,
" %" MMG5_PRId
" normals, %" MMG5_PRId
" tangents updated (%" MMG5_PRId
" failed)\n",nn,nt,nf);
757 double to,tp,t,nnew[3],p[3],o[3],result;
758 int it,maxit,pos,
ier;
787 if ( result <= 0.0 ) {
800 while ( ++it < maxit );
821 double *tabl,c[3],n[3],nnew[3],*cptr,lm1,lm2,cx,cy,cz,res0,res,result;
822 int i,it,nit,ilist,noupdate,
ier;
826 for (k=1; k<=
mesh->
nt; k++) {
828 if ( !
MG_EOK(pt) )
continue;
829 for (i=0; i<3; i++) {
831 if ( !ppt->
s ) ppt->
s = k;
846 while ( it++ < nit ) {
848 for (k=1; k<=
mesh->
np; k++) {
852 tabl[iad+0] = ppt->
c[0];
853 tabl[iad+1] = ppt->
c[1];
854 tabl[iad+2] = ppt->
c[2];
856 if ( !
MG_VOK(ppt) )
continue;
863 if ( pt->
v[1] == k ) i = 1;
864 else if ( pt->
v[2] == k ) i = 2;
870 for (i=1; i<=ilist; i++) {
884 tabl[iad+0] = cptr[0] + lm1 * (cx - cptr[0]);
885 tabl[iad+1] = cptr[1] + lm1 * (cy - cptr[1]);
886 tabl[iad+2] = cptr[2] + lm1 * (cz - cptr[2]);
892 for (k=1; k<=
mesh->
np; k++) {
895 if ( !
MG_VOK(ppt) )
continue;
902 if ( pt->
v[1] == k ) i = 1;
903 else if ( pt->
v[2] == k ) i = 2;
909 for (i=1; i<=ilist; i++) {
910 iad = 3*(list[i]-1) + 1;
921 c[0] = tabl[iad+0] - lm2 * (cx - tabl[iad+0]);
922 c[1] = tabl[iad+1] - lm2 * (cy - tabl[iad+1]);
923 c[2] = tabl[iad+2] - lm2 * (cz - tabl[iad+2]);
933 for (kt = 0 ; kt<ilist ; kt++) {
936 if ( !
MG_EOK(pt) )
continue;
941 tnew.
v[i] = pt->
v[i];
945 if ( pt->
v[1] == k ) i = 1;
946 if ( pt->
v[2] == k ) i = 2;
952 if ( result < 0.0 ) {
959 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]);
966 if ( it == 1 ) res0 = res;
967 if ( res0 >
MMG5_EPSD ) res = res / res0;
969 fprintf(stdout,
" iter %5d res %.3E\r",it,res);
972 if ( it > 1 && res <
MMG5_EPS )
break;
975 for (k=1; k<=
mesh->
np; ++k) {
982 fprintf(stdout,
" %" MMG5_PRId
" coordinates regularized: %.3e\n",nn,res);
1001 if ( !
mesh->
nt )
return 1;
1009 for (k=1; k<=
mesh->
nt; k++) {
1016 else if ( jel > 0 ) {
1024 fprintf(stdout,
" ## "); fflush(stdout);
1025 if ( dup > 0 ) fprintf(stdout,
" %"MMG5_PRId
" duplicate removed",dup);
1026 fprintf(stdout,
"\n");
1046 fprintf(stderr,
"\n ## Hashing problem. Exit program.\n");
1058 fprintf(stderr,
"\n ## Topology problem. Exit program.\n");
1067 fprintf(stderr,
"\n ## Geometry problem. Exit program.\n");
1073 fprintf(stderr,
"\n ## Singularity problem. Exit program.\n");
1080 fprintf(stderr,
"\n ## Normal problem. Exit program.\n");
1085 fprintf(stderr,
"\n ## Normal regularization problem. Exit program.\n");
1098 fprintf(stderr,
"\n ## Analysis problem. Exit program.\n");
1104 fprintf(stderr,
"\n ## Analysis problem. Exit program.\n");
1110 fprintf(stderr,
"\n ## Hashing problem. Exit program.\n");
1122 fprintf(stderr,
"\n ## Topology problem. Exit program.\n");
1131 fprintf(stderr,
"\n ## Geometry problem. Exit program.\n");
1137 fprintf(stderr,
"\n ## Singularity problem. Exit program.\n");
1143 fprintf(stderr,
"\n ## Coordinates regularization problem. Exit program.\n");
1150 fprintf(stderr,
"\n ## Normal problem. Exit program.\n");
1155 fprintf(stderr,
"\n ## Normal regularization problem. Exit program.\n");
if(!ier) exit(EXIT_FAILURE)
int MMG5_regnor(MMG5_pMesh mesh)
int MMGS_analys_for_norver(MMG5_pMesh mesh)
static int setdhd(MMG5_pMesh mesh)
static int MMGS_dichotomy(MMG5_pMesh mesh, MMG5_pTria pt, MMG5_int k, double *c, double *n)
int MMGS_regver(MMG5_pMesh mesh)
static int norver(MMG5_pMesh mesh)
int MMGS_analys(MMG5_pMesh mesh)
static void nmpoints(MMG5_pMesh mesh)
int MMGS_setadj(MMG5_pMesh mesh)
int MMGS_remDup(MMG5_pMesh mesh)
static int MMG5_singul(MMG5_pMesh mesh)
int MMG5_boulec(MMG5_pMesh mesh, MMG5_int *adjt, MMG5_int start, int ip, double *tt)
int MMG5_boulet(MMG5_pMesh mesh, MMG5_int start, int ip, MMG5_int *list, int8_t s, int8_t *opn)
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)
MMG5_int MMG5_hashFace(MMG5_pMesh mesh, MMG5_Hash *hash, MMG5_int ia, MMG5_int ib, MMG5_int ic, MMG5_int k)
int MMG5_hashNew(MMG5_pMesh mesh, MMG5_Hash *hash, MMG5_int hsiz, MMG5_int hmax)
int MMGS_assignEdge(MMG5_pMesh mesh)
int MMGS_bdryUpdate(MMG5_pMesh mesh)
int MMGS_hashTria(MMG5_pMesh mesh)
int MMGS_delElt(MMG5_pMesh mesh, MMG5_int iel)
#define MMG5_SAFE_CALLOC(ptr, size, type, law)
#define MMG5_ADD_MEM(mesh, size, message, law)
static const uint8_t MMG5_iprv2[3]
#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)
#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 triangles of a MMG mesh.
Structure to store surface vertices of an MMG mesh.