53MMG5_BezierTgt(
double c1[3],
double c2[3],
double n1[3],
double n2[3],
double t1[3],
double t2[3]) {
54 double ux,uy,uz,b[3],n[3],dd;
60 n[0] = 0.5*(n1[0]+n2[0]);
61 n[1] = 0.5*(n1[1]+n2[1]);
62 n[2] = 0.5*(n1[2]+n2[2]);
64 b[0] = uy*n[2] - uz*n[1];
65 b[1] = uz*n[0] - ux*n[2];
66 b[2] = ux*n[1] - uy*n[0];
68 t1[0] = n1[1]*b[2] - n1[2]*b[1];
69 t1[1] = n1[2]*b[0] - n1[0]*b[2];
70 t1[2] = n1[0]*b[1] - n1[1]*b[0];
72 t2[0] = -( n2[1]*b[2] - n2[2]*b[1] );
73 t2[1] = -( n2[2]*b[0] - n2[0]*b[2] );
74 t2[2] = -( n2[0]*b[1] - n2[1]*b[0] );
76 dd = t1[0]*t1[0] + t1[1]*t1[1] + t1[2]*t1[2];
86 dd = t2[0]*t2[0] + t2[1]*t2[1] + t2[2]*t2[2];
118 ll = ux*ux + uy*uy + uz*uz;
153 double b1[3],int8_t ised,
double v[3]) {
156 double ux,uy,uz,ps,ps1,ps2,*n1,*n2,np0[3],np1[3],t0[3],t1[3],il,ll,alpha;
162 np0[0] = np0[1] = np0[2] = 0;
163 np1[0] = np1[1] = np1[2] = 0;
181 ux = p1->
c[0] - p0->
c[0];
182 uy = p1->
c[1] - p0->
c[1];
183 uz = p1->
c[2] - p0->
c[2];
185 ll = ux*ux + uy*uy + uz*uz;
206 memcpy(t0,&(p0->
n[0]),3*
sizeof(
double));
207 ps = t0[0]*ux + t0[1]*uy + t0[2]*uz;
220 memcpy(t1,&(p1->
n[0]),3*
sizeof(
double));
221 ps = -( t1[0]*ux + t1[1]*uy + t1[2]*uz );
235 ps1 = v[0]*n1[0] + v[1]*n1[1] + v[2]*n1[2];
236 ps2 = v[0]*n2[0] + v[1]*n2[1] + v[2]*n2[2];
237 if ( fabs(ps2) > fabs(ps1) )
238 memcpy(np0,&(pxp0->
n2[0]),3*
sizeof(double));
240 memcpy(np0,&(pxp0->
n1[0]),3*
sizeof(
double));
243 memcpy(np0,&(pxp0->
n1[0]),3*
sizeof(
double));
250 ps1 = -(v[0]*n1[0] + v[1]*n1[1] + v[2]*n1[2]);
251 ps2 = -(v[0]*n2[0] + v[1]*n2[1] + v[2]*n2[2]);
252 if ( fabs(ps2) > fabs(ps1) )
253 memcpy(np1,&(pxp1->
n2[0]),3*
sizeof(double));
255 memcpy(np1,&(pxp1->
n1[0]),3*
sizeof(
double));
258 memcpy(np1,&(pxp1->
n1[0]),3*
sizeof(
double));
303 b0[0] = p0->
c[0] + alpha * t0[0];
304 b0[1] = p0->
c[1] + alpha * t0[1];
305 b0[2] = p0->
c[2] + alpha * t0[2];
307 b1[0] = p1->
c[0] + alpha * t1[0];
308 b1[1] = p1->
c[1] + alpha * t1[1];
309 b1[2] = p1->
c[2] + alpha * t1[2];
329 double *n1,*n2,nt[3],t1[3],t2[3],ps,ps2,dd,ux,uy,uz,l,ll,alpha;
331 int8_t i,i1,i2,im,isnm;
343 for (i=0; i<3; i++) {
344 memcpy(&pb->
b[i],p[i]->
c,3*
sizeof(
double));
347 if (
MG_SIN(p[i]->tag) ) {
355 else if( p[i]->tag &
MG_NOM){
364 memcpy(&pb->
t[i],p[i]->
n,3*
sizeof(
double));
369 if (
MG_EDG(p[i]->tag) ) {
377 ps = pxp->
n1[0]*nt[0] + pxp->
n1[1]*nt[1] + pxp->
n1[2]*nt[2];
378 ps2 = pxp->
n2[0]*nt[0] + pxp->
n2[1]*nt[1] + pxp->
n2[2]*nt[2];
393 assert ( ps > 0. || ps2 > 0. &&
394 "Negative projection of normal at tria onto normal at point: surface degeneracy");
397 if ( (ps > 0.) || (ps2 >0.) ) {
400 memcpy(&pb->
n[i],pxp->
n1,3*
sizeof(
double));
403 memcpy(&pb->
n[i],pxp->
n2,3*
sizeof(
double));
412 memcpy(&pb->
n[i],pxp->
n1,3*
sizeof(
double));
415 memcpy(&pb->
n[i],pxp->
n2,3*
sizeof(
double));
418 memcpy(&pb->
t[i],p[i]->
n,3*
sizeof(
double));
421 ps = pb->
n[i][0]*nt[0] + pb->
n[i][1]*nt[1] + pb->
n[i][2]*nt[2];
428 memcpy(&pb->
n[i],pxp->
n1,3*
sizeof(
double));
437 for (i=0; i<3; i++) {
449 for (i=0; i<3; i++) {
450 if ( p[i]->tag &
MG_NOM ) {
451 ps = pb->
n[i][0]*pb->
n[im][0] + pb->
n[i][1]*pb->
n[im][1] + pb->
n[i][2]*pb->
n[im][2];
463 for (i=1; i<3; i++) {
464 if ( p[i]->tag &
MG_NOM ) {
465 ps = pb->
n[i][0]*pb->
n[0][0] + pb->
n[i][1]*pb->
n[0][1] + pb->
n[i][2]*pb->
n[0][2];
477 for (i=0; i<3; i++) {
481 ux = p[i2]->
c[0] - p[i1]->
c[0];
482 uy = p[i2]->
c[1] - p[i1]->
c[1];
483 uz = p[i2]->
c[2] - p[i1]->
c[2];
485 ll = ux*ux + uy*uy + uz*uz;
494 if (
MG_SIN(p[i1]->tag) ) {
501 memcpy(t1,&pb->
t[i1],3*
sizeof(
double));
502 ps = t1[0]*ux + t1[1]*uy + t1[2]*uz;
509 if (
MG_SIN(p[i2]->tag) ) {
516 memcpy(t2,&pb->
t[i2],3*
sizeof(
double));
517 ps = -(t2[0]*ux + t2[1]*uy + t2[2]*uz);
528 ps = ux*(pb->
t[i1][0]+pb->
t[i2][0]) + uy*(pb->
t[i1][1]+pb->
t[i2][1]) + uz*(pb->
t[i1][2]+pb->
t[i2][2]);
530 pb->
t[i+3][0] = pb->
t[i1][0] + pb->
t[i2][0] - ps*ux;
531 pb->
t[i+3][1] = pb->
t[i1][1] + pb->
t[i2][1] - ps*uy;
532 pb->
t[i+3][2] = pb->
t[i1][2] + pb->
t[i2][2] - ps*uz;
533 dd = pb->
t[i+3][0]*pb->
t[i+3][0] + pb->
t[i+3][1]*pb->
t[i+3][1] + pb->
t[i+3][2]*pb->
t[i+3][2];
556 pb->
b[2*i+3][0] = p[i1]->
c[0] + alpha * t1[0];
557 pb->
b[2*i+3][1] = p[i1]->
c[1] + alpha * t1[1];
558 pb->
b[2*i+3][2] = p[i1]->
c[2] + alpha * t1[2];
560 pb->
b[2*i+4][0] = p[i2]->
c[0] + alpha * t2[0];
561 pb->
b[2*i+4][1] = p[i2]->
c[1] + alpha * t2[1];
562 pb->
b[2*i+4][2] = p[i2]->
c[2] + alpha * t2[2];
567 ps = ux*(n1[0]+n2[0]) + uy*(n1[1]+n2[1]) + uz*(n1[2]+n2[2]);
569 pb->
n[i+3][0] = n1[0] + n2[0] - ps*ux;
570 pb->
n[i+3][1] = n1[1] + n2[1] - ps*uy;
571 pb->
n[i+3][2] = n1[2] + n2[2] - ps*uz;
572 dd = pb->
n[i+3][0]*pb->
n[i+3][0] + pb->
n[i+3][1]*pb->
n[i+3][1] + pb->
n[i+3][2]*pb->
n[i+3][2];
582 for (i=0; i<3; i++) {
584 pb->
b[9][0] -= dd * pb->
b[i][0];
585 pb->
b[9][1] -= dd * pb->
b[i][1];
586 pb->
b[9][2] -= dd * pb->
b[i][2];
588 for (i=0; i<3; i++) {
589 pb->
b[9][0] += 0.25 * (pb->
b[2*i+3][0] + pb->
b[2*i+4][0]);
590 pb->
b[9][1] += 0.25 * (pb->
b[2*i+3][1] + pb->
b[2*i+4][1]);
591 pb->
b[9][2] += 0.25 * (pb->
b[2*i+3][2] + pb->
b[2*i+4][2]);
609 double dd,u,v,w,ps,ux,uy,uz;
612 memset(to,0,3*
sizeof(
double));
617 for (i=0; i<3; i++) {
618 o[i] = pb->
b[0][i]*w*w*w + pb->
b[1][i]*u*u*u + pb->
b[2][i]*v*v*v \
619 + 3.0 * (pb->
b[3][i]*u*u*v + pb->
b[4][i]*u*v*v + pb->
b[5][i]*w*v*v \
620 + pb->
b[6][i]*w*w*v + pb->
b[7][i]*w*w*u + pb->
b[8][i]*w*u*u)\
621 + 6.0 * pb->
b[9][i]*u*v*w;
624 no[i] = pb->
n[0][i]*w*w + pb->
n[1][i]*u*u + pb->
n[2][i]*v*v \
625 + 2.0 * (pb->
n[3][i]*u*v + pb->
n[4][i]*v*w + pb->
n[5][i]*u*w);
630 assert ( no[0]*no[0] + no[1]*no[1] + no[2]*no[2] > 0. );
634 ux = pb->
b[2][0] - pb->
b[1][0];
635 uy = pb->
b[2][1] - pb->
b[1][1];
636 uz = pb->
b[2][2] - pb->
b[1][2];
637 dd = ux*ux + uy*uy + uz*uz;
657 ps = pb->
t[1][0]* pb->
t[2][0] + pb->
t[1][1]* pb->
t[2][1] + pb->
t[1][2]* pb->
t[2][2];
659 to[0] = pb->
t[1][0]*u + pb->
t[2][0]*v;
660 to[1] = pb->
t[1][1]*u + pb->
t[2][1]*v;
661 to[2] = pb->
t[1][2]*u + pb->
t[2][2]*v;
664 to[0] = -pb->
t[1][0]*u + pb->
t[2][0]*v;
665 to[1] = -pb->
t[1][1]*u + pb->
t[2][1]*v;
666 to[2] = -pb->
t[1][2]*u + pb->
t[2][2]*v;
671 ux = pb->
b[2][0] - pb->
b[0][0];
672 uy = pb->
b[2][1] - pb->
b[0][1];
673 uz = pb->
b[2][2] - pb->
b[0][2];
674 dd = ux*ux + uy*uy + uz*uz;
694 ps = pb->
t[0][0]* pb->
t[2][0] + pb->
t[0][1]* pb->
t[2][1] + pb->
t[0][2]* pb->
t[2][2];
696 to[0] = pb->
t[0][0]*w + pb->
t[2][0]*v;
697 to[1] = pb->
t[0][1]*w + pb->
t[2][1]*v;
698 to[2] = pb->
t[0][2]*w + pb->
t[2][2]*v;
701 to[0] = -pb->
t[0][0]*w + pb->
t[2][0]*v;
702 to[1] = -pb->
t[0][1]*w + pb->
t[2][1]*v;
703 to[2] = -pb->
t[0][2]*w + pb->
t[2][2]*v;
708 ux = pb->
b[1][0] - pb->
b[0][0];
709 uy = pb->
b[1][1] - pb->
b[0][1];
710 uz = pb->
b[1][2] - pb->
b[0][2];
711 dd = ux*ux + uy*uy + uz*uz;
731 ps = pb->
t[0][0]* pb->
t[1][0] + pb->
t[0][1]* pb->
t[1][1] + pb->
t[0][2]* pb->
t[1][2];
733 to[0] = pb->
t[0][0]*w + pb->
t[1][0]*u;
734 to[1] = pb->
t[0][1]*w + pb->
t[1][1]*u;
735 to[2] = pb->
t[0][2]*w + pb->
t[1][2]*u;
738 to[0] = -pb->
t[0][0]*w + pb->
t[1][0]*u;
739 to[1] = -pb->
t[0][1]*w + pb->
t[1][1]*u;
740 to[2] = -pb->
t[0][2]*w + pb->
t[1][2]*u;
744 dd = no[0]*no[0] + no[1]*no[1] + no[2]*no[2];
752 dd = to[0]*to[0] + to[1]*to[1] + to[2]*to[2];
int MMG5_BezierEdge(MMG5_pMesh mesh, MMG5_int ip0, MMG5_int ip1, double b0[3], double b1[3], int8_t ised, double v[3])
int MMG3D_bezierInt(MMG5_pBezier pb, double uv[2], double o[3], double no[3], double to[3])
int MMG5_BezierTgt(double c1[3], double c2[3], double n1[3], double n2[3], double t1[3], double t2[3])
double MMG5_BezierGeod(double c1[3], double c2[3], double t1[3], double t2[3])
int MMG5_mmg3dBezierCP(MMG5_pMesh mesh, MMG5_Tria *pt, MMG5_pBezier pb, int8_t ori)
static const uint8_t MMG5_iprv2[3]
#define MG_EDG_OR_NOM(tag)
static const uint8_t MMG5_inxt2[6]
int MMG5_nortri(MMG5_pMesh mesh, MMG5_pTria pt, double *n)
#define MG_SIN_OR_NOM(tag)
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.