18 const int ref_type_num_children[8] = { 0, 2, 2, 4, 2, 4, 4, 8 };
23 const int quad_deref_table[3][4 + 4] =
25 { 0, 1, 1, 0, 1, 1, 0, 0 },
26 { 0, 0, 1, 1, 0, 0, 1, 1 },
27 { 0, 1, 2, 3, 1, 1, 3, 3 }
30 const int hex_deref_table[7][8 + 6] =
32 { 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0 },
33 { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1 },
34 { 0, 1, 2, 3, 0, 1, 2, 3, 1, 1, 1, 3, 3, 3 },
35 { 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1 },
36 { 0, 1, 1, 0, 3, 2, 2, 3, 1, 1, 1, 3, 3, 3 },
37 { 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 0, 3, 3, 3 },
38 { 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 1, 7, 7, 7 }
41 const int prism_deref_table[7][6 + 5] =
43 {-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
44 {-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1 },
45 { 0, 1, 2, 0, 1, 2, 0, 0, 0, 1, 0 },
46 { 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0 },
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, 4, 5, 6, 0, 5, 0, 5, 0 }
55 const char quad_hilbert_child_order[8][4] =
57 {0,1,2,3}, {0,3,2,1}, {1,2,3,0}, {1,0,3,2},
58 {2,3,0,1}, {2,1,0,3}, {3,0,1,2}, {3,2,1,0}
61 const char quad_hilbert_child_state[8][4] =
63 {1,0,0,5}, {0,1,1,4}, {3,2,2,7}, {2,3,3,6},
64 {5,4,4,1}, {4,5,5,0}, {7,6,6,3}, {6,7,7,2}
67 const char hex_hilbert_child_order[24][8] =
69 {0,1,2,3,7,6,5,4}, {0,3,7,4,5,6,2,1}, {0,4,5,1,2,6,7,3},
70 {1,0,3,2,6,7,4,5}, {1,2,6,5,4,7,3,0}, {1,5,4,0,3,7,6,2},
71 {2,1,5,6,7,4,0,3}, {2,3,0,1,5,4,7,6}, {2,6,7,3,0,4,5,1},
72 {3,0,4,7,6,5,1,2}, {3,2,1,0,4,5,6,7}, {3,7,6,2,1,5,4,0},
73 {4,0,1,5,6,2,3,7}, {4,5,6,7,3,2,1,0}, {4,7,3,0,1,2,6,5},
74 {5,1,0,4,7,3,2,6}, {5,4,7,6,2,3,0,1}, {5,6,2,1,0,3,7,4},
75 {6,2,3,7,4,0,1,5}, {6,5,1,2,3,0,4,7}, {6,7,4,5,1,0,3,2},
76 {7,3,2,6,5,1,0,4}, {7,4,0,3,2,1,5,6}, {7,6,5,4,0,1,2,3}
79 const char hex_hilbert_child_state[24][8] =
81 {1,2,2,7,7,21,21,17}, {2,0,0,22,22,16,16,8}, {0,1,1,15,15,6,6,23},
82 {4,5,5,10,10,18,18,14}, {5,3,3,19,19,13,13,11}, {3,4,4,12,12,9,9,20},
83 {8,7,7,17,17,23,23,2}, {6,8,8,0,0,15,15,22}, {7,6,6,21,21,1,1,16},
84 {11,10,10,14,14,20,20,5}, {9,11,11,3,3,12,12,19}, {10,9,9,18,18,4,4,13},
85 {13,14,14,5,5,19,19,10}, {14,12,12,20,20,11,11,4}, {12,13,13,9,9,3,3,18},
86 {16,17,17,2,2,22,22,7}, {17,15,15,23,23,8,8,1}, {15,16,16,6,6,0,0,21},
87 {20,19,19,11,11,14,14,3}, {18,20,20,4,4,10,10,12}, {19,18,18,13,13,5,5,9},
88 {23,22,22,8,8,17,17,0}, {21,23,23,1,1,7,7,15}, {22,21,21,16,16,2,2,6}
97 const RefCoord T_HALF = (1ll << 59);
98 const RefCoord T_ONE = (1ll << 60);
99 const RefCoord T_TWO = (1ll << 61);
102 const RefCoord S_HALF = 1;
103 const RefCoord S_ONE = 2;
104 const RefCoord S_TWO = 4;
106 const RefCoord tri_corners[3][3] =
113 const RefCoord quad_corners[4][3] =
121 const RefCoord hex_corners[8][3] =
129 {T_ONE, T_ONE, T_ONE},
133 const RefCoord prism_corners[6][3] =
143 typedef RefCoord RefPoint[3];
144 const RefPoint* geom_corners[7] =
160 void Apply(
const RefCoord src[3], RefCoord dst[3])
const
162 for (
int i = 0; i < 3; i++)
164 dst[i] = (src[i]*
s[i] >> 1) +
t[i];
169 const RefTrf quad_parent_rt1[2] =
171 { {S_HALF, S_ONE, 0}, { 0, 0, 0} },
172 { {S_HALF, S_ONE, 0}, {T_HALF, 0, 0} }
175 const RefTrf quad_child_rt1[2] =
177 { {S_TWO, S_ONE, 0}, { 0, 0, 0} },
178 { {S_TWO, S_ONE, 0}, {-T_ONE, 0, 0} }
181 const RefTrf quad_parent_rt2[2] =
183 { {S_ONE, S_HALF, 0}, {0, 0, 0} },
184 { {S_ONE, S_HALF, 0}, {0, T_HALF, 0} }
187 const RefTrf quad_child_rt2[2] =
189 { {S_ONE, S_TWO, 0}, {0, 0, 0} },
190 { {S_ONE, S_TWO, 0}, {0, -T_ONE, 0} }
193 const RefTrf quad_parent_rt3[4] =
195 { {S_HALF, S_HALF, 0}, { 0, 0, 0} },
196 { {S_HALF, S_HALF, 0}, {T_HALF, 0, 0} },
197 { {S_HALF, S_HALF, 0}, {T_HALF, T_HALF, 0} },
198 { {S_HALF, S_HALF, 0}, { 0, T_HALF, 0} }
201 const RefTrf quad_child_rt3[4] =
203 { {S_TWO, S_TWO, 0}, { 0, 0, 0} },
204 { {S_TWO, S_TWO, 0}, {-T_ONE, 0, 0} },
205 { {S_TWO, S_TWO, 0}, {-T_ONE, -T_ONE, 0} },
206 { {S_TWO, S_TWO, 0}, { 0, -T_ONE, 0} }
209 const RefTrf* quad_parent[4] =
217 const RefTrf* quad_child[4] =
225 const RefTrf hex_parent_rt1[2] =
227 { {S_HALF, S_ONE, S_ONE}, { 0, 0, 0} },
228 { {S_HALF, S_ONE, S_ONE}, {T_HALF, 0, 0} }
231 const RefTrf hex_child_rt1[2] =
233 { {S_TWO, S_ONE, S_ONE}, { 0, 0, 0} },
234 { {S_TWO, S_ONE, S_ONE}, {-T_ONE, 0, 0} }
237 const RefTrf hex_parent_rt2[2] =
239 { {S_ONE, S_HALF, S_ONE}, {0, 0, 0} },
240 { {S_ONE, S_HALF, S_ONE}, {0, T_HALF, 0} }
243 const RefTrf hex_child_rt2[2] =
245 { {S_ONE, S_TWO, S_ONE}, {0, 0, 0} },
246 { {S_ONE, S_TWO, S_ONE}, {0, -T_ONE, 0} }
249 const RefTrf hex_parent_rt3[4] =
251 { {S_HALF, S_HALF, S_ONE}, { 0, 0, 0} },
252 { {S_HALF, S_HALF, S_ONE}, {T_HALF, 0, 0} },
253 { {S_HALF, S_HALF, S_ONE}, {T_HALF, T_HALF, 0} },
254 { {S_HALF, S_HALF, S_ONE}, { 0, T_HALF, 0} }
257 const RefTrf hex_child_rt3[4] =
259 { {S_TWO, S_TWO, S_ONE}, { 0, 0, 0} },
260 { {S_TWO, S_TWO, S_ONE}, {-T_ONE, 0, 0} },
261 { {S_TWO, S_TWO, S_ONE}, {-T_ONE, -T_ONE, 0} },
262 { {S_TWO, S_TWO, S_ONE}, { 0, -T_ONE, 0} }
265 const RefTrf hex_parent_rt4[2] =
267 { {S_ONE, S_ONE, S_HALF}, {0, 0, 0} },
268 { {S_ONE, S_ONE, S_HALF}, {0, 0, T_HALF} }
271 const RefTrf hex_child_rt4[2] =
273 { {S_ONE, S_ONE, S_TWO}, {0, 0, 0} },
274 { {S_ONE, S_ONE, S_TWO}, {0, 0, -T_ONE} }
277 const RefTrf hex_parent_rt5[4] =
279 { {S_HALF, S_ONE, S_HALF}, { 0, 0, 0} },
280 { {S_HALF, S_ONE, S_HALF}, {T_HALF, 0, 0} },
281 { {S_HALF, S_ONE, S_HALF}, {T_HALF, 0, T_HALF} },
282 { {S_HALF, S_ONE, S_HALF}, { 0, 0, T_HALF} }
285 const RefTrf hex_child_rt5[4] =
287 { {S_TWO, S_ONE, S_TWO}, { 0, 0, 0} },
288 { {S_TWO, S_ONE, S_TWO}, {-T_ONE, 0, 0} },
289 { {S_TWO, S_ONE, S_TWO}, {-T_ONE, 0, -T_ONE} },
290 { {S_TWO, S_ONE, S_TWO}, { 0, 0, -T_ONE} }
293 const RefTrf hex_parent_rt6[4] =
295 { {S_ONE, S_HALF, S_HALF}, {0, 0, 0} },
296 { {S_ONE, S_HALF, S_HALF}, {0, T_HALF, 0} },
297 { {S_ONE, S_HALF, S_HALF}, {0, 0, T_HALF} },
298 { {S_ONE, S_HALF, S_HALF}, {0, T_HALF, T_HALF} }
301 const RefTrf hex_child_rt6[4] =
303 { {S_ONE, S_TWO, S_TWO}, {0, 0, 0} },
304 { {S_ONE, S_TWO, S_TWO}, {0, -T_ONE, 0} },
305 { {S_ONE, S_TWO, S_TWO}, {0, 0, -T_ONE} },
306 { {S_ONE, S_TWO, S_TWO}, {0, -T_ONE, -T_ONE} }
309 const RefTrf hex_parent_rt7[8] =
311 { {S_HALF, S_HALF, S_HALF}, { 0, 0, 0} },
312 { {S_HALF, S_HALF, S_HALF}, {T_HALF, 0, 0} },
313 { {S_HALF, S_HALF, S_HALF}, {T_HALF, T_HALF, 0} },
314 { {S_HALF, S_HALF, S_HALF}, { 0, T_HALF, 0} },
315 { {S_HALF, S_HALF, S_HALF}, { 0, 0, T_HALF} },
316 { {S_HALF, S_HALF, S_HALF}, {T_HALF, 0, T_HALF} },
317 { {S_HALF, S_HALF, S_HALF}, {T_HALF, T_HALF, T_HALF} },
318 { {S_HALF, S_HALF, S_HALF}, { 0, T_HALF, T_HALF} }
321 const RefTrf hex_child_rt7[8] =
323 { {S_TWO, S_TWO, S_TWO}, { 0, 0, 0} },
324 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, 0} },
325 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, -T_ONE, 0} },
326 { {S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, 0} },
327 { {S_TWO, S_TWO, S_TWO}, { 0, 0, -T_ONE} },
328 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, -T_ONE} },
329 { {S_TWO, S_TWO, S_TWO}, {-T_ONE, -T_ONE, -T_ONE} },
330 { {S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, -T_ONE} }
333 const RefTrf* hex_parent[8] =
345 const RefTrf* hex_child[8] =
357 const RefTrf tri_parent_rt3[4] =
359 { { S_HALF, S_HALF, 0}, { 0, 0, 0} },
360 { { S_HALF, S_HALF, 0}, {T_HALF, 0, 0} },
361 { { S_HALF, S_HALF, 0}, { 0, T_HALF, 0} },
362 { {-S_HALF, -S_HALF, 0}, {T_HALF, T_HALF, 0} }
365 const RefTrf tri_child_rt3[4] =
367 { { S_TWO, S_TWO, 0}, { 0, 0, 0} },
368 { { S_TWO, S_TWO, 0}, {-T_ONE, 0, 0} },
369 { { S_TWO, S_TWO, 0}, { 0, -T_ONE, 0} },
370 { {-S_TWO, -S_TWO, 0}, { T_ONE, T_ONE, 0} }
373 const RefTrf* tri_parent[4] =
379 const RefTrf* tri_child[4] =
385 const RefTrf prism_parent_rt3[4] =
387 { { S_HALF, S_HALF, S_ONE}, { 0, 0, 0} },
388 { { S_HALF, S_HALF, S_ONE}, {T_HALF, 0, 0} },
389 { { S_HALF, S_HALF, S_ONE}, { 0, T_HALF, 0} },
390 { {-S_HALF, -S_HALF, S_ONE}, {T_HALF, T_HALF, 0} }
393 const RefTrf prism_child_rt3[4] =
395 { { S_TWO, S_TWO, S_ONE}, { 0, 0, 0} },
396 { { S_TWO, S_TWO, S_ONE}, {-T_ONE, 0, 0} },
397 { { S_TWO, S_TWO, S_ONE}, { 0, -T_ONE, 0} },
398 { {-S_TWO, -S_TWO, S_ONE}, { T_ONE, T_ONE, 0} }
401 const RefTrf prism_parent_rt4[2] =
403 { {S_ONE, S_ONE, S_HALF}, {0, 0, 0} },
404 { {S_ONE, S_ONE, S_HALF}, {0, 0, T_HALF} }
407 const RefTrf prism_child_rt4[2] =
409 { {S_ONE, S_ONE, S_TWO}, {0, 0, 0} },
410 { {S_ONE, S_ONE, S_TWO}, {0, 0, -T_ONE} }
413 const RefTrf prism_parent_rt7[8] =
415 { { S_HALF, S_HALF, S_HALF}, { 0, 0, 0} },
416 { { S_HALF, S_HALF, S_HALF}, {T_HALF, 0, 0} },
417 { { S_HALF, S_HALF, S_HALF}, { 0, T_HALF, 0} },
418 { {-S_HALF, -S_HALF, S_HALF}, {T_HALF, T_HALF, 0} },
419 { { S_HALF, S_HALF, S_HALF}, { 0, 0, T_HALF} },
420 { { S_HALF, S_HALF, S_HALF}, {T_HALF, 0, T_HALF} },
421 { { S_HALF, S_HALF, S_HALF}, { 0, T_HALF, T_HALF} },
422 { {-S_HALF, -S_HALF, S_HALF}, {T_HALF, T_HALF, T_HALF} }
425 const RefTrf prism_child_rt7[8] =
427 { { S_TWO, S_TWO, S_TWO}, { 0, 0, 0} },
428 { { S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, 0} },
429 { { S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, 0} },
430 { {-S_TWO, -S_TWO, S_TWO}, { T_ONE, T_ONE, 0} },
431 { { S_TWO, S_TWO, S_TWO}, { 0, 0, -T_ONE} },
432 { { S_TWO, S_TWO, S_TWO}, {-T_ONE, 0, -T_ONE} },
433 { { S_TWO, S_TWO, S_TWO}, { 0, -T_ONE, -T_ONE} },
434 { {-S_TWO, -S_TWO, S_TWO}, { T_ONE, T_ONE, -T_ONE} }
437 const RefTrf* prism_parent[8] =
446 const RefTrf* prism_child[8] =
455 const RefTrf** geom_parent[7] =
466 const RefTrf** geom_child[7] =