Procházet zdrojové kódy

Vlib: alloc rect boundaries

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51851 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz před 13 roky
rodič
revize
1a78f0b6c2
2 změnil soubory, kde provedl 17 přidání a 5 odebrání
  1. 7 1
      lib/vector/Vlib/break_polygons.c
  2. 10 4
      lib/vector/Vlib/snap.c

+ 7 - 1
lib/vector/Vlib/break_polygons.c

@@ -113,12 +113,18 @@ void Vect_break_polygons_file(struct Map_info *Map, int type, struct Map_info *E
     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()");
 

+ 10 - 4
lib/vector/Vlib/snap.c

@@ -93,9 +93,6 @@ Vect_snap_lines_list(struct Map_info *Map, const struct ilist *List_lines,
     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 @@ Vect_snap_lines_list(struct Map_info *Map, const struct ilist *List_lines,
     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 @@ Vect_snap_lines(struct Map_info *Map, int type, double thresh,
 		struct Map_info *Err)
 {
     int line, nlines, ltype;
-
     struct ilist *List;
 
     List = Vect_new_list();