1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 18:58:58 +02:00
cae-tools/poly2d/test/area

104 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/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);
q = p2d_area(p, 1, 1);
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);
q = p2d_area(p, 1, 0.7);
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);
q = p2d_area(pl, 0.7, 0.7);
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
###############################################################################