Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

guge_mcpattern.cpp

Go to the documentation of this file.
00001 /* LIBGUL - Geometry Utility Library
00002  * Copyright (C) 1998-1999 Norbert Irmer
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
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      /*    0  1  2  3  4  5  6  7  */
00029 /* 0 */  { 0, 0, 2, 0, 8, 0, 0, 0},
00030 
00031 /* 1 */  { 0, 0, 0, 3, 0, 9, 0, 0},
00032 
00033 /* 2 */  { 2, 0, 0, 1, 0, 0,10, 0},
00034 
00035 /* 3 */  { 0, 3, 1, 0, 0, 0, 0,11},
00036 
00037 /* 4 */  { 8, 0, 0, 0, 0, 4, 6, 0},
00038 
00039 /* 5 */  { 0, 9, 0, 0, 4, 0, 0, 7},
00040 
00041 /* 6 */  { 0, 0,10, 0, 6, 0, 0, 5},
00042 
00043 /* 7 */  { 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 /* 00 */ { 0,  0, 0, 0x00},
00075 /* 01 */ { 1,  0, 1, 0x01},
00076 /* 02 */ { 1,  1, 1, 0x01},
00077 /* 03 */ { 2,  0, 2, 0x03},
00078 /* 04 */ { 1,  3, 1, 0x01},
00079 /* 05 */ { 2,  3, 2, 0x03},
00080 /* 06 */ { 3,  6, 2, 0x21},
00081 /* 07 */ { 5,  3, 3, 0x0b},
00082 /* 08 */ { 1,  2, 1, 0x01},
00083 /* 09 */ { 3, 10, 2, 0x21},
00084 /* 0a */ { 2,  1, 2, 0x03},
00085 /* 0b */ { 5,  0, 3, 0x0b},
00086 /* 0c */ { 2,  2, 2, 0x03},
00087 /* 0d */ { 5,  2, 3, 0x0b},
00088 /* 0e */ { 5,  1, 3, 0x0b},
00089 /* 0f */ { 8,  0, 4, 0x0f},
00090 /* 10 */ { 1,  4, 1, 0x01},
00091 /* 11 */ { 2,  5, 2, 0x03},
00092 /* 12 */ { 3,  9, 2, 0x21},
00093 /* 13 */ { 5,  6, 3, 0x0b},
00094 /* 14 */ { 3,  3, 2, 0x21},
00095 /* 15 */ { 5, 15, 3, 0x0b},
00096 /* 16 */ { 7,  3, 3, 0x29},
00097 /* 17 */ { 9,  0, 4, 0x17},
00098 /* 18 */ { 4,  2, 2, 0x81},
00099 /* 19 */ { 6, 15, 3, 0x83},
00100 /* 1a */ { 6, 10, 3, 0x83},
00101 /* 1b */ {11,  1, 4, 0x47},
00102 /* 1c */ { 6,  2, 3, 0x83},
00103 /* 1d */ {14,  3, 4, 0x27},
00104 /* 1e */ {12,  2, 4, 0x87},
00105 /* 1f */ { 5, 22, 5, 0x0b},
00106 /* 20 */ { 1,  7, 1, 0x01},
00107 /* 21 */ { 3,  0, 2, 0x21},
00108 /* 22 */ { 2,  7, 2, 0x03},
00109 /* 23 */ { 5,  7, 3, 0x0b},
00110 /* 24 */ { 4,  3, 2, 0x81},
00111 /* 25 */ { 6,  3, 3, 0x83},
00112 /* 26 */ { 6,  7, 3, 0x83},
00113 /* 27 */ {14,  0, 4, 0x27},
00114 /* 28 */ { 3,  7, 2, 0x21},
00115 /* 29 */ { 7,  0, 3, 0x29},
00116 /* 2a */ { 5, 10, 3, 0x0b},
00117 /* 2b */ { 9,  1, 4, 0x17},
00118 /* 2c */ { 6, 18, 3, 0x83},
00119 /* 2d */ {12,  3, 4, 0x87},
00120 /* 2e */ {11,  2, 4, 0x47},
00121 /* 2f */ { 5, 23, 5, 0x0b},
00122 /* 30 */ { 2,  4, 2, 0x03},
00123 /* 31 */ { 5,  5, 3, 0x0b},
00124 /* 32 */ { 5,  4, 3, 0x0b},
00125 /* 33 */ { 8,  4, 4, 0x0f},
00126 /* 34 */ { 6, 20, 3, 0x83},
00127 /* 35 */ {11,  4, 4, 0x47},
00128 /* 36 */ {12,  7, 4, 0x87},
00129 /* 37 */ { 5, 17, 5, 0x0b},
00130 /* 38 */ { 6,  4, 3, 0x83},
00131 /* 39 */ {12,  4, 4, 0x87},
00132 /* 3a */ {14,  7, 4, 0x27},
00133 /* 3b */ { 5, 16, 5, 0x0b},
00134 /* 3c */ {10,  2, 4, 0xc3},
00135 /* 3d */ { 6, 22, 5, 0x83},
00136 /* 3e */ { 6, 16, 5, 0x83},
00137 /* 3f */ { 2, 16, 6, 0x03},
00138 /* 40 */ { 1, 12, 1, 0x01},
00139 /* 41 */ { 3,  5, 2, 0x21},
00140 /* 42 */ { 4,  1, 2, 0x81},
00141 /* 43 */ { 6,  6, 3, 0x83},
00142 /* 44 */ { 2, 13, 2, 0x03},
00143 /* 45 */ { 5, 14, 3, 0x0b},
00144 /* 46 */ { 6, 19, 3, 0x83},
00145 /* 47 */ {11,  0, 4, 0x47},
00146 /* 48 */ { 3,  2, 2, 0x21},
00147 /* 49 */ { 7,  2, 3, 0x29},
00148 /* 4a */ { 6,  1, 3, 0x83},
00149 /* 4b */ {12,  1, 4, 0x87},
00150 /* 4c */ { 5, 19, 3, 0x0b},
00151 /* 4d */ { 9,  3, 4, 0x17},
00152 /* 4e */ {14,  2, 4, 0x27},
00153 /* 4f */ { 5, 21, 5, 0x0b},
00154 /* 50 */ { 2, 12, 2, 0x03},
00155 /* 51 */ { 5, 12, 3, 0x0b},
00156 /* 52 */ { 6, 12, 3, 0x83},
00157 /* 53 */ {14,  5, 4, 0x27},
00158 /* 54 */ { 5, 13, 3, 0x0b},
00159 /* 55 */ { 8, 12, 4, 0x0f},
00160 /* 56 */ {12, 12, 4, 0x87},
00161 /* 57 */ { 5,  8, 5, 0x0b},
00162 /* 58 */ { 6, 23, 3, 0x83},
00163 /* 59 */ {12, 15, 4, 0x87},
00164 /* 5a */ {10,  1, 4, 0xc3},
00165 /* 5b */ { 6,  8, 5, 0x83},
00166 /* 5c */ {11, 12, 4, 0x47},
00167 /* 5d */ { 5,  9, 5, 0x0b},
00168 /* 5e */ { 6, 21, 5, 0x83},
00169 /* 5f */ { 2,  8, 6, 0x03},
00170 /* 60 */ { 3,  8, 2, 0x21},
00171 /* 61 */ { 7,  5, 3, 0x29},
00172 /* 62 */ { 6,  9, 3, 0x83},
00173 /* 63 */ {12,  6, 4, 0x87},
00174 /* 64 */ { 6, 13, 3, 0x83},
00175 /* 65 */ {12, 13, 4, 0x87},
00176 /* 66 */ {10,  7, 4, 0xc3},
00177 /* 67 */ { 6, 17, 5, 0x83},
00178 /* 68 */ { 7,  8, 3, 0x29},
00179 /* 69 */ {13,  0, 4, 0x69},
00180 /* 6a */ {12,  9, 4, 0x87},
00181 /* 6b */ { 7, 13, 5, 0x29},
00182 /* 6c */ {12, 18, 4, 0x87},
00183 /* 6d */ { 7,  4, 5, 0x29},
00184 /* 6e */ { 6,  5, 5, 0x83},
00185 /* 6f */ { 3,  4, 6, 0x21},
00186 /* 70 */ { 5, 20, 3, 0x0b},
00187 /* 71 */ { 9,  4, 4, 0x17},
00188 /* 72 */ {11,  7, 4, 0x47},
00189 /* 73 */ { 5, 18, 5, 0x0b},
00190 /* 74 */ {14, 12, 4, 0x27},
00191 /* 75 */ { 5, 11, 5, 0x0b},
00192 /* 76 */ { 6, 11, 5, 0x83},
00193 /* 77 */ { 2, 11, 6, 0x03},
00194 /* 78 */ {12, 23, 4, 0x87},
00195 /* 79 */ { 7,  1, 5, 0x29},
00196 /* 7a */ { 6, 14, 5, 0x83},
00197 /* 7b */ { 3, 11, 6, 0x21},
00198 /* 7c */ { 6,  0, 5, 0x83},
00199 /* 7d */ { 3,  1, 6, 0x21},
00200 /* 7e */ { 4,  0, 6, 0x81},
00201 /* 7f */ { 1, 11, 7, 0x01},
00202 /* 80 */ { 1, 11, 1, 0x01},
00203 /* 81 */ { 4,  0, 2, 0x81},
00204 /* 82 */ { 3,  1, 2, 0x21},
00205 /* 83 */ { 6,  0, 3, 0x83},
00206 /* 84 */ { 3, 11, 2, 0x21},
00207 /* 85 */ { 6, 14, 3, 0x83},
00208 /* 86 */ { 7,  1, 3, 0x29},
00209 /* 87 */ {12,  0, 4, 0x87},
00210 /* 88 */ { 2, 11, 2, 0x03},
00211 /* 89 */ { 6, 11, 3, 0x83},
00212 /* 8a */ { 5, 11, 3, 0x0b},
00213 /* 8b */ {14,  1, 4, 0x27},
00214 /* 8c */ { 5, 18, 3, 0x0b},
00215 /* 8d */ {11,  3, 4, 0x47},
00216 /* 8e */ { 9,  2, 4, 0x17},
00217 /* 8f */ { 5, 20, 5, 0x0b},
00218 /* 90 */ { 3,  4, 2, 0x21},
00219 /* 91 */ { 6,  5, 3, 0x83},
00220 /* 92 */ { 7,  4, 3, 0x29},
00221 /* 93 */ {12,  5, 4, 0x87},
00222 /* 94 */ { 7, 13, 3, 0x29},
00223 /* 95 */ {12, 14, 4, 0x87},
00224 /* 96 */ {13,  1, 4, 0x69},
00225 /* 97 */ { 7,  8, 5, 0x29},
00226 /* 98 */ { 6, 17, 3, 0x83},
00227 /* 99 */ {10,  5, 4, 0xc3},
00228 /* 9a */ {12, 10, 4, 0x87},
00229 /* 9b */ { 6, 13, 5, 0x83},
00230 /* 9c */ {12, 17, 4, 0x87},
00231 /* 9d */ { 6,  9, 5, 0x83},
00232 /* 9e */ { 7,  5, 5, 0x29},
00233 /* 9f */ { 3,  8, 6, 0x21},
00234 /* a0 */ { 2,  8, 2, 0x03},
00235 /* a1 */ { 6, 21, 3, 0x83},
00236 /* a2 */ { 5,  9, 3, 0x0b},
00237 /* a3 */ {11,  6, 4, 0x47},
00238 /* a4 */ { 6,  8, 3, 0x83},
00239 /* a5 */ {10,  3, 4, 0xc3},
00240 /* a6 */ {12,  8, 4, 0x87},
00241 /* a7 */ { 6, 23, 5, 0x83},
00242 /* a8 */ { 5,  8, 3, 0x0b},
00243 /* a9 */ {12, 11, 4, 0x87},
00244 /* aa */ { 8,  8, 4, 0x0f},
00245 /* ab */ { 5, 13, 5, 0x0b},
00246 /* ac */ {14, 11, 4, 0x27},
00247 /* ad */ { 6, 12, 5, 0x83},
00248 /* ae */ { 5, 12, 5, 0x0b},
00249 /* af */ { 2, 12, 6, 0x03},
00250 /* b0 */ { 5, 21, 3, 0x0b},
00251 /* b1 */ {14,  4, 4, 0x27},
00252 /* b2 */ { 9,  7, 4, 0x17},
00253 /* b3 */ { 5, 19, 5, 0x0b},
00254 /* b4 */ {12, 20, 4, 0x87},
00255 /* b5 */ { 6,  1, 5, 0x83},
00256 /* b6 */ { 7,  2, 5, 0x29},
00257 /* b7 */ { 3,  2, 6, 0x21},
00258 /* b8 */ {11, 11, 4, 0x47},
00259 /* b9 */ { 6, 19, 5, 0x83},
00260 /* ba */ { 5, 14, 5, 0x0b},
00261 /* bb */ { 2, 13, 6, 0x03},
00262 /* bc */ { 6,  6, 5, 0x83},
00263 /* bd */ { 4,  1, 6, 0x81},
00264 /* be */ { 3,  5, 6, 0x21},
00265 /* bf */ { 1, 12, 7, 0x01},
00266 /* c0 */ { 2, 16, 2, 0x03},
00267 /* c1 */ { 6, 16, 3, 0x83},
00268 /* c2 */ { 6, 22, 3, 0x83},
00269 /* c3 */ {10,  0, 4, 0xc3},
00270 /* c4 */ { 5, 16, 3, 0x0b},
00271 /* c5 */ {14, 13, 4, 0x27},
00272 /* c6 */ {12, 19, 4, 0x87},
00273 /* c7 */ { 6,  4, 5, 0x83},
00274 /* c8 */ { 5, 17, 3, 0x0b},
00275 /* c9 */ {12, 16, 4, 0x87},
00276 /* ca */ {11, 10, 4, 0x47},
00277 /* cb */ { 6, 20, 5, 0x83},
00278 /* cc */ { 8, 16, 4, 0x0f},
00279 /* cd */ { 5,  4, 5, 0x0b},
00280 /* ce */ { 5,  5, 5, 0x0b},
00281 /* cf */ { 2,  4, 6, 0x03},
00282 /* d0 */ { 5, 23, 3, 0x0b},
00283 /* d1 */ {11, 15, 4, 0x47},
00284 /* d2 */ {12, 22, 4, 0x87},
00285 /* d3 */ { 6, 18, 5, 0x83},
00286 /* d4 */ { 9, 12, 4, 0x17},
00287 /* d5 */ { 5, 10, 5, 0x0b},
00288 /* d6 */ { 7,  0, 5, 0x29},
00289 /* d7 */ { 3,  7, 6, 0x21},
00290 /* d8 */ {14, 16, 4, 0x27},
00291 /* d9 */ { 6,  7, 5, 0x83},
00292 /* da */ { 6,  3, 5, 0x83},
00293 /* db */ { 4,  3, 6, 0x81},
00294 /* dc */ { 5,  7, 5, 0x0b},
00295 /* dd */ { 2,  7, 6, 0x03},
00296 /* de */ { 3,  0, 6, 0x21},
00297 /* df */ { 1,  7, 7, 0x01},
00298 /* e0 */ { 5, 22, 3, 0x0b},
00299 /* e1 */ {12, 21, 4, 0x87},
00300 /* e2 */ {14,  8, 4, 0x27},
00301 /* e3 */ { 6,  2, 5, 0x83},
00302 /* e4 */ {11, 19, 4, 0x47},
00303 /* e5 */ { 6, 10, 5, 0x83},
00304 /* e6 */ { 6, 15, 5, 0x83},
00305 /* e7 */ { 4,  2, 6, 0x81},
00306 /* e8 */ { 9, 11, 4, 0x17},
00307 /* e9 */ { 7,  3, 5, 0x29},
00308 /* ea */ { 5, 15, 5, 0x0b},
00309 /* eb */ { 3,  3, 6, 0x21},
00310 /* ec */ { 5,  6, 5, 0x0b},
00311 /* ed */ { 3,  9, 6, 0x21},
00312 /* ee */ { 2,  5, 6, 0x03},
00313 /* ef */ { 1,  4, 7, 0x01},
00314 /* f0 */ { 8, 20, 4, 0x0f},
00315 /* f1 */ { 5,  1, 5, 0x0b},
00316 /* f2 */ { 5,  2, 5, 0x0b},
00317 /* f3 */ { 2,  2, 6, 0x03},
00318 /* f4 */ { 5,  0, 5, 0x0b},
00319 /* f5 */ { 2,  1, 6, 0x03},
00320 /* f6 */ { 3, 10, 6, 0x21},
00321 /* f7 */ { 1,  2, 7, 0x01},
00322 /* f8 */ { 5,  3, 5, 0x0b},
00323 /* f9 */ { 3,  6, 6, 0x21},
00324 /* fa */ { 2,  3, 6, 0x03},
00325 /* fb */ { 1,  3, 7, 0x01},
00326 /* fc */ { 2,  0, 6, 0x03},
00327 /* fd */ { 1,  1, 7, 0x01},
00328 /* fe */ { 1,  0, 7, 0x01},
00329 /* ff */ { 0,  0, 8, 0x00},
00330 };
00331 
00332 }
00333 
00334 /*----------------------------------------------------------------------------
00335 
00336   Program to create the above tables
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     6 7
00358    4 5
00359     2 3
00360    0 1
00361 */
00362   {0,1,2,3,4,5,6,7},  /* down */
00363   {2,0,3,1,6,4,7,5},  /* 90   */
00364   {3,2,1,0,7,6,5,4},  /* 180  */
00365   {1,3,0,2,5,7,4,6},  /* -90  */
00366 /*
00367     4 5
00368    0 1
00369     6 7
00370    2 3
00371 */
00372   {2,3,6,7,0,1,4,5}, /* front */
00373   {0,2,4,6,1,3,5,7}, /* 90    */
00374   {1,0,5,4,3,2,7,6}, /* 180   */
00375   {3,1,7,5,2,0,6,4}, /* -90   */  
00376 /*
00377     5 1
00378    4 0
00379     7 3
00380    6 2
00381 */
00382   {6,2,7,3,4,0,5,1}, /* right */
00383   {4,0,6,2,5,1,7,3}, /* 90    */  
00384   {5,1,4,0,7,3,6,2}, /* 180   */
00385   {7,3,5,1,6,2,4,0}, /* -90   */
00386 /*
00387     0 4
00388    1 5
00389     2 6
00390    3 7
00391 */
00392   {3,7,2,6,1,5,0,4}, /* left */  
00393   {2,6,0,4,3,7,1,5}, /* 90   */
00394   {0,4,1,5,2,6,3,7}, /* 180  */
00395   {1,5,3,7,0,4,2,6}, /* -90  */
00396 /*
00397     1 0
00398    5 4
00399     3 2
00400    7 6
00401 */
00402   {7,6,3,2,5,4,1,0}, /* back */ 
00403   {6,4,2,0,7,5,3,1}, /* 90   */
00404   {4,5,0,1,6,7,2,3}, /* 180  */
00405   {5,7,1,3,4,6,0,2}, /* -90  */
00406 /*  
00407     3 2
00408    1 0
00409     7 6
00410    5 4
00411 */
00412   {5,4,7,6,1,0,3,2}, /* top */
00413   {7,5,6,4,3,1,2,0}, /* 90  */
00414   {6,7,4,5,2,3,0,1}, /* 180 */
00415   {4,6,5,7,0,2,1,3}  /* -90 */
00416 };
00417 
00418 int cubepatterns[] = {
00419 /* pattern 0
00420     6 7    0 0
00421    4 5    0 0
00422     2 3    0 0
00423    0 1    0 0
00424 */    
00425   0x00,
00426 /* pattern 1
00427     6 7    0 0
00428    4 5    0 0
00429     2 3    0 0
00430    0 1    x 0
00431 */
00432   0x01,
00433 /* pattern 2
00434     6 7    0 0
00435    4 5    0 0
00436     2 3    0 0
00437    0 1    x x
00438 */
00439   0x03,
00440 /* pattern 3
00441     6 7    0 0
00442    4 5    0 x
00443     2 3    0 0
00444    0 1    x 0
00445 */
00446   0x21,
00447 /* pattern 4
00448     6 7    0 x
00449    4 5    0 0
00450     2 3    0 0
00451    0 1    x 0
00452 */
00453   0x81,
00454 /* pattern 5
00455     6 7    0 0
00456    4 5    0 0
00457     2 3    0 x
00458    0 1    x x
00459 */
00460   0x0b,
00461 /* pattern 6
00462     6 7    0 x
00463    4 5    0 0
00464     2 3    0 0
00465    0 1    x x
00466 */
00467   0x83,
00468 /* pattern 7
00469     6 7    0 0
00470    4 5    0 x
00471     2 3    0 x
00472    0 1    x 0
00473 */
00474   0x29,
00475 /* pattern 8
00476     6 7    0 0
00477    4 5    0 0
00478     2 3    x x
00479    0 1    x x
00480 */
00481   0x0f,
00482 /* pattern 9
00483     6 7    0 0
00484    4 5    x 0
00485     2 3    x 0
00486    0 1    x x
00487 */
00488   0x17,
00489 /* pattern 10
00490     6 7    x x
00491    4 5    0 0
00492     2 3    0 0
00493    0 1    x x
00494 */
00495   0xc3,
00496 /* pattern 11
00497     6 7    x 0
00498    4 5    0 0
00499     2 3    x 0
00500    0 1    x x
00501 */
00502   0x47,
00503 /* pattern 12
00504     6 7    0 x
00505    4 5    0 0
00506     2 3    x 0
00507    0 1    x x
00508 */
00509   0x87,
00510 /* pattern 13
00511     6 7    x 0
00512    4 5    0 x
00513     2 3    0 x
00514    0 1    x 0
00515 */
00516   0x69,
00517 /* pattern 14
00518     6 7    0 0
00519    4 5    0 x
00520     2 3    x 0
00521    0 1    x x
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 

Generated on Mon Jan 21 04:17:27 2002 for GUL 0.6 - Geometry Utility Library by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001