From 523bf18206f550a315c6c17e5a0a253381b0f8bf Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@fe.uni-lj.si>
Date: Thu, 07 Jun 2012 11:16:16 +0000
Subject: [PATCH] Spherical harmonics. Almost everyhing is done. Missing triangle area calculation when vertex is moved or bond is flipped. Also missing volume calculation on vertex move or bondflip. Calculation of co coefficient is not done completely yet. Problems are in numbering the coefficients. Newly added data structure ts_spharm is referenced from ts_vesicle. Missing function for initialization and freeing the memory of that datastructure -- but that memory is already used by some functions.

---
 src/vesicle.c |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/vesicle.c b/src/vesicle.c
index e294f93..e1cc21d 100644
--- a/src/vesicle.c
+++ b/src/vesicle.c
@@ -4,34 +4,53 @@
 #include "triangle.h"
 #include "bond.h"
 #include "cell.h"
-
+#include "stdlib.h"
 
 ts_vesicle *init_vesicle(ts_uint N, ts_uint ncmax1, ts_uint ncmax2, ts_uint
 ncmax3, ts_double stepsize){
-    ts_vesicle *vesicle;
+    ts_vesicle *vesicle=(ts_vesicle *)malloc(sizeof(ts_vesicle));
     vesicle->vlist=init_vertex_list(N);
     vesicle->blist=init_bond_list();
     vesicle->tlist=init_triangle_list();
     vesicle->clist=init_cell_list(ncmax1, ncmax2, ncmax3, stepsize);
-    return TS_SUCCESS;
+    return vesicle;
 }
 
 ts_bool vesicle_translate(ts_vesicle *vesicle,ts_double x, ts_double y, ts_double z){
 	ts_uint i;
-	ts_vertex *vtx=vesicle->vlist->vertex;
+	ts_vertex **vtx=vesicle->vlist->vtx;
 	ts_uint nn=vesicle->vlist->n;
 	for(i=0;i<nn;i++){
-		vtx[i]->data->x+=x;
-		vtx[i]->data->y+=y;
-		vtx[i]->data->z+=z;
+		vtx[i]->x+=x;
+		vtx[i]->y+=y;
+		vtx[i]->z+=z;
 	}
 	return TS_SUCCESS;
 }
 
 ts_bool vesicle_free(ts_vesicle *vesicle){
-    vertex_list_free(vesicle->vlist);
+    vtx_list_free(vesicle->vlist);
     bond_list_free(vesicle->blist);
     triangle_list_free(vesicle->tlist);
     cell_list_free(vesicle->clist);
+    free(vesicle);
+    return TS_SUCCESS;
+}
+
+ts_bool vesicle_volume(ts_vesicle *vesicle){
+    ts_double volume;
+    ts_double vol;
+    ts_uint i;
+    ts_triangle **tria=vesicle->tlist->tria;
+    volume=0;
+    for(i=0; i<vesicle->tlist->n;i++){
+        vol=(tria[i]->vertex[0]->x+ tria[i]->vertex[1]->x + tria[i]->vertex[2]->x) * tria[i]->xnorm + 
+       (tria[i]->vertex[0]->y+ tria[i]->vertex[1]->y + tria[i]->vertex[2]->y) * tria[i]->ynorm + 
+    (tria[i]->vertex[0]->z+ tria[i]->vertex[1]->z + tria[i]->vertex[2]->z) *
+tria[i]->znorm;
+    volume=volume-vol/18.0;
+    }
+
+    vesicle->volume=volume;
     return TS_SUCCESS;
 }

--
Gitblit v1.9.3