5 * Vertices in strip are numbered as follows:
7 * ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 ___ 4 __
9 * / \ / \ / \ / \ / \ / \ / \
10 * / \ / \ / \ / \ / \ / \ / \
11 * X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 ___ 4
12 * Y-2 Y-2 Y-2 1 1 1 1 1
13 * \ / \ / \ / \ / \ / \ / \ /
14 * \ / \ / \ / \ / \ / \ / \ /
15 * ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3 __
18 * . . . . . . . . . . . . . . .
20 * X-4 ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 ___ 3
21 * 1 1 1 1 Y-2 Y-2 Y-2 Y-2
22 * \ / \ / \ / \ / \ / \ / \ /
23 * \ / \ / \ / \ / \ / \ / \ /
24 * ___ X-4 ___ X-3 ___ X-2 ___ X-1 ___ 0 ___ 1 ___ 2 __
28 * 0 <= x < X x = distance along
29 * 0 <= y < Y y = distance across
31 * Vertices are in reading order from diagram above ie x varies fastest.
33 * Y must be even. The actual location opposite (0,0) is (X-(Y-1)/2,0),
34 * and likewise opposite (0,Y-1) is ((Y-1)/2,0).
36 * We label edges as follows:
45 * (This numbering permits the order-4 nodes at the strip's edge
46 * to have a contiguous edge numbering 2..5 or 0..3.)
48 * When we iterate over edges, we iterate first over vertices and then
49 * over edges 0 to 2, disregarding edges 3 to 5.
62 /* vertex number: 0000 | y | x
69 #define Y1 (1 << YSHIFT)
70 #define YMASK ((Y-1) << YSHIFT)
76 #define FOR_VERTEX(v) \
77 for ((v)=0; (v)<N; (v)++)
79 #define VE_MIN(v) ((v) & YMASK ? 0 : 2)
80 #define VE_MAX(v) (~(v) & YMASK ? V6 : 4)
82 #define FOR_VPEDGE(v,e) \
83 for ((e)=VE_MIN(v); (e)<VE_MAX(v); (e)++)
85 extern int edge_end2(unsigned v1, int e);
86 #define EDGE_END2 edge_end2
88 #define FOR_VEDGE_X(v1,e,v2,init,otherwise) \
89 FOR_VPEDGE((v1),(e)) \
90 if (((v2)= EDGE_END2((v1),(e)), \
92 (v2)) < 0) { otherwise; } else
94 #define NOTHING ((void)0)
96 #define FOR_VEDGE(v1,e,v2) \
97 FOR_VEDGE_X(v1,e,v2,NOTHING,NOTHING)
99 #define FOR_EDGE(v1,e,v2) \
101 FOR_VEDGE((v1),(e),(v2))
103 #define FOR_RIM_VERTEX(vy,vx,v) \
104 for ((vy)=0; (vy)<Y; (vy)+=Y-1) \
105 for ((vx)=0; (v)= (vy)<<YSHIFT | (vx), (vx)<X; (vx)++)
107 typedef double Vertices[N][D3];