From a54f2937b16dae6b8706da108a4e80177f897d64 Mon Sep 17 00:00:00 2001 From: Algiane Date: Tue, 8 Oct 2024 17:02:38 +0200 Subject: [PATCH 1/2] Solve small inconsistencies in variable types for distpt and distnv functions. The variable used to store if the distance is realized by p1 or p2 have to have consistent types. A char is sufficient to store the info and more consistent with the unsigned char type or the piont tag in which the resulting value is copied sometimes . --- sources/mshdis1_2d.c | 13 ++++++++----- sources/mshdis1_s.c | 3 ++- sources/mshdist.h | 8 ++++---- sources/tools_2d.c | 7 ++++--- sources/tools_s.c | 4 ++-- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/sources/mshdis1_2d.c b/sources/mshdis1_2d.c index eca88b7..1e72198 100755 --- a/sources/mshdis1_2d.c +++ b/sources/mshdis1_2d.c @@ -77,7 +77,8 @@ int iniredist_2d(Info info, pMesh mesh, pSol sol){ pTria pt; pPoint p0,p1,p2,pa; double *solTmp,d; - int *bndy,i,j,nb,nc,i0,i1,i2,proj; + int *bndy,i,j,nb,nc,i0,i1,i2; + char proj; nb = 0; bndy = (int*)calloc(mesh->nt+1,sizeof(int)); @@ -191,7 +192,8 @@ int inidist_2d(Info info,pMesh mesh1,pMesh mesh2,pSol sol1,pBucket bucket) { pEdge pe; pPoint p1,p2,pa,pb; double cb[3],d; - int *adja,*list,base,iadr,ilist,i,j,k,ia,ib,iel,jel,ier,cur,nc,tag,npp,i0,i1; + int *adja,*list,base,iadr,ilist,i,j,k,ia,ib,iel,jel,ier,cur,nc,npp,i0,i1; + char tag; for (k=1; k<=sol1->np; k++) sol1->val[k] = INIVAL_2d; @@ -679,8 +681,8 @@ int iniencdomain_2d(Info info,pMesh mesh, pSol sol){ pPoint pa,pb,p0,p1,p2; double d; int ied,ier,*actiedg,nb,k,l,ip0,ip1,ip2,ia,*adja,iel,jel; - int ilist,*list,base,cur,nc,iadr,ib,tag; - char i,i0,i1,i2; + int ilist,*list,base,cur,nc,iadr,ib; + char tag,i,i0,i1,i2; /* Hash edges of the mesh */ ier = hashEdge_2d(mesh); @@ -1442,11 +1444,12 @@ int ppgdist_2d(Info info,pMesh mesh,pSol sol) { /* Compute L^1,L^2 and L^\infty errors when compared to interpolation of real sdf */ int errdist(pMesh mesh, pMesh mesh2, pSol sol){ - int k,l,proj,i0,i1,i2; + int k,l,i0,i1,i2; pTria pt; pEdge pe; pPoint p0,p1,p2; double errLInfty,errL1,errL2,*dist,area; + char proj; errLInfty = 0.0; errL1 = 0.0; diff --git a/sources/mshdis1_s.c b/sources/mshdis1_s.c index c22b004..8a12070 100755 --- a/sources/mshdis1_s.c +++ b/sources/mshdis1_s.c @@ -8,7 +8,8 @@ int iniredist_s(Info info, pMesh mesh, pSol sol){ pTria pt; pPoint p0,p1,p2; double *solTmp,d; - int *bndy,i,j,nb,nc,i0,i1,i2,proj; + int *bndy,i,j,nb,nc,i0,i1,i2; + char proj; nb = 0; bndy = (int*)calloc(mesh->nt+1,sizeof(int)); diff --git a/sources/mshdist.h b/sources/mshdist.h index 51386f8..923c68a 100755 --- a/sources/mshdist.h +++ b/sources/mshdist.h @@ -166,12 +166,12 @@ int eqquad(double*,double*); int intersec_2d(pPoint,pPoint,pPoint,pPoint); int intersec_3d(pPoint p1,pPoint q1,pPoint r1,pPoint p2,pPoint q2,pPoint r2); int interSegTria(pMesh mesh,pPoint pa,pPoint pb,pTria pt); -double distpt_2d(pPoint,pPoint,pPoint,int*); -double distnv0_2d(pMesh,pSol,int,pPoint,int*); -double distnv0_s(pMesh,pSol,int,pPoint,int*); +double distpt_2d(pPoint,pPoint,pPoint,char*); +double distnv0_2d(pMesh,pSol,int,pPoint,char*); +double distnv0_s(pMesh,pSol,int,pPoint,char*); int buildcircum_3d(pMesh,double *); int circumcoords(pPoint,pPoint,pPoint,double *); -double distpt_s(pPoint,pPoint,pPoint,int*); +double distpt_s(pPoint,pPoint,pPoint,char*); double distptplan(pPoint,pPoint,pPoint,pPoint); double distpt_3d(pPoint p0,pPoint p1,pPoint p2,pPoint pq,char *proj); double distnv0_3d(pMesh,pSol,int,pPoint,char*); diff --git a/sources/tools_2d.c b/sources/tools_2d.c index a8a7130..ecd1c8a 100755 --- a/sources/tools_2d.c +++ b/sources/tools_2d.c @@ -80,7 +80,7 @@ int intersec_2d(pPoint p1,pPoint p2,pPoint pa,pPoint pb) { /* Return (squared) distance from point pa to segment (p1,p2); proj = 2 if distance is realized by p1 or p2, 1 if it is realized by the orthogonal projection of pa on (p1p2) */ -double distpt_2d(pPoint p1,pPoint p2,pPoint pa,int *proj) { +double distpt_2d(pPoint p1,pPoint p2,pPoint pa,char *proj) { double a,b,c,d,dd,ux,uy,vx,vy,wx,wy,xp,yp,lambda; *proj = 1; @@ -138,7 +138,7 @@ double distpt_2d(pPoint p1,pPoint p2,pPoint pa,int *proj) { } /* compute (squared) distance from pa to the 0 level set in triangle ntria ; same use of proj as before */ -double distnv0_2d(pMesh mesh, pSol sol, int ntria, pPoint pa, int *proj) { +double distnv0_2d(pMesh mesh, pSol sol, int ntria, pPoint pa, char *proj) { pTria pt; pPoint p0,p1,p2; Point q,r; @@ -251,7 +251,8 @@ double hausdorff(pMesh mesh1, pMesh mesh2){ pPoint p0,p1,pmil,p2,p3; Point mil; double rho1,rho2,haus,d, d0,d1,dmil; - int k,j,proj,nac1,nac2; + int k,j,nac1,nac2; + char proj; rho1 = 0.0; rho2 = 0.0; diff --git a/sources/tools_s.c b/sources/tools_s.c index 152623f..33c90cb 100755 --- a/sources/tools_s.c +++ b/sources/tools_s.c @@ -5,7 +5,7 @@ extern unsigned char inxt2[5]; /* Return (squared) distance from point pa to segment (p1,p2); proj = 2 if distance is realized by p1 or p2, 1 if it is realized by the orthogonal projection of pa on (p1p2) */ -double distpt_s(pPoint p0,pPoint p1,pPoint pa,int *proj) { +double distpt_s(pPoint p0,pPoint p1,pPoint pa,char *proj) { double ux,uy,uz,p1p0,pap0,ps,lambda; ux = p1->c[0] - p0->c[0]; @@ -39,7 +39,7 @@ double distpt_s(pPoint p0,pPoint p1,pPoint pa,int *proj) { } /* Compute (squared) distance from pa to the 0 level set in triangle k */ -double distnv0_s(pMesh mesh, pSol sol, int k, pPoint pa, int *proj) { +double distnv0_s(pMesh mesh, pSol sol, int k, pPoint pa, char *proj) { pTria pt; pPoint p0,p1,p2; Point q,r; From 3f0d1a4cf1e33310bd71336b9a89f7b3d1c5ca2e Mon Sep 17 00:00:00 2001 From: Algiane Date: Tue, 8 Oct 2024 17:05:56 +0200 Subject: [PATCH 2/2] Homogeneization of the prototype for ppgdist and ppgdistfmm functions. As the ppgdist_s function is not implemented, the ppgdist pointer points toward the ppgdistfmm_s function for surface test cases. In this case, both funcs have to have the same prototype. Other functions are modified to maintain the prototypes consistencies. --- sources/mshdis1_2d.c | 2 +- sources/mshdis1_3d.c | 2 +- sources/mshdis1_s.c | 2 +- sources/mshdist.c | 2 +- sources/mshdist.h | 6 +++--- sources/mshdistexterns.c | 2 +- sources/mshdistexterns.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sources/mshdis1_2d.c b/sources/mshdis1_2d.c index 1e72198..830aa0c 100755 --- a/sources/mshdis1_2d.c +++ b/sources/mshdis1_2d.c @@ -1079,7 +1079,7 @@ double actival_2d(pMesh mesh,pSol sol,int k,int i) { } /* Propagation of the signed distance field by the Fast Marching Method */ -int ppgdistfmm_2d(pMesh mesh,pSol sol){ +int ppgdistfmm_2d(Info info,pMesh mesh,pSol sol){ Queue q; pQueue pq; pTria pt,pt1; diff --git a/sources/mshdis1_3d.c b/sources/mshdis1_3d.c index 8c68ced..c829c9f 100755 --- a/sources/mshdis1_3d.c +++ b/sources/mshdis1_3d.c @@ -1446,7 +1446,7 @@ double actival_3d(pMesh mesh,pSol sol,int k,int i) { } /* Propagation of the signed distance function by the Fast Marching Method */ -int ppgdistfmm_3d(pMesh mesh,pSol sol) { +int ppgdistfmm_3d(Info info,pMesh mesh,pSol sol) { Queue q; pQueue pq; pTetra pt,pt1; diff --git a/sources/mshdis1_s.c b/sources/mshdis1_s.c index 8a12070..15cd39f 100755 --- a/sources/mshdis1_s.c +++ b/sources/mshdis1_s.c @@ -547,7 +547,7 @@ double actival_s(pMesh mesh,pSol sol,int start,int i) { } /* Propagation of the signed distance function by the Fast Marching Method */ -int ppgdistfmm_s(pMesh mesh,pSol sol) { +int ppgdistfmm_s(Info info,pMesh mesh,pSol sol) { Queue q; pQueue pq; pTria pt,pt1; diff --git a/sources/mshdist.c b/sources/mshdist.c index bbeff6f..f1e26c8 100755 --- a/sources/mshdist.c +++ b/sources/mshdist.c @@ -473,7 +473,7 @@ static int mshdis1(Info info,pMesh mesh1,pMesh mesh2,pSol sol1) { if ( info.imprim ) fprintf(stdout," ** Propagation [%d cpu]\n",info.ncpu); if ( info.fmm ) - ier = ppgdistfmm(mesh1,sol1); + ier = ppgdistfmm(info,mesh1,sol1); else ier = ppgdist(info,mesh1,sol1); chrono(OFF,&info.ctim[4]); diff --git a/sources/mshdist.h b/sources/mshdist.h index 923c68a..9a77bbc 100755 --- a/sources/mshdist.h +++ b/sources/mshdist.h @@ -207,9 +207,9 @@ int pack_s(pMesh ,pSol ,int *); int unpack_s(pMesh ,pSol ,int *); int ppgdist_2d(Info info,pMesh mesh, pSol sol); int ppgdist_3d(Info info,pMesh mesh, pSol sol); -int ppgdistfmm_2d(pMesh mesh, pSol sol); -int ppgdistfmm_s(pMesh mesh, pSol sol); -int ppgdistfmm_3d(pMesh mesh, pSol sol); +int ppgdistfmm_2d(Info info,pMesh mesh, pSol sol); +int ppgdistfmm_s(Info info,pMesh mesh, pSol sol); +int ppgdistfmm_3d(Info info,pMesh mesh, pSol sol); int iniencdomain_2d(Info info,pMesh mesh, pSol sol); int iniencdomain_s(Info info,pMesh mesh, pSol sol); int iniencdomain_3d(Info info,pMesh mesh, pSol sol); diff --git a/sources/mshdistexterns.c b/sources/mshdistexterns.c index 5a1909e..390cf51 100644 --- a/sources/mshdistexterns.c +++ b/sources/mshdistexterns.c @@ -8,4 +8,4 @@ extern int (*iniredist)(Info ,pMesh ,pSol ) = NULL; extern int (*iniencdomain)(Info ,pMesh ,pSol ) = NULL; extern int (*inireftrias)(Info ,pMesh, pSol) = NULL; extern int (*ppgdist)(Info info,pMesh mesh, pSol sol) = NULL; -extern int (*ppgdistfmm)(pMesh mesh, pSol sol) = NULL; +extern int (*ppgdistfmm)(Info info,pMesh mesh, pSol sol) = NULL; diff --git a/sources/mshdistexterns.h b/sources/mshdistexterns.h index d5dc3bd..cead365 100644 --- a/sources/mshdistexterns.h +++ b/sources/mshdistexterns.h @@ -11,6 +11,6 @@ extern int (*iniredist)(Info ,pMesh ,pSol ); extern int (*iniencdomain)(Info ,pMesh ,pSol ); extern int (*inireftrias)(Info ,pMesh, pSol); extern int (*ppgdist)(Info info,pMesh mesh, pSol sol); -extern int (*ppgdistfmm)(pMesh mesh, pSol sol); +extern int (*ppgdistfmm)(Info info,pMesh mesh, pSol sol); #endif