From a37ba25eb9dc4b99ced8e8dcc3c36b9ed434a262 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Thu, 06 Mar 2014 07:58:36 +0000 Subject: [PATCH] Fixed a bug in vertex reinit. Still buggy. --- src/io.c | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/io.c b/src/io.c index 262e482..d022d89 100644 --- a/src/io.c +++ b/src/io.c @@ -127,6 +127,8 @@ poly_list->poly->bond */ + fwrite(vesicle->clist, sizeof(ts_cell_list),1, fh); + fclose(fh); return TS_SUCCESS; } @@ -170,11 +172,13 @@ for(i=0;i<vesicle->tlist->n;i++){ vesicle->tlist->tria[i]=(ts_triangle *)malloc(sizeof(ts_triangle)); } - - /*restore vertices*/ +/* prerequisity. Vertices must be malloced before vertexes are recreated */ vesicle->vlist->vtx=(ts_vertex **)calloc(vesicle->vlist->n,sizeof(ts_vertex *)); - for(i=0;i<vesicle->vlist->n;i++){ + for(i=0;i<vesicle->vlist->n;i++){ vesicle->vlist->vtx[i]=(ts_vertex *)malloc(sizeof(ts_vertex)); + } + /*restore vertices*/ + for(i=0;i<vesicle->vlist->n;i++){ retval=fread(vesicle->vlist->vtx[i],sizeof(ts_vertex),1,fh); /*restore neigh, bond, tristar. Ignoring cell */ vesicle->vlist->vtx[i]->neigh=(ts_vertex **)calloc(vesicle->vlist->vtx[i]->neigh_no, sizeof(ts_vertex *)); @@ -298,8 +302,14 @@ } } - - +// recreating space for cells // + vesicle->clist=(ts_cell_list *)malloc(sizeof(ts_cell_list)); + retval=fread(vesicle->clist, sizeof(ts_cell_list), 1,fh); + vesicle->clist->cell=(ts_cell **)malloc(sizeof(ts_cell *)*vesicle->clist->ncmax[0]*vesicle->clist->ncmax[1]*vesicle->clist->ncmax[2]); + for(i=0;i<vesicle->clist->ncmax[0]*vesicle->clist->ncmax[1]*vesicle->clist->ncmax[2];i++){ + vesicle->clist->cell[i]=(ts_cell *)calloc(1,sizeof(ts_cell)); + vesicle->clist->cell[i]->idx=i+1; // We enumerate cells! Probably never required! + } if(retval); fclose(fh); -- Gitblit v1.9.3