Index: trunk/src/route-rnd/regression/poly.c =================================================================== --- trunk/src/route-rnd/regression/poly.c (revision 1424) +++ trunk/src/route-rnd/regression/poly.c (nonexistent) @@ -1,76 +0,0 @@ -#include -#include -#include "../rtpoly.h" - -static inline int rtpoly_isc_cline_(const rtpoly_t *poly, double x1, double y1, double x2, double y2) -{ - g2d_cline_t cl; - cl.p1.x = x1; cl.p1.y = y1; - cl.p2.x = x2; cl.p2.y = y2; - return rtpoly_isc_cline(poly, &cl); -} - -static inline int rtpoly_isc_triangle(const rtpoly_t *poly, double cx, double cy, double r) -{ - int n, res; - double a, step = 2.0*M_PI/3.0; - rtpoly_t tri; - rtpoly_new_begin(&tri); - - for(n = 0, a = 0; n < 3; n++, a+=step) { -/* printf(" %f %f\n", cx + cos(a) * r, cy + sin(a) * r);*/ - rtpoly_new_append(&tri, cx + cos(a) * r, cy + sin(a) * r); - } - - rtpoly_new_end(&tri); - res = rtpoly_isc_rtpoly(poly, &tri); - rtpoly_free(&tri); - return res; -} - -int main(int argc, char *argv[]) -{ - int end; - rtpoly_t poly; - - rtpoly_new_begin(&poly); - - rtpoly_new_append(&poly, 1,1); - rtpoly_new_append(&poly, 5,1); - rtpoly_new_append(&poly, 5,5); - rtpoly_new_append(&poly, 1,5); - - end = rtpoly_new_end(&poly); - printf("end=%d area=%f %f;%f - %f;%f\n", end, poly.area, poly.bbox.p1.x, poly.bbox.p1.y, poly.bbox.p2.x, poly.bbox.p2.y); - - printf("point isc:\n"); - printf(" in: %d\n", rtpoly_isc_point(&poly, 3, 3)); - printf(" out left: %d\n", rtpoly_isc_point(&poly, -3, 3)); - printf(" out right: %d\n", rtpoly_isc_point(&poly, 15, 3)); - printf(" on edge1: %d\n", rtpoly_isc_point(&poly, 1, 3)); - printf(" on edge2: %d\n", rtpoly_isc_point(&poly, 3, 1)); - printf(" on corner: %d\n", rtpoly_isc_point(&poly, 1, 1)); - - printf("circ isc:\n"); - printf(" in: %d\n", rtpoly_isc_circle(&poly, 3, 3, 2)); - printf(" left1: %d\n", rtpoly_isc_circle(&poly, -1, 3, 2.2)); - printf(" left2: %d\n", rtpoly_isc_circle(&poly, -1, 3, 2)); - printf(" left3: %d\n", rtpoly_isc_circle(&poly, -1, -2, 2)); - printf(" corner: %d\n", rtpoly_isc_circle(&poly, 0, 0, 1.48)); - - printf("cline isc:\n"); - printf(" in: %d\n", rtpoly_isc_cline_(&poly, 2, 2, 3, 3)); - printf(" side-yes: %d\n", rtpoly_isc_cline_(&poly, 0, 1, 2, 1.5)); - printf(" side-nope: %d\n", rtpoly_isc_cline_(&poly, 0, 1, 2, 0.9)); - printf(" corner-yes: %d\n", rtpoly_isc_cline_(&poly, 0, 0, 1, 1)); - - - printf("rtpoly isc:\n"); - printf(" in: %d\n", rtpoly_isc_triangle(&poly, 3, 3, 1)); - printf(" left-yes: %d\n", rtpoly_isc_triangle(&poly, 0, 3, 1)); - printf(" left-yes: %d\n", rtpoly_isc_triangle(&poly, 0, 3, 2)); - printf(" left-no: %d\n", rtpoly_isc_triangle(&poly, -1, 3, 1)); - - - return 0; -} Index: trunk/src/route-rnd/regression/raline.ref =================================================================== --- trunk/src/route-rnd/regression/raline.ref (revision 1424) +++ trunk/src/route-rnd/regression/raline.ref (nonexistent) @@ -1,60 +0,0 @@ - -1 removing within a negative range: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -0+10 20+30 40+50 60+70 - -2 removing within a positive range: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ ++++ +++++ +++++++++++ +++++++++++ -0+10 20+23 26+30 40+50 60+70 - -3 removing from within pos to within next pos: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ ++++ +++++ +++++++++++ -0+10 20+23 46+50 60+70 - -4 removing from within pos to within far pos: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ ++++ +++++ -0+10 20+23 66+70 - -5 removing from start of pos to within far pos: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ +++++ -0+10 66+70 - -6 removing from within pos to end of far pos: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ ++++ +++++++++++ -0+10 20+23 60+70 - -7 removing from within a hole to middle of a pos: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ ++++++ -0+10 65+70 - -8 removing from within a hole to middle of a hole: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ +++++++++++ -0+10 60+70 - -9 removing from pos-end to middle of a hole: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ +++++++++++ -0+10 60+70 - -10 removing from pos-end to pos-begin: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ +++++++++++ -0+10 60+70 - -10 removing from pos-end to pos-end: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ -+++++++++++ +++++++++++ -0+10 60+70 - -10 removing everything: -+++++++++++ +++++++++++ +++++++++++ +++++++++++ - - Index: trunk/src/route-rnd/regression/grid.c =================================================================== --- trunk/src/route-rnd/regression/grid.c (revision 1424) +++ trunk/src/route-rnd/regression/grid.c (nonexistent) @@ -1,16 +0,0 @@ -#include -#include "../util_grid.h" - -int main() -{ - double d, origin, spacing; - int res; - - vtd0_t coords = {0}; - while(scanf("%lf\n", &d) == 1) - vtd0_append(&coords, d); - - res = rtrnd_grid_detect(&coords, &origin, &spacing); - printf("res=%d %f:%f\n", res, spacing, origin); - -} \ No newline at end of file Index: trunk/src/route-rnd/regression/raline.c =================================================================== --- trunk/src/route-rnd/regression/raline.c (revision 1424) +++ trunk/src/route-rnd/regression/raline.c (nonexistent) @@ -1,124 +0,0 @@ -#include -#include -#include "../util_grid.h" - - -static void draw(rtrnd_raline_t *ra) -{ - char line[71]; - long n; - - memset(line, ' ', sizeof(line)); - line[70] = '\0'; - for(n = 0; n < ra->minor.used; n+=2) { - int from = ra->minor.array[n], to = ra->minor.array[n+1]; - assert(from < to); - assert(from >= 0); - assert(to <= 70); - assert(from != to); - memset(line+from, '+', to-from+1); - } - printf("%s\n", line); -} - -static void dump(rtrnd_raline_t *ra) -{ - long n; - for(n = 0; n < ra->minor.used; n+=2) { - if (n > 0) printf(" "); - printf("%.0f+%.0f", ra->minor.array[n], ra->minor.array[n+1]); - } - printf("\n"); -} - - -void reset(rtrnd_raline_t *ra) -{ - ra->minor.used = 0; - vtd0_append(&ra->minor, 00); vtd0_append(&ra->minor, 10); - vtd0_append(&ra->minor, 20); vtd0_append(&ra->minor, 30); - vtd0_append(&ra->minor, 40); vtd0_append(&ra->minor, 50); - vtd0_append(&ra->minor, 60); vtd0_append(&ra->minor, 70); -} - -int main() -{ - rtrnd_raline_t ra = {0}; - - - printf("\n1 removing within a negative range:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 13, 16) == 0); - draw(&ra); dump(&ra); - - printf("\n2 removing within a positive range:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 23, 26) == 0); - draw(&ra); dump(&ra); - - printf("\n3 removing from within pos to within next pos:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 23, 46) == 0); - draw(&ra); dump(&ra); - - printf("\n4 removing from within pos to within far pos:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 23, 66) == 0); - draw(&ra); dump(&ra); - - printf("\n5 removing from start of pos to within far pos:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 20, 66) == 0); - draw(&ra); dump(&ra); - - printf("\n6 removing from within pos to end of far pos:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 23, 50) == 0); - draw(&ra); dump(&ra); - - printf("\n7 removing from within a hole to middle of a pos:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 13, 65) == 0); - draw(&ra); dump(&ra); - - printf("\n8 removing from within a hole to middle of a hole:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 13, 55) == 0); - draw(&ra); dump(&ra); - - - printf("\n9 removing from pos-end to middle of a hole:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 20, 55) == 0); - draw(&ra); dump(&ra); - - printf("\n10 removing from pos-end to pos-begin:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 20, 60) == 0); - draw(&ra); dump(&ra); - - printf("\n10 removing from pos-end to pos-end:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 20, 50) == 0); - draw(&ra); dump(&ra); - - - printf("\n10 removing everything:\n"); - reset(&ra); - draw(&ra); - assert(rtrnd_raline_block(&ra, 00, 70) == 0); - draw(&ra); dump(&ra); - - return 0; -} Index: trunk/src/route-rnd/regression/Makefile =================================================================== --- trunk/src/route-rnd/regression/Makefile (revision 1424) +++ trunk/src/route-rnd/regression/Makefile (nonexistent) @@ -1,15 +0,0 @@ -ROOT=../../.. -CFLAGS = -Wall -g -I$(ROOT)/src_3rd -I.. -LDFLAGS = -lm - -LOCLIBS = $(ROOT)/src_3rd/genvector/libgenvector.a $(ROOT)/src_3rd/genht/libgenht.a -DATAO=../htdi.o ../data.o ../rtree.o ../compat_misc.o ../netseg.o ../find.o ../rtpoly.o -GRIDO=../util_grid.o - -all: raline grid poly - -raline: raline.o $(DATA) $(LOCLIBS) - -poly: poly.o $(DATAO) $(LOCLIBS) - -grid: grid.o $(GRIDO) $(DATAO) $(LOCLIBS) Index: trunk/src/route-rnd/regression/lowlev/Makefile =================================================================== --- trunk/src/route-rnd/regression/lowlev/Makefile (nonexistent) +++ trunk/src/route-rnd/regression/lowlev/Makefile (revision 1425) @@ -0,0 +1,15 @@ +ROOT=../../.. +CFLAGS = -Wall -g -I$(ROOT)/src_3rd -I.. +LDFLAGS = -lm + +LOCLIBS = $(ROOT)/src_3rd/genvector/libgenvector.a $(ROOT)/src_3rd/genht/libgenht.a +DATAO=../htdi.o ../data.o ../rtree.o ../compat_misc.o ../netseg.o ../find.o ../rtpoly.o +GRIDO=../util_grid.o + +all: raline grid poly + +raline: raline.o $(DATA) $(LOCLIBS) + +poly: poly.o $(DATAO) $(LOCLIBS) + +grid: grid.o $(GRIDO) $(DATAO) $(LOCLIBS) Index: trunk/src/route-rnd/regression/lowlev/grid.c =================================================================== --- trunk/src/route-rnd/regression/lowlev/grid.c (nonexistent) +++ trunk/src/route-rnd/regression/lowlev/grid.c (revision 1425) @@ -0,0 +1,16 @@ +#include +#include "../util_grid.h" + +int main() +{ + double d, origin, spacing; + int res; + + vtd0_t coords = {0}; + while(scanf("%lf\n", &d) == 1) + vtd0_append(&coords, d); + + res = rtrnd_grid_detect(&coords, &origin, &spacing); + printf("res=%d %f:%f\n", res, spacing, origin); + +} \ No newline at end of file Index: trunk/src/route-rnd/regression/lowlev/poly.c =================================================================== --- trunk/src/route-rnd/regression/lowlev/poly.c (nonexistent) +++ trunk/src/route-rnd/regression/lowlev/poly.c (revision 1425) @@ -0,0 +1,76 @@ +#include +#include +#include "../rtpoly.h" + +static inline int rtpoly_isc_cline_(const rtpoly_t *poly, double x1, double y1, double x2, double y2) +{ + g2d_cline_t cl; + cl.p1.x = x1; cl.p1.y = y1; + cl.p2.x = x2; cl.p2.y = y2; + return rtpoly_isc_cline(poly, &cl); +} + +static inline int rtpoly_isc_triangle(const rtpoly_t *poly, double cx, double cy, double r) +{ + int n, res; + double a, step = 2.0*M_PI/3.0; + rtpoly_t tri; + rtpoly_new_begin(&tri); + + for(n = 0, a = 0; n < 3; n++, a+=step) { +/* printf(" %f %f\n", cx + cos(a) * r, cy + sin(a) * r);*/ + rtpoly_new_append(&tri, cx + cos(a) * r, cy + sin(a) * r); + } + + rtpoly_new_end(&tri); + res = rtpoly_isc_rtpoly(poly, &tri); + rtpoly_free(&tri); + return res; +} + +int main(int argc, char *argv[]) +{ + int end; + rtpoly_t poly; + + rtpoly_new_begin(&poly); + + rtpoly_new_append(&poly, 1,1); + rtpoly_new_append(&poly, 5,1); + rtpoly_new_append(&poly, 5,5); + rtpoly_new_append(&poly, 1,5); + + end = rtpoly_new_end(&poly); + printf("end=%d area=%f %f;%f - %f;%f\n", end, poly.area, poly.bbox.p1.x, poly.bbox.p1.y, poly.bbox.p2.x, poly.bbox.p2.y); + + printf("point isc:\n"); + printf(" in: %d\n", rtpoly_isc_point(&poly, 3, 3)); + printf(" out left: %d\n", rtpoly_isc_point(&poly, -3, 3)); + printf(" out right: %d\n", rtpoly_isc_point(&poly, 15, 3)); + printf(" on edge1: %d\n", rtpoly_isc_point(&poly, 1, 3)); + printf(" on edge2: %d\n", rtpoly_isc_point(&poly, 3, 1)); + printf(" on corner: %d\n", rtpoly_isc_point(&poly, 1, 1)); + + printf("circ isc:\n"); + printf(" in: %d\n", rtpoly_isc_circle(&poly, 3, 3, 2)); + printf(" left1: %d\n", rtpoly_isc_circle(&poly, -1, 3, 2.2)); + printf(" left2: %d\n", rtpoly_isc_circle(&poly, -1, 3, 2)); + printf(" left3: %d\n", rtpoly_isc_circle(&poly, -1, -2, 2)); + printf(" corner: %d\n", rtpoly_isc_circle(&poly, 0, 0, 1.48)); + + printf("cline isc:\n"); + printf(" in: %d\n", rtpoly_isc_cline_(&poly, 2, 2, 3, 3)); + printf(" side-yes: %d\n", rtpoly_isc_cline_(&poly, 0, 1, 2, 1.5)); + printf(" side-nope: %d\n", rtpoly_isc_cline_(&poly, 0, 1, 2, 0.9)); + printf(" corner-yes: %d\n", rtpoly_isc_cline_(&poly, 0, 0, 1, 1)); + + + printf("rtpoly isc:\n"); + printf(" in: %d\n", rtpoly_isc_triangle(&poly, 3, 3, 1)); + printf(" left-yes: %d\n", rtpoly_isc_triangle(&poly, 0, 3, 1)); + printf(" left-yes: %d\n", rtpoly_isc_triangle(&poly, 0, 3, 2)); + printf(" left-no: %d\n", rtpoly_isc_triangle(&poly, -1, 3, 1)); + + + return 0; +} Index: trunk/src/route-rnd/regression/lowlev/raline.c =================================================================== --- trunk/src/route-rnd/regression/lowlev/raline.c (nonexistent) +++ trunk/src/route-rnd/regression/lowlev/raline.c (revision 1425) @@ -0,0 +1,124 @@ +#include +#include +#include "../util_grid.h" + + +static void draw(rtrnd_raline_t *ra) +{ + char line[71]; + long n; + + memset(line, ' ', sizeof(line)); + line[70] = '\0'; + for(n = 0; n < ra->minor.used; n+=2) { + int from = ra->minor.array[n], to = ra->minor.array[n+1]; + assert(from < to); + assert(from >= 0); + assert(to <= 70); + assert(from != to); + memset(line+from, '+', to-from+1); + } + printf("%s\n", line); +} + +static void dump(rtrnd_raline_t *ra) +{ + long n; + for(n = 0; n < ra->minor.used; n+=2) { + if (n > 0) printf(" "); + printf("%.0f+%.0f", ra->minor.array[n], ra->minor.array[n+1]); + } + printf("\n"); +} + + +void reset(rtrnd_raline_t *ra) +{ + ra->minor.used = 0; + vtd0_append(&ra->minor, 00); vtd0_append(&ra->minor, 10); + vtd0_append(&ra->minor, 20); vtd0_append(&ra->minor, 30); + vtd0_append(&ra->minor, 40); vtd0_append(&ra->minor, 50); + vtd0_append(&ra->minor, 60); vtd0_append(&ra->minor, 70); +} + +int main() +{ + rtrnd_raline_t ra = {0}; + + + printf("\n1 removing within a negative range:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 13, 16) == 0); + draw(&ra); dump(&ra); + + printf("\n2 removing within a positive range:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 23, 26) == 0); + draw(&ra); dump(&ra); + + printf("\n3 removing from within pos to within next pos:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 23, 46) == 0); + draw(&ra); dump(&ra); + + printf("\n4 removing from within pos to within far pos:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 23, 66) == 0); + draw(&ra); dump(&ra); + + printf("\n5 removing from start of pos to within far pos:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 20, 66) == 0); + draw(&ra); dump(&ra); + + printf("\n6 removing from within pos to end of far pos:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 23, 50) == 0); + draw(&ra); dump(&ra); + + printf("\n7 removing from within a hole to middle of a pos:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 13, 65) == 0); + draw(&ra); dump(&ra); + + printf("\n8 removing from within a hole to middle of a hole:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 13, 55) == 0); + draw(&ra); dump(&ra); + + + printf("\n9 removing from pos-end to middle of a hole:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 20, 55) == 0); + draw(&ra); dump(&ra); + + printf("\n10 removing from pos-end to pos-begin:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 20, 60) == 0); + draw(&ra); dump(&ra); + + printf("\n10 removing from pos-end to pos-end:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 20, 50) == 0); + draw(&ra); dump(&ra); + + + printf("\n10 removing everything:\n"); + reset(&ra); + draw(&ra); + assert(rtrnd_raline_block(&ra, 00, 70) == 0); + draw(&ra); dump(&ra); + + return 0; +} Index: trunk/src/route-rnd/regression/lowlev/raline.ref =================================================================== --- trunk/src/route-rnd/regression/lowlev/raline.ref (nonexistent) +++ trunk/src/route-rnd/regression/lowlev/raline.ref (revision 1425) @@ -0,0 +1,60 @@ + +1 removing within a negative range: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ +++++++++++ +++++++++++ +++++++++++ +0+10 20+30 40+50 60+70 + +2 removing within a positive range: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ ++++ +++++ +++++++++++ +++++++++++ +0+10 20+23 26+30 40+50 60+70 + +3 removing from within pos to within next pos: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ ++++ +++++ +++++++++++ +0+10 20+23 46+50 60+70 + +4 removing from within pos to within far pos: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ ++++ +++++ +0+10 20+23 66+70 + +5 removing from start of pos to within far pos: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ +++++ +0+10 66+70 + +6 removing from within pos to end of far pos: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ ++++ +++++++++++ +0+10 20+23 60+70 + +7 removing from within a hole to middle of a pos: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ ++++++ +0+10 65+70 + +8 removing from within a hole to middle of a hole: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ +++++++++++ +0+10 60+70 + +9 removing from pos-end to middle of a hole: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ +++++++++++ +0+10 60+70 + +10 removing from pos-end to pos-begin: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ +++++++++++ +0+10 60+70 + +10 removing from pos-end to pos-end: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ ++++++++++++ +++++++++++ +0+10 60+70 + +10 removing everything: ++++++++++++ +++++++++++ +++++++++++ +++++++++++ + +