[GRASS-SVN] r70783 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 21 13:45:45 PDT 2017


Author: mmetz
Date: 2017-03-21 13:45:45 -0700 (Tue, 21 Mar 2017)
New Revision: 70783

Modified:
   grass/trunk/lib/vector/Vlib/intersect.c
Log:
vectorlib: fix r70780

Modified: grass/trunk/lib/vector/Vlib/intersect.c
===================================================================
--- grass/trunk/lib/vector/Vlib/intersect.c	2017-03-21 20:40:02 UTC (rev 70782)
+++ grass/trunk/lib/vector/Vlib/intersect.c	2017-03-21 20:45:45 UTC (rev 70783)
@@ -114,6 +114,7 @@
 {
     static int first_3d = 1;
     double d, d1, d2, r1, dtol, t;
+    int switched;
 
     /* TODO: Works for points ? */
 
@@ -129,19 +130,17 @@
 
     /*  'Sort' each segment by x, y 
      *   MUST happen before D, D1, D2 are calculated */
-    if (ax2 < ax1 || (ax2 == ax1 && ay2 < ay1)) {
-	t = ax1;
-	ax1 = ax2;
-	ax2 = t;
-	t = ay1;
-	ay1 = ay2;
-	ay2 = t;
-	t = az1;
-	az1 = az2;
-	az2 = t;
+    /*  'Sort' each segment by x, y 
+     *   MUST happen before D, D1, D2 are calculated */
+    switched = 0;
+    if (bx2 < bx1)
+	switched = 1;
+    else if (bx2 == bx1) {
+	if (by2 < by1)
+	    switched = 1;
     }
 
-    if (bx2 < bx1 || (bx2 == bx1 && by2 < by1)) {
+    if (switched) {
 	t = bx1;
 	bx1 = bx2;
 	bx2 = t;
@@ -153,6 +152,26 @@
 	bz2 = t;
     }
 
+    switched = 0;
+    if (ax2 < ax1)
+	switched = 1;
+    else if (ax2 == ax1) {
+	if (ay2 < ay1)
+	    switched = 1;
+    }
+
+    if (switched) {
+	t = ax1;
+	ax1 = ax2;
+	ax2 = t;
+	t = ay1;
+	ay1 = ay2;
+	ay2 = t;
+	t = az1;
+	az1 = az2;
+	az2 = t;
+    }
+
     /* Check for identical segments */
     if (ax1 == bx1 && ay1 == by1 && ax2 == bx2 && ay2 == by2) {
 	G_debug(2, " -> identical segments");



More information about the grass-commit mailing list