From 3cd5f4a96d445b55da8a7e6da8509bbd7d5d41b8 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@fe.uni-lj.si>
Date: Thu, 15 Sep 2016 06:29:31 +0000
Subject: [PATCH] Fixes #19.

---
 src/main.c    |    1 +
 src/poly.c    |    9 +++++----
 src/restore.c |    7 ++++++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/main.c b/src/main.c
index c2e51af..596d4a5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -48,6 +48,7 @@
 		ts_fprintf(stdout,"**** Restoring vesicle from VTK points list ****\n");
 		ts_fprintf(stdout,"************************************************\n\n");
 		vesicle = parseDump(command_line_args.dump_from_vtk);
+//		write_vertex_xml_file(vesicle,9999); // here you can test if restoration and rewritting results in the same dump file. Only the date od creation of dump file must differ.
 		tape = vesicle->tape;
 		int arguments_no;
 		FILE *fd=fopen(".status","r");
diff --git a/src/poly.c b/src/poly.c
index 252b1c6..7c7450b 100644
--- a/src/poly.c
+++ b/src/poly.c
@@ -156,9 +156,9 @@
 
 ts_bool poly_free(ts_poly *poly){
 
-	if (poly->grafted_vtx!=NULL){
-		poly->grafted_vtx->grafted_poly=NULL;
-	}
+//	if (poly->grafted_vtx!=NULL){
+//		poly->grafted_vtx->grafted_poly=NULL;
+//	}
 	vtx_list_free(poly->vlist);
 	bond_list_free(poly->blist);
 	free(poly);
@@ -168,8 +168,9 @@
 
 ts_bool poly_list_free(ts_poly_list *poly_list){
 	ts_uint i;
-
+	//fprintf(stderr,"no. of polys=%d\n", poly_list->n);
 	for(i=0;i<poly_list->n;i++){
+	//	fprintf(stderr,"%d poly address in mem=%ld\n",i+1,(long)&(poly_list->poly[i]));
 		poly_free(poly_list->poly[i]);
 	}
 	free(poly_list->poly);
diff --git a/src/restore.c b/src/restore.c
index 3a93d3f..086bf1c 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -372,6 +372,7 @@
 	char *b;
 	int idx, polyidx;
 	char *token[2];
+	int temp_cnt=0;
 	while (child != NULL) {
 		conname=xmlGetProp(child, (xmlChar *)"Name");
 		if ((!xmlStrcmp(child->name, (const xmlChar *)"DataArray")) && !xmlStrcmp(conname, (const xmlChar *)"connectivity") ){
@@ -383,11 +384,15 @@
 			while(token[0]!=NULL){
 				if(idx<3*(vesicle->vlist->n-2)){
 					bond_add(vesicle->blist, vesicle->vlist->vtx[atoi(token[0])], vesicle->vlist->vtx[atoi(token[1])]);
+					//fprintf(stderr,"Bonds in vesicle count idx=%d\n",idx);
 				}
 				else {
 				//find grafted vtx
 					if(vesicle->tape->npoly && vesicle->tape->nmono && (vesicle->tape->nmono-1)==(idx-3*(vesicle->vlist->n-2))%(vesicle->tape->nmono)
-						&& idx<(3*vesicle->vlist->n-2+vesicle->tape->nmono*vesicle->tape->npoly+vesicle->tape->npoly)){
+						&& idx<(3*vesicle->vlist->n-2+vesicle->tape->nmono*vesicle->tape->npoly)){
+						temp_cnt++;
+						//fprintf(stderr,"%d: Bonds in poly count idx=%d, t1=%s t2=%s\n",temp_cnt,idx, token[0], token[1]);
+						
 						polyidx=(idx-3*(vesicle->vlist->n-2))/(vesicle->tape->nmono);
 						//fprintf(stderr,"poly=%d, vertex=%d\n",polyidx,atoi(token[0]));
 						vesicle->poly_list->poly[polyidx]->grafted_vtx=vesicle->vlist->vtx[atoi(token[0])];

--
Gitblit v1.9.3