From 2870ab279d5dce60c24e7a3e35d8a5e421003548 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Sat, 08 Mar 2014 07:36:34 +0000 Subject: [PATCH] backuping vtxes complete. debugging bondflip --- src/triangle.c | 29 +++++++++++++++++++++++------ 1 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/triangle.c b/src/triangle.c index f842130..311e138 100644 --- a/src/triangle.c +++ b/src/triangle.c @@ -147,11 +147,14 @@ //fatal("In triangle_remove_neighbour: Specified neighbour does not exist for given triangle",3); } tria->neigh_no--; +// fprintf(stderr,"*** tria_number=%d\n",tria->neigh_no); tria->neigh=(ts_triangle **)realloc(tria->neigh,tria->neigh_no*sizeof(ts_triangle *)); if(tria->neigh == NULL){ + fprintf(stderr,"Ooops: tria->neigh_no=%d\n",tria->neigh_no); fatal("Reallocation of memory failed during removal of vertex neighbour in triangle_remove_neighbour",100); } /* we repeat the procedure for neighbour */ + j=0; for(i=0;i<ntria->neigh_no;i++){ if(ntria->neigh[i]!=tria){ ntria->neigh[j]=ntria->neigh[i]; @@ -163,8 +166,10 @@ //fatal("In triangle_remove_neighbour: Specified neighbour does not exist for given triangle",3); } ntria->neigh_no--; +// fprintf(stderr,"*** ntria_number=%d\n",ntria->neigh_no); ntria->neigh=(ts_triangle **)realloc(ntria->neigh,ntria->neigh_no*sizeof(ts_triangle *)); if(ntria->neigh == NULL){ + fprintf(stderr,"Ooops: ntria->neigh_no=%d\n",ntria->neigh_no); fatal("Reallocation of memory failed during removal of vertex neighbour in triangle_remove_neighbour",100); } return TS_SUCCESS; @@ -194,12 +199,12 @@ */ ts_bool triangle_normal_vector(ts_triangle *tria){ ts_double x21,x31,y21,y31,z21,z31,xden; - x21=tria->vertex[1]->data->x - tria->vertex[0]->data->x; - x31=tria->vertex[2]->data->x - tria->vertex[0]->data->x; - y21=tria->vertex[1]->data->y - tria->vertex[0]->data->y; - y31=tria->vertex[2]->data->y - tria->vertex[0]->data->y; - z21=tria->vertex[1]->data->z - tria->vertex[0]->data->z; - z31=tria->vertex[2]->data->z - tria->vertex[0]->data->z; + x21=tria->vertex[1]->x - tria->vertex[0]->x; + x31=tria->vertex[2]->x - tria->vertex[0]->x; + y21=tria->vertex[1]->y - tria->vertex[0]->y; + y31=tria->vertex[2]->y - tria->vertex[0]->y; + z21=tria->vertex[1]->z - tria->vertex[0]->z; + z31=tria->vertex[2]->z - tria->vertex[0]->z; tria->xnorm=y21*z31 - z21*y31; tria->ynorm=z21*x31 - x21*z31; @@ -219,6 +224,18 @@ tria->xnorm=tria->xnorm/xden; tria->ynorm=tria->ynorm/xden; tria->znorm=tria->znorm/xden; + +/* Here it is an excellent point to recalculate volume of the triangle and + * store it into datastructure. Volume is required at least by constant volume + * calculation of vertex move and bondflip and spherical harmonics. */ + tria->volume=(tria->vertex[0]->x+ tria->vertex[1]->x + tria->vertex[2]->x) * tria->xnorm + + (tria->vertex[0]->y+ tria->vertex[1]->y + tria->vertex[2]->y) * tria->ynorm + + (tria->vertex[0]->z+ tria->vertex[1]->z + tria->vertex[2]->z) * tria->znorm; + tria->volume=-xden*tria->volume/18.0; +/* Also, area can be calculated in each triangle */ + tria->area=xden/2; + + return TS_SUCCESS; } -- Gitblit v1.9.3