[GRASS-SVN] r55265 - in grass/trunk: include/defs lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Feb 28 10:51:16 PST 2013


Author: mmetz
Date: 2013-02-28 10:51:16 -0800 (Thu, 28 Feb 2013)
New Revision: 55265

Modified:
   grass/trunk/include/defs/vector.h
   grass/trunk/lib/vector/Vlib/intersect.c
Log:
Vlib: optimize Vect_line_intersection()

Modified: grass/trunk/include/defs/vector.h
===================================================================
--- grass/trunk/include/defs/vector.h	2013-02-28 17:56:47 UTC (rev 55264)
+++ grass/trunk/include/defs/vector.h	2013-02-28 18:51:16 UTC (rev 55265)
@@ -423,6 +423,7 @@
                               double *, double *, double *, double *,
                               double *, double *, int);
 int Vect_line_intersection(struct line_pnts *, struct line_pnts *,
+                           struct bound_box *, struct bound_box *,
                            struct line_pnts ***, struct line_pnts ***, int *,
                            int *, int);
 int Vect_line_check_intersection(struct line_pnts *, struct line_pnts *, int);

Modified: grass/trunk/lib/vector/Vlib/intersect.c
===================================================================
--- grass/trunk/lib/vector/Vlib/intersect.c	2013-02-28 17:56:47 UTC (rev 55264)
+++ grass/trunk/lib/vector/Vlib/intersect.c	2013-02-28 18:51:16 UTC (rev 55265)
@@ -600,6 +600,8 @@
 int
 Vect_line_intersection(struct line_pnts *APoints,
 		       struct line_pnts *BPoints,
+		       struct bound_box *ABox,
+		       struct bound_box *BBox,
 		       struct line_pnts ***ALines,
 		       struct line_pnts ***BLines,
 		       int *nalines, int *nblines, int with_z)
@@ -692,27 +694,25 @@
      *  is build first for the second line and segments from the first line are broken by segments
      *  in bound box */
 
-    dig_line_box(APoints, &box);
-    dig_line_box(BPoints, &abbox);
-
-    if (!Vect_box_overlap(&box, &abbox)) {
+    if (!Vect_box_overlap(ABox, BBox)) {
 	*nalines = 0;
 	*nblines = 0;
 	return 0;
     }
     
-    if (abbox.N > box.N)
-	abbox.N = box.N;
-    if (abbox.S < box.S)
-	abbox.S = box.S;
-    if (abbox.E > box.E)
-	abbox.E = box.E;
-    if (abbox.W < box.W)
-	abbox.W = box.W;
-    if (abbox.T > box.T)
-	abbox.T = box.T;
-    if (abbox.B < box.B)
-	abbox.B = box.B;
+    abbox = *BBox;
+    if (abbox.N > ABox->N)
+	abbox.N = ABox->N;
+    if (abbox.S < ABox->S)
+	abbox.S = ABox->S;
+    if (abbox.E > ABox->E)
+	abbox.E = ABox->E;
+    if (abbox.W < ABox->W)
+	abbox.W = ABox->W;
+    if (abbox.T > ABox->T)
+	abbox.T = ABox->T;
+    if (abbox.B < ABox->B)
+	abbox.B = ABox->B;
 
     abbox.N += rethresh;
     abbox.S -= rethresh;



More information about the grass-commit mailing list