From 144784496550cccc927607be8edc487af7aa851f Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Mon, 24 Mar 2014 08:53:44 +0000
Subject: [PATCH] Fix.

---
 src/main.c     |    2 +-
 src/timestep.c |    3 +++
 src/io.c       |   33 +++++++++++++++++++++++++++++++++
 src/io.h       |    2 ++
 4 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/src/io.c b/src/io.c
index b222081..17adda4 100644
--- a/src/io.c
+++ b/src/io.c
@@ -918,6 +918,39 @@
 
 
 
+ts_bool write_pov_file(ts_vesicle *vesicle, char *filename){
+	FILE *fh;
+	ts_uint i;
+	
+	fh=fopen(filename, "w");
+	if(fh==NULL){
+		err("Cannot open file %s for writing");
+		return TS_FAIL;
+	}
+
+	for(i=0;i<vesicle->tlist->n;i++){
+	
+	fprintf(fh,"\ttriangle {");
+	fprintf(fh,"\t<%e,%e,%e> <%e,%e,%e> <%e,%e,%e> }\n", 
+	vesicle->tlist->tria[i]->vertex[0]->x,
+	vesicle->tlist->tria[i]->vertex[0]->y,
+	vesicle->tlist->tria[i]->vertex[0]->z,
+
+	vesicle->tlist->tria[i]->vertex[1]->x,
+	vesicle->tlist->tria[i]->vertex[1]->y,
+	vesicle->tlist->tria[i]->vertex[1]->z,
+
+	vesicle->tlist->tria[i]->vertex[2]->x,
+	vesicle->tlist->tria[i]->vertex[2]->y,
+	vesicle->tlist->tria[i]->vertex[2]->z
+	);
+	}
+		
+	fclose(fh);
+	return TS_SUCCESS;
+}
+
+
 ts_tape *parsetape(char *filename){
   //  long int nshell=17,ncxmax=60, ncymax=60, nczmax=60, npoly=10, nmono=20, pswitch=0;  // THIS IS DUE TO CONFUSE BUG!
     ts_tape *tape=(ts_tape *)calloc(1,sizeof(ts_tape));
diff --git a/src/io.h b/src/io.h
index bfc6173..8118db4 100644
--- a/src/io.h
+++ b/src/io.h
@@ -98,6 +98,8 @@
 ts_bool write_vertex_vtk_file(ts_vesicle *vesicle,ts_char *filename, ts_char *text);
 ts_bool write_vertex_xml_file(ts_vesicle *vesicle, ts_uint timestepno);
 ts_bool write_master_xml_file(ts_char *filename);
+ts_bool write_pov_file(ts_vesicle *vesicle, char *filename);
+
 ts_tape *parsetape(char *filename);
 ts_bool tape_free(ts_tape *tape);
 
diff --git a/src/main.c b/src/main.c
index 588e277..c052928 100644
--- a/src/main.c
+++ b/src/main.c
@@ -49,7 +49,7 @@
 		vesicle->dmax=tape->dmax*tape->dmax;
 		poly_assign_filament_xi(vesicle,tape);
 
-		if(command_line_args.reset_iteration_count) start_iteration=tape->inititer-1;
+		if(command_line_args.reset_iteration_count) start_iteration=tape->inititer;
 		else start_iteration++;
 
 		if(start_iteration>=tape->iterations){
diff --git a/src/timestep.c b/src/timestep.c
index d631d42..3369b9f 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -11,6 +11,7 @@
 
 ts_bool run_simulation(ts_vesicle *vesicle, ts_uint mcsweeps, ts_uint inititer, ts_uint iterations, ts_uint start_iteration){
 	ts_uint i, j;
+ 	char filename[255];
 
 	centermass(vesicle);
 	cell_occupation(vesicle);
@@ -25,6 +26,8 @@
             dump_state(vesicle,i);
 		if(i>=inititer){
 			write_vertex_xml_file(vesicle,i-inititer);
+		//	sprintf(filename,"timestep-%05d.pov",i-inititer);
+			write_pov_file(vesicle,filename);
 		}
 	}
 	return TS_SUCCESS;

--
Gitblit v1.9.3