mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-04-21 12:27:27 +03:00
poly2d/: add foreach_v2d* and foreach_edges looping constructs
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
compile_and_run()
|
||||
{
|
||||
CFLAGS="-Wall -Werror -g -std=gnu99 -I.."
|
||||
LIBS="-lpoly2d -lCGAL -lCGAL_Core -lboost_thread"
|
||||
LIBS="$LIBS -lstdc++ -lmpfr -lgmp -lm"
|
||||
|
||||
@@ -54,7 +55,7 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
EOF
|
||||
gcc -Wall -Werror -g -I.. _.c -L.. $LIBS || return
|
||||
gcc $CFLAGS _.c -L.. $LIBS || return
|
||||
$VALGRIND ./a.out
|
||||
}
|
||||
|
||||
|
||||
121
poly2d/test/forall
Executable file
121
poly2d/test/forall
Executable file
@@ -0,0 +1,121 @@
|
||||
#!/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
|
||||
|
||||
###############################################################################
|
||||
Reference in New Issue
Block a user