00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "stdafx.h"
00021
00022 #include "gul_types.h"
00023 #include "guge_mcpattern.h"
00024
00025 namespace guge {
00026
00027 int EdgePerms[8][8] = {
00028
00029 { 0, 0, 2, 0, 8, 0, 0, 0},
00030
00031 { 0, 0, 0, 3, 0, 9, 0, 0},
00032
00033 { 2, 0, 0, 1, 0, 0,10, 0},
00034
00035 { 0, 3, 1, 0, 0, 0, 0,11},
00036
00037 { 8, 0, 0, 0, 0, 4, 6, 0},
00038
00039 { 0, 9, 0, 0, 4, 0, 0, 7},
00040
00041 { 0, 0,10, 0, 6, 0, 0, 5},
00042
00043 { 0, 0, 0,11, 0, 7, 5, 0},
00044 };
00045
00046 int VertexPerms[24][8] = {
00047 {0,1,2,3,4,5,6,7},
00048 {1,3,0,2,5,7,4,6},
00049 {3,2,1,0,7,6,5,4},
00050 {2,0,3,1,6,4,7,5},
00051 {4,5,0,1,6,7,2,3},
00052 {0,4,1,5,2,6,3,7},
00053 {1,0,5,4,3,2,7,6},
00054 {5,1,4,0,7,3,6,2},
00055 {5,7,1,3,4,6,0,2},
00056 {1,5,3,7,0,4,2,6},
00057 {3,1,7,5,2,0,6,4},
00058 {7,3,5,1,6,2,4,0},
00059 {6,4,2,0,7,5,3,1},
00060 {2,6,0,4,3,7,1,5},
00061 {0,2,4,6,1,3,5,7},
00062 {4,0,6,2,5,1,7,3},
00063 {7,6,3,2,5,4,1,0},
00064 {3,7,2,6,1,5,0,4},
00065 {2,3,6,7,0,1,4,5},
00066 {6,2,7,3,4,0,5,1},
00067 {5,4,7,6,1,0,3,2},
00068 {7,5,6,4,3,1,2,0},
00069 {6,7,4,5,2,3,0,1},
00070 {4,6,5,7,0,2,1,3},
00071 };
00072
00073 PatternRec PatternTable[256] = {
00074 { 0, 0, 0, 0x00},
00075 { 1, 0, 1, 0x01},
00076 { 1, 1, 1, 0x01},
00077 { 2, 0, 2, 0x03},
00078 { 1, 3, 1, 0x01},
00079 { 2, 3, 2, 0x03},
00080 { 3, 6, 2, 0x21},
00081 { 5, 3, 3, 0x0b},
00082 { 1, 2, 1, 0x01},
00083 { 3, 10, 2, 0x21},
00084 { 2, 1, 2, 0x03},
00085 { 5, 0, 3, 0x0b},
00086 { 2, 2, 2, 0x03},
00087 { 5, 2, 3, 0x0b},
00088 { 5, 1, 3, 0x0b},
00089 { 8, 0, 4, 0x0f},
00090 { 1, 4, 1, 0x01},
00091 { 2, 5, 2, 0x03},
00092 { 3, 9, 2, 0x21},
00093 { 5, 6, 3, 0x0b},
00094 { 3, 3, 2, 0x21},
00095 { 5, 15, 3, 0x0b},
00096 { 7, 3, 3, 0x29},
00097 { 9, 0, 4, 0x17},
00098 { 4, 2, 2, 0x81},
00099 { 6, 15, 3, 0x83},
00100 { 6, 10, 3, 0x83},
00101 {11, 1, 4, 0x47},
00102 { 6, 2, 3, 0x83},
00103 {14, 3, 4, 0x27},
00104 {12, 2, 4, 0x87},
00105 { 5, 22, 5, 0x0b},
00106 { 1, 7, 1, 0x01},
00107 { 3, 0, 2, 0x21},
00108 { 2, 7, 2, 0x03},
00109 { 5, 7, 3, 0x0b},
00110 { 4, 3, 2, 0x81},
00111 { 6, 3, 3, 0x83},
00112 { 6, 7, 3, 0x83},
00113 {14, 0, 4, 0x27},
00114 { 3, 7, 2, 0x21},
00115 { 7, 0, 3, 0x29},
00116 { 5, 10, 3, 0x0b},
00117 { 9, 1, 4, 0x17},
00118 { 6, 18, 3, 0x83},
00119 {12, 3, 4, 0x87},
00120 {11, 2, 4, 0x47},
00121 { 5, 23, 5, 0x0b},
00122 { 2, 4, 2, 0x03},
00123 { 5, 5, 3, 0x0b},
00124 { 5, 4, 3, 0x0b},
00125 { 8, 4, 4, 0x0f},
00126 { 6, 20, 3, 0x83},
00127 {11, 4, 4, 0x47},
00128 {12, 7, 4, 0x87},
00129 { 5, 17, 5, 0x0b},
00130 { 6, 4, 3, 0x83},
00131 {12, 4, 4, 0x87},
00132 {14, 7, 4, 0x27},
00133 { 5, 16, 5, 0x0b},
00134 {10, 2, 4, 0xc3},
00135 { 6, 22, 5, 0x83},
00136 { 6, 16, 5, 0x83},
00137 { 2, 16, 6, 0x03},
00138 { 1, 12, 1, 0x01},
00139 { 3, 5, 2, 0x21},
00140 { 4, 1, 2, 0x81},
00141 { 6, 6, 3, 0x83},
00142 { 2, 13, 2, 0x03},
00143 { 5, 14, 3, 0x0b},
00144 { 6, 19, 3, 0x83},
00145 {11, 0, 4, 0x47},
00146 { 3, 2, 2, 0x21},
00147 { 7, 2, 3, 0x29},
00148 { 6, 1, 3, 0x83},
00149 {12, 1, 4, 0x87},
00150 { 5, 19, 3, 0x0b},
00151 { 9, 3, 4, 0x17},
00152 {14, 2, 4, 0x27},
00153 { 5, 21, 5, 0x0b},
00154 { 2, 12, 2, 0x03},
00155 { 5, 12, 3, 0x0b},
00156 { 6, 12, 3, 0x83},
00157 {14, 5, 4, 0x27},
00158 { 5, 13, 3, 0x0b},
00159 { 8, 12, 4, 0x0f},
00160 {12, 12, 4, 0x87},
00161 { 5, 8, 5, 0x0b},
00162 { 6, 23, 3, 0x83},
00163 {12, 15, 4, 0x87},
00164 {10, 1, 4, 0xc3},
00165 { 6, 8, 5, 0x83},
00166 {11, 12, 4, 0x47},
00167 { 5, 9, 5, 0x0b},
00168 { 6, 21, 5, 0x83},
00169 { 2, 8, 6, 0x03},
00170 { 3, 8, 2, 0x21},
00171 { 7, 5, 3, 0x29},
00172 { 6, 9, 3, 0x83},
00173 {12, 6, 4, 0x87},
00174 { 6, 13, 3, 0x83},
00175 {12, 13, 4, 0x87},
00176 {10, 7, 4, 0xc3},
00177 { 6, 17, 5, 0x83},
00178 { 7, 8, 3, 0x29},
00179 {13, 0, 4, 0x69},
00180 {12, 9, 4, 0x87},
00181 { 7, 13, 5, 0x29},
00182 {12, 18, 4, 0x87},
00183 { 7, 4, 5, 0x29},
00184 { 6, 5, 5, 0x83},
00185 { 3, 4, 6, 0x21},
00186 { 5, 20, 3, 0x0b},
00187 { 9, 4, 4, 0x17},
00188 {11, 7, 4, 0x47},
00189 { 5, 18, 5, 0x0b},
00190 {14, 12, 4, 0x27},
00191 { 5, 11, 5, 0x0b},
00192 { 6, 11, 5, 0x83},
00193 { 2, 11, 6, 0x03},
00194 {12, 23, 4, 0x87},
00195 { 7, 1, 5, 0x29},
00196 { 6, 14, 5, 0x83},
00197 { 3, 11, 6, 0x21},
00198 { 6, 0, 5, 0x83},
00199 { 3, 1, 6, 0x21},
00200 { 4, 0, 6, 0x81},
00201 { 1, 11, 7, 0x01},
00202 { 1, 11, 1, 0x01},
00203 { 4, 0, 2, 0x81},
00204 { 3, 1, 2, 0x21},
00205 { 6, 0, 3, 0x83},
00206 { 3, 11, 2, 0x21},
00207 { 6, 14, 3, 0x83},
00208 { 7, 1, 3, 0x29},
00209 {12, 0, 4, 0x87},
00210 { 2, 11, 2, 0x03},
00211 { 6, 11, 3, 0x83},
00212 { 5, 11, 3, 0x0b},
00213 {14, 1, 4, 0x27},
00214 { 5, 18, 3, 0x0b},
00215 {11, 3, 4, 0x47},
00216 { 9, 2, 4, 0x17},
00217 { 5, 20, 5, 0x0b},
00218 { 3, 4, 2, 0x21},
00219 { 6, 5, 3, 0x83},
00220 { 7, 4, 3, 0x29},
00221 {12, 5, 4, 0x87},
00222 { 7, 13, 3, 0x29},
00223 {12, 14, 4, 0x87},
00224 {13, 1, 4, 0x69},
00225 { 7, 8, 5, 0x29},
00226 { 6, 17, 3, 0x83},
00227 {10, 5, 4, 0xc3},
00228 {12, 10, 4, 0x87},
00229 { 6, 13, 5, 0x83},
00230 {12, 17, 4, 0x87},
00231 { 6, 9, 5, 0x83},
00232 { 7, 5, 5, 0x29},
00233 { 3, 8, 6, 0x21},
00234 { 2, 8, 2, 0x03},
00235 { 6, 21, 3, 0x83},
00236 { 5, 9, 3, 0x0b},
00237 {11, 6, 4, 0x47},
00238 { 6, 8, 3, 0x83},
00239 {10, 3, 4, 0xc3},
00240 {12, 8, 4, 0x87},
00241 { 6, 23, 5, 0x83},
00242 { 5, 8, 3, 0x0b},
00243 {12, 11, 4, 0x87},
00244 { 8, 8, 4, 0x0f},
00245 { 5, 13, 5, 0x0b},
00246 {14, 11, 4, 0x27},
00247 { 6, 12, 5, 0x83},
00248 { 5, 12, 5, 0x0b},
00249 { 2, 12, 6, 0x03},
00250 { 5, 21, 3, 0x0b},
00251 {14, 4, 4, 0x27},
00252 { 9, 7, 4, 0x17},
00253 { 5, 19, 5, 0x0b},
00254 {12, 20, 4, 0x87},
00255 { 6, 1, 5, 0x83},
00256 { 7, 2, 5, 0x29},
00257 { 3, 2, 6, 0x21},
00258 {11, 11, 4, 0x47},
00259 { 6, 19, 5, 0x83},
00260 { 5, 14, 5, 0x0b},
00261 { 2, 13, 6, 0x03},
00262 { 6, 6, 5, 0x83},
00263 { 4, 1, 6, 0x81},
00264 { 3, 5, 6, 0x21},
00265 { 1, 12, 7, 0x01},
00266 { 2, 16, 2, 0x03},
00267 { 6, 16, 3, 0x83},
00268 { 6, 22, 3, 0x83},
00269 {10, 0, 4, 0xc3},
00270 { 5, 16, 3, 0x0b},
00271 {14, 13, 4, 0x27},
00272 {12, 19, 4, 0x87},
00273 { 6, 4, 5, 0x83},
00274 { 5, 17, 3, 0x0b},
00275 {12, 16, 4, 0x87},
00276 {11, 10, 4, 0x47},
00277 { 6, 20, 5, 0x83},
00278 { 8, 16, 4, 0x0f},
00279 { 5, 4, 5, 0x0b},
00280 { 5, 5, 5, 0x0b},
00281 { 2, 4, 6, 0x03},
00282 { 5, 23, 3, 0x0b},
00283 {11, 15, 4, 0x47},
00284 {12, 22, 4, 0x87},
00285 { 6, 18, 5, 0x83},
00286 { 9, 12, 4, 0x17},
00287 { 5, 10, 5, 0x0b},
00288 { 7, 0, 5, 0x29},
00289 { 3, 7, 6, 0x21},
00290 {14, 16, 4, 0x27},
00291 { 6, 7, 5, 0x83},
00292 { 6, 3, 5, 0x83},
00293 { 4, 3, 6, 0x81},
00294 { 5, 7, 5, 0x0b},
00295 { 2, 7, 6, 0x03},
00296 { 3, 0, 6, 0x21},
00297 { 1, 7, 7, 0x01},
00298 { 5, 22, 3, 0x0b},
00299 {12, 21, 4, 0x87},
00300 {14, 8, 4, 0x27},
00301 { 6, 2, 5, 0x83},
00302 {11, 19, 4, 0x47},
00303 { 6, 10, 5, 0x83},
00304 { 6, 15, 5, 0x83},
00305 { 4, 2, 6, 0x81},
00306 { 9, 11, 4, 0x17},
00307 { 7, 3, 5, 0x29},
00308 { 5, 15, 5, 0x0b},
00309 { 3, 3, 6, 0x21},
00310 { 5, 6, 5, 0x0b},
00311 { 3, 9, 6, 0x21},
00312 { 2, 5, 6, 0x03},
00313 { 1, 4, 7, 0x01},
00314 { 8, 20, 4, 0x0f},
00315 { 5, 1, 5, 0x0b},
00316 { 5, 2, 5, 0x0b},
00317 { 2, 2, 6, 0x03},
00318 { 5, 0, 5, 0x0b},
00319 { 2, 1, 6, 0x03},
00320 { 3, 10, 6, 0x21},
00321 { 1, 2, 7, 0x01},
00322 { 5, 3, 5, 0x0b},
00323 { 3, 6, 6, 0x21},
00324 { 2, 3, 6, 0x03},
00325 { 1, 3, 7, 0x01},
00326 { 2, 0, 6, 0x03},
00327 { 1, 1, 7, 0x01},
00328 { 1, 0, 7, 0x01},
00329 { 0, 0, 8, 0x00},
00330 };
00331
00332 }
00333
00334
00335
00336
00337
00338
00339
00340 #if 0
00341
00342 #include <stdio.h>
00343
00344 typedef struct
00345 {
00346 int method;
00347 int perm;
00348 int nbits;
00349 int pat;
00350 }
00351 PatternRec;
00352
00353
00354 int hcubeperms[24][8] =
00355 {
00356
00357
00358
00359
00360
00361
00362 {0,1,2,3,4,5,6,7},
00363 {2,0,3,1,6,4,7,5},
00364 {3,2,1,0,7,6,5,4},
00365 {1,3,0,2,5,7,4,6},
00366
00367
00368
00369
00370
00371
00372 {2,3,6,7,0,1,4,5},
00373 {0,2,4,6,1,3,5,7},
00374 {1,0,5,4,3,2,7,6},
00375 {3,1,7,5,2,0,6,4},
00376
00377
00378
00379
00380
00381
00382 {6,2,7,3,4,0,5,1},
00383 {4,0,6,2,5,1,7,3},
00384 {5,1,4,0,7,3,6,2},
00385 {7,3,5,1,6,2,4,0},
00386
00387
00388
00389
00390
00391
00392 {3,7,2,6,1,5,0,4},
00393 {2,6,0,4,3,7,1,5},
00394 {0,4,1,5,2,6,3,7},
00395 {1,5,3,7,0,4,2,6},
00396
00397
00398
00399
00400
00401
00402 {7,6,3,2,5,4,1,0},
00403 {6,4,2,0,7,5,3,1},
00404 {4,5,0,1,6,7,2,3},
00405 {5,7,1,3,4,6,0,2},
00406
00407
00408
00409
00410
00411
00412 {5,4,7,6,1,0,3,2},
00413 {7,5,6,4,3,1,2,0},
00414 {6,7,4,5,2,3,0,1},
00415 {4,6,5,7,0,2,1,3}
00416 };
00417
00418 int cubepatterns[] = {
00419
00420
00421
00422
00423
00424
00425 0x00,
00426
00427
00428
00429
00430
00431
00432 0x01,
00433
00434
00435
00436
00437
00438
00439 0x03,
00440
00441
00442
00443
00444
00445
00446 0x21,
00447
00448
00449
00450
00451
00452
00453 0x81,
00454
00455
00456
00457
00458
00459
00460 0x0b,
00461
00462
00463
00464
00465
00466
00467 0x83,
00468
00469
00470
00471
00472
00473
00474 0x29,
00475
00476
00477
00478
00479
00480
00481 0x0f,
00482
00483
00484
00485
00486
00487
00488 0x17,
00489
00490
00491
00492
00493
00494
00495 0xc3,
00496
00497
00498
00499
00500
00501
00502 0x47,
00503
00504
00505
00506
00507
00508
00509 0x87,
00510
00511
00512
00513
00514
00515
00516 0x69,
00517
00518
00519
00520
00521
00522
00523 0x27,
00524 };
00525
00526 int ncubepatterns = sizeof(cubepatterns)/sizeof(int);
00527
00528 int main()
00529 {
00530 int method,pat,i,j,k,bit,npat,nbit,nbits;
00531 PatternRec cubetab[256];
00532 int cubeperms[24][8];
00533
00534 for( i = 0; i < 256; i++ )
00535 {
00536 cubetab[i].method = -1;
00537 cubetab[i].perm = -1;
00538 cubetab[i].nbits = -1;
00539 cubetab[i].pat = -1;
00540 }
00541
00542 for( i = 0; i < 24; i++ )
00543 {
00544 for( j = 0; j < 8; j++ )
00545 cubeperms[i][hcubeperms[i][j]] = j;
00546 }
00547 printf( "NUIndex NU_MCVertexPerms[24][8] = {\n" );
00548 for( i = 0; i < 24; i++ )
00549 {
00550 printf( "{%d", cubeperms[i][0] );
00551 for( j = 1; j < 8; j++ )
00552 printf( ",%d", cubeperms[i][j] );
00553 printf( "},\n" );
00554 }
00555 printf( "};\n" );
00556
00557
00558 for( k = 0; k < ncubepatterns; k++ )
00559 {
00560 method = k;
00561 pat = cubepatterns[k];
00562
00563 for( i = 0; i < 24; i++ )
00564 {
00565 nbits = 0;
00566 bit = 1;
00567 npat = 0;
00568 for( j = 0; j < 8; j++ )
00569 {
00570 if( (pat & bit) != 0 )
00571 {
00572 nbits++;
00573 nbit = cubeperms[i][j];
00574 npat |= 1 << nbit;
00575 }
00576 bit += bit;
00577 }
00578 if( (cubetab[npat].method != -1) && (cubetab[npat].method != method) )
00579 { fprintf( stderr, "Error: Overwriting existing information\n"); exit(-1); }
00580
00581 if( cubetab[npat].method == -1 )
00582 {
00583 cubetab[npat].method = method;
00584 cubetab[npat].perm = i;
00585 cubetab[npat].nbits = nbits;
00586 cubetab[npat].pat = pat;
00587 }
00588
00589 if( nbits < 4 )
00590 {
00591 npat = (~npat) & 0xff;
00592
00593 if( (cubetab[npat].method != -1) && (cubetab[npat].method != method) )
00594 { fprintf( stderr, "Error: Overwriting existing information\n"); exit(-1); }
00595
00596 if( cubetab[npat].method == -1 )
00597 {
00598 cubetab[npat].method = method;
00599 cubetab[npat].perm = i;
00600 cubetab[npat].nbits = 8 - nbits;
00601 cubetab[npat].pat = pat;
00602 }
00603 }
00604 }
00605 }
00606
00607 printf( "PatternRec PatternTable[256] = {\n" );
00608
00609 j = 0;
00610 for( i = 0; i < 256; i++ )
00611 {
00612 if( cubetab[i].method != -1 )
00613 {
00614 fprintf( stderr, "%02x %2d %02d %d %02x\n",
00615 i, cubetab[i].method, cubetab[i].perm,
00616 cubetab[i].nbits, cubetab[i].pat );
00617 j++;
00618 }
00619 else
00620 { fprintf(stderr, "Error: empty entry in pattern table\n"); exit(-1); }
00621
00622 printf( "/* %02x */ {%2d, %2d, %d, 0x%02x},\n",
00623 i, cubetab[i].method, cubetab[i].perm,
00624 cubetab[i].nbits, cubetab[i].pat );
00625 }
00626 printf( "};\n" );
00627
00628 fprintf( stderr, "number of patterns = %d\n", j );
00629
00630 return(0);
00631 }
00632
00633 #endif
00634
00635
00636
00637
00638