40 static int8_t mmgWarn0=0;
47 *det = (p2->
c[0]-p1->
c[0])*(p3->
c[1]-p1->
c[1]) - (p2->
c[1]-p1->
c[1])*(p3->
c[0]-p1->
c[0]);
51 fprintf(stderr,
"\n ## Warning: %s: at least 1 flat triangle. abort.\n",
58 b2 = (c[0]-p1->
c[0])*(p3->
c[1]-p1->
c[1]) - (c[1]-p1->
c[1])*(p3->
c[0]-p1->
c[0]);
59 b3 = (p2->
c[0]-p1->
c[0])*(c[1]-p1->
c[1]) -(p2->
c[1]-p1->
c[1])*(c[0]-p1->
c[0]);
75 if ( !
MG_EOK(pt) )
return 0;
91 double la[3],lb[3],det;
97 la[2] = 1.0-(la[0]+la[1]);
100 if ( !
ier )
return 0;
101 lb[2] = 1.0-(lb[0]+lb[1]);
104 for (i=0; i<3; i++) {
105 if ( fabs(la[i]-1.0) < 1.0e-12 ) {
106 if ( lb[i] < 0.0 )
return i+1;
109 if ( fabs(lb[i]-1.0) < 1.0e-12) {
110 if ( la[i] < 0.0 )
return i+1;
116 for (i=0; i<3; i++) {
117 if ( ( la[i] >= 0.0 && lb[i] <= 0.0 ) || ( la[i] <= 0.0 && lb[i] >= 0.0 ) ) {
123 if ( icompt > 1 )
return ireturn;
132 double a11,a21,a12,a22,area1,area2,area3,prod1,prod2,prod3;
140 if ( !
MG_EOK(pt) )
return 0;
143 if ( pt->
v[0] == ib || pt->
v[1] == ib || pt->
v[2] == ib) ibreak = 1;
150 a11 = ppb->
c[0] - ppa->
c[0];
151 a21 = ppb->
c[1] - ppa->
c[1];
153 a12 = p1->
c[0] - ppa->
c[0];
154 a22 = p1->
c[1] - ppa->
c[1];
155 area1 = a11*a22 - a12*a21;
157 a12 = p2->
c[0] - ppa->
c[0];
158 a22 = p2->
c[1] - ppa->
c[1];
159 area2 = a11*a22 - a12*a21;
161 a12 = p3->
c[0] - ppa->
c[0];
162 a22 = p3->
c[1] - ppa->
c[1];
163 area3 = a11*a22 - a12*a21;
170 if ( prod1 > 0 && ((prod2 < 0 || prod3 < 0))) {
177 if ( prod2 > 0 && ((prod1 < 0 || prod3 < 0))) {
184 if ( prod3 > 0 && ((prod2 < 0 || prod1 < 0))) {
192 if ( pt->
v[i] == ia || ibreak ) {
194 if ( (prod1 < 0) || (prod2 < 0) || (prod3 < 0) ) {
201 if ( ibreak && ( pt->
v[(i+1)%3] == ia || pt->
v[(i+2)%3] == ia ) ) {
204 else if ( pt->
v[i] == ia && ( pt->
v[(i+1)%3] == ib || pt->
v[(i+2)%3] == ib ) ) {
223 MMG5_int iel,base,iadr,*adja,iter,
ier;
225 double l1,l2,l3,det,eps;
226 static int8_t mmgWarn0 = 0;
233 mvDir[0] = mvDir[1] = mvDir[2] = 0;
238 if ( iel >
mesh->
nt )
return 0;
242 if ( pt->
base == base) {
245 fprintf(stderr,
"\n ## Warning: %s: numerical problem, please make"
246 " a bug report.\n",__func__);
251 if ( (pt->
v[0] == ip) || (pt->
v[1] == ip) || (pt->
v[2] == ip) )
return iel;
259 if ( !
ier )
return 0;
274 if(!mvDir[0] && !mvDir[1] && !mvDir[2]) {
281 if (!mvDir[i])
continue;
295 if (mvDir[i])
continue;
309 }
while ( iter<=mesh->nt );
332 double a[3],a11,a21,a12,a22,area1,area2,area3,prod1,prod2,prod3;
334 MMG5_int iadr,*adja,k,ibreak,i,ncompt,lon,iare,ivert;
335 static int8_t mmgWarn=0;
347 if(pt->
v[0]==ia || pt->
v[1]==ia || pt->
v[2]==ia) ivert = 1;
358 printf(
" Try to enforce edge %" MMG5_PRId
" %" MMG5_PRId
"\n",ia,ib);
371 if ( pt->
v[0] == ib || pt->
v[1] == ib || pt->
v[2] == ib ) ibreak = 1;
378 a11 = ppb->
c[0] - ppa->
c[0];
379 a21 = ppb->
c[1] - ppa->
c[1];
380 a12 = ppt1->
c[0] - ppa->
c[0];
381 a22 = ppt1->
c[1] - ppa->
c[1];
382 area1 = a11*a22 - a12*a21;
384 a12 = ppt2->
c[0] - ppa->
c[0];
385 a22 = ppt2->
c[1] - ppa->
c[1];
386 area2 = a11*a22 - a12*a21;
388 a12 = ppt3->
c[0] - ppa->
c[0];
389 a22 = ppt3->
c[1] - ppa->
c[1];
390 area3 = a11*a22 - a12*a21;
409 if ( prod1 > 0.0 && ((prod2 < 0.0 || prod3 < 0.0))) {
412 list[lon++] = 3*k + iare-1;
430 if ( prod2 > 0.0 && ((prod1 < 0.0 || prod3 < 0.0 ))) {
433 list[lon++] = 3*k + iare-1;
451 if ( prod3 > 0.0 && ((prod2 < 0.0 || prod1 < 0.0 ))) {
454 list[lon++] = 3*k + iare-1;
474 if ( pt->
v[i] == ia || ibreak ) {
475 if ( (prod1 < 0.0) || (prod2 < 0.0) || (prod3 < 0.0) ) {
478 list[lon++] = 3*k + iare-1;
484 if ( ibreak && ( pt->
v[(i+1)%3] == ia || pt->
v[(i+2)%3] == ia) ){
489 else if ( pt->
v[i] == ia && ( pt->
v[(i+1)%3] == ib || pt->
v[(i+2)%3] == ib ) ) {
509 niaib = sqrt(a11*a11+a21*a21 );
516 npti = sqrt((ppb->
c[0]-ppt4->
c[0])*(ppb->
c[0]-ppt4->
c[0])+
517 (ppb->
c[1]-ppt4->
c[1])*(ppb->
c[1]-ppt4->
c[1]));
518 if ( niaib > npti ) {
540 assert ( pt->
v[i] == ia );
565 k = adja[(i+1)%3] / 3;
579 if ( ibreak == 1 || ibreak == -10 )
continue;
580 if ( ibreak > 1 )
break;
586 fprintf(stderr,
"\n ## Error: %s: unexpected failure."
587 " Check your initial data and/or report the bug. lon:%" MMG5_PRId
". %e %e %e\n"
588 " tria %" MMG5_PRId
": %" MMG5_PRId
" %" MMG5_PRId
" %" MMG5_PRId
",\n",
589 __func__,lon, area1,area2,area3,k,
mesh->
tria[k].
v[0],
610 while ( ncompt < mesh->nt );
613 lon = ( ibreak == 4 ) ? 4 : ((-1)*lon);
double MMG2D_quickcal(MMG5_pMesh, MMG5_pTria)
MMG5_int MMG2D_findTria(MMG5_pMesh mesh, MMG5_int ip)
MMG5_int MMG2D_isInTriangle(MMG5_pMesh mesh, MMG5_int k, double c[2])
int MMG2D_cutEdge(MMG5_pMesh mesh, MMG5_pTria pt, MMG5_pPoint ppa, MMG5_pPoint ppb)
int MMG2D_coorbary(MMG5_pMesh mesh, MMG5_pTria pt, double c[2], double *det, double *l1, double *l2)
int MMG2D_locateEdge(MMG5_pMesh mesh, MMG5_int ia, MMG5_int ib, MMG5_int *kdep, MMG5_int *list)
int MMG2D_cutEdgeTriangle(MMG5_pMesh mesh, MMG5_int k, MMG5_int ia, MMG5_int ib)
static const uint8_t MMG5_iprv2[3]
static const uint8_t MMG5_inxt2[6]
Structure to store vertices of an MMG mesh.
Structure to store triangles of a MMG mesh.