Root/
| 1 | #!/bin/sh |
| 2 | . ./Common |
| 3 | |
| 4 | ############################################################################### |
| 5 | |
| 6 | tst "forall_v2d_once, open polygon" <<EOF |
| 7 | struct p2d *p = p2d_new(); |
| 8 | const struct v2d *v; |
| 9 | |
| 10 | p2d_append(p, v2d_new(0, 0)); |
| 11 | p2d_append(p, v2d_new(1, 0)); |
| 12 | p2d_append(p, v2d_new(2, 3)); |
| 13 | forall_v2d_once(v, p->v) |
| 14 | printf("%g %g\n", v->x, v->y); |
| 15 | EOF |
| 16 | |
| 17 | expect <<EOF |
| 18 | 0 0 |
| 19 | 1 0 |
| 20 | 2 3 |
| 21 | EOF |
| 22 | |
| 23 | #------------------------------------------------------------------------------ |
| 24 | |
| 25 | tst "forall_v2d_once, closed polygon" <<EOF |
| 26 | struct p2d *p = p2d_new(); |
| 27 | const struct v2d *v; |
| 28 | |
| 29 | p2d_append(p, v2d_new(0, 0)); |
| 30 | p2d_append(p, v2d_new(1, 0)); |
| 31 | p2d_append(p, v2d_new(2, 3)); |
| 32 | p2d_close(p); |
| 33 | forall_v2d_once(v, p->v) |
| 34 | printf("%g %g\n", v->x, v->y); |
| 35 | EOF |
| 36 | |
| 37 | expect <<EOF |
| 38 | 0 0 |
| 39 | 1 0 |
| 40 | 2 3 |
| 41 | EOF |
| 42 | |
| 43 | #------------------------------------------------------------------------------ |
| 44 | |
| 45 | tst "forall_v2d, open polygon" <<EOF |
| 46 | struct p2d *p = p2d_new(); |
| 47 | const struct v2d *v; |
| 48 | |
| 49 | p2d_append(p, v2d_new(0, 0)); |
| 50 | p2d_append(p, v2d_new(1, 0)); |
| 51 | p2d_append(p, v2d_new(2, 3)); |
| 52 | forall_v2d(v, p->v) |
| 53 | printf("%g %g\n", v->x, v->y); |
| 54 | EOF |
| 55 | |
| 56 | expect <<EOF |
| 57 | 0 0 |
| 58 | 1 0 |
| 59 | 2 3 |
| 60 | EOF |
| 61 | |
| 62 | #------------------------------------------------------------------------------ |
| 63 | |
| 64 | tst "forall_v2d, closed polygon" <<EOF |
| 65 | struct p2d *p = p2d_new(); |
| 66 | const struct v2d *v; |
| 67 | |
| 68 | p2d_append(p, v2d_new(0, 0)); |
| 69 | p2d_append(p, v2d_new(1, 0)); |
| 70 | p2d_append(p, v2d_new(2, 3)); |
| 71 | p2d_close(p); |
| 72 | forall_v2d(v, p->v) |
| 73 | printf("%g %g\n", v->x, v->y); |
| 74 | EOF |
| 75 | |
| 76 | expect <<EOF |
| 77 | 0 0 |
| 78 | 1 0 |
| 79 | 2 3 |
| 80 | 0 0 |
| 81 | EOF |
| 82 | |
| 83 | #------------------------------------------------------------------------------ |
| 84 | |
| 85 | tst "forall_edges, open polygon" <<EOF |
| 86 | struct p2d *p = p2d_new(); |
| 87 | const struct v2d *a, *b; |
| 88 | |
| 89 | p2d_append(p, v2d_new(0, 0)); |
| 90 | p2d_append(p, v2d_new(1, 0)); |
| 91 | p2d_append(p, v2d_new(2, 3)); |
| 92 | forall_edges(a, b, p->v) |
| 93 | printf("%g %g %g %g\n", a->x, a->y, b->x, b->y); |
| 94 | EOF |
| 95 | |
| 96 | expect <<EOF |
| 97 | 0 0 1 0 |
| 98 | 1 0 2 3 |
| 99 | EOF |
| 100 | |
| 101 | #------------------------------------------------------------------------------ |
| 102 | |
| 103 | tst "forall_edges, closed polygon" <<EOF |
| 104 | struct p2d *p = p2d_new(); |
| 105 | const struct v2d *a, *b; |
| 106 | |
| 107 | p2d_append(p, v2d_new(0, 0)); |
| 108 | p2d_append(p, v2d_new(1, 0)); |
| 109 | p2d_append(p, v2d_new(2, 3)); |
| 110 | p2d_close(p); |
| 111 | forall_edges(a, b, p->v) |
| 112 | printf("%g %g %g %g\n", a->x, a->y, b->x, b->y); |
| 113 | EOF |
| 114 | |
| 115 | expect <<EOF |
| 116 | 0 0 1 0 |
| 117 | 1 0 2 3 |
| 118 | 2 3 0 0 |
| 119 | EOF |
| 120 | |
| 121 | ############################################################################### |
| 122 |
Branches:
master
