From 7d62fc765adc11bbcb7db0716ac5dc19145dca80 Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Sun, 15 Jun 2014 10:58:40 +0000
Subject: [PATCH] To be sure a fix in comparing the floating point numbers

---
 src/cross-section.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/cross-section.c b/src/cross-section.c
index b98d34c..d25f934 100644
--- a/src/cross-section.c
+++ b/src/cross-section.c
@@ -27,7 +27,7 @@
 		if(Dsq<vesicle->dmax){
 			for(j=0;j<vtx->neigh_no;j++){
 				ppn1=vtx->neigh[j]->x*a+vtx->neigh[j]->y*b+vtx->neigh[j]->z*c+d;
-				if(pp*ppn1<=0){ //the combination of vertices are good candidates for a crossection
+				if(pp*ppn1<=0.0){ //the combination of vertices are good candidates for a crossection
 					//find triangle that belongs to the two vertices
 					ntria=0;
 					for(k=0;k<vtx->tristar_no;k++){
@@ -37,12 +37,7 @@
 							ntria++;
 						}
 					}
-					// if ntria !=1 there is probably something wrong I would say...
-					if(ntria==0) continue;
-				/*	if(ntria!=1) { //there should be 2 triangles. of course, all some of them will be doubled.
-						fprintf(stderr,"ntria=%u\n",ntria);
-						fatal ("Error in mesh. 2 triangles not found",123123);
-					} */
+					if(ntria==0) continue; // no need to continue
 					//find the two intersections (in general) to form a intersection line
 					for(l=0;l<ntria;l++){
 					//we add intersection line between two points for each of the triangles found above.
@@ -63,7 +58,7 @@
 ts_bool add_crosssection_point(ts_coord_list *pts, ts_double a, ts_double b, ts_double c, ts_double d, ts_vertex *vtx1, ts_vertex *vtx2){
 	ts_double pp=vtx1->x*a+vtx1->y*b+vtx1->z*c+d;
 	ts_double pp2=vtx2->x*a+vtx1->y*b+vtx2->z*c+d;
-	if(pp*pp2<=0){
+	if(pp*pp2<=0.0){
 	ts_double u=pp/(a*(vtx1->x-vtx2->x)+b*(vtx1->y-vtx2->y)+c*(vtx1->z-vtx2->z));
 	add_coord(pts, vtx1->x+u*(vtx2->x - vtx1->x),
 		vtx1->y+u*(vtx2->y - vtx1->y),		

--
Gitblit v1.9.3