2012-05-05 03:40:55 +03:00
|
|
|
#!/bin/sh
|
|
|
|
. ./Common
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
tst "area without holes, constant offset" <<EOF
|
|
|
|
struct p2d *p = p2d_new();
|
|
|
|
struct p2d *q;
|
|
|
|
|
|
|
|
p2d_append(p, v2d_new(0, 0));
|
|
|
|
p2d_append(p, v2d_new(5.5, 0));
|
|
|
|
p2d_append(p, v2d_new(5.5, 4.5));
|
|
|
|
p2d_append(p, v2d_new(0, 4.5));
|
|
|
|
p2d_close(p);
|
2012-05-08 04:45:39 +03:00
|
|
|
q = p2d_area(p, 1, 1);
|
2012-05-05 03:40:55 +03:00
|
|
|
p2d_write_gnuplot_all(stdout, q);
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
1 1
|
|
|
|
4.5 1
|
|
|
|
4.5 3.5
|
|
|
|
1 3.5
|
|
|
|
1 1
|
|
|
|
|
|
|
|
2 2
|
|
|
|
3.5 2
|
|
|
|
3.5 2.5
|
|
|
|
2 2.5
|
|
|
|
2 2
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
tst "area without holes, offset with overlap" <<EOF
|
|
|
|
struct p2d *p = p2d_new();
|
|
|
|
struct p2d *q;
|
|
|
|
|
|
|
|
p2d_append(p, v2d_new(0, 0));
|
|
|
|
p2d_append(p, v2d_new(5.5, 0));
|
|
|
|
p2d_append(p, v2d_new(5.5, 4.5));
|
|
|
|
p2d_append(p, v2d_new(0, 4.5));
|
|
|
|
p2d_close(p);
|
2012-05-08 04:45:39 +03:00
|
|
|
q = p2d_area(p, 1, 0.7);
|
2012-05-05 03:40:55 +03:00
|
|
|
p2d_write_gnuplot_all(stdout, q);
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
1 1
|
|
|
|
4.5 1
|
|
|
|
4.5 3.5
|
|
|
|
1 3.5
|
|
|
|
1 1
|
|
|
|
|
|
|
|
1.7 1.7
|
|
|
|
3.8 1.7
|
|
|
|
3.8 2.8
|
|
|
|
1.7 2.8
|
|
|
|
1.7 1.7
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
tst "area with one symmetric hole" <<EOF
|
|
|
|
struct p2d *pl, *p;
|
|
|
|
struct p2d *q;
|
|
|
|
|
|
|
|
pl = p = p2d_new();
|
|
|
|
p2d_append(p, v2d_new(0, 0));
|
|
|
|
p2d_append(p, v2d_new(20, 0));
|
|
|
|
p2d_append(p, v2d_new(20, 10));
|
|
|
|
p2d_append(p, v2d_new(0, 10));
|
|
|
|
p2d_close(p);
|
|
|
|
|
|
|
|
p = p->next = p2d_new();
|
|
|
|
p2d_append(p, v2d_new(2, 2));
|
|
|
|
p2d_append(p, v2d_new(2, 8));
|
|
|
|
p2d_append(p, v2d_new(18, 8));
|
|
|
|
p2d_append(p, v2d_new(18, 2));
|
|
|
|
p2d_close(p);
|
|
|
|
|
2012-05-08 04:45:39 +03:00
|
|
|
q = p2d_area(pl, 0.7, 0.7);
|
2012-05-05 03:40:55 +03:00
|
|
|
p2d_write_gnuplot_all(stdout, q);
|
|
|
|
EOF
|
|
|
|
|
|
|
|
expect <<EOF
|
|
|
|
0.7 0.7
|
|
|
|
19.3 0.7
|
|
|
|
19.3 9.3
|
|
|
|
0.7 9.3
|
|
|
|
0.7 0.7
|
|
|
|
|
|
|
|
1.3 1.3
|
|
|
|
1.3 8.7
|
|
|
|
18.7 8.7
|
|
|
|
18.7 1.3
|
|
|
|
1.3 1.3
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
###############################################################################
|