mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
poly2d/: Yet another 2D polygon library (WIP)
This commit is contained in:
103
poly2d/test/area
Executable file
103
poly2d/test/area
Executable file
@@ -0,0 +1,103 @@
|
||||
#!/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, 0);
|
||||
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.3);
|
||||
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);
|
||||
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
|
||||
|
||||
###############################################################################
|
||||
Reference in New Issue
Block a user