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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 15 02:59:01 PDT 2013


Author: mmetz
Date: 2013-04-15 02:58:59 -0700 (Mon, 15 Apr 2013)
New Revision: 55813

Modified:
   grass/trunk/lib/vector/Vlib/intersect.c
Log:
Vlib: clean up Vect_segment_intersection()

Modified: grass/trunk/lib/vector/Vlib/intersect.c
===================================================================
--- grass/trunk/lib/vector/Vlib/intersect.c	2013-04-15 08:30:21 UTC (rev 55812)
+++ grass/trunk/lib/vector/Vlib/intersect.c	2013-04-15 09:58:59 UTC (rev 55813)
@@ -128,6 +128,19 @@
 	first_3d = 0;
     }
 
+    /* Check identical segments */
+    if ((ax1 == bx1 && ay1 == by1 && ax2 == bx2 && ay2 == by2) ||
+	(ax1 == bx2 && ay1 == by2 && ax2 == bx1 && ay2 == by1)) {
+	G_debug(2, " -> identical segments");
+	*x1 = ax1;
+	*y1 = ay1;
+	*z1 = az1;
+	*x2 = ax2;
+	*y2 = ay2;
+	*z2 = az2;
+	return 5;
+    }
+
     /*  'Sort' lines by x, y */
     switched = 0;
     if (bx2 < bx1)
@@ -169,19 +182,6 @@
 	az2 = t;
     }
 
-    /* Check identical segments */
-    if ((ax1 == bx1 && ay1 == by1 && ax2 == bx2 && ay2 == by2) ||
-	(ax1 == bx2 && ay1 == by2 && ax2 == bx1 && ay2 == by1)) {
-	G_debug(2, " -> identical segments");
-	*x1 = ax1;
-	*y1 = ay1;
-	*z1 = az1;
-	*x2 = ax2;
-	*y2 = ay2;
-	*z2 = az2;
-	return 5;
-    }
-
     /* Check distinct (non-touching) segments */
     if ((bx1 > ax1 && bx2 > ax1 && bx1 > ax2 && bx2 > ax2) ||
 	(bx1 < ax1 && bx2 < ax1 && bx1 < ax2 && bx2 < ax2)) {
@@ -240,17 +240,7 @@
     /* original code assumed lines were not both vertical
      *  so there is a special case if they are */
     if (ax1 == ax2) {
-	if (bx1 != bx2)
-	    G_fatal_error("Vect_segment_intersection(): bx1 != bx2");
-	if (ax1 != bx1)
-	    G_fatal_error("Vect_segment_intersection(): ax1 != bx1");
-
 	G_debug(2, "  -> collinear vertical");
-	/* TODO: remove, already checked above */
-	if (ay1 > by2 || ay2 < by1) {
-	    G_debug(2, "   -> no intersection");
-	    return 0;
-	}
 
 	/* end points */
 	if (ay1 == by2) {



More information about the grass-commit mailing list