[GRASS-SVN] r57953 - grass/trunk/vector/v.voronoi
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 7 00:09:12 PDT 2013
Author: mmetz
Date: 2013-10-07 00:09:12 -0700 (Mon, 07 Oct 2013)
New Revision: 57953
Removed:
grass/trunk/vector/v.voronoi/dt_write.c
grass/trunk/vector/v.voronoi/sw_output.c
grass/trunk/vector/v.voronoi/write.h
Modified:
grass/trunk/vector/v.voronoi/main.c
grass/trunk/vector/v.voronoi/sw_defs.h
grass/trunk/vector/v.voronoi/sw_geometry.c
grass/trunk/vector/v.voronoi/sw_main.c
grass/trunk/vector/v.voronoi/sw_voronoi.c
grass/trunk/vector/v.voronoi/vo_extend.c
grass/trunk/vector/v.voronoi/vo_write.c
Log:
v.voronoi: remove unused functions
Deleted: grass/trunk/vector/v.voronoi/dt_write.c
===================================================================
--- grass/trunk/vector/v.voronoi/dt_write.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/dt_write.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -1,94 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <float.h>
-#include <grass/gis.h>
-#include <grass/vector.h>
-#include <grass/display.h>
-#include "sw_defs.h"
-#include "defs.h"
-#include "write.h"
-
-int write_triple(struct Site *s1, struct Site *s2, struct Site *s3)
-{
- int i;
- int node;
- static struct line_pnts *Points = NULL;
- static struct line_cats *Cats = NULL;
- struct Site *sa, *sb;
-
-
- if (!Points) {
- Points = Vect_new_line_struct();
- Cats = Vect_new_cats_struct();
- }
-
- if (triangulate) {
- for (i = 0; i < 3; i++) {
- switch (i) {
- case 0:
- sa = s1;
- sb = s2;
- break;
- case 1:
- sa = s2;
- sb = s3;
- break;
- case 2:
- sa = s3;
- sb = s1;
- break;
- }
-
- /* Look if the line already exists */
- node =
- Vect_find_node(&Out, sa->coord.x, sa->coord.y, 0.0, 0.0, 0);
-
- if (node > 0) { /* node found */
- int j, nlines;
- int found = 0;
- double x, y, z;
-
- nlines = Vect_get_node_n_lines(&Out, node);
-
- for (j = 0; j < nlines; j++) {
- int line, node2;
-
- line = Vect_get_node_line(&Out, node, j);
-
- if (line > 0)
- Vect_get_line_nodes(&Out, line, NULL, &node2);
- else
- Vect_get_line_nodes(&Out, abs(line), &node2, NULL);
-
- Vect_get_node_coor(&Out, node2, &x, &y, &z);
-
- if (x == sb->coord.x && y == sb->coord.y) {
- found = 1;
- break;
- }
- }
-
- if (found)
- continue; /* next segment */
- }
-
- /* Not found, write it */
- Vect_reset_line(Points);
- if (mode3d) {
- G_debug(3, "sa->coord.z: %f", sa->coord.z);
- Vect_append_point(Points, sa->coord.x, sa->coord.y,
- sa->coord.z);
- Vect_append_point(Points, sb->coord.x, sb->coord.y,
- sb->coord.z);
- }
- else {
- Vect_append_point(Points, sa->coord.x, sa->coord.y, 0.0);
- Vect_append_point(Points, sb->coord.x, sb->coord.y, 0.0);
- }
- Vect_write_line(&Out, Type, Points, Cats);
- }
- }
-
- return 0;
-}
Modified: grass/trunk/vector/v.voronoi/main.c
===================================================================
--- grass/trunk/vector/v.voronoi/main.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/main.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -197,12 +197,11 @@
siteidx = 0;
geominit();
- triangulate = 0;
plot = 0;
debug = 0;
G_message(_("Processing Voronoi triangulation..."));
- voronoi(triangulate, nextone);
+ voronoi(nextone);
/* Close free ends by current region */
verbose = G_verbose();
Modified: grass/trunk/vector/v.voronoi/sw_defs.h
===================================================================
--- grass/trunk/vector/v.voronoi/sw_defs.h 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/sw_defs.h 2013-10-07 07:09:12 UTC (rev 57953)
@@ -46,7 +46,7 @@
struct Halfedge *PQnext;
};
-extern int triangulate, sorted, plot, debug, mode3d;
+extern int sorted, plot, debug, mode3d;
extern struct Site *sites;
extern int nsites;
extern int siteidx;
@@ -111,18 +111,13 @@
int makefree(struct Freenode *, struct Freelist *);
char *myalloc(unsigned);
-/* sw_output.c */
-int openpl(void);
-int line(int, int, int, int);
-int circle(int, int, int);
-int range(int, int, int, int);
-int out_bisector(struct Edge *);
-int out_ep(struct Edge *);
-int out_vertex(struct Site *);
-int out_site(struct Site *);
-int out_triple(struct Site *, struct Site *, struct Site *);
-int plotinit(void);
-int clip_line(struct Edge *);
-
/* sw_voronoi.c */
-int voronoi(int, struct Site *(*)(void));
+int voronoi(struct Site *(*)(void));
+
+/* vo_extend.c */
+int extend_line(double, double, double, double, double, double, double,
+ double, double, double *, double *, int);
+
+/* vo_write.c */
+int write_ep(struct Edge *);
+
Modified: grass/trunk/vector/v.voronoi/sw_geometry.c
===================================================================
--- grass/trunk/vector/v.voronoi/sw_geometry.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/sw_geometry.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -61,7 +61,6 @@
}
newedge->edgenbr = nedges;
- out_bisector(newedge);
nedges++;
return (newedge);
}
@@ -196,7 +195,7 @@
ref(s);
if (e->ep[re - lr] == (struct Site *)NULL)
return -1;
- out_ep(e);
+ write_ep(e);
deref(e->reg[le]);
deref(e->reg[re]);
makefree((struct Freenode *)e, &efl);
@@ -217,7 +216,6 @@
{
v->sitenbr = -1;
nvertices++;
- out_vertex(v);
return 0;
}
Modified: grass/trunk/vector/v.voronoi/sw_main.c
===================================================================
--- grass/trunk/vector/v.voronoi/sw_main.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/sw_main.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -8,7 +8,7 @@
#include "sw_defs.h"
#include "defs.h"
-int triangulate, sorted, plot, debug, mode3d;
+int sorted, plot, debug, mode3d;
struct Site *sites;
int nsites;
int siteidx;
Deleted: grass/trunk/vector/v.voronoi/sw_output.c
===================================================================
--- grass/trunk/vector/v.voronoi/sw_output.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/sw_output.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -1,213 +0,0 @@
-#include <stdio.h>
-#include <math.h>
-#include <float.h>
-#include <grass/vector.h>
-#include "sw_defs.h"
-#include "write.h"
-
-int openpl(void)
-{
- return 0;
-}
-int line(int a, int b, int c, int d)
-{
- return 0;
-}
-int circle(int a, int b, int c)
-{
- return 0;
-}
-int range(int a, int b, int c, int d)
-{
- return 0;
-}
-
-double pxmin, pxmax, pymin, pymax, cradius;
-
-int out_bisector(struct Edge *e)
-{
- if (triangulate & plot & !debug) {
- line(e->reg[0]->coord.x, e->reg[0]->coord.y, e->reg[1]->coord.x,
- e->reg[1]->coord.y);
- }
-
- /*
- if(!triangulate & !plot &!debug) {
- fprintf (stdout,"l %.*g %.*g %.*g \n", DBL_DIG, e->a, DBL_DIG, e->b, DBL_DIG, e->c);
- }
-
- if(debug) {
- fprintf (stdout,"line(%d) %gx+%gy=%g, bisecting %d %d\n", e->edgenbr,
- e->a, e->b, e->c, e->reg[le]->sitenbr, e->reg[re]->sitenbr);
- }
- */
-
- return 0;
-}
-
-int out_ep(struct Edge *e)
-{
- if ((!triangulate) & plot)
- clip_line(e);
- if ((!triangulate) & !plot) {
- /*
- fprintf (stdout,"e %d", e->edgenbr);
- fprintf (stdout," %d ", e->ep[le] != (struct Site *)NULL ? e->ep[le]->sitenbr : -1);
- fprintf (stdout,"%d\n", e->ep[re] != (struct Site *)NULL ? e->ep[re]->sitenbr : -1);
- */
-
- write_ep(e);
- }
-
- return 0;
-}
-
-int out_vertex(struct Site *v)
-{
- /*
- if(!triangulate & !plot &!debug)
- fprintf (stdout,"v %.*g %.*g\n", DBL_DIG, v->coord.x, DBL_DIG, v->coord.y);
- if(debug)
- fprintf (stdout,"vertex(%d) at %f %f\n", v->sitenbr, v->coord.x, v->coord.y);
- */
-
- return 0;
-}
-
-
-int out_site(struct Site *s)
-{
- if ((!triangulate) & plot & (!debug))
- circle(s->coord.x, s->coord.y, cradius);
-
- /*
- if(!triangulate & !plot & !debug)
- fprintf (stdout,"s %f %f\n", s->coord.x, s->coord.y);
- if(debug)
- fprintf (stdout,"site (%d) at %f %f\n", s->sitenbr, s->coord.x, s->coord.y);
- */
-
- return 0;
-}
-
-int out_triple(struct Site *s1, struct Site *s2, struct Site *s3)
-{
- if (triangulate & !plot & !debug) {
- /* fprintf (stdout,"%d %d %d\n", s1->sitenbr, s2->sitenbr, s3->sitenbr); */
-
- write_triple(s1, s2, s3);
- }
-
- /*
- if(debug)
- fprintf (stdout,"circle through left=%d right=%d bottom=%d\n",
- s1->sitenbr, s2->sitenbr, s3->sitenbr);
- */
-
- return 0;
-}
-
-int plotinit(void)
-{
- double dx, dy, d;
-
- dy = ymax - ymin;
- dx = xmax - xmin;
- d = (dx > dy ? dx : dy) * 1.1;
- pxmin = xmin - (d - dx) / 2.0;
- pxmax = xmax + (d - dx) / 2.0;
- pymin = ymin - (d - dy) / 2.0;
- pymax = ymax + (d - dy) / 2.0;
- cradius = (pxmax - pxmin) / 350.0;
- openpl();
- range(pxmin, pymin, pxmax, pymax);
-
- return 0;
-}
-
-
-int clip_line(struct Edge *e)
-{
- struct Site *s1, *s2;
- double x1, x2, y1, y2;
-
- if (e->a == 1.0 && e->b >= 0.0) {
- s1 = e->ep[1];
- s2 = e->ep[0];
- }
- else {
- s1 = e->ep[0];
- s2 = e->ep[1];
- }
-
- if (e->a == 1.0) {
- y1 = pymin;
- if (s1 != (struct Site *)NULL && s1->coord.y > pymin)
- y1 = s1->coord.y;
- if (y1 > pymax)
- return -1;
- x1 = e->c - e->b * y1;
- y2 = pymax;
- if (s2 != (struct Site *)NULL && s2->coord.y < pymax)
- y2 = s2->coord.y;
- if (y2 < pymin)
- return (0);
- x2 = e->c - e->b * y2;
- if (((x1 > pxmax) & (x2 > pxmax)) | ((x1 < pxmin) & (x2 < pxmin)))
- return -1;
-
- if (x1 > pxmax) {
- x1 = pxmax;
- y1 = (e->c - x1) / e->b;
- }
- if (x1 < pxmin) {
- x1 = pxmin;
- y1 = (e->c - x1) / e->b;
- }
- if (x2 > pxmax) {
- x2 = pxmax;
- y2 = (e->c - x2) / e->b;
- }
- if (x2 < pxmin) {
- x2 = pxmin;
- y2 = (e->c - x2) / e->b;
- }
- }
- else {
- x1 = pxmin;
- if (s1 != (struct Site *)NULL && s1->coord.x > pxmin)
- x1 = s1->coord.x;
- if (x1 > pxmax)
- return (0);
- y1 = e->c - e->a * x1;
- x2 = pxmax;
- if (s2 != (struct Site *)NULL && s2->coord.x < pxmax)
- x2 = s2->coord.x;
- if (x2 < pxmin)
- return (0);
- y2 = e->c - e->a * x2;
- if (((y1 > pymax) & (y2 > pymax)) | ((y1 < pymin) & (y2 < pymin)))
- return 0;
-
- if (y1 > pymax) {
- y1 = pymax;
- x1 = (e->c - y1) / e->a;
- }
- if (y1 < pymin) {
- y1 = pymin;
- x1 = (e->c - y1) / e->a;
- }
- if (y2 > pymax) {
- y2 = pymax;
- x2 = (e->c - y2) / e->a;
- }
- if (y2 < pymin) {
- y2 = pymin;
- x2 = (e->c - y2) / e->a;
- }
- }
-
- line(x1, y1, x2, y2);
-
- return 0;
-}
Modified: grass/trunk/vector/v.voronoi/sw_voronoi.c
===================================================================
--- grass/trunk/vector/v.voronoi/sw_voronoi.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/sw_voronoi.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -6,7 +6,7 @@
Performance suffers if they are wrong; better to make nsites,
deltax, and deltay too big than too small. (?) */
-int voronoi(int triangulate, struct Site *(*nextsite) (void))
+int voronoi(struct Site *(*nextsite) (void))
{
struct Site *newsite, *bot, *top, *temp, *p;
struct Site *v;
@@ -17,7 +17,6 @@
PQinitialize();
bottomsite = (*nextsite) ();
- out_site(bottomsite);
ELinitialize();
newsite = (*nextsite) ();
@@ -30,7 +29,6 @@
(newsite->coord.y == newintstar.y &&
newsite->coord.x < newintstar.x))) { /* new site is smallest */
- out_site(newsite);
lbnd = ELleftbnd(&(newsite->coord));
rbnd = ELright(lbnd);
bot = rightreg(lbnd);
@@ -65,7 +63,6 @@
rrbnd = ELright(rbnd);
bot = leftreg(lbnd);
top = rightreg(rbnd);
- out_triple(bot, top, rightreg(lbnd));
v = lbnd->vertex;
makevertex(v);
@@ -100,7 +97,7 @@
for (lbnd = ELright(ELleftend); lbnd != ELrightend; lbnd = ELright(lbnd)) {
e = lbnd->ELedge;
- out_ep(e);
+ write_ep(e);
}
/* TODO: free memory */
Modified: grass/trunk/vector/v.voronoi/vo_extend.c
===================================================================
--- grass/trunk/vector/v.voronoi/vo_extend.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/vo_extend.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -3,7 +3,6 @@
#include <grass/vector.h>
#include "sw_defs.h"
#include "defs.h"
-#include "write.h"
/*-extend_line() finds coordinates along the boundary of a window
* that also lie on a specified line (ax+by=c). The
@@ -34,14 +33,14 @@
double nx, ny; /* intersection coordinates */
if (x >= w && x <= e && y >= s && y <= n) {
- /* vertical line? */
+ /* horizontal line? */
if (a == 0) {
*c_x = knownPointAtLeft ? e : w;
*c_y = y;
return 1;
}
- /* horizontal line? */
+ /* vertical line? */
if (b == 0) {
*c_x = x;
*c_y = knownPointAtLeft ? s : n;
Modified: grass/trunk/vector/v.voronoi/vo_write.c
===================================================================
--- grass/trunk/vector/v.voronoi/vo_write.c 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/vo_write.c 2013-10-07 07:09:12 UTC (rev 57953)
@@ -6,34 +6,72 @@
#include <grass/display.h>
#include "sw_defs.h"
#include "defs.h"
-#include "write.h"
int write_ep(struct Edge *e)
{
static struct line_pnts *Points = NULL;
static struct line_cats *Cats = NULL;
+ double x1, y1, x2, y2;
if (!Points) {
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
}
- if (!triangulate) {
- double x1, y1, x2, y2;
-
- if (in_area && e->reg[le]->sitenbr == e->reg[re]->sitenbr)
+ if (in_area && e->reg[le]->sitenbr == e->reg[re]->sitenbr)
+ return 0;
+
+ if (e->ep[le] != NULL && e->ep[re] != NULL) { /* both end defined */
+ x1 = e->ep[le]->coord.x;
+ y1 = e->ep[le]->coord.y;
+ x2 = e->ep[re]->coord.x;
+ y2 = e->ep[re]->coord.y;
+
+ if (!Vect_point_in_box(x1, y1, 0.0, &Box) ||
+ !Vect_point_in_box(x2, y2, 0.0, &Box)) {
+ Vect_box_clip(&x1, &y1, &x2, &y2, &Box);
+ }
+
+ /* Don't write zero length */
+ if (x1 == x2 && y1 == y2)
return 0;
- if (e->ep[le] != NULL && e->ep[re] != NULL) { /* both end defined */
+ Vect_reset_line(Points);
+ Vect_append_point(Points, x1, y1, 0.0);
+ Vect_append_point(Points, x2, y2, 0.0);
+ Vect_write_line(&Out, Type, Points, Cats);
+ }
+ else {
+ int knownPointAtLeft = -1;
+
+ if (e->ep[le] != NULL) {
x1 = e->ep[le]->coord.x;
y1 = e->ep[le]->coord.y;
- x2 = e->ep[re]->coord.x;
- y2 = e->ep[re]->coord.y;
+ knownPointAtLeft = 1;
+ }
+ else if (e->ep[re] != NULL) {
+ x1 = e->ep[re]->coord.x;
+ y1 = e->ep[re]->coord.y;
+ knownPointAtLeft = 0;
+ }
- if (!Vect_point_in_box(x1, y1, 0.0, &Box) ||
- !Vect_point_in_box(x2, y2, 0.0, &Box)) {
- Vect_box_clip(&x1, &y1, &x2, &y2, &Box);
+ if (knownPointAtLeft == -1) {
+ x2 = (e->reg[le]->coord.x + e->reg[re]->coord.x) / 2.0;
+ y2 = (e->reg[le]->coord.y + e->reg[re]->coord.y) / 2.0;
+ knownPointAtLeft = 0;
+ if (!extend_line(Box.S, Box.N, Box.W, Box.E,
+ e->a, e->b, e->c, x2, y2, &x1, &y1,
+ knownPointAtLeft)) {
+
+ G_warning("Undefined edge, unable to extend line");
+
+ return 0;
}
+ knownPointAtLeft = 1;
+ }
+ if (extend_line(Box.S, Box.N, Box.W, Box.E,
+ e->a, e->b, e->c, x1, y1, &x2, &y2,
+ knownPointAtLeft)) {
/* Don't write zero length */
if (x1 == x2 && y1 == y2)
@@ -44,48 +82,6 @@
Vect_append_point(Points, x2, y2, 0.0);
Vect_write_line(&Out, Type, Points, Cats);
}
- else {
- int knownPointAtLeft = -1;
-
- if (e->ep[le] != NULL) {
- x1 = e->ep[le]->coord.x;
- y1 = e->ep[le]->coord.y;
- knownPointAtLeft = 1;
- }
- else if (e->ep[re] != NULL) {
- x1 = e->ep[re]->coord.x;
- y1 = e->ep[re]->coord.y;
- knownPointAtLeft = 0;
- }
-
- if (knownPointAtLeft == -1) {
- x2 = (e->reg[le]->coord.x + e->reg[re]->coord.x) / 2.0;
- y2 = (e->reg[le]->coord.y + e->reg[re]->coord.y) / 2.0;
- knownPointAtLeft = 0;
- if (!extend_line(Box.S, Box.N, Box.W, Box.E,
- e->a, e->b, e->c, x2, y2, &x1, &y1,
- knownPointAtLeft)) {
-
- G_warning("Undefined edge, unable to extend line");
-
- return 0;
- }
- knownPointAtLeft = 1;
- }
- if (extend_line(Box.S, Box.N, Box.W, Box.E,
- e->a, e->b, e->c, x1, y1, &x2, &y2,
- knownPointAtLeft)) {
-
- /* Don't write zero length */
- if (x1 == x2 && y1 == y2)
- return 0;
-
- Vect_reset_line(Points);
- Vect_append_point(Points, x1, y1, 0.0);
- Vect_append_point(Points, x2, y2, 0.0);
- Vect_write_line(&Out, Type, Points, Cats);
- }
- }
}
return 0;
Deleted: grass/trunk/vector/v.voronoi/write.h
===================================================================
--- grass/trunk/vector/v.voronoi/write.h 2013-10-07 06:27:42 UTC (rev 57952)
+++ grass/trunk/vector/v.voronoi/write.h 2013-10-07 07:09:12 UTC (rev 57953)
@@ -1,7 +0,0 @@
-
-/* vo_extend.c */
-int extend_line(double, double, double, double, double, double, double,
- double, double, double *, double *, int);
-
-int write_ep(struct Edge *);
-int write_triple(struct Site *, struct Site *, struct Site *);
More information about the grass-commit
mailing list