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

svn_grass at osgeo.org svn_grass at osgeo.org
Mon May 28 04:52:53 PDT 2012


Author: mmetz
Date: 2012-05-28 04:52:53 -0700 (Mon, 28 May 2012)
New Revision: 51851

Modified:
   grass/trunk/lib/vector/Vlib/break_polygons.c
   grass/trunk/lib/vector/Vlib/snap.c
Log:
Vlib: alloc rect boundaries

Modified: grass/trunk/lib/vector/Vlib/break_polygons.c
===================================================================
--- grass/trunk/lib/vector/Vlib/break_polygons.c	2012-05-28 11:49:14 UTC (rev 51850)
+++ grass/trunk/lib/vector/Vlib/break_polygons.c	2012-05-28 11:52:53 UTC (rev 51851)
@@ -113,12 +113,18 @@
     struct RTree *RTree;
     int npoints, nallpoints, nmarks;
     XPNT2 XPnt;
-    struct RTree_Rect rect;
     double dx, dy, a1 = 0, a2 = 0;
     int closed, last_point;
     char cross;
     int fd, xpntfd;
     char *filename;
+    static struct RTree_Rect rect;
+    static int rect_init = 0;
+
+    if (!rect_init) {
+	rect.boundary = G_malloc(6 * sizeof(RectReal));
+	rect_init = 6;
+    }
     
     G_debug(1, "File-based version of Vect_break_polygons()");
 

Modified: grass/trunk/lib/vector/Vlib/snap.c
===================================================================
--- grass/trunk/lib/vector/Vlib/snap.c	2012-05-28 11:49:14 UTC (rev 51850)
+++ grass/trunk/lib/vector/Vlib/snap.c	2012-05-28 11:52:53 UTC (rev 51851)
@@ -93,9 +93,6 @@
     int line, ltype, line_idx;
     double thresh2;
 
-    struct RTree *RTree;
-    int rtreefd = -1;
-    struct RTree_Rect rect;
     int point;			/* index in points array */
     int nanchors, ntosnap;	/* number of anchors and number of points to be snapped */
     int nsnapped, ncreated;	/* number of snapped verices, number of new vertices (on segments) */
@@ -107,6 +104,16 @@
     int *Index = NULL;		/* indexes of anchors for vertices */
     int aindex = 0;		/* allocated Index */
 
+    struct RTree *RTree;
+    int rtreefd = -1;
+    static struct RTree_Rect rect;
+    static int rect_init = 0;
+
+    if (!rect_init) {
+	rect.boundary = G_malloc(6 * sizeof(RectReal));
+	rect_init = 6;
+    }
+
     if (List_lines->n_values < 1)
 	return;
 
@@ -469,7 +476,6 @@
 		struct Map_info *Err)
 {
     int line, nlines, ltype;
-
     struct ilist *List;
 
     List = Vect_new_list();



More information about the grass-commit mailing list