From 7010269f3bc74c764f5b4e9c72dd069ce34fb244 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo@altea> Date: Wed, 18 May 2016 17:56:30 +0000 Subject: [PATCH] Fix in memory leak. There were also leaks in the old code probably. --- src/frame.c | 52 ++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/frame.c b/src/frame.c index 1ee270b..b29d3e3 100644 --- a/src/frame.c +++ b/src/frame.c @@ -1,9 +1,13 @@ +/* vim: set ts=4 sts=4 sw=4 noet : */ #include<stdlib.h> #include "general.h" #include "cell.h" #include "frame.h" + + +#include "triangle.h" ts_bool centermass(ts_vesicle *vesicle){ - ts_uint i, n=vesicle->vlist->n; + ts_uint i,j, n=vesicle->vlist->n; ts_vertex **vtx=vesicle->vlist->vtx; vesicle->cm[0]=0; vesicle->cm[1]=0; @@ -22,21 +26,37 @@ vtx[i]->y-=vesicle->cm[1]; vtx[i]->z-=vesicle->cm[2]; } +//move polymers for the same vector as we moved vesicle + for(i=0;i<vesicle->poly_list->n;i++){ + for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ + vesicle->poly_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0]; + vesicle->poly_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1]; + vesicle->poly_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2]; + } + } +//move filaments for the same vector as we moved vesicle + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + vesicle->filament_list->poly[i]->vlist->vtx[j]->x-=vesicle->cm[0]; + vesicle->filament_list->poly[i]->vlist->vtx[j]->y-=vesicle->cm[1]; + vesicle->filament_list->poly[i]->vlist->vtx[j]->z-=vesicle->cm[2]; + } + } - vesicle->cm[0]=0; - vesicle->cm[1]=0; - vesicle->cm[2]=0; + vesicle->cm[0]=0.0; + vesicle->cm[1]=0.0; + vesicle->cm[2]=0.0; + + for(i=0;i<vesicle->tlist->n;i++){ + triangle_normal_vector(vesicle->tlist->tria[i]); + } + return TS_SUCCESS; } ts_bool cell_occupation(ts_vesicle *vesicle){ ts_uint i,j,cellidx, n=vesicle->vlist->n; - //ts_double shift; - //ts_double dcell; - //shift=(ts_double) vesicle->clist->ncmax[0]/2; - //dcell=1.0/(1.0 + vesicle->stepsize); - //`fprintf(stderr, "Bil sem tu\n"); cell_list_cell_occupation_clear(vesicle->clist); for(i=0;i<n;i++){ @@ -47,17 +67,21 @@ cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->vlist->vtx[i]); } +//Add all polymers to cells for(i=0;i<vesicle->poly_list->n;i++){ for(j=0;j<vesicle->poly_list->poly[i]->vlist->n;j++){ cellidx=vertex_self_avoidance(vesicle, vesicle->poly_list->poly[i]->vlist->vtx[j]); cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->poly_list->poly[i]->vlist->vtx[j]); } } +//Add all filaments to cells + for(i=0;i<vesicle->filament_list->n;i++){ + for(j=0;j<vesicle->filament_list->poly[i]->vlist->n;j++){ + cellidx=vertex_self_avoidance(vesicle, vesicle->filament_list->poly[i]->vlist->vtx[j]); + cell_add_vertex(vesicle->clist->cell[cellidx],vesicle->filament_list->poly[i]->vlist->vtx[j]); + } + } + - - - //fprintf(stderr, "Bil sem tu\n"); - //if(dcell); - //if(shift); return TS_SUCCESS; } -- Gitblit v1.9.3