Skip to content

Commit

Permalink
Solve small inconsistencies in variable types for distpt and distnv f…
Browse files Browse the repository at this point in the history
…unctions.

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
.
  • Loading branch information
Algiane committed Oct 8, 2024
1 parent fc49872 commit a54f293
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
13 changes: 8 additions & 5 deletions sources/mshdis1_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion sources/mshdis1_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
8 changes: 4 additions & 4 deletions sources/mshdist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);
Expand Down
7 changes: 4 additions & 3 deletions sources/tools_2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions sources/tools_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit a54f293

Please sign in to comment.