64 double np[3][3],nq[3],*nr1,*nr2,nt[3],ps,ps2,*n1,*n2,dd,c1[3],c2[3],hausd;
65 double cosn1,cosn2,calnat,calchg,cal1,cal2,cosnat,coschg,ux,uy,uz,ll,loni,lona;
66 MMG5_int *adja,j,kk,l,ip0,ip1,ip2,iq;
85 if ( !adja[i] )
return 0;
119 loni = MMGS_lenEdg(
mesh,met,ip1,ip2,0);
120 lona = MMGS_lenEdg(
mesh,met,ip0,iq,0);
122 if ( lona > 1.0 ) lona = 1.0 / lona;
123 if ( lona < loni || !loni )
return 0;
129 ps = c1[0]*c2[0] + c1[1]*c2[1] + c1[2]*c2[2];
133 for (j=0; j<3; j++) {
134 if (
MS_SIN(p[j]->tag) ) {
137 else if (
MG_EDG(p[j]->tag) ) {
141 ps = nr1[0]*nt[0] + nr1[1]*nt[1] + nr1[2]*nt[2];
142 ps2 = nr2[0]*nt[0] + nr2[1]*nt[1] + nr2[2]*nt[2];
143 if ( fabs(ps) > fabs(ps2) )
144 memcpy(&np[j],nr1,3*
sizeof(
double));
146 memcpy(&np[j],nr2,3*
sizeof(
double));
149 memcpy(&np[j],p[j]->n,3*
sizeof(
double));
159 ps = nr1[0]*nt[0] + nr1[1]*nt[1] + nr1[2]*nt[2];
160 ps2 = nr2[0]*nt[0] + nr2[1]*nt[1] + nr2[2]*nt[2];
161 if ( fabs(ps) > fabs(ps2) )
162 memcpy(&nq,nr1,3*
sizeof(
double));
164 memcpy(&nq,nr2,3*
sizeof(
double));
167 memcpy(&nq,q->
n,3*
sizeof(
double));
171 ux = p[2]->
c[0] - p[1]->
c[0];
172 uy = p[2]->
c[1] - p[1]->
c[1];
173 uz = p[2]->
c[2] - p[1]->
c[2];
175 ll = ux*ux + uy*uy + uz*uz;
181 ps = ux*n1[0] + uy*n1[1] + uz*n1[2];
182 c1[0] = (2.0*p[1]->
c[0] + p[2]->
c[0] - ps*n1[0]) / 3.0 - p[1]->c[0];
183 c1[1] = (2.0*p[1]->
c[1] + p[2]->
c[1] - ps*n1[1]) / 3.0 - p[1]->c[1];
184 c1[2] = (2.0*p[1]->
c[2] + p[2]->
c[2] - ps*n1[2]) / 3.0 - p[1]->c[2];
186 ps = -(ux*n2[0] + uy*n2[1] + uz*n2[2]);
187 c2[0] = (2.0*p[2]->
c[0] + p[1]->
c[0] - ps*n2[0]) / 3.0 - p[2]->c[0];
188 c2[1] = (2.0*p[2]->
c[1] + p[1]->
c[1] - ps*n2[1]) / 3.0 - p[2]->c[1];
189 c2[2] = (2.0*p[2]->
c[2] + p[1]->
c[2] - ps*n2[2]) / 3.0 - p[2]->c[2];
192 ps = c1[0]*ux + c1[1]*uy + c1[2]*uz;
194 dd = c1[0]*c1[0] + c1[1]*c1[1] + c1[2]*c1[2];
195 cosn1 = ps / (dd*ll);
196 cosn1 *= (1.0-cosn1);
199 ps = -c2[0]*ux - c2[1]*uy - c2[2]*uz;
201 dd = c2[0]*c2[0]+c2[1]*c2[1]+c2[2]*c2[2];
202 cosn2 = ps / (dd*ll);
203 cosn2 *= (1.0-cosn2);
206 cosnat =
MG_MAX(fabs(cosn1),fabs(cosn2));
207 cosnat = cosnat <
MMG5_EPS ? 0.0 : cosnat;
211 ux = q->
c[0] - p[0]->
c[0];
212 uy = q->
c[1] - p[0]->
c[1];
213 uz = q->
c[2] - p[0]->
c[2];
215 ll = ux*ux + uy*uy + uz*uz;
221 ps = ux*n1[0] + uy*n1[1] + uz*n1[2];
222 c1[0] = (2.0*p[0]->
c[0] + q->
c[0] - ps*n1[0]) / 3.0 - p[0]->c[0];
223 c1[1] = (2.0*p[0]->
c[1] + q->
c[1] - ps*n1[1]) / 3.0 - p[0]->c[1];
224 c1[2] = (2.0*p[0]->
c[2] + q->
c[2] - ps*n1[2]) / 3.0 - p[0]->c[2];
226 ps = -(ux*n2[0] + uy*n2[1] + uz*n2[2]);
227 c2[0] = (2.0*q->
c[0] + p[0]->
c[0] - ps*n2[0]) / 3.0 - q->
c[0];
228 c2[1] = (2.0*q->
c[1] + p[0]->
c[1] - ps*n2[1]) / 3.0 - q->
c[1];
229 c2[2] = (2.0*q->
c[2] + p[0]->
c[2] - ps*n2[2]) / 3.0 - q->
c[2];
232 ps = c1[0]*ux + c1[1]*uy + c1[2]*uz;
234 dd = c1[0]*c1[0] + c1[1]*c1[1] + c1[2]*c1[2];
235 cosn1 = ps / (dd*ll);
236 cosn1 *= (1.0-cosn1);
239 ps = -c2[0]*ux - c2[1]*uy - c2[2]*uz;
241 dd = c2[0]*c2[0]+c2[1]*c2[1]+c2[2]*c2[2];
242 cosn2 = ps / (dd*ll);
243 cosn2 *= (1.0-cosn2);
246 coschg =
MG_MAX(fabs(cosn1),fabs(cosn2));
247 coschg = coschg <
MMG5_EPS ? 0.0 : coschg;
250 if ( coschg > hausd*hausd )
return 0;
252 if ( typchk == 2 && met->
m ) {
254 pt0->
v[0]= ip0; pt0->
v[1]= ip1; pt0->
v[2]= ip2;
256 pt0->
tag[1] = pt->
tag[i1];
257 pt0->
tag[2] = pt->
tag[i2];
258 cal1 = MMG5_calelt(
mesh,met,pt0);
261 pt0->
v[0]= ip1; pt0->
v[1]= iq; pt0->
v[2]= ip2;
262 pt0->
tag[0] = pt->
tag[i1];
263 pt0->
tag[1] = pt->
tag[ii];
264 pt0->
tag[2] = pt->
tag[i2];
265 cal2 = MMG5_calelt(
mesh,met,pt0);
267 calnat =
MG_MIN(cal1,cal2);
271 pt0->
v[0]= ip0; pt0->
v[1]= ip1; pt0->
v[2]= iq;
273 pt0->
tag[1] = pt->
tag[i1];
274 pt0->
tag[2] = pt->
tag[ii];
275 cal1 = MMG5_calelt(
mesh,met,pt0);
277 pt0->
v[0]= ip0; pt0->
v[1]= iq; pt0->
v[2]= ip2;
279 pt0->
tag[1] = pt->
tag[ii];
280 pt0->
tag[2] = pt->
tag[i2];
281 cal2 = MMG5_calelt(
mesh,met,pt0);
283 calchg =
MG_MIN(cal1,cal2);
286 pt0->
v[0]= ip0; pt0->
v[1]= ip1; pt0->
v[2]= ip2;
287 cal1 = MMGS_caltri(
mesh,met,pt0);
288 pt0->
v[0]= ip1; pt0->
v[1]= iq; pt0->
v[2]= ip2;
289 cal2 = MMGS_caltri(
mesh,met,pt0);
290 calnat =
MG_MIN(cal1,cal2);
291 pt0->
v[0]= ip0; pt0->
v[1]= ip1; pt0->
v[2]= iq;
292 cal1 = MMGS_caltri(
mesh,met,pt0);
293 pt0->
v[0]= ip0; pt0->
v[1]= iq; pt0->
v[2]= ip2;
294 cal2 = MMGS_caltri(
mesh,met,pt0);
295 calchg =
MG_MIN(cal1,cal2);
300 if ( calchg < MMG5_EPS && calnat >= calchg )
return 0;
303 if ( coschg < hausd*hausd && cosnat > hausd*hausd )
return 1;
305 return calchg > 1.01 * calnat;
320 MMG5_int *adja,adj,k11,k21,ip1,ip2,i2save,j2save;
321 int8_t i1,i2,j,jj,j2,v11,v21;
340 if ( k11 < 1 )
return 0;
348 if ( k21 < 1 )
return 0;
352 pt->
v[i2] = pt1->
v[j];
354 pt1->
v[j2] = pt->
v[i];
358 if ( pt->
v[i] == ip2 ) {
364 if ( pt1->
v[j] == ip1 ) {
372 pt->
tag[i] = pt1->
tag[jj];
373 pt->
edg[i] = pt1->
edg[jj];
375 pt1->
tag[j] = pt->
tag[i1];
376 pt1->
edg[j] = pt->
edg[i1];
384 mesh->
adja[3*(k-1)+1+i] = 3*k21+v21;
385 mesh->
adja[3*(k21-1)+1+v21] = 3*k+i;
386 mesh->
adja[3*(k-1)+1+i1] = 3*adj+jj;
387 mesh->
adja[3*(adj-1)+1+jj] = 3*k+i1;
388 mesh->
adja[3*(k11-1)+1+v11] = 3*adj+j;
389 mesh->
adja[3*(adj-1)+1+j] = 3*k11+v11;
static const uint8_t MMG5_iprv2[3]
static const uint8_t MMG5_inxt2[6]
int MMG5_nortri(MMG5_pMesh mesh, MMG5_pTria pt, double *n)
int MMG5_norpts(MMG5_pMesh, MMG5_int, MMG5_int, MMG5_int, double *)
Local parameters for a specific entity and reference.
Structure to store vertices of an MMG mesh.
Structure to store triangles of a MMG mesh.
int chkswp(MMG5_pMesh mesh, MMG5_pSol met, MMG5_int k, int i, int8_t typchk, double(*MMGS_lenEdg)(MMG5_pMesh, MMG5_pSol, MMG5_int, MMG5_int, int8_t), double(*MMGS_caltri)(MMG5_pMesh, MMG5_pSol, MMG5_pTria))
int swapar(MMG5_pMesh mesh, MMG5_int k, int i)