From b01cc1ac677dc712c27337be8ee4f11ea336f31b Mon Sep 17 00:00:00 2001
From: Samo Penic <samo@andromeda>
Date: Sun, 05 Dec 2010 13:02:22 +0000
Subject: [PATCH] Fixed some nasty bugs. Still, I suspect the vertex neighbours are not correctly oriented or something, since tristar triangles are not successfully set. (tristar_no is not always the same as neigh_no!)

---
 src/bond.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/bond.c b/src/bond.c
index 289079a..1478720 100644
--- a/src/bond.c
+++ b/src/bond.c
@@ -10,10 +10,15 @@
 }
 
 ts_bond  *bond_add(ts_bond_list *blist, ts_vertex *vtx1, ts_vertex *vtx2){
-    
+    ts_uint i;
     /* no vertices must be null! */
     if(vtx1==NULL || vtx2==NULL) return NULL;
-    /* TODO: Verify if the bond already exists... Don't do multiple bonds */
+    /* Verify if the bond already exists... Don't do multiple bonds */
+    for(i=0;i<blist->n;i++){
+       if((blist->bond[i]->data->vtx1==vtx1 || blist->bond[i]->data->vtx1==vtx2)
+        &&(blist->bond[i]->data->vtx2==vtx1 || blist->bond[i]->data->vtx2==vtx2))
+        return blist->bond[i];
+    }
 	blist->n++;
 	blist->bond=(ts_bond **)realloc(blist->bond,blist->n*sizeof(ts_bond *));
 	if(blist->bond==NULL) fatal("Cannot reallocate memory for additional **ts_bond.",100);

--
Gitblit v1.9.3