18 const int ref_type_num_children[8] = { 0, 2, 2, 4, 2, 4, 4, 8 };
27 const int quad_deref_table[3][4 + 4] =
29 { 0, 1, 1, 0, 1, 1, 0, 0 },
30 { 0, 0, 1, 1, 0, 0, 1, 1 },
31 { 0, 1, 2, 3, 1, 1, 3, 3 }
34 const int hex_deref_table[7][8 + 6] =
36 { 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0 },
37 { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1 },
38 { 0, 1, 2, 3, 0, 1, 2, 3, 1, 1, 1, 3, 3, 3 },
39 { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 },
40 { 0, 1, 1, 0, 3, 2, 2, 3, 1, 1, 1, 3, 3, 3 },
41 { 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 0, 3, 3, 3 },
42 { 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 1, 7, 7, 7 }
45 const int prism_deref_table[7][6 + 5] =
47 {-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
48 {-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
49 { 0, 1, 2, 0, 1, 2, 0, 0, 0, 1, 0 },
50 { 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0 },
51 {-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
52 {-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
53 { 0, 1, 2, 4, 5, 6, 0, 5, 0, 5, 0 }
56 const int pyramid_deref_table[7][5 + 5] =
58 {-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
59 {-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
60 {-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
61 {-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
62 {-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
63 {-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
64 { 0, 1, 2, 3, 5, 0, 5, 5, 5, 5 }
69 const char quad_hilbert_child_order[8][4] =
71 {0,1,2,3}, {0,3,2,1}, {1,2,3,0}, {1,0,3,2},
72 {2,3,0,1}, {2,1,0,3}, {3,0,1,2}, {3,2,1,0}
75 const char quad_hilbert_child_state[8][4] =
77 {1,0,0,5}, {0,1,1,4}, {3,2,2,7}, {2,3,3,6},
78 {5,4,4,1}, {4,5,5,0}, {7,6,6,3}, {6,7,7,2}
81 const char hex_hilbert_child_order[24][8] =
83 {0,1,2,3,7,6,5,4}, {0,3,7,4,5,6,2,1}, {0,4,5,1,2,6,7,3},
84 {1,0,3,2,6,7,4,5}, {1,2,6,5,4,7,3,0}, {1,5,4,0,3,7,6,2},
85 {2,1,5,6,7,4,0,3}, {2,3,0,1,5,4,7,6}, {2,6,7,3,0,4,5,1},
86 {3,0,4,7,6,5,1,2}, {3,2,1,0,4,5,6,7}, {3,7,6,2,1,5,4,0},
87 {4,0,1,5,6,2,3,7}, {4,5,6,7,3,2,1,0}, {4,7,3,0,1,2,6,5},
88 {5,1,0,4,7,3,2,6}, {5,4,7,6,2,3,0,1}, {5,6,2,1,0,3,7,4},
89 {6,2,3,7,4,0,1,5}, {6,5,1,2,3,0,4,7}, {6,7,4,5,1,0,3,2},
90 {7,3,2,6,5,1,0,4}, {7,4,0,3,2,1,5,6}, {7,6,5,4,0,1,2,3}
93 const char hex_hilbert_child_state[24][8] =
95 {1,2,2,7,7,21,21,17}, {2,0,0,22,22,16,16,8}, {0,1,1,15,15,6,6,23},
96 {4,5,5,10,10,18,18,14}, {5,3,3,19,19,13,13,11}, {3,4,4,12,12,9,9,20},
97 {8,7,7,17,17,23,23,2}, {6,8,8,0,0,15,15,22}, {7,6,6,21,21,1,1,16},
98 {11,10,10,14,14,20,20,5}, {9,11,11,3,3,12,12,19}, {10,9,9,18,18,4,4,13},
99 {13,14,14,5,5,19,19,10}, {14,12,12,20,20,11,11,4}, {12,13,13,9,9,3,3,18},
100 {16,17,17,2,2,22,22,7}, {17,15,15,23,23,8,8,1}, {15,16,16,6,6,0,0,21},
101 {20,19,19,11,11,14,14,3}, {18,20,20,4,4,10,10,12}, {19,18,18,13,13,5,5,9},
102 {23,22,22,8,8,17,17,0}, {21,23,23,1,1,7,7,15}, {22,21,21,16,16,2,2,6}
111 const RefCoord T_HALF = (1ll << 59);
112 const RefCoord T_ONE = (1ll << 60);
113 const RefCoord T_TWO = (1ll << 61);
116 const RefCoord S_HALF = 1;
117 const RefCoord S_ONE = 2;
118 const RefCoord S_TWO = 4;
120 const RefCoord tri_corners[3][3] =
127 const RefCoord quad_corners[4][3] =
135 const RefCoord hex_corners[8][3] =
143 {T_ONE, T_ONE, T_ONE},
147 const RefCoord prism_corners[6][3] =
157 const RefCoord pyramid_corners[5][3] =
166 typedef RefCoord RefPoint[3];
167 const RefPoint* geom_corners[8] =
184 void Apply(
const RefCoord src[3], RefCoord dst[3])
const 186 for (
int i = 0; i < 3; i++)
188 dst[i] = (src[i]*
s[i] >> 1) +
t[i];
193 const RefTrf quad_parent_rt1[2] =
195 { {S_HALF, S_ONE, 0}, { 0, 0, 0} },
196 { {S_HALF, S_ONE, 0}, {T_HALF, 0, 0} }
199 const RefTrf quad_child_rt1[2] =
201 { {S_TWO, S_ONE, 0}, { 0, 0, 0} },
202 { {S_TWO, S_ONE, 0}, {-T_ONE, 0, 0} }
205 const RefTrf quad_parent_rt2[2] =
207 { {S_ONE, S_HALF, 0}, {0, 0, 0} },
208 { {S_ONE, S_HALF, 0}, {0, T_HALF, 0} }
211 const RefTrf quad_child_rt2[2] =
213 { {S_ONE, S_TWO, 0}, {0, 0, 0} },
214 { {S_ONE, S_TWO, 0}, {0, -T_ONE, 0} }
217 const RefTrf quad_parent_rt3[4] =
219 { {S_HALF, S_HALF, 0}, { 0, 0, 0} },
220 { {S_HALF, S_HALF, 0}, {T_HALF, 0, 0} },
221 { {S_HALF, S_HALF, 0}, {T_HALF, T_HALF, 0} },
222 { {S_HALF, S_HALF, 0}, { 0, T_HALF, 0} }
225 const RefTrf quad_child_rt3[4] =
227 { {S_TWO, S_TWO, 0}, { 0, 0, 0} },
228 { {S_TWO, S_TWO, 0}, {-T_ONE, 0, 0} },
229 { {S_TWO, S_TWO, 0}, {-T_ONE, -T_ONE, 0} },
230 { {S_TWO, S_TWO, 0}, { 0, -T_ONE, 0} }
233 const RefTrf* quad_parent[4] =
241 const RefTrf* quad_child[4] =
249 const RefTrf hex_parent_rt1[2] =
251 { {S_HALF, S_ONE, S_ONE}, { 0, 0, 0} },
252 { {S_HALF, S_ONE, S_ONE}, {T_HALF, 0, 0} }
255 const RefTrf hex_child_rt1[2] =
257 { {S_TWO, S_ONE, S_ONE}, { 0, 0, 0} },
258 { {S_TWO, S_ONE, S_ONE}, {-T_ONE, 0, 0} }
261 const RefTrf hex_parent_rt2[2] =
263 { {S_ONE, S_HALF, S_ONE}, {0, 0, 0} },
264 { {S_ONE, S_HALF, S_ONE}, {0, T_HALF, 0} }
267 const RefTrf hex_child_rt2[2] =
269 { {S_ONE, S_TWO, S_ONE}, {0, 0, 0} },
270 { {S_ONE, S_TWO, S_ONE}, {0, -T_ONE, 0} }
273 const RefTrf hex_parent_rt3[4] =
275 { {S_HALF, S_HALF, S_ONE}, { 0, 0, 0} },
276 { {S_HALF, S_HALF, S_ONE}, {T_HALF, 0, 0} },
277 { {S_HALF, S_HALF, S_ONE}, {T_HALF, T_HALF, 0} },
278 { {S_HALF, S_HALF, S_ONE}, { 0, T_HALF, 0} }
281 const RefTrf hex_child_rt3[4] =
283 { {S_TWO, S_TWO, S_ONE}, { 0, 0, 0} },
284 { {S_TWO, S_TWO, S_ONE}, {-T_ONE, 0, 0} },
285 { {S_TWO, S_TWO, S_ONE}, {-T_ONE, -T_ONE, 0} },
286 { {S_TWO, S_TWO, S_ONE}, { 0, -T_ONE, 0} }
289 const RefTrf hex_parent_rt4[2] =
291 { {S_ONE, S_ONE, S_HALF}, {0, 0, 0} },
292 { {S_ONE, S_ONE, S_HALF}, {0, 0, T_HALF} }
295 const RefTrf hex_child_rt4[2] =
297 { {S_ONE, S_ONE, S_TWO}, {0, 0, 0} },
298 { {S_ONE, S_ONE, S_TWO}, {0, 0, -T_ONE} }
301 const RefTrf hex_parent_rt5[4] =
303 { {S_HALF, S_ONE, S_HALF}, { 0, 0, 0} },
304 { {S_HALF, S_ONE, S_HALF}, {T_HALF, 0, 0} },
305 { {S_HALF, S_ONE, S_HALF}, {T_HALF, 0, T_HALF} },
306 { {S_HALF, S_ONE, S_HALF}, { 0, 0, T_HALF} }
309 const RefTrf hex_child_rt5[4] =
311 { {S_TWO, S_ONE, S_TWO}, { 0, 0, 0} },
312 { {S_TWO, S_ONE, S_TWO}, {-T_ONE, 0, 0} },
313 { {S_TWO, S_ONE, S_TWO}, {-T_ONE, 0, -T_ONE} },
314 { {S_TWO, S_ONE, S_TWO}, { 0, 0, -T_ONE} }
317 const RefTrf hex_parent_rt6[4] =
319 { {S_ONE, S_HALF, S_HALF}, {0, 0, 0} },
320 { {S_ONE, S_HALF, S_HALF}, {0, T_HALF, 0} },
321 { {S_ONE, S_HALF, S_HALF}, {0, 0, T_HALF} },
322 { {S_ONE, S_HALF, S_HALF}, {0, T_HALF, T_HALF} }
325 const RefTrf hex_child_rt6[4] =
327 { {S_ONE, S_TWO, S_TWO}, {0, 0, 0} },
328 { {S_ONE, S_TWO, S_TWO}, {0, -T_ONE, 0} },
329 { {S_ONE, S_TWO, S_TWO}, {0, 0, -T_ONE} },
330 { {S_ONE, S_TWO, S_TWO}, {0, -T_ONE, -T_ONE} }
333 const RefTrf hex_parent_rt7[8] =
335 { {S_HALF, S_HALF, S_HALF}, { 0, 0, 0} },
336 { {S_HALF, S_HALF, S_HALF}, {T_HALF, 0, 0} },
337 { {S_HALF, S_HALF, S_HALF}, {T_HALF, T_HALF, 0} },
338 { {S_HALF, S_HALF, S_HALF}, { 0, T_HALF, 0} },
339 { {S_HALF, S_HALF, S_HALF}, { 0, 0, T_HALF} },
340 { {S_HALF, S_HALF, S_HALF}, {T_HALF, 0, T_HALF} },
341 { {S_HALF, S_HALF, S_HALF}, {T_HALF, T_HALF, T_HALF} },
342 { {S_HALF, S_HALF, S_HALF}, { 0, T_HALF, T_HALF} }
345 const RefTrf hex_child_rt7[8] =
347 { {S_TWO, S_TWO, S_TWO}, { 0, 0, 0} },
348 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, 0} },
349 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, -T_ONE, 0} },
350 { {S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, 0} },
351 { {S_TWO, S_TWO, S_TWO}, { 0, 0, -T_ONE} },
352 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, -T_ONE} },
353 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, -T_ONE, -T_ONE} },
354 { {S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, -T_ONE} }
357 const RefTrf* hex_parent[8] =
369 const RefTrf* hex_child[8] =
381 const RefTrf tri_parent_rt3[4] =
383 { { S_HALF, S_HALF, 0}, { 0, 0, 0} },
384 { { S_HALF, S_HALF, 0}, {T_HALF, 0, 0} },
385 { { S_HALF, S_HALF, 0}, { 0, T_HALF, 0} },
386 { {-S_HALF, -S_HALF, 0}, {T_HALF, T_HALF, 0} }
389 const RefTrf tri_child_rt3[4] =
391 { { S_TWO, S_TWO, 0}, { 0, 0, 0} },
392 { { S_TWO, S_TWO, 0}, {-T_ONE, 0, 0} },
393 { { S_TWO, S_TWO, 0}, { 0, -T_ONE, 0} },
394 { {-S_TWO, -S_TWO, 0}, { T_ONE, T_ONE, 0} }
397 const RefTrf* tri_parent[4] =
403 const RefTrf* tri_child[4] =
409 const RefTrf prism_parent_rt3[4] =
411 { { S_HALF, S_HALF, S_ONE}, { 0, 0, 0} },
412 { { S_HALF, S_HALF, S_ONE}, {T_HALF, 0, 0} },
413 { { S_HALF, S_HALF, S_ONE}, { 0, T_HALF, 0} },
414 { {-S_HALF, -S_HALF, S_ONE}, {T_HALF, T_HALF, 0} }
417 const RefTrf prism_child_rt3[4] =
419 { { S_TWO, S_TWO, S_ONE}, { 0, 0, 0} },
420 { { S_TWO, S_TWO, S_ONE}, {-T_ONE, 0, 0} },
421 { { S_TWO, S_TWO, S_ONE}, { 0, -T_ONE, 0} },
422 { {-S_TWO, -S_TWO, S_ONE}, { T_ONE, T_ONE, 0} }
425 const RefTrf prism_parent_rt4[2] =
427 { {S_ONE, S_ONE, S_HALF}, {0, 0, 0} },
428 { {S_ONE, S_ONE, S_HALF}, {0, 0, T_HALF} }
431 const RefTrf prism_child_rt4[2] =
433 { {S_ONE, S_ONE, S_TWO}, {0, 0, 0} },
434 { {S_ONE, S_ONE, S_TWO}, {0, 0, -T_ONE} }
437 const RefTrf prism_parent_rt7[8] =
439 { { S_HALF, S_HALF, S_HALF}, { 0, 0, 0} },
440 { { S_HALF, S_HALF, S_HALF}, {T_HALF, 0, 0} },
441 { { S_HALF, S_HALF, S_HALF}, { 0, T_HALF, 0} },
442 { {-S_HALF, -S_HALF, S_HALF}, {T_HALF, T_HALF, 0} },
443 { { S_HALF, S_HALF, S_HALF}, { 0, 0, T_HALF} },
444 { { S_HALF, S_HALF, S_HALF}, {T_HALF, 0, T_HALF} },
445 { { S_HALF, S_HALF, S_HALF}, { 0, T_HALF, T_HALF} },
446 { {-S_HALF, -S_HALF, S_HALF}, {T_HALF, T_HALF, T_HALF} }
449 const RefTrf prism_child_rt7[8] =
451 { { S_TWO, S_TWO, S_TWO}, { 0, 0, 0} },
452 { { S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, 0} },
453 { { S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, 0} },
454 { {-S_TWO, -S_TWO, S_TWO}, { T_ONE, T_ONE, 0} },
455 { { S_TWO, S_TWO, S_TWO}, { 0, 0, -T_ONE} },
456 { { S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, -T_ONE} },
457 { { S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, -T_ONE} },
458 { {-S_TWO, -S_TWO, S_TWO}, { T_ONE, T_ONE, -T_ONE} }
461 const RefTrf* prism_parent[8] =
470 const RefTrf* prism_child[8] =
479 const RefTrf** geom_parent[7] =
490 const RefTrf** geom_child[7] =