1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2024-12-23 09:55:32 +02:00
cae-tools/poly2d/test/forall

122 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
. ./Common
###############################################################################
tst "forall_v2d_once, open polygon" <<EOF
struct p2d *p = p2d_new();
const struct v2d *v;
p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 0));
p2d_append(p, v2d_new(2, 3));
forall_v2d_once(v, p->v)
printf("%g %g\n", v->x, v->y);
EOF
expect <<EOF
0 0
1 0
2 3
EOF
#------------------------------------------------------------------------------
tst "forall_v2d_once, closed polygon" <<EOF
struct p2d *p = p2d_new();
const struct v2d *v;
p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 0));
p2d_append(p, v2d_new(2, 3));
p2d_close(p);
forall_v2d_once(v, p->v)
printf("%g %g\n", v->x, v->y);
EOF
expect <<EOF
0 0
1 0
2 3
EOF
#------------------------------------------------------------------------------
tst "forall_v2d, open polygon" <<EOF
struct p2d *p = p2d_new();
const struct v2d *v;
p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 0));
p2d_append(p, v2d_new(2, 3));
forall_v2d(v, p->v)
printf("%g %g\n", v->x, v->y);
EOF
expect <<EOF
0 0
1 0
2 3
EOF
#------------------------------------------------------------------------------
tst "forall_v2d, closed polygon" <<EOF
struct p2d *p = p2d_new();
const struct v2d *v;
p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 0));
p2d_append(p, v2d_new(2, 3));
p2d_close(p);
forall_v2d(v, p->v)
printf("%g %g\n", v->x, v->y);
EOF
expect <<EOF
0 0
1 0
2 3
0 0
EOF
#------------------------------------------------------------------------------
tst "forall_edges, open polygon" <<EOF
struct p2d *p = p2d_new();
const struct v2d *a, *b;
p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 0));
p2d_append(p, v2d_new(2, 3));
forall_edges(a, b, p->v)
printf("%g %g %g %g\n", a->x, a->y, b->x, b->y);
EOF
expect <<EOF
0 0 1 0
1 0 2 3
EOF
#------------------------------------------------------------------------------
tst "forall_edges, closed polygon" <<EOF
struct p2d *p = p2d_new();
const struct v2d *a, *b;
p2d_append(p, v2d_new(0, 0));
p2d_append(p, v2d_new(1, 0));
p2d_append(p, v2d_new(2, 3));
p2d_close(p);
forall_edges(a, b, p->v)
printf("%g %g %g %g\n", a->x, a->y, b->x, b->y);
EOF
expect <<EOF
0 0 1 0
1 0 2 3
2 3 0 0
EOF
###############################################################################