// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** * @author Mike Yurick * * Adapted from the paper/implementation: * "Efficient Implementation of Marching Cubes' cases with topological guarantees". * Lewinar, et al. * * He uses a different sign convention, cube corner and edge setup, so the implementation has * been reworked to be made usable with our cube conventions. There were also a couple of errors * in his tables/tests which I have corrected. There is a unit test in the VolumetricsTestSuite * called testMarchingCubesTopology which verifies the correctness of the topology of a mesh * created from a randomly generated level set. */ #pragma once #include #include // DEBUG // extern std::map cubeCaseCounter; /** * Cube conventions: * 6 ________ 7 _____11_ _6______ * /| /| 9/| /| /| 3 /| * / | / | / | 10/ | / 4| / | * 4 /____|__ 5 | /__8_|__ / 7 /____|__ / | * | | | | | 6 | | | 1 | | 2 | * | 2|__|_____|3 | |__|__5__| | |__|_____| * | / | / 2 1/ 4 / | / | / * | / | / | / | /3 | / | / * |/_______|/ |/___0___|/ |/_______|/ * 0 1 5 * * //// Z-up right handed coordinate system //// * X is rightwards * Y is away from the screen * Z is up * * //// The 12 edges in their canonical order //// * 01,02,04,13,15,23,26,37,45,46,57,67 * * Given a cubeCase, ((cubeCase >> (7-N)) & 1) is the sign bit of cube corner N * The sign bit is 1 for negative signed distance, and 0 for positive signed distance. */ namespace frantic { namespace volumetrics { /** * Disambiguated Marching Cubes tables. * * For each of the possible cube cases listed in the disambiguatedCases table, * there is a specific triangulation of the edge vertices, depending on a number * of factors. * * The disambiguatedCubeCases table lists all of possible cube configurations and * the unique cube case to which they correspond, of which there are 14. A unique * cube case refers to particular configuration of signed corner values, regardless * of orientation. For example, a cube with only corners 2 and 3 negative is the same * cube case as one with only corners 4 and 5 negative (case 2). They simply have a * different orientation. The disambiguatedCubeCases table notes both the unique cube * case and a particular orientation. * * For each of the unique cube cases, one or more triangle tables give the * particular triangulation of the edge vertices as a list of edges that should * be connected to comprise a face. Each face list table entry thus has a * multiple of 3 valid edge indices. The specific triangulation of these * edge vertices depends upon resolving any possible cube case ambiguities. * * An ambiguous case means that the corner values of the cube can lend themselves * to more than one possible triangulation of edge vertices. However, only one * such triangulation is correct, and it can be determined by performing a few * tests using the corner values of the cubes. For example, imagine the case * where corners 0 and 7 are the only negative corners. It could be that the * implicit surface being discretized does just passes across each corner, and a * single triangle over each corner vertex could correctly represent the surface * topology. However, it could also be the case that the surface passes through * the interior of the cube, connecting the two corners on the inside. In this * case, several more triangles of a different configuration will be necessary * to model the "tunnel" the surface makes through the interior of the cube. * Such ambiguities occur in a number of cases, both on faces and the interior, * where opposite corners are of the same sign and may either be separated * or connected by the implicit surface being modeled. The tests aim to determine * which is the case, so that the appropriate triangulation can be used. They * all work on essentially the same principle of determining whether the corner * values which lie in a plane indicate that like corner values on that plane * are "connected". Some interior tests require an edge to be specified in order * to determine the orientation of such a plane, while face tests already have * a plane defined by the cube fase. For tests requireing an edge, it is encoded * as the last entry in the appropriate test tables. Details on the testing * procedure can be found in the above mentioned paper. * * If a case is not ambiguous, it has only one possible interpretation and one * possible triangulation of the edge vertices. Thus, it has only a single * triangle table, and the disambiguatedCubeCases table indicates which table * this is, and which row. When a case is ambiguous, there is a testing table that * contains which face or internal test must be performed in order to * disambiguate an determine the correct triangulation. Depending on the outcome * of the test, the appropriate subcase triangle table specifies the correct * edge vertex triangulation. A minus sign indicates that result of the * test should be inverted, in order to account for unique cube cases * where the corner values are inverted. In some cases, the tests will reveal * the necessity for an additional vertex at the centre of the cube in order * to specify an accurate triangulation. In these cases, the table entries * will have edge indices up to 12, indicating the new centre vertex which will * have to be added. * */ static const char disambiguatedCubeCases[256][2] = { /* 0: */ { 0, -1 }, /* 1: 0, */ { 1, 15 }, /* 2: 1, */ { 1, 14 }, /* 3: 0, 1, */ { 2, 23 }, /* 4: 2, */ { 1, 12 }, /* 5: 0, 2, */ { 2, 22 }, /* 6: 1, 2, */ { 3, 20 }, /* 7: 0, 1, 2, */ { 5, 46 }, /* 8: 3, */ { 1, 13 }, /* 9: 0, 3, */ { 3, 23 }, /* 10: 1, 3, */ { 2, 20 }, /* 11: 0, 1, 3, */ { 5, 47 }, /* 12: 2, 3, */ { 2, 18 }, /* 13: 0, 2, 3, */ { 5, 43 }, /* 14: 1, 2, 3, */ { 5, 38 }, /* 15: 0, 1, 2, 3, */ { 8, 5 }, /* 16: 4, */ { 1, 11 }, /* 17: 0, 4, */ { 2, 21 }, /* 18: 1, 4, */ { 3, 19 }, /* 19: 0, 1, 4, */ { 5, 45 }, /* 20: 2, 4, */ { 3, 15 }, /* 21: 0, 2, 4, */ { 5, 42 }, /* 22: 1, 2, 4, */ { 7, 12 }, /* 23: 0, 1, 2, 4, */ { 9, 6 }, /* 24: 3, 4, */ { 4, 5 }, /* 25: 0, 3, 4, */ { 6, 45 }, /* 26: 1, 3, 4, */ { 6, 38 }, /* 27: 0, 1, 3, 4, */ { 11, 11 }, /* 28: 2, 3, 4, */ { 6, 31 }, /* 29: 0, 2, 3, 4, */ { 14, 8 }, /* 30: 1, 2, 3, 4, */ { 12, 11 }, /* 31: 0, 1, 2, 3, 4, */ { 5, 23 }, /* 32: 5, */ { 1, 10 }, /* 33: 0, 5, */ { 3, 22 }, /* 34: 1, 5, */ { 2, 19 }, /* 35: 0, 1, 5, */ { 5, 44 }, /* 36: 2, 5, */ { 4, 4 }, /* 37: 0, 2, 5, */ { 6, 43 }, /* 38: 1, 2, 5, */ { 6, 36 }, /* 39: 0, 1, 2, 5, */ { 14, 10 }, /* 40: 3, 5, */ { 3, 17 }, /* 41: 0, 3, 5, */ { 7, 15 }, /* 42: 1, 3, 5, */ { 5, 37 }, /* 43: 0, 1, 3, 5, */ { 9, 7 }, /* 44: 2, 3, 5, */ { 6, 30 }, /* 45: 0, 2, 3, 5, */ { 12, 19 }, /* 46: 1, 2, 3, 5, */ { 11, 5 }, /* 47: 0, 1, 2, 3, 5, */ { 5, 22 }, /* 48: 4, 5, */ { 2, 15 }, /* 49: 0, 4, 5, */ { 5, 40 }, /* 50: 1, 4, 5, */ { 5, 35 }, /* 51: 0, 1, 4, 5, */ { 8, 4 }, /* 52: 2, 4, 5, */ { 6, 26 }, /* 53: 0, 2, 4, 5, */ { 11, 7 }, /* 54: 1, 2, 4, 5, */ { 12, 8 }, /* 55: 0, 1, 2, 4, 5, */ { 5, 17 }, /* 56: 3, 4, 5, */ { 6, 29 }, /* 57: 0, 3, 4, 5, */ { 12, 18 }, /* 58: 1, 3, 4, 5, */ { 14, 4 }, /* 59: 0, 1, 3, 4, 5, */ { 5, 19 }, /* 60: 2, 3, 4, 5, */ { 10, 0 }, /* 61: 0, 2, 3, 4, 5, */ { 6, 15 }, /* 62: 1, 2, 3, 4, 5, */ { 6, 8 }, /* 63: 0, 1, 2, 3, 4, 5, */ { 2, 11 }, /* 64: 6, */ { 1, 8 }, /* 65: 0, 6, */ { 3, 21 }, /* 66: 1, 6, */ { 4, 6 }, /* 67: 0, 1, 6, */ { 6, 46 }, /* 68: 2, 6, */ { 2, 16 }, /* 69: 0, 2, 6, */ { 5, 41 }, /* 70: 1, 2, 6, */ { 6, 35 }, /* 71: 0, 1, 2, 6, */ { 11, 10 }, /* 72: 3, 6, */ { 3, 16 }, /* 73: 0, 3, 6, */ { 7, 14 }, /* 74: 1, 3, 6, */ { 6, 37 }, /* 75: 0, 1, 3, 6, */ { 12, 23 }, /* 76: 2, 3, 6, */ { 5, 32 }, /* 77: 0, 2, 3, 6, */ { 9, 5 }, /* 78: 1, 2, 3, 6, */ { 14, 5 }, /* 79: 0, 1, 2, 3, 6, */ { 5, 20 }, /* 80: 4, 6, */ { 2, 14 }, /* 81: 0, 4, 6, */ { 5, 39 }, /* 82: 1, 4, 6, */ { 6, 34 }, /* 83: 0, 1, 4, 6, */ { 14, 9 }, /* 84: 2, 4, 6, */ { 5, 29 }, /* 85: 0, 2, 4, 6, */ { 8, 3 }, /* 86: 1, 2, 4, 6, */ { 12, 7 }, /* 87: 0, 1, 2, 4, 6, */ { 5, 16 }, /* 88: 3, 4, 6, */ { 6, 27 }, /* 89: 0, 3, 4, 6, */ { 12, 17 }, /* 90: 1, 3, 4, 6, */ { 10, 2 }, /* 91: 0, 1, 3, 4, 6, */ { 6, 22 }, /* 92: 2, 3, 4, 6, */ { 11, 2 }, /* 93: 0, 2, 3, 4, 6, */ { 5, 13 }, /* 94: 1, 2, 3, 4, 6, */ { 6, 7 }, /* 95: 0, 1, 2, 3, 4, 6, */ { 2, 10 }, /* 96: 5, 6, */ { 3, 12 }, /* 97: 0, 5, 6, */ { 7, 13 }, /* 98: 1, 5, 6, */ { 6, 33 }, /* 99: 0, 1, 5, 6, */ { 12, 20 }, /* 100: 2, 5, 6, */ { 6, 24 }, /* 101: 0, 2, 5, 6, */ { 12, 13 }, /* 102: 1, 2, 5, 6, */ { 10, 1 }, /* 103: 0, 1, 2, 5, 6, */ { 6, 19 }, /* 104: 3, 5, 6, */ { 7, 9 }, /* 105: 0, 3, 5, 6, */ { 13, 1 }, /* 106: 1, 3, 5, 6, */ { 12, 9 }, /* 107: 0, 1, 3, 5, 6, */ { 7, 7 }, /* 108: 2, 3, 5, 6, */ { 12, 2 }, /* 109: 0, 2, 3, 5, 6, */ { 7, 5 }, /* 110: 1, 2, 3, 5, 6, */ { 6, 6 }, /* 111: 0, 1, 2, 3, 5, 6, */ { 3, 10 }, /* 112: 4, 5, 6, */ { 5, 26 }, /* 113: 0, 4, 5, 6, */ { 9, 4 }, /* 114: 1, 4, 5, 6, */ { 11, 3 }, /* 115: 0, 1, 4, 5, 6, */ { 5, 14 }, /* 116: 2, 4, 5, 6, */ { 14, 0 }, /* 117: 0, 2, 4, 5, 6, */ { 5, 11 }, /* 118: 1, 2, 4, 5, 6, */ { 6, 3 }, /* 119: 0, 1, 2, 4, 5, 6, */ { 2, 6 }, /* 120: 3, 4, 5, 6, */ { 12, 1 }, /* 121: 0, 3, 4, 5, 6, */ { 7, 4 }, /* 122: 1, 3, 4, 5, 6, */ { 6, 5 }, /* 123: 0, 1, 3, 4, 5, 6, */ { 3, 9 }, /* 124: 2, 3, 4, 5, 6, */ { 6, 0 }, /* 125: 0, 2, 3, 4, 5, 6, */ { 3, 5 }, /* 126: 1, 2, 3, 4, 5, 6, */ { 4, 0 }, /* 127: 0, 1, 2, 3, 4, 5, 6, */ { 1, 6 }, /* 128: 7 */ { 1, 9 }, /* 129: 0, 7 */ { 4, 7 }, /* 130: 1, 7 */ { 3, 18 }, /* 131: 0, 1, 7 */ { 6, 47 }, /* 132: 2, 7 */ { 3, 14 }, /* 133: 0, 2, 7 */ { 6, 42 }, /* 134: 1, 2, 7 */ { 7, 11 }, /* 135: 0, 1, 2, 7 */ { 12, 22 }, /* 136: 3, 7 */ { 2, 17 }, /* 137: 0, 3, 7 */ { 6, 44 }, /* 138: 1, 3, 7 */ { 5, 36 }, /* 139: 0, 1, 3, 7 */ { 14, 11 }, /* 140: 2, 3, 7 */ { 5, 33 }, /* 141: 0, 2, 3, 7 */ { 11, 8 }, /* 142: 1, 2, 3, 7 */ { 9, 3 }, /* 143: 0, 1, 2, 3, 7 */ { 5, 21 }, /* 144: 4, 7 */ { 3, 13 }, /* 145: 0, 4, 7 */ { 6, 41 }, /* 146: 1, 4, 7 */ { 7, 10 }, /* 147: 0, 1, 4, 7 */ { 12, 21 }, /* 148: 2, 4, 7 */ { 7, 8 }, /* 149: 0, 2, 4, 7 */ { 12, 14 }, /* 150: 1, 2, 4, 7 */ { 13, 0 }, /* 151: 0, 1, 2, 4, 7 */ { 7, 6 }, /* 152: 3, 4, 7 */ { 6, 28 }, /* 153: 0, 3, 4, 7 */ { 10, 4 }, /* 154: 1, 3, 4, 7 */ { 12, 10 }, /* 155: 0, 1, 3, 4, 7 */ { 6, 23 }, /* 156: 2, 3, 4, 7 */ { 12, 3 }, /* 157: 0, 2, 3, 4, 7 */ { 6, 14 }, /* 158: 1, 2, 3, 4, 7 */ { 7, 2 }, /* 159: 0, 1, 2, 3, 4, 7 */ { 3, 11 }, /* 160: 5, 7 */ { 2, 13 }, /* 161: 0, 5, 7 */ { 6, 40 }, /* 162: 1, 5, 7 */ { 5, 34 }, /* 163: 0, 1, 5, 7 */ { 11, 9 }, /* 164: 2, 5, 7 */ { 6, 25 }, /* 165: 0, 2, 5, 7 */ { 10, 3 }, /* 166: 1, 2, 5, 7 */ { 12, 6 }, /* 167: 0, 1, 2, 5, 7 */ { 6, 20 }, /* 168: 3, 5, 7 */ { 5, 31 }, /* 169: 0, 3, 5, 7 */ { 12, 16 }, /* 170: 1, 3, 5, 7 */ { 8, 2 }, /* 171: 0, 1, 3, 5, 7 */ { 5, 18 }, /* 172: 2, 3, 5, 7 */ { 14, 2 }, /* 173: 0, 2, 3, 5, 7 */ { 6, 13 }, /* 174: 1, 2, 3, 5, 7 */ { 5, 8 }, /* 175: 0, 1, 2, 3, 5, 7 */ { 2, 9 }, /* 176: 4, 5, 7 */ { 5, 27 }, /* 177: 0, 4, 5, 7 */ { 14, 6 }, /* 178: 1, 4, 5, 7 */ { 9, 2 }, /* 179: 0, 1, 4, 5, 7 */ { 5, 15 }, /* 180: 2, 4, 5, 7 */ { 12, 0 }, /* 181: 0, 2, 4, 5, 7 */ { 6, 10 }, /* 182: 1, 2, 4, 5, 7 */ { 7, 1 }, /* 183: 0, 1, 2, 4, 5, 7 */ { 3, 7 }, /* 184: 3, 4, 5, 7 */ { 11, 1 }, /* 185: 0, 3, 4, 5, 7 */ { 6, 12 }, /* 186: 1, 3, 4, 5, 7 */ { 5, 6 }, /* 187: 0, 1, 3, 4, 5, 7 */ { 2, 7 }, /* 188: 2, 3, 4, 5, 7 */ { 6, 1 }, /* 189: 0, 2, 3, 4, 5, 7 */ { 4, 1 }, /* 190: 1, 2, 3, 4, 5, 7 */ { 3, 2 }, /* 191: 0, 1, 2, 3, 4, 5, 7 */ { 1, 7 }, /* 192: 6, 7 */ { 2, 12 }, /* 193: 0, 6, 7 */ { 6, 39 }, /* 194: 1, 6, 7 */ { 6, 32 }, /* 195: 0, 1, 6, 7 */ { 10, 5 }, /* 196: 2, 6, 7 */ { 5, 28 }, /* 197: 0, 2, 6, 7 */ { 14, 7 }, /* 198: 1, 2, 6, 7 */ { 12, 5 }, /* 199: 0, 1, 2, 6, 7 */ { 6, 18 }, /* 200: 3, 6, 7 */ { 5, 30 }, /* 201: 0, 3, 6, 7 */ { 12, 15 }, /* 202: 1, 3, 6, 7 */ { 11, 4 }, /* 203: 0, 1, 3, 6, 7 */ { 6, 21 }, /* 204: 2, 3, 6, 7 */ { 8, 1 }, /* 205: 0, 2, 3, 6, 7 */ { 5, 12 }, /* 206: 1, 2, 3, 6, 7 */ { 5, 7 }, /* 207: 0, 1, 2, 3, 6, 7 */ { 2, 8 }, /* 208: 4, 6, 7 */ { 5, 25 }, /* 209: 0, 4, 6, 7 */ { 11, 6 }, /* 210: 1, 4, 6, 7 */ { 12, 4 }, /* 211: 0, 1, 4, 6, 7 */ { 6, 17 }, /* 212: 2, 4, 6, 7 */ { 9, 0 }, /* 213: 0, 2, 4, 6, 7 */ { 5, 10 }, /* 214: 1, 2, 4, 6, 7 */ { 7, 0 }, /* 215: 0, 1, 2, 4, 6, 7 */ { 3, 6 }, /* 216: 3, 4, 6, 7 */ { 14, 1 }, /* 217: 0, 3, 4, 6, 7 */ { 6, 11 }, /* 218: 1, 3, 4, 6, 7 */ { 6, 4 }, /* 219: 0, 1, 3, 4, 6, 7 */ { 4, 3 }, /* 220: 2, 3, 4, 6, 7 */ { 5, 3 }, /* 221: 0, 2, 3, 4, 6, 7 */ { 2, 4 }, /* 222: 1, 2, 3, 4, 6, 7 */ { 3, 1 }, /* 223: 0, 1, 2, 3, 4, 6, 7 */ { 1, 5 }, /* 224: 5, 6, 7 */ { 5, 24 }, /* 225: 0, 5, 6, 7 */ { 12, 12 }, /* 226: 1, 5, 6, 7 */ { 14, 3 }, /* 227: 0, 1, 5, 6, 7 */ { 6, 16 }, /* 228: 2, 5, 6, 7 */ { 11, 0 }, /* 229: 0, 2, 5, 6, 7 */ { 6, 9 }, /* 230: 1, 2, 5, 6, 7 */ { 6, 2 }, /* 231: 0, 1, 2, 5, 6, 7 */ { 4, 2 }, /* 232: 3, 5, 6, 7 */ { 9, 1 }, /* 233: 0, 3, 5, 6, 7 */ { 7, 3 }, /* 234: 1, 3, 5, 6, 7 */ { 5, 5 }, /* 235: 0, 1, 3, 5, 6, 7 */ { 3, 8 }, /* 236: 2, 3, 5, 6, 7 */ { 5, 2 }, /* 237: 0, 2, 3, 5, 6, 7 */ { 3, 4 }, /* 238: 1, 2, 3, 5, 6, 7 */ { 2, 2 }, /* 239: 0, 1, 2, 3, 5, 6, 7 */ { 1, 4 }, /* 240: 4, 5, 6, 7 */ { 8, 0 }, /* 241: 0, 4, 5, 6, 7 */ { 5, 9 }, /* 242: 1, 4, 5, 6, 7 */ { 5, 4 }, /* 243: 0, 1, 4, 5, 6, 7 */ { 2, 5 }, /* 244: 2, 4, 5, 6, 7 */ { 5, 0 }, /* 245: 0, 2, 4, 5, 6, 7 */ { 2, 3 }, /* 246: 1, 2, 4, 5, 6, 7 */ { 3, 0 }, /* 247: 0, 1, 2, 4, 5, 6, 7 */ { 1, 2 }, /* 248: 3, 4, 5, 6, 7 */ { 5, 1 }, /* 249: 0, 3, 4, 5, 6, 7 */ { 3, 3 }, /* 250: 1, 3, 4, 5, 6, 7 */ { 2, 1 }, /* 251: 0, 1, 3, 4, 5, 6, 7 */ { 1, 3 }, /* 252: 2, 3, 4, 5, 6, 7 */ { 2, 0 }, /* 253: 0, 2, 3, 4, 5, 6, 7 */ { 1, 1 }, /* 254: 1, 2, 3, 4, 5, 6, 7 */ { 1, 0 }, /* 255: 0, 1, 2, 3, 4, 5, 6, 7 */ { 0, -1 } }; /** * Triangle table for unique cube case 1. No ambiguity. */ static const char triangles1[16][3] = { { 0, 2, 1 }, { 0, 3, 4 }, { 3, 5, 7 }, { 1, 6, 5 }, { 8, 9, 2 }, { 4, 10, 8 }, { 7, 11, 10 }, { 9, 11, 6 }, { 9, 6, 11 }, { 7, 10, 11 }, { 4, 8, 10 }, { 8, 2, 9 }, { 1, 5, 6 }, { 3, 7, 5 }, { 0, 4, 3 }, { 0, 1, 2 } }; /** * Triangle table for unique cube case 2. No ambiguity. */ static const char triangles2[24][6] = { { 3, 2, 1, 4, 2, 3 }, { 0, 6, 5, 2, 6, 0 }, { 8, 1, 0, 9, 1, 8 }, { 4, 5, 7, 0, 5, 4 }, { 0, 10, 8, 3, 10, 0 }, { 1, 7, 3, 6, 7, 1 }, { 3, 11, 10, 5, 11, 3 }, { 9, 5, 1, 11, 5, 9 }, { 4, 9, 2, 10, 9, 4 }, { 11, 2, 8, 6, 2, 11 }, { 7, 8, 4, 11, 8, 7 }, { 6, 10, 7, 9, 10, 6 }, { 6, 7, 10, 9, 6, 10 }, { 7, 4, 8, 11, 7, 8 }, { 11, 8, 2, 6, 11, 2 }, { 4, 2, 9, 10, 4, 9 }, { 9, 1, 5, 11, 9, 5 }, { 3, 10, 11, 5, 3, 11 }, { 1, 3, 7, 6, 1, 7 }, { 0, 8, 10, 3, 0, 10 }, { 4, 7, 5, 0, 4, 5 }, { 8, 0, 1, 9, 8, 1 }, { 0, 5, 6, 2, 0, 6 }, { 3, 1, 2, 4, 3, 2 } }; /** * Test and triangle tables for ambiguous unique cube case 3. * 1 face test. * * The triangle tables in order of the following test outcomes: * -test on the specified face is negative * -test on the specified face is positive */ static const char test3[24] = { 5, 1, 4, 5, 1, 2, 2, 3, 4, 3, 6, 6, -6, -6, -3, -4, -3, -2, -2, -1, -5, -4, -1, -5 }; static const char triangles3_1[24][6] = { { 0, 2, 1, 3, 5, 7 }, { 4, 10, 8, 0, 2, 1 }, { 1, 0, 2, 6, 9, 11 }, { 3, 4, 0, 5, 1, 6 }, { 0, 3, 4, 2, 8, 9 }, { 4, 0, 3, 10, 7, 11 }, { 3, 5, 7, 4, 10, 8 }, { 7, 3, 5, 11, 6, 9 }, { 2, 8, 9, 1, 6, 5 }, { 5, 1, 6, 7, 11, 10 }, { 10, 7, 11, 8, 9, 2 }, { 8, 4, 10, 9, 11, 6 }, { 10, 4, 8, 6, 11, 9 }, { 11, 7, 10, 2, 9, 8 }, { 6, 1, 5, 10, 11, 7 }, { 9, 8, 2, 5, 6, 1 }, { 5, 3, 7, 9, 6, 11 }, { 7, 5, 3, 8, 10, 4 }, { 3, 0, 4, 11, 7, 10 }, { 4, 3, 0, 9, 8, 2 }, { 0, 4, 3, 6, 1, 5 }, { 2, 0, 1, 11, 9, 6 }, { 8, 10, 4, 1, 2, 0 }, { 1, 2, 0, 7, 5, 3 } }; static const char triangles3_2[24][12] = { { 7, 1, 5, 7, 2, 1, 7, 3, 0, 2, 7, 0 }, { 1, 8, 2, 1, 10, 8, 1, 0, 4, 10, 1, 4 }, { 11, 2, 9, 11, 0, 2, 11, 6, 1, 0, 11, 1 }, { 6, 0, 1, 6, 4, 0, 6, 5, 3, 4, 6, 3 }, { 9, 4, 8, 9, 3, 4, 9, 2, 0, 3, 9, 0 }, { 11, 3, 7, 11, 0, 3, 4, 0, 11, 4, 11, 10 }, { 8, 7, 10, 8, 5, 7, 8, 4, 3, 5, 8, 3 }, { 9, 5, 6, 9, 3, 5, 9, 11, 7, 3, 9, 7 }, { 5, 9, 6, 5, 8, 9, 5, 1, 2, 8, 5, 2 }, { 10, 6, 11, 10, 1, 6, 10, 7, 5, 1, 10, 5 }, { 2, 11, 9, 2, 7, 11, 2, 8, 10, 7, 2, 10 }, { 6, 10, 11, 6, 4, 10, 6, 9, 8, 4, 6, 8 }, { 11, 10, 6, 10, 4, 6, 8, 9, 6, 8, 6, 4 }, { 9, 11, 2, 11, 7, 2, 10, 8, 2, 10, 2, 7 }, { 11, 6, 10, 6, 1, 10, 5, 7, 10, 5, 10, 1 }, { 6, 9, 5, 9, 8, 5, 2, 1, 5, 2, 5, 8 }, { 6, 5, 9, 5, 3, 9, 7, 11, 9, 7, 9, 3 }, { 10, 7, 8, 7, 5, 8, 3, 4, 8, 3, 8, 5 }, { 7, 3, 11, 3, 0, 11, 11, 0, 4, 10, 11, 4 }, { 8, 4, 9, 4, 3, 9, 0, 2, 9, 0, 9, 3 }, { 1, 0, 6, 0, 4, 6, 3, 5, 6, 3, 6, 4 }, { 9, 2, 11, 2, 0, 11, 1, 6, 11, 1, 11, 0 }, { 2, 8, 1, 8, 10, 1, 4, 0, 1, 4, 1, 10 }, { 5, 1, 7, 1, 2, 7, 0, 3, 7, 0, 7, 2 } }; /** * Test and triangle tables for ambiguous unique cube case 4. * Interior test, no reference edge required. * * The triangle tables in order of the following test outcomes: * -test on the interior is negative * -test on the interior is positive */ static const char test4[8] = { 7, 7, 7, 7, -7, -7, -7, -7 }; static const char triangles4_1[8][6] = { { 0, 2, 1, 10, 7, 11 }, { 0, 3, 4, 6, 9, 11 }, { 3, 5, 7, 2, 8, 9 }, { 4, 10, 8, 5, 1, 6 }, { 8, 10, 4, 6, 1, 5 }, { 7, 5, 3, 9, 8, 2 }, { 4, 3, 0, 11, 9, 6 }, { 1, 2, 0, 11, 7, 10 } }; static const char triangles4_2[8][18] = { { 2, 10, 0, 10, 2, 11, 1, 11, 2, 11, 1, 7, 0, 7, 1, 7, 0, 10 }, { 4, 11, 3, 11, 4, 9, 0, 9, 4, 9, 0, 6, 3, 6, 0, 6, 3, 11 }, { 7, 9, 5, 9, 7, 8, 3, 8, 7, 8, 3, 2, 5, 2, 3, 2, 5, 9 }, { 6, 8, 1, 8, 6, 10, 5, 10, 6, 10, 5, 4, 1, 4, 5, 4, 1, 8 }, { 1, 8, 6, 10, 6, 8, 6, 10, 5, 4, 5, 10, 5, 4, 1, 8, 1, 4 }, { 5, 9, 7, 8, 7, 9, 7, 8, 3, 2, 3, 8, 3, 2, 5, 9, 5, 2 }, { 3, 11, 4, 9, 4, 11, 4, 9, 0, 6, 0, 9, 0, 6, 3, 11, 3, 6 }, { 0, 10, 2, 11, 2, 10, 2, 11, 1, 7, 1, 11, 1, 7, 0, 10, 0, 7 } }; /** * Triangle table for unique cube case 5. No ambiguity. */ static const char triangles5[48][9] = { { 5, 2, 1, 5, 7, 2, 7, 4, 2 }, { 3, 6, 5, 3, 4, 6, 4, 2, 6 }, { 8, 3,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4, 11, 0, 0, 11, 5 }, { 10, 7, 5, 10, 5, 8, 8, 5, 0 }, { 1, 0, 4, 1, 4, 6, 6, 4, 7 }, { 1, 6, 11, 1, 11, 0, 0, 11, 8 }, { 4, 0, 1, 4, 1, 10, 10, 1, 9 }, { 9, 2, 0, 9, 0, 11, 11, 0, 5 }, { 6, 9, 8, 6, 8, 5, 5, 8, 0 }, { 0, 3, 7, 0, 7, 2, 2, 7, 6 }, { 2, 8, 10, 2, 10, 1, 1, 10, 3 }, { 8, 4, 3, 8, 3, 9, 9, 3, 1 }, { 3, 5, 6, 3, 6, 4, 4, 6, 2 }, { 5, 1, 2, 5, 2, 7, 7, 2, 4 } }; /** * Test and triangle tables for ambiguous unique cube case 6. * 1 face test and possibly the interior requiring a reference edge. * * The triangle tables in order of the following test outcomes: * -test on the specified face is negative : * -test on the interior is negative * -test on the interior is positive * -test on the specified face is positive */ static const char test6[48][3] = { { 2, 7, 7 }, { 4, 7, 6 }, { 5, 7, 3 }, { 5, 7, 1 }, { 1, 7, 4 }, { 3, 7, 7 }, { 6, 7, 10 }, { 1, 7, 2 }, { 4, 7, 2 }, { 1, 7, 2 }, { 3, 7, 6 }, { 5, 7, 5 }, { 5, 7, 0 }, { 1, 7, 4 }, { 6, 7, 11 }, { 2, 7, 4 }, { 4, 7, 2 }, { 2, 7, 4 }, { 2, 7, 7 }, { 6, 7, 9 }, { 3, 7, 7 }, { 4, 7, 6 }, { 3, 7, 6 }, { 6, 7, 8 }, { -6, -7, 8 }, { -3, -7, 6 }, { -4, -7, 6 }, { -3, -7, 7 }, { -6, -7, 9 }, { -2, -7, 7 }, { -2, -7, 4 }, { -4, -7, 2 }, { -2, -7, 4 }, { -6, -7, 11 }, { -1, -7, 4 }, { -5, -7, 0 }, { -5, -7, 5 }, { -3, -7, 6 }, { -1, -7, 2 }, { -4, -7, 2 }, { -1, -7, 2 }, { -6, -7, 10 }, { -3, -7, 7 }, { -1, -7, 4 }, { -5, -7, 1 }, { -5, -7, 3 }, { -4, -7, 6 }, { -2, -7, 7 } }; static const char triangles6_1_1[48][9] = { { 11, 10, 7, 1, 3, 2, 4, 2, 3 }, { 6, 9, 11, 4, 1, 3, 1, 4, 2 }, { 3, 5, 7, 9, 0, 8, 0, 9, 1 }, { 1, 0, 2, 10, 5, 11, 5, 10, 3 }, { 10, 8, 4, 5, 0, 6, 2, 6, 0 }, { 7, 11, 10, 2, 5, 0, 5, 2, 6 }, { 7, 11, 10, 0, 8, 1, 9, 1, 8 }, { 1, 0, 2, 11, 8, 7, 4, 7, 8 }, { 2, 1, 0, 7, 9, 10, 9, 7, 6 }, { 2, 8, 9, 7, 0, 5, 0, 7, 4 }, { 9, 11, 6, 0, 5, 4, 7, 4, 5 }, { 5, 1, 6, 8, 3, 10, 3, 8, 0 }, { 0, 3, 4, 11, 1, 9, 1, 11, 5 }, { 4, 0, 3, 6, 8, 11, 8, 6, 2 }, { 6, 9, 11, 3, 10, 0, 8, 0, 10 }, { 0, 3, 4, 9, 10, 6, 7, 6, 10 }, { 8, 9, 2, 3, 1, 7, 6, 7, 1 }, { 4, 10, 8, 6, 3, 1, 3, 6, 7 }, { 7, 3, 5, 2, 10, 9, 10, 2, 4 }, { 2, 8, 9, 5, 11, 3, 10, 3, 11 }, { 3, 5, 7, 8, 11, 2, 6, 2, 11 }, { 5, 1, 6, 10, 9, 4, 2, 4, 9 }, { 6, 5, 1, 4, 11, 8, 11, 4, 7 }, { 4, 10, 8, 1, 9, 5, 11, 5, 9 }, { 8, 10, 4, 5, 9, 1, 9, 5, 11 }, { 1, 5, 6, 8, 11, 4, 7, 4, 11 }, { 6, 1, 5, 4, 9, 10, 9, 4, 2 }, { 7, 5, 3, 2, 11, 8, 11, 2, 6 }, { 9, 8, 2, 3, 11, 5, 11, 3, 10 }, { 5, 3, 7, 9, 10, 2, 4, 2, 10 }, { 8, 10, 4, 1, 3, 6, 7, 6, 3 }, { 2, 9, 8, 7, 1, 3, 1, 7, 6 }, { 4, 3, 0, 6, 10, 9, 10, 6, 7 }, { 11, 9, 6, 0, 10, 3, 10, 0, 8 }, { 3, 0, 4, 11, 8, 6, 2, 6, 8 }, { 4, 3, 0, 9, 1, 11, 5, 11, 1 }, { 6, 1, 5, 10, 3, 8, 0, 8, 3 }, { 6, 11, 9, 4, 5, 0, 5, 4, 7 }, { 9, 8, 2, 5, 0, 7, 4, 7, 0 }, { 0, 1, 2, 10, 9, 7, 6, 7, 9 }, { 2, 0, 1, 7, 8, 11, 8, 7, 4 }, { 10, 11, 7, 1, 8, 0, 8, 1, 9 }, { 10, 11, 7, 0, 5, 2, 6, 2, 5 }, { 4, 8, 10, 6, 0, 5, 0, 6, 2 }, { 2, 0, 1, 11, 5, 10, 3, 10, 5 }, { 7, 5, 3, 8, 0, 9, 1, 9, 0 }, { 11, 9, 6, 3, 1, 4, 2, 4, 1 }, { 7, 10, 11, 2, 3, 1, 3, 2, 4 } }; static const char triangles6_1_2[48][27] = { { 3, 12, 1, 12, 7, 1, 11, 1, 7, 1, 11, 2, 10, 2, 11, 2, 10, 12, 12, 4, 2, 3, 4, 12, 12, 10, 7 }, { 3, 12, 1, 3, 6, 12, 6, 3, 11, 4, 11, 3, 11, 4, 9, 12, 9, 4, 4, 2, 12, 12, 2, 1, 6, 9, 12 }, { 8, 12, 0, 8, 3, 12, 3, 8, 7, 9, 7, 8, 7, 9, 5, 12, 5, 9, 9, 1, 12, 12, 1, 0, 3, 5, 12 }, { 11, 12, 5, 11, 1, 12, 1, 11, 2, 10, 2, 11, 2, 10, 0, 12, 0, 10, 10, 3, 12, 12, 3, 5, 1, 0, 12 }, { 0, 12, 5, 12, 4, 5, 10, 5, 4, 5, 10, 6, 8, 6, 10, 6, 8, 12, 12, 2, 6, 0, 2, 12, 12, 8, 4 }, { 0, 12, 5, 0, 7, 12, 7, 0, 10, 2, 10, 0, 10, 2, 11, 12, 11, 2, 2, 6, 12, 12, 6, 5, 7, 11, 12 }, { 8, 12, 0, 12, 10, 0, 7, 0, 10, 0, 7, 1, 11, 1, 7, 1, 11, 12, 12, 9, 1, 8, 9, 12, 12, 11, 10 }, { 8, 12, 11, 12, 2, 11, 1, 11, 2, 11, 1, 7, 0, 7, 1, 7, 0, 12, 12, 4, 7, 8, 4, 12, 12, 0, 2 }, { 10, 12, 9, 10, 2, 12, 2, 10, 0, 7, 0, 10, 0, 7, 1, 12, 1, 7, 7, 6, 12, 12, 6, 9, 2, 1, 12 }, { 5, 12, 0, 5, 2, 12, 2, 5, 9, 7, 9, 5, 9, 7, 8, 12, 8, 7, 7, 4, 12, 12, 4, 0, 2, 8, 12 }, { 5, 12, 0, 12, 6, 0, 9, 0, 6, 0, 9, 4, 11, 4, 9, 4, 11, 12, 12, 7, 4, 5, 7, 12, 12, 11, 6 }, { 10, 12, 3, 10, 5, 12, 5, 10, 6, 8, 6, 10, 6, 8, 1, 12, 1, 8, 8, 0, 12, 12, 0, 3, 5, 1, 12 }, { 9, 12, 1, 9, 0, 12, 0, 9, 4, 11, 4, 9, 4, 11, 3, 12, 3, 11, 11, 5, 12, 12, 5, 1, 0, 3, 12 }, { 11, 12, 8, 11, 4, 12, 4, 11, 3, 6, 3, 11, 3, 6, 0, 12, 0, 6, 6, 2, 12, 12, 2, 8, 4, 0, 12 }, { 10, 12, 3, 12, 11, 3, 6, 3, 11, 3, 6, 0, 9, 0, 6, 0, 9, 12, 12, 8, 0, 10, 8, 12, 12, 9, 11 }, { 10, 12, 9, 12, 4, 9, 0, 9, 4, 9, 0, 6, 3, 6, 0, 6, 3, 12, 12, 7, 6, 10, 7, 12, 12, 3, 4 }, { 1, 12, 3, 12, 2, 3, 8, 3, 2, 3, 8, 7, 9, 7, 8, 7, 9, 12, 12, 6, 7, 1, 6, 12, 12, 9, 2 }, { 1, 12, 3, 1, 4, 12, 4, 1, 8, 6, 8, 1, 8, 6, 10, 12, 10, 6, 6, 7, 12, 12, 7, 3, 4, 10, 12 }, { 9, 12, 10, 9, 7, 12, 7, 9, 5, 2, 5, 9, 5, 2, 3, 12, 3, 2, 2, 4, 12, 12, 4, 10, 7, 3, 12 }, { 11, 12, 5, 12, 9, 5, 2, 5, 9, 5, 2, 3, 8, 3, 2, 3, 8, 12, 12, 10, 3, 11, 10, 12, 12, 8, 9 }, { 11, 12, 8, 12, 7, 8, 3, 8, 7, 8, 3, 2, 5, 2, 3, 2, 5, 12, 12, 6, 2, 11, 6, 12, 12, 5, 7 }, { 9, 12, 10, 12, 6, 10, 5, 10, 6, 10, 5, 4, 1, 4, 5, 4, 1, 12, 12, 2, 4, 9, 2, 12, 12, 1, 6 }, { 8, 12, 11, 8, 6, 12, 6, 8, 1, 4, 1, 8, 1, 4, 5, 12, 5, 4, 4, 7, 12, 12, 7, 11, 6, 5, 12 }, { 9, 12, 1, 12, 8, 1, 4, 1, 8, 1, 4, 5, 10, 5, 4, 5, 10, 12, 12, 11, 5, 9, 11, 12, 12, 10, 8 }, { 1, 12, 9, 1, 8, 12, 8, 1, 4, 5, 4, 1, 4, 5, 10, 12, 10, 5, 5, 11, 12, 12, 11, 9, 8, 10, 12 }, { 11, 12, 8, 12, 6, 8, 1, 8, 6, 8, 1, 4, 5, 4, 1, 4, 5, 12, 12, 7, 4, 11, 7, 12, 12, 5, 6 }, { 10, 12, 9, 10, 6, 12, 6, 10, 5, 4, 5, 10, 5, 4, 1, 12, 1, 4, 4, 2, 12, 12, 2, 9, 6, 1, 12 }, { 8, 12, 11, 8, 7, 12, 7, 8, 3, 2, 3, 8, 3, 2, 5, 12, 5, 2, 2, 6, 12, 12, 6, 11, 7, 5, 12 }, { 5, 12, 11, 5, 9, 12, 9, 5, 2, 3, 2, 5, 2, 3, 8, 12, 8, 3, 3, 10, 12, 12, 10, 11, 9, 8, 12 }, { 10, 12, 9, 12, 7, 9, 5, 9, 7, 9, 5, 2, 3, 2, 5, 2, 3, 12, 12, 4, 2, 10, 4, 12, 12, 3, 7 }, { 3, 12, 1, 12, 4, 1, 8, 1, 4, 1, 8, 6, 10, 6, 8, 6, 10, 12, 12, 7, 6, 3, 7, 12, 12, 10, 4 }, { 3, 12, 1, 3, 2, 12, 2, 3, 8, 7, 8, 3, 8, 7, 9, 12, 9, 7, 7, 6, 12, 12, 6, 1, 2, 9, 12 }, { 9, 12, 10, 9, 4, 12, 4, 9, 0, 6, 0, 9, 0, 6, 3, 12, 3, 6, 6, 7, 12, 12, 7, 10, 4, 3, 12 }, { 3, 12, 10, 3, 11, 12, 11, 3, 6, 0, 6, 3, 6, 0, 9, 12, 9, 0, 0, 8, 12, 12, 8, 10, 11, 9, 12 }, { 8, 12, 11, 12, 4, 11, 3, 11, 4, 11, 3, 6, 0, 6, 3, 6, 0, 12, 12, 2, 6, 8, 2, 12, 12, 0, 4 }, { 1, 12, 9, 12, 0, 9, 4, 9, 0, 9, 4, 11, 3, 11, 4, 11, 3, 12, 12, 5, 11, 1, 5, 12, 12, 3, 0 }, { 3, 12, 10, 12, 5, 10, 6, 10, 5, 10, 6, 8, 1, 8, 6, 8, 1, 12, 12, 0, 8, 3, 0, 12, 12, 1, 5 }, { 0, 12, 5, 0, 6, 12, 6, 0, 9, 4, 9, 0, 9, 4, 11, 12, 11, 4, 4, 7, 12, 12, 7, 5, 6, 11, 12 }, { 0, 12, 5, 12, 2, 5, 9, 5, 2, 5, 9, 7, 8, 7, 9, 7, 8, 12, 12, 4, 7, 0, 4, 12, 12, 8, 2 }, { 9, 12, 10, 12, 2, 10, 0, 10, 2, 10, 0, 7, 1, 7, 0, 7, 1, 12, 12, 6, 7, 9, 6, 12, 12, 1, 2 }, { 11, 12, 8, 11, 2, 12, 2, 11, 1, 7, 1, 11, 1, 7, 0, 12, 0, 7, 7, 4, 12, 12, 4, 8, 2, 0, 12 }, { 0, 12, 8, 0, 10, 12, 10, 0, 7, 1, 7, 0, 7, 1, 11, 12, 11, 1, 1, 9, 12, 12, 9, 8, 10, 11, 12 }, { 5, 12, 0, 12, 7, 0, 10, 0, 7, 0, 10, 2, 11, 2, 10, 2, 11, 12, 12, 6, 2, 5, 6, 12, 12, 11, 7 }, { 5, 12, 0, 5, 4, 12, 4, 5, 10, 6, 10, 5, 10, 6, 8, 12, 8, 6, 6, 2, 12, 12, 2, 0, 4, 8, 12 }, { 5, 12, 11, 12, 1, 11, 2, 11, 1, 11, 2, 10, 0, 10, 2, 10, 0, 12, 12, 3, 10, 5, 3, 12, 12, 0, 1 }, { 0, 12, 8, 12, 3, 8, 7, 8, 3, 8, 7, 9, 5, 9, 7, 9, 5, 12, 12, 1, 9, 0, 1, 12, 12, 5, 3 }, { 1, 12, 3, 12, 6, 3, 11, 3, 6, 3, 11, 4, 9, 4, 11, 4, 9, 12, 12, 2, 4, 1, 2, 12, 12, 9, 6 }, { 1, 12, 3, 1, 7, 12, 7, 1, 11, 2, 11, 1, 11, 2, 10, 12, 10, 2, 2, 4, 12, 12, 4, 3, 7, 10, 12 }, }; static const char triangles6_2[48][15] = { { 3, 7, 1, 11, 1, 7, 1, 11, 2, 10, 2, 11, 2, 10, 4 }, { 3, 6, 1, 6, 3, 11, 4, 11, 3, 11, 4, 9, 2, 9, 4 }, { 8, 3, 0, 3, 8, 7, 9, 7, 8, 7, 9, 5, 1, 5, 9 }, { 11, 1, 5, 1, 11, 2, 10, 2, 11, 2, 10, 0, 3, 0, 10 }, { 0, 4, 5, 10, 5, 4, 5, 10, 6, 8, 6, 10, 6, 8, 2 }, { 0, 7, 5, 7, 0, 10, 2, 10, 0, 10, 2, 11, 6, 11, 2 }, { 8, 10, 0, 7, 0, 10, 0, 7, 1, 11, 1, 7, 1, 11, 9 }, { 8, 2, 11, 1, 11, 2, 11, 1, 7, 0, 7, 1, 7, 0, 4 }, { 10, 2, 9, 2, 10, 0, 7, 0, 10, 0, 7, 1, 6, 1, 7 }, { 5, 2, 0, 2, 5, 9, 7, 9, 5, 9, 7, 8, 4, 8, 7 }, { 5, 6, 0, 9, 0, 6, 0, 9, 4, 11, 4, 9, 4, 11, 7 }, { 10, 5, 3, 5, 10, 6, 8, 6, 10, 6, 8, 1, 0, 1, 8 }, { 9, 0, 1, 0, 9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 0, 9, 8, 9, 0 }, { 8, 4, 11, 3, 11, 4, 11, 3, 6, 0, 6, 3, 6, 0, 2 }, { 1, 0, 9, 4, 9, 0, 9, 4, 11, 3, 11, 4, 11, 3, 5 }, { 3, 5, 10, 6, 10, 5, 10, 6, 8, 1, 8, 6, 8, 1, 0 }, { 0, 6, 5, 6, 0, 9, 4, 9, 0, 9, 4, 11, 7, 11, 4 }, { 0, 2, 5, 9, 5, 2, 5, 9, 7, 8, 7, 9, 7, 8, 4 }, { 9, 2, 10, 0, 10, 2, 10, 0, 7, 1, 7, 0, 7, 1, 6 }, { 11, 2, 8, 2, 11, 1, 7, 1, 11, 1, 7, 0, 4, 0, 7 }, { 0, 10, 8, 10, 0, 7, 1, 7, 0, 7, 1, 11, 9, 11, 1 }, { 5, 7, 0, 10, 0, 7, 0, 10, 2, 11, 2, 10, 2, 11, 6 }, { 5, 4, 0, 4, 5, 10, 6, 10, 5, 10, 6, 8, 2, 8, 6 }, { 5, 1, 11, 2, 11, 1, 11, 2, 10, 0, 10, 2, 10, 0, 3 }, { 0, 3, 8, 7, 8, 3, 8, 7, 9, 5, 9, 7, 9, 5, 1 }, { 1, 6, 3, 11, 3, 6, 3, 11, 4, 9, 4, 11, 4, 9, 2 }, { 1, 7, 3, 7, 1, 11, 2, 11, 1, 11, 2, 10, 4, 10, 2 } }; /** * Test and triangle tables for ambiguous unique cube case 7. * 3 face tests and possibly the interior requiring a reference edge. * * The triangle tables in order of the following test outcomes: * -tests on the 3 specified faces are negative * -test on the first specified face is positive * -test on the second specified face is positive * -tests on the first and the second specified faces are positive * -test on the third specified face is positive * -tests on the first and the third specified faces are positive * -tests on the second and the third specified faces are positive * -tests on the 3 specified faces are positive : * -test on the interior is positive * -test on the interior is negative */ static const char test7[16][5] = { { 1, 2, 5, 7, 3 }, { 3, 4, 5, 7, 1 }, { 4, 1, 6, 7, 8 }, { 4, 1, 5, 7, 0 }, { 2, 3, 5, 7, 5 }, { 1, 2, 6, 7, 10 }, { 2, 3, 6, 7, 11 }, { 3, 4, 6, 7, 9 }, { -3, -4, -6, -7, 9 }, { -2, -3, -6, -7, 11 }, { -1, -2, -6, -7, 10 }, { -2, -3, -5, -7, 5 }, { -4, -1, -5, -7, 0 }, { -4, -1, -6, -7, 8 }, { -3, -4, -5, -7, 1 }, { -1, -2, -5, -7, 3 } }; static const char triangles7_1[16][9] = { { 4, 10, 8, 7, 3, 5, 2, 1, 0 }, { 6, 9, 11, 2, 1, 0, 7, 3, 5 }, { 1, 0, 2, 10, 8, 4, 9, 11, 6 }, { 2, 8, 9, 4, 0, 3, 6, 5, 1 }, { 7, 11, 10, 6, 5, 1, 4, 0, 3 }, { 0, 3, 4, 11, 10, 7, 8, 9, 2 }, { 3, 5, 7, 9, 11, 6, 10, 8, 4 }, { 5, 1, 6, 8, 9, 2, 11, 10, 7 }, { 6, 1, 5, 2, 9, 8, 7, 10, 11 }, { 7, 5, 3, 6, 11, 9, 4, 8, 10 }, { 4, 3, 0, 7, 10, 11, 2, 9, 8 }, { 10, 11, 7, 1, 5, 6, 3, 0, 4 }, { 9, 8, 2, 3, 0, 4, 1, 5, 6 }, { 2, 0, 1, 4, 8, 10, 6, 11, 9 }, { 11, 9, 6, 0, 1, 2, 5, 3, 7 }, { 8, 10, 4, 5, 3, 7, 0, 1, 2 } }; static const char triangles7_2[16][3][15] = { { { 3, 5, 7, 1, 8, 2, 8, 1, 10, 0, 10, 1, 10, 0, 4 }, { 1, 0, 2, 4, 3, 8, 5, 8, 3, 8, 5, 10, 7, 10, 5 }, { 4, 10, 8, 0, 7, 3, 7, 0, 2, 7, 2, 5, 1, 5, 2 } }, { { 1, 0, 2, 3, 11, 7, 11, 3, 9, 5, 9, 3, 9, 5, 6 }, { 3, 5, 7, 6, 1, 11, 0, 11, 1, 11, 0, 9, 2, 9, 0 }, { 6, 9, 11, 5, 2, 1, 2, 5, 7, 2, 7, 0, 3, 0, 7 } }, { { 4, 10, 8, 6, 1, 11, 0, 11, 1, 11, 0, 9, 2,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, 7 }, { 8, 10, 4, 7, 11, 3, 9, 3, 11, 3, 9, 5, 6, 5, 9 }, { 7, 5, 3, 10, 6, 11, 6, 10, 4, 6, 4, 9, 8, 9, 4 } }, { { 7, 10, 11, 9, 0, 2, 0, 9, 3, 8, 3, 9, 3, 8, 4 }, { 9, 8, 2, 4, 10, 0, 11, 0, 10, 0, 11, 3, 7, 3, 11 }, { 4, 3, 0, 8, 7, 10, 7, 8, 2, 7, 2, 11, 9, 11, 2 } }, { { 6, 1, 5, 4, 10, 0, 11, 0, 10, 0, 11, 3, 7, 3, 11 }, { 4, 3, 0, 10, 5, 7, 5, 10, 1, 11, 1, 10, 1, 11, 6 }, { 7, 10, 11, 5, 6, 3, 4, 3, 6, 1, 4, 6, 4, 1, 0 } }, { { 4, 3, 0, 6, 9, 5, 8, 5, 9, 5, 8, 1, 2, 1, 8 }, { 6, 1, 5, 9, 0, 2, 0, 9, 3, 8, 3, 9, 3, 8, 4 }, { 9, 8, 2, 0, 4, 1, 6, 1, 4, 3, 6, 4, 6, 3, 5 } }, { { 8, 10, 4, 11, 1, 6, 1, 11, 0, 9, 0, 11, 0, 9, 2 }, { 11, 9, 6, 2, 8, 1, 10, 1, 8, 1, 10, 0, 4, 0, 10 }, { 2, 0, 1, 9, 4, 8, 4, 9, 6, 4, 6, 10, 11, 10, 6 } }, { { 2, 0, 1, 7, 11, 3, 9, 3, 11, 3, 9, 5, 6, 5, 9 }, { 7, 5, 3, 11, 1, 6, 1, 11, 0, 9, 0, 11, 0, 9, 2 }, { 11, 9, 6, 1, 2, 5, 7, 5, 2, 0, 7, 2, 7, 0, 3 } }, { { 7, 5, 3, 2, 8, 1, 10, 1, 8, 1, 10, 0, 4, 0, 10 }, { 2, 0, 1, 8, 3, 4, 3, 8, 5, 10, 5, 8, 5, 10, 7 }, { 8, 10, 4, 3, 7, 0, 2, 0, 7, 5, 2, 7, 2, 5, 1 } } }; static const char triangles7_3[16][3][27] = { { { 12, 5, 7, 12, 7, 10, 12, 10, 8, 12, 8, 2, 12, 2, 1, 12, 1, 0, 12, 0, 4, 12, 4, 3, 12, 3, 5 }, { 12, 10, 8, 12, 8, 2, 12, 2, 1, 12, 1, 5, 12, 5, 7, 12, 7, 3, 12, 3, 0, 12, 0, 4, 12, 4, 10 }, { 10, 8, 12, 7, 10, 12, 5, 7, 12, 1, 5, 12, 2, 1, 12, 0, 2, 12, 3, 0, 12, 4, 3, 12, 8, 4, 12 } }, { { 12, 0, 2, 12, 2, 9, 12, 9, 11, 12, 11, 7, 12, 7, 3, 12, 3, 5, 12, 5, 6, 12, 6, 1, 12, 1, 0 }, { 12, 9, 11, 12, 11, 7, 12, 7, 3, 12, 3, 0, 12, 0, 2, 12, 2, 1, 12, 1, 5, 12, 5, 6, 12, 6, 9 }, { 9, 11, 12, 2, 9, 12, 0, 2, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 1, 5, 12, 6, 1, 12, 11, 6, 12 } }, { { 4, 10, 12, 0, 4, 12, 1, 0, 12, 6, 1, 12, 11, 6, 12, 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12 }, { 1, 0, 12, 6, 1, 12, 11, 6, 12, 10, 11, 12, 4, 10, 12, 8, 4, 12, 9, 8, 12, 2, 9, 12, 0, 2, 12 }, { 12, 1, 0, 12, 0, 4, 12, 4, 10, 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8, 12, 8, 2, 12, 2, 1 } }, { { 12, 3, 4, 12, 4, 8, 12, 8, 9, 12, 9, 6, 12, 6, 5, 12, 5, 1, 12, 1, 2, 12, 2, 0, 12, 0, 3 }, { 12, 8, 9, 12, 9, 6, 12, 6, 5, 12, 5, 3, 12, 3, 4, 12, 4, 0, 12, 0, 1, 12, 1, 2, 12, 2, 8 }, { 8, 9, 12, 4, 8, 12, 3, 4, 12, 5, 3, 12, 6, 5, 12, 1, 6, 12, 0, 1, 12, 2, 0, 12, 9, 2, 12 } }, { { 12, 1, 6, 12, 6, 11, 12, 11, 10, 12, 10, 4, 12, 4, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 1 }, { 12, 11, 10, 12, 10, 4, 12, 4, 0, 12, 0, 1, 12, 1, 6, 12, 6, 5, 12, 5, 3, 12, 3, 7, 12, 7, 11 }, { 11, 10, 12, 6, 11, 12, 1, 6, 12, 0, 1, 12, 4, 0, 12, 3, 4, 12, 5, 3, 12, 7, 5, 12, 10, 7, 12 } }, { { 7, 11, 12, 3, 7, 12, 0, 3, 12, 2, 0, 12, 9, 2, 12, 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12 }, { 0, 3, 12, 2, 0, 12, 9, 2, 12, 11, 9, 12, 7, 11, 12, 10, 7, 12, 8, 10, 12, 4, 8, 12, 3, 4, 12 }, { 12, 0, 3, 12, 3, 7, 12, 7, 11, 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10, 12, 10, 4, 12, 4, 0 } }, { { 6, 9, 12, 5, 6, 12, 3, 5, 12, 4, 3, 12, 8, 4, 12, 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12 }, { 3, 5, 12, 4, 3, 12, 8, 4, 12, 9, 8, 12, 6, 9, 12, 11, 6, 12, 10, 11, 12, 7, 10, 12, 5, 7, 12 }, { 12, 3, 5, 12, 5, 6, 12, 6, 9, 12, 9, 8, 12, 8, 4, 12, 4, 10, 12, 10, 11, 12, 11, 7, 12, 7, 3 } }, { { 2, 8, 12, 1, 2, 12, 5, 1, 12, 7, 5, 12, 10, 7, 12, 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12 }, { 5, 1, 12, 7, 5, 12, 10, 7, 12, 8, 10, 12, 2, 8, 12, 9, 2, 12, 11, 9, 12, 6, 11, 12, 1, 6, 12 }, { 12, 5, 1, 12, 1, 2, 12, 2, 8, 12, 8, 10, 12, 10, 7, 12, 7, 11, 12, 11, 9, 12, 9, 6, 12, 6, 5 } }, { { 12, 8, 2, 12, 2, 1, 12, 1, 5, 12, 5, 7, 12, 7, 10, 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8 }, { 12, 1, 5, 12, 5, 7, 12, 7, 10, 12, 10, 8, 12, 8, 2, 12, 2, 9, 12, 9, 11, 12, 11, 6, 12, 6, 1 }, { 1, 5, 12, 2, 1, 12, 8, 2, 12, 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12, 6, 9, 12, 5, 6, 12 } }, { { 12, 9, 6, 12, 6, 5, 12, 5, 3, 12, 3, 4, 12, 4, 8, 12, 8, 10, 12, 10, 7, 12, 7, 11, 12, 11, 9 }, { 12, 5, 3, 12, 3, 4, 12, 4, 8, 12, 8, 9, 12, 9, 6, 12, 6, 11, 12, 11, 10, 12, 10, 7, 12, 7, 5 }, { 5, 3, 12, 6, 5, 12, 9, 6, 12, 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12, 7, 11, 12, 3, 7, 12 } }, { { 12, 11, 7, 12, 7, 3, 12, 3, 0, 12, 0, 2, 12, 2, 9, 12, 9, 8, 12, 8, 4, 12, 4, 10, 12, 10, 11 }, { 12, 3, 0, 12, 0, 2, 12, 2, 9, 12, 9, 11, 12, 11, 7, 12, 7, 10, 12, 10, 8, 12, 8, 4, 12, 4, 3 }, { 3, 0, 12, 7, 3, 12, 11, 7, 12, 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12, 4, 10, 12, 0, 4, 12 } }, { { 6, 1, 12, 11, 6, 12, 10, 11, 12, 4, 10, 12, 0, 4, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 1, 5, 12 }, { 10, 11, 12, 4, 10, 12, 0, 4, 12, 1, 0, 12, 6, 1, 12, 5, 6, 12, 3, 5, 12, 7, 3, 12, 11, 7, 12 }, { 12, 10, 11, 12, 11, 6, 12, 6, 1, 12, 1, 0, 12, 0, 4, 12, 4, 3, 12, 3, 5, 12, 5, 7, 12, 7, 10 } }, { { 4, 3, 12, 8, 4, 12, 9, 8, 12, 6, 9, 12, 5, 6, 12, 1, 5, 12, 2, 1, 12, 0, 2, 12, 3, 0, 12 }, { 9, 8, 12, 6, 9, 12, 5, 6, 12, 3, 5, 12, 4, 3, 12, 0, 4, 12, 1, 0, 12, 2, 1, 12, 8, 2, 12 }, { 12, 9, 8, 12, 8, 4, 12, 4, 3, 12, 3, 5, 12, 5, 6, 12, 6, 1, 12, 1, 0, 12, 0, 2, 12, 2, 9 } }, { { 12, 10, 4, 12, 4, 0, 12, 0, 1, 12, 1, 6, 12, 6, 11, 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10 }, { 12, 0, 1, 12, 1, 6, 12, 6, 11, 12, 11, 10, 12, 10, 4, 12, 4, 8, 12, 8, 9, 12, 9, 2, 12, 2, 0 }, { 0, 1, 12, 4, 0, 12, 10, 4, 12, 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12, 2, 8, 12, 1, 2, 12 } }, { { 2, 0, 12, 9, 2, 12, 11, 9, 12, 7, 11, 12, 3, 7, 12, 5, 3, 12, 6, 5, 12, 1, 6, 12, 0, 1, 12 }, { 11, 9, 12, 7, 11, 12, 3, 7, 12, 0, 3, 12, 2, 0, 12, 1, 2, 12, 5, 1, 12, 6, 5, 12, 9, 6, 12 }, { 12, 11, 9, 12, 9, 2, 12, 2, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 1, 12, 1, 6, 12, 6, 11 } }, { { 7, 5, 12, 10, 7, 12, 8, 10, 12, 2, 8, 12, 1, 2, 12, 0, 1, 12, 4, 0, 12, 3, 4, 12, 5, 3, 12 }, { 8, 10, 12, 2, 8, 12, 1, 2, 12, 5, 1, 12, 7, 5, 12, 3, 7, 12, 0, 3, 12, 4, 0, 12, 10, 4, 12 }, { 12, 8, 10, 12, 10, 7, 12, 7, 5, 12, 5, 1, 12, 1, 2, 12, 2, 0, 12, 0, 3, 12, 3, 4, 12, 4, 8 } } }; static const char triangles7_4_1[16][15] = { { 1, 8, 2, 8, 1, 7, 5, 7, 1, 8, 7, 10, 4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 3, 7, 3, 5, 0, 1, 0, 5, 0, 1, 2, 0, 2, 4 } }; /** * Triangle table for unique cube case 8. No ambiguity. */ static const char triangles8[6][6] = { { 4, 2, 7, 7, 2, 6 }, { 3, 10, 1, 1, 10, 9 }, { 0, 8, 5, 8, 11, 5 }, { 0, 5, 8, 8, 5, 11 }, { 3, 1, 10, 1, 9, 10 }, { 4, 7, 2, 7, 6, 2 } }; /** * Triangle table for unique cube case 9. No ambiguity. */ static const char triangles9[8][12] = { { 5, 7, 10, 1, 5, 10, 1, 10, 8, 1, 8, 2 }, { 8, 9, 6, 4, 8, 6, 4, 6, 5, 4, 5, 3 }, { 7, 9, 11, 3, 9, 7, 3, 2, 9, 3, 0, 2 }, { 1, 11, 6, 0, 11, 1, 0, 10, 11, 0, 4, 10 }, { 1, 6, 11, 0, 1, 11, 0, 11, 10, 0, 10, 4 }, { 7, 11, 9, 3, 7, 9, 3, 9, 2, 3, 2, 0 }, { 8, 6, 9, 4, 6, 8, 4, 5, 6, 4, 3, 5 }, { 5, 10, 7, 1, 10, 5, 1, 8, 10, 1, 2, 8 } }; /** * Test and triangle tables for ambiguous unique cube case 10. * 2 face tests and possibly the interior, no reference edge required. * * The triangle tables in order of the following test outcomes: * -tests on both specified faces are negative : * -if the test on the interior is negative * -if the test on the interior is positive * -tests on both specified faces are positive * -test on the first specified face is positive * -test on the second specified face is positive */ static const char test10[6][3] = { { 2, 4, 7 }, { 5, 6, 7 }, { 1, 3, 7 }, { 1, 3, 7 }, { 5, 6, 7 }, { 2, 4, 7 } }; static const char triangles10_1_1[6][12] = { { 10, 7, 9, 6, 9, 7, 2, 3, 4, 3, 2, 1 }, { 3, 5, 10, 11, 10, 5, 8, 1, 0, 1, 8, 9 }, { 6, 0, 2, 0, 6, 5, 8, 4, 11, 7, 11, 4 }, { 4, 0, 7, 5, 7, 0, 11, 2, 8, 2, 11, 6 }, { 9, 5, 1, 5, 9, 11, 0, 3, 8, 10, 8, 3 }, { 9, 4, 10, 4, 9, 2, 7, 3, 6, 1, 6, 3 } }; static const char triangles10_1_2[6][24] = { { 1, 6, 9, 1, 9, 2, 4, 2, 9, 10, 4, 9, 4, 10, 7, 4, 7, 3, 1, 3, 7, 6, 1, 7 }, { 9, 11, 10, 9, 10, 8, 0, 8, 10, 3, 0, 10, 0, 3, 5, 0, 5, 1, 9, 1, 5, 11, 9, 5 }, { 6, 5, 7, 11, 6, 7, 6, 11, 8, 6, 8, 2, 0, 2, 8, 4, 0, 8, 0, 4, 7, 0, 7, 5 }, { 6, 5, 7, 6, 7, 11, 8, 11, 7, 4, 8, 7, 8, 4, 0, 8, 0, 2, 6, 2, 0, 5, 6, 0 }, { 9, 11, 10, 8, 9, 10, 9, 8, 0, 9, 0, 1, 5, 1, 0, 3, 5, 0, 5, 3, 10, 5, 10, 11 }, { 9, 2, 1, 6, 9, 1, 9, 6, 7, 9, 7, 10, 4, 10, 7, 3, 4, 7, 4, 3, 1, 4, 1, 2 } }; static const char triangles10_1_1_[6][12] = { { 10, 4, 9, 2, 9, 4, 6, 3, 7, 3, 6, 1 }, { 1, 5, 9, 11, 9, 5, 8, 3, 0, 3, 8, 10 }, { 7, 0, 4, 0, 7, 5, 8, 2, 11, 6, 11, 2 }, { 2, 0, 6, 5, 6, 0, 11, 4, 8, 4, 11, 7 }, { 10, 5, 3, 5, 10, 11, 0, 1, 8, 9, 8, 1 }, { 9, 7, 10, 7, 9, 6, 4, 3, 2, 1, 2, 3 } }; static const char triangles10_2[6][24] = { { 12, 10, 4, 12, 4, 2, 12, 2, 1, 12, 1, 3, 12, 3, 7, 12, 7, 6, 12, 6, 9, 12, 9, 10 }, { 12, 3, 0, 12, 0, 8, 12, 8, 9, 12, 9, 1, 12, 1, 5, 12, 5, 11, 12, 11, 10, 12, 10, 3 }, { 8, 2, 12, 11, 8, 12, 7, 11, 12, 4, 7, 12, 0, 4, 12, 5, 0, 12, 6, 5, 12, 2, 6, 12 }, { 12, 4, 8, 12, 8, 11, 12, 11, 6, 12, 6, 2, 12, 2, 0, 12, 0, 5, 12, 5, 7, 12, 7, 4 }, { 0, 1, 12, 8, 0, 12, 10, 8, 12, 3, 10, 12, 5, 3, 12, 11, 5, 12, 9, 11, 12, 1, 9, 12 }, { 7, 10, 12, 6, 7, 12, 1, 6, 12, 3, 1, 12, 4, 3, 12, 2, 4, 12, 9, 2, 12, 10, 9, 12 } }; static const char triangles10_2_[6][24] = { { 2, 9, 12, 4, 2, 12, 3, 4, 12, 1, 3, 12, 6, 1, 12, 7, 6, 12, 10, 7, 12, 9, 10, 12 }, { 8, 10, 12, 0, 8, 12, 1, 0, 12, 9, 1, 12, 11, 9, 12, 5, 11, 12, 3, 5, 12, 10, 3, 12 }, { 12, 6, 11, 12, 11, 8, 12, 8, 4, 12, 4, 7, 12, 7, 5, 12, 5, 0, 12, 0, 2, 12, 2, 6 }, { 11, 7, 12, 8, 11, 12, 2, 8, 12, 6, 2, 12, 5, 6, 12, 0, 5, 12, 4, 0, 12, 7, 4, 12 }, { 12, 9, 8, 12, 8, 0, 12, 0, 3, 12, 3, 10, 12, 10, 11, 12, 11, 5, 12, 5, 1, 12, 1, 9 }, { 12, 9, 6, 12, 6, 7, 12, 7, 3, 12, 3, 1, 12, 1, 2, 12, 2, 4, 12, 4, 10, 12, 10, 9 } }; /** * Triangle table for unique cube case 11. No ambiguity. */ static const char triangles11[12][12] = { { 5, 7, 4, 5, 4, 9, 5, 9, 1, 9, 4, 8 }, { 3, 11, 5, 3, 2, 11, 3, 4, 2, 2, 9, 11 }, { 2, 1, 3, 2, 3, 11, 2, 11, 8, 11, 3, 7 }, { 0, 2, 6, 0, 6, 10, 0, 10, 3, 10, 6, 11 }, { 4, 10, 9, 4, 9, 5, 4, 5, 0, 5, 9, 6 }, { 10, 0, 8, 10, 6, 0, 10, 7, 6, 6, 1, 0 }, { 10, 8, 0, 10, 0, 6, 10, 6, 7, 6, 0, 1 }, { 4, 9, 10, 4, 5, 9, 4, 0, 5, 5, 6, 9 }, { 0, 6, 2, 0, 10, 6, 0, 3, 10, 10, 11, 6 }, { 2, 3, 1, 2, 11, 3, 2, 8, 11, 11, 7, 3 }, { 3, 5, 11, 3, 11, 2, 3, 2, 4, 2, 11, 9 }, { 5, 4, 7, 5, 9, 4, 5, 1, 9, 9, 8, 4 } }; /** * Test and triangle tables for ambiguous unique cube case 12. * 2 face tests and possibly the interior requiring a refrence edge. * * The triangle tables in order of the following test outcomes: * -tests on both faces are negative : * -test on the interior is negative * -test on the interior is positive * -tests on both faces are positive * -test on the first face is positive * -test on the second face is positive */ static const char test12[24][4] = { { 4, 3, 7, 6 }, { 3, 2, 7, 7 }, { 2, 6, 7, 10 }, { 6, 4, 7, 9 }, { 2, 1, 7, 4 }, { 5, 2, 7, 3 }, { 5, 3, 7, 5 }, { 5, 1, 7, 0 }, { 5, 4, 7, 1 }, { 6, 3, 7, 11 }, { 1, 6, 7, 8 }, { 1, 4, 7, 2 }, { 4, 1, 7, 2 }, { 6, 1, 7, 8 }, { 3, 6, 7, 11 }, { 4, 5, 7, 1 }, { 1, 5, 7, 0 }, { 3, 5, 7, 5 }, { 2, 5, 7, 3 }, { 1, 2, 7, 4 }, { 4, 6, 7, 9 }, { 6, 2, 7, 10 }, { 2, 3, 7, 7 }, { 3, 4, 7, 6 } }; static const char triangles12_1_1[24][12] = { { 9, 11, 6, 7, 1, 5, 1, 7, 2, 4, 2, 7 }, { 11, 10, 7, 4, 5, 3, 5, 4, 6, 2, 6, 4 }, { 7, 11, 10, 9, 4, 8, 4, 9, 3, 1, 3, 9 }, { 9, 11, 6, 8, 2, 10, 1, 10, 2, 10, 1, 3 }, { 10, 8, 4, 2, 3, 0, 3, 2, 7, 6, 7, 2 }, { 3, 5, 7, 0, 4, 1, 10, 1, 4, 1, 10, 9 }, { 7, 3, 5, 0, 6, 1, 6, 0, 11, 8, 11, 0 }, { 2, 1, 0, 5, 4, 3, 4, 5, 8, 11, 8, 5 }, { 1, 0, 2, 5, 6, 3, 9, 3, 6, 3, 9, 10 }, { 11, 10, 7, 9, 6, 8, 5, 8, 6, 8, 5, 0 }, { 4, 10, 8, 11, 2, 9, 2, 11, 0, 5, 0, 11 }, { 2, 1, 0, 9, 8, 6, 4, 6, 8, 6, 4, 7 }, { 8, 9, 2, 6, 0, 1, 0, 6, 4, 7, 4, 6 }, { 8, 9, 2, 10, 4, 11, 0, 11, 4, 11, 0, 5 }, { 6, 9, 11, 8, 7, 10, 7, 8, 5, 0, 5, 8 }, { 6, 5, 1, 3, 2, 0, 2, 3, 9, 10, 9, 3 }, { 0, 3, 4, 1, 2, 5, 8, 5, 2, 5, 8, 11 }, { 5, 1, 6, 3, 7, 0, 11, 0, 7, 0, 11, 8 }, { 4, 0, 3, 1, 7, 5, 7, 1, 10, 9, 10, 1 }, { 4, 0, 3, 8, 10, 2, 7, 2, 10, 2, 7, 6 }, { 2, 8, 9, 10, 6, 11, 6, 10, 1, 3, 1, 10 }, { 10, 8, 4, 11, 7, 9, 3, 9, 7, 9, 3, 1 }, { 7, 3, 5, 10, 11, 4, 6, 4, 11, 4, 6, 2 }, { 6, 5, 1, 11, 9, 7, 2, 7, 9, 7, 2, 4 } }; static const char triangles12_1_2[24][24] = { { 9, 1, 6, 1, 9, 2, 4, 2, 9, 11, 4, 9, 4, 11, 7, 5, 7, 11, 6, 5, 11, 5, 6, 1 }, { 11, 5, 7, 5, 11, 6, 2, 6, 11, 10, 2, 11, 2, 10, 4, 3, 4, 10, 7, 3, 10, 3, 7, 5 }, { 7, 4, 10, 4, 7, 3, 1, 3, 7, 11, 1, 7, 1, 11, 9, 8, 9, 11, 10, 8, 11, 8, 10, 4 }, { 9, 2, 6, 1, 6, 2, 6, 1, 3, 6, 3, 11, 10, 11, 3, 11, 10, 8, 11, 8, 9, 2, 9, 8 }, { 10, 3, 4, 3, 10, 7, 6, 7, 10, 8, 6, 10, 6, 8, 2, 0, 2, 8, 4, 0, 8, 0, 4, 3 }, { 3, 4, 7, 10, 7, 4, 7, 10, 9, 7, 9, 5, 1, 5, 9, 5, 1, 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8, 11 }, { 5, 3, 7, 1, 6, 0, 11, 0, 6, 0, 11, 8 }, { 7, 5, 3, 1, 4, 0, 4, 1, 10, 9, 10, 1 }, { 4, 8, 10, 0, 3, 2, 7, 2, 3, 2, 7, 6 }, { 6, 11, 9, 10, 2, 8, 2, 10, 1, 3, 1, 10 }, { 10, 11, 7, 8, 4, 9, 3, 9, 4, 9, 3, 1 }, { 7, 10, 11, 3, 5, 4, 6, 4, 5, 4, 6, 2 }, { 6, 11, 9, 5, 1, 7, 2, 7, 1, 7, 2, 4 } }; static const char triangles12_2[24][24] = { { 4, 2, 12, 7, 4, 12, 5, 7, 12, 1, 5, 12, 6, 1, 12, 11, 6, 12, 9, 11, 12, 2, 9, 12 }, { 2, 6, 12, 4, 2, 12, 3, 4, 12, 5, 3, 12, 7, 5, 12, 10, 7, 12, 11, 10, 12, 6, 11, 12 }, { 1, 3, 12, 9, 1, 12, 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12, 7, 11, 12, 3, 7, 12 }, { 12, 1, 3, 12, 3, 10, 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8, 12, 8, 2, 12, 2, 1 }, { 6, 7, 12, 2, 6, 12, 0, 2, 12, 3, 0, 12, 4, 3, 12, 8, 4, 12, 10, 8, 12, 7, 10, 12 }, { 12, 10, 9, 12, 9, 1, 12, 1, 5, 12, 5, 7, 12, 7, 3, 12, 3, 0, 12, 0, 4, 12, 4, 10 }, { 8, 11, 12, 0, 8, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 1, 5, 12, 6, 1, 12, 11, 6, 12 }, { 11, 8, 12, 5, 11, 12, 1, 5, 12, 2, 1, 12, 0, 2, 12, 3, 0, 12, 4, 3, 12, 8, 4, 12 }, { 12, 9, 10, 12, 10, 3, 12, 3, 0, 12, 0, 2, 12, 2, 1, 12, 1, 5, 12, 5, 6, 12, 6, 9 }, { 12, 5, 0, 12, 0, 8, 12, 8, 10, 12, 10, 7, 12, 7, 11, 12, 11, 9, 12, 9, 6, 12, 6, 5 }, { 5, 0, 12, 11, 5, 12, 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12, 4, 10, 12, 0, 4, 12 }, { 12, 4, 7, 12, 7, 6, 12, 6, 9, 12, 9, 8, 12, 8, 2, 12, 2, 1, 12, 1, 0, 12, 0, 4 }, { 7, 4, 12, 6, 7, 12, 9, 6, 12, 8, 9, 12, 2, 8, 12, 1, 2, 12, 0, 1, 12, 4, 0, 12 }, { 12, 0, 5, 12, 5, 11, 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10, 12, 10, 4, 12, 4, 0 }, { 0, 5, 12, 8, 0, 12, 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12, 6, 9, 12, 5, 6, 12 }, { 10, 9, 12, 3, 10, 12, 0, 3, 12, 2, 0, 12, 1, 2, 12, 5, 1, 12, 6, 5, 12, 9, 6, 12 }, { 12, 8, 11, 12, 11, 5, 12, 5, 1, 12, 1, 2, 12, 2, 0, 12, 0, 3, 12, 3, 4, 12, 4, 8 }, { 12, 11, 8, 12, 8, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 1, 12, 1, 6, 12, 6, 11 }, { 9, 10, 12, 1, 9, 12, 5, 1, 12, 7, 5, 12, 3, 7, 12, 0, 3, 12, 4, 0, 12, 10, 4, 12 }, { 12, 7, 6, 12, 6, 2, 12, 2, 0, 12, 0, 3, 12, 3, 4, 12, 4, 8, 12, 8, 10, 12, 10, 7 }, { 3, 1, 12, 10, 3, 12, 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12, 2, 8, 12, 1, 2, 12 }, { 12, 3, 1, 12, 1, 9, 12, 9, 8, 12, 8, 4, 12, 4, 10, 12, 10, 11, 12, 11, 7, 12, 7, 3 }, { 12, 6, 2, 12, 2, 4, 12, 4, 3, 12, 3, 5, 12, 5, 7, 12, 7, 10, 12, 10, 11, 12, 11, 6 }, { 12, 2, 4, 12, 4, 7, 12, 7, 5, 12, 5, 1, 12, 1, 6, 12, 6, 11, 12, 11, 9, 12, 9, 2 } }; static const char triangles12_2_[24][24] = { { 12, 5, 6, 12, 6, 9, 12, 9, 11, 12, 11, 7, 12, 7, 4, 12, 4, 2, 12, 2, 1, 12, 1, 5 }, { 12, 3, 7, 12, 7, 11, 12, 11, 10, 12, 10, 4, 12, 4, 2, 12, 2, 6, 12, 6, 5, 12, 5, 3 }, { 12, 8, 10, 12, 10, 7, 12, 7, 11, 12, 11, 9, 12, 9, 1, 12, 1, 3, 12, 3, 4, 12, 4, 8 }, { 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12, 3, 10, 12, 1, 3, 12, 6, 1, 12, 11, 6, 12 }, { 12, 0, 4, 12, 4, 10, 12, 10, 8, 12, 8, 2, 12, 2, 6, 12, 6, 7, 12, 7, 3, 12, 3, 0 }, { 3, 5, 12, 4, 3, 12, 0, 4, 12, 1, 0, 12, 9, 1, 12, 10, 9, 12, 7, 10, 12, 5, 7, 12 }, { 12, 3, 5, 12, 5, 6, 12, 6, 1, 12, 1, 0, 12, 0, 8, 12, 8, 11, 12, 11, 7, 12, 7, 3 }, { 12, 1, 0, 12, 0, 4, 12, 4, 3, 12, 3, 5, 12, 5, 11, 12, 11, 8, 12, 8, 2, 12, 2, 1 }, { 1, 0, 12, 6, 1, 12, 5, 6, 12, 3, 5, 12, 10, 3, 12, 9, 10, 12, 2, 9, 12, 0, 2, 12 }, { 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12, 0, 8, 12, 5, 0, 12, 7, 5, 12, 10, 7, 12 }, { 12, 9, 8, 12, 8, 4, 12, 4, 10, 12, 10, 11, 12, 11, 5, 12, 5, 0, 12, 0, 2, 12, 2, 9 }, { 2, 9, 12, 0, 2, 12, 1, 0, 12, 6, 1, 12, 7, 6, 12, 4, 7, 12, 8, 4, 12, 9, 8, 12 }, { 12, 9, 2, 12, 2, 0, 12, 0, 1, 12, 1, 6, 12, 6, 7, 12, 7, 4, 12, 4, 8, 12, 8, 9 }, { 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12, 5, 11, 12, 0, 5, 12, 2, 0, 12, 9, 2, 12 }, { 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8, 12, 8, 0, 12, 0, 5, 12, 5, 7, 12, 7, 10 }, { 12, 0, 1, 12, 1, 6, 12, 6, 5, 12, 5, 3, 12, 3, 10, 12, 10, 9, 12, 9, 2, 12, 2, 0 }, { 0, 1, 12, 4, 0, 12, 3, 4, 12, 5, 3, 12, 11, 5, 12, 8, 11, 12, 2, 8, 12, 1, 2, 12 }, { 5, 3, 12, 6, 5, 12, 1, 6, 12, 0, 1, 12, 8, 0, 12, 11, 8, 12, 7, 11, 12, 3, 7, 12 }, { 12, 5, 3, 12, 3, 4, 12, 4, 0, 12, 0, 1, 12, 1, 9, 12, 9, 10, 12, 10, 7, 12, 7, 5 }, { 4, 0, 12, 10, 4, 12, 8, 10, 12, 2, 8, 12, 6, 2, 12, 7, 6, 12, 3, 7, 12, 0, 3, 12 }, { 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10, 12, 10, 3, 12, 3, 1, 12, 1, 6, 12, 6, 11 }, { 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12, 1, 9, 12, 3, 1, 12, 4, 3, 12, 8, 4, 12 }, { 7, 3, 12, 11, 7, 12, 10, 11, 12, 4, 10, 12, 2, 4, 12, 6, 2, 12, 5, 6, 12, 3, 5, 12 }, { 6, 5, 12, 9, 6, 12, 11, 9, 12, 7, 11, 12, 4, 7, 12, 2, 4, 12, 1, 2, 12, 5, 1, 12 } }; /** * Test and triangulation tables for ambiguous unique cube case 13. * All faces and interior are to be tested. * * Case 13 is a little ridiculous. There are actually only 2 possible configurations for case 13, * but they each require potentially every test to be applied, and can result in one of many, many * edge triangulations. The only cases requiring an internal test are those who return certain * face test results with 3 positive tests, of which there are only 4 (and their complements). * Which edge needs to determine the plane direction differs depending on the outcome of the tests. * For lack of a better way to do it, I've encoded the edge information in an additional test13_5 * table. */ static const char test13[2][7] = { { 1, 2, 3, 4, 5, 6, 7 }, { 2, 3, 4, 1, 5, 6, 7 }, }; static const char triangles13_1[2][12] = { { 6, 9, 11, 3, 5, 7, 2, 1, 0, 4, 10, 8 }, { 2, 8, 9, 5, 1, 6, 4, 0, 3, 7, 11, 10 } }; static const char triangles13_1_[2][12] = { { 9, 8, 2, 6, 1, 5, 3, 0, 4, 10, 11, 7 }, { 11, 9, 6, 7, 5, 3, 0, 1, 2, 8, 10, 4 } }; static const char triangles13_2[2][6][18] = { { { 3, 5, 7, 6, 9, 11, 1, 8, 2, 8, 1, 10, 0, 10, 1, 10, 0, 4 }, { 2, 1, 0, 6, 9, 11, 4, 3, 8, 5, 8, 3, 8, 5, 10, 7, 10, 5 }, { 4, 10, 8, 2, 1, 0, 3, 11, 7, 11, 3, 9, 5, 9, 3, 9, 5, 6 }, { 4, 10, 8, 3, 5, 7, 6, 1, 11, 0, 11, 1, 11, 0, 9, 2, 9, 0 }, { 4, 10, 8, 6, 9, 11, 0, 7, 3, 7, 0, 2, 7, 2, 5, 1, 5, 2 }, { 3, 5, 7, 1, 0, 2, 8, 4, 9, 6, 9, 4, 10, 6, 4, 6, 10, 11 } }, { { 5, 1, 6, 2, 8, 9, 0, 10, 4, 10, 0, 11, 3, 11, 0, 11, 3, 7 }, { 4, 0, 3, 2, 8, 9, 7, 5, 10, 1, 10, 5, 10, 1, 11, 6, 11, 1 }, { 11, 10, 7, 4, 0, 3, 5, 9, 6, 9, 5, 8, 1, 8, 5, 8, 1, 2 }, { 11, 10, 7, 5, 1, 6, 2, 0, 9, 3, 9, 0, 9, 3, 8, 4, 8, 3 }, { 11, 10, 7, 2, 8, 9, 3, 6, 5, 6, 3, 4, 6, 4, 1, 0, 1, 4 }, { 5, 1, 6, 0, 3, 4, 10, 7, 8, 2, 8, 7, 11, 2, 7, 2, 11, 9 } } }; static const char triangles13_2_[2][6][18] = { { { 7, 10, 11, 6, 1, 5, 9, 0, 2, 0, 9, 3, 8, 3, 9, 3, 8, 4 }, { 6, 1, 5, 9, 8, 2, 4, 10, 0, 11, 0, 10, 0, 11, 3, 7, 3, 11 }, { 3, 0, 4, 9, 8, 2, 10, 5, 7, 5, 10, 1, 11, 1, 10, 1, 11, 6 }, { 7, 10, 11, 3, 0, 4, 6, 9, 5, 8, 5, 9, 5, 8, 1, 2, 1, 8 }, { 7, 10, 11, 9, 8, 2, 5, 6, 3, 4, 3, 6, 1, 4, 6, 4, 1, 0 }, { 6, 1, 5, 4, 3, 0, 8, 7, 10, 7, 8, 2, 7, 2, 11, 9, 11, 2 } }, { { 11, 9, 6, 2, 0, 1, 8, 3, 4, 3, 8, 5, 10, 5, 8, 5, 10, 7 }, { 2, 0, 1, 8, 10, 4, 7, 11, 3, 9, 3, 11, 3, 9, 5, 6, 5, 9 }, { 5, 3, 7, 8, 10, 4, 11, 1, 6, 1, 11, 0, 9, 0, 11, 0, 9, 2 }, { 11, 9, 6, 5, 3, 7, 2, 8, 1, 10, 1, 8, 1, 10, 0, 4, 0, 10 }, { 11, 9, 6, 8, 10, 4, 1, 2, 5, 7, 5, 2, 0, 7, 2, 7, 0, 3 }, { 2, 0, 1, 7, 5, 3, 10, 6, 11, 6, 10, 4, 6, 4, 9, 8, 9, 4 } } }; static const char triangles13_3[2][12][30] = { { { 6, 9, 11, 12, 5, 7, 12, 7, 10, 12, 10, 8, 12, 8, 2, 12, 2, 1, 12, 1, 0, 12, 0, 4, 12, 4, 3, 12, 3, 5 }, { 3, 5, 7, 4, 10, 12, 0, 4, 12, 1, 0, 12, 6, 1, 12, 11, 6, 12, 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12 }, { 6, 9, 11, 12, 10, 8, 12, 8, 2, 12, 2, 1, 12, 1, 5, 12, 5, 7, 12, 7, 3, 12, 3, 0, 12, 0, 4, 12, 4, 10 }, { 3, 5, 7, 12, 1, 0, 12, 0, 4, 12, 4, 10, 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8, 12, 8, 2, 12, 2, 1 }, { 2, 1, 0, 6, 9, 12, 5, 6, 12, 3, 5, 12, 4, 3, 12, 8, 4, 12, 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12 }, { 6, 9, 11, 10, 8, 12, 7, 10, 12, 5, 7, 12, 1, 5, 12, 2, 1, 12, 0, 2, 12, 3, 0, 12, 4, 3, 12, 8, 4, 12 }, { 2, 1, 0, 3, 5, 12, 4, 3, 12, 8, 4, 12, 9, 8, 12, 6, 9, 12, 11, 6, 12, 10, 11, 12, 7, 10, 12, 5, 7, 12 }, { 4, 10, 8, 12, 0, 2, 12, 2, 9, 12, 9, 11, 12, 11, 7, 12, 7, 3, 12, 3, 5, 12, 5, 6, 12, 6, 1, 12, 1, 0 }, { 4, 10, 8, 12, 9, 11, 12, 11, 7, 12, 7, 3, 12, 3, 0, 12, 0, 2, 12, 2, 1, 12, 1, 5, 12, 5, 6, 12, 6, 9 }, { 2, 1, 0, 12, 3, 5, 12, 5, 6, 12, 6, 9, 12, 9, 8, 12, 8, 4, 12, 4, 10, 12, 10, 11, 12, 11, 7, 12, 7, 3 }, { 4, 10, 8, 9, 11, 12, 2, 9, 12, 0, 2, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 1, 5, 12, 6, 1, 12, 11, 6, 12 }, { 3, 5, 7, 1, 0, 12, 6, 1, 12, 11, 6, 12, 10, 11, 12, 4, 10, 12, 8, 4, 12, 9, 8, 12, 2, 9, 12, 0, 2, 12 } }, { { 2, 8, 9, 12, 1, 6, 12, 6, 11, 12, 11, 10, 12, 10, 4, 12, 4, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 1 }, { 5, 1, 6, 7, 11, 12, 3, 7, 12, 0, 3, 12, 2, 0, 12, 9, 2, 12, 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12 }, { 2, 8, 9, 12, 11, 10, 12, 10, 4, 12, 4, 0, 12, 0, 1, 12, 1, 6, 12, 6, 5, 12, 5, 3, 12, 3, 7, 12, 7, 11 }, { 5, 1, 6, 12, 0, 3, 12, 3, 7, 12, 7, 11, 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10, 12, 10, 4, 12, 4, 0 }, { 0, 3, 4, 2, 8, 12, 1, 2, 12, 5, 1, 12, 7, 5, 12, 10, 7, 12, 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12 }, { 2, 8, 9, 11, 10, 12, 6, 11, 12, 1, 6, 12, 0, 1, 12, 4, 0, 12, 3, 4, 12, 5, 3, 12, 7, 5, 12, 10, 7, 12 }, { 4, 0, 3, 5, 1, 12, 7, 5, 12, 10, 7, 12, 8, 10, 12, 2, 8, 12, 9, 2, 12, 11, 9, 12, 6, 11, 12, 1, 6, 12 }, { 11, 10, 7, 12, 3, 4, 12, 4, 8, 12, 8, 9, 12, 9, 6, 12, 6, 5, 12, 5, 1, 12, 1, 2, 12, 2, 0, 12, 0, 3 }, { 11, 10, 7, 12, 8, 9, 12, 9, 6, 12, 6, 5, 12, 5, 3, 12, 3, 4, 12, 4, 0, 12, 0, 1, 12, 1, 2, 12, 2, 8 }, { 4, 0, 3, 12, 5, 1, 12, 1, 2, 12, 2, 8, 12, 8, 10, 12, 10, 7, 12, 7, 11, 12, 11, 9, 12, 9, 6, 12, 6, 5 }, { 11, 10, 7, 8, 9, 12, 4, 8, 12, 3, 4, 12, 5, 3, 12, 6, 5, 12, 1, 6, 12, 0, 1, 12, 2, 0, 12, 9, 2, 12 }, { 5, 1, 6, 0, 3, 12, 2, 0, 12, 9, 2, 12, 11, 9, 12, 7, 11, 12, 10, 7, 12, 8, 10, 12, 4, 8, 12, 3, 4, 12 } } }; static const char triangles13_3_[2][12][30] = { { { 1, 5, 6, 2, 9, 12, 0, 2, 12, 3, 0, 12, 7, 3, 12, 11, 7, 12, 10, 11, 12, 4, 10, 12, 8, 4, 12, 9, 8, 12 }, { 10, 11, 7, 12, 5, 6, 12, 6, 9, 12, 9, 8, 12, 8, 4, 12, 4, 3, 12, 3, 0, 12, 0, 2, 12, 2, 1, 12, 1, 5 }, { 7, 10, 11, 12, 9, 8, 12, 8, 4, 12, 4, 3, 12, 3, 5, 12, 5, 6, 12, 6, 1, 12, 1, 0, 12, 0, 2, 12, 2, 9 }, { 6, 1, 5, 12, 3, 0, 12, 0, 2, 12, 2, 9, 12, 9, 11, 12, 11, 7, 12, 7, 10, 12, 10, 8, 12, 8, 4, 12, 4, 3 }, { 9, 8, 2, 6, 1, 12, 11, 6, 12, 10, 11, 12, 4, 10, 12, 0, 4, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 1, 5, 12 }, { 9, 8, 2, 10, 11, 12, 4, 10, 12, 0, 4, 12, 1, 0, 12, 6, 1, 12, 5, 6, 12, 3, 5, 12, 7, 3, 12, 11, 7, 12 }, { 6, 1, 5, 3, 0, 12, 7, 3, 12, 11, 7, 12, 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12, 4, 10, 12, 0, 4, 12 }, { 3, 0, 4, 12, 8, 2, 12, 2, 1, 12, 1, 5, 12, 5, 7, 12, 7, 10, 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8 }, { 9, 8, 2, 12, 10, 11, 12, 11, 6, 12, 6, 1, 12, 1, 0, 12, 0, 4, 12, 4, 3, 12, 3, 5, 12, 5, 7, 12, 7, 10 }, { 3, 0, 4, 12, 1, 5, 12, 5, 7, 12, 7, 10, 12, 10, 8, 12, 8, 2, 12, 2, 9, 12, 9, 11, 12, 11, 6, 12, 6, 1 }, { 7, 10, 11, 9, 8, 12, 6, 9, 12, 5, 6, 12, 3, 5, 12, 4, 3, 12, 0, 4, 12, 1, 0, 12, 2, 1, 12, 8, 2, 12 }, { 4, 3, 0, 1, 5, 12, 2, 1, 12, 8, 2, 12, 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12, 6, 9, 12, 5, 6, 12 } }, { { 0, 1, 2, 4, 8, 12, 3, 4, 12, 5, 3, 12, 6, 5, 12, 9, 6, 12, 11, 9, 12, 7, 11, 12, 10, 7, 12, 8, 10, 12 }, { 6, 11, 9, 12, 1, 2, 12, 2, 8, 12, 8, 10, 12, 10, 7, 12, 7, 5, 12, 5, 3, 12, 3, 4, 12, 4, 0, 12, 0, 1 }, { 11, 9, 6, 12, 8, 10, 12, 10, 7, 12, 7, 5, 12, 5, 1, 12, 1, 2, 12, 2, 0, 12, 0, 3, 12, 3, 4, 12, 4, 8 }, { 2, 0, 1, 12, 5, 3, 12, 3, 4, 12, 4, 8, 12, 8, 9, 12, 9, 6, 12, 6, 11, 12, 11, 10, 12, 10, 7, 12, 7, 5 }, { 8, 10, 4, 2, 0, 12, 9, 2, 12, 11, 9, 12, 7, 11, 12, 3, 7, 12, 5, 3, 12, 6, 5, 12, 1, 6, 12, 0, 1, 12 }, { 8, 10, 4, 11, 9, 12, 7, 11, 12, 3, 7, 12, 0, 3, 12, 2, 0, 12, 1, 2, 12, 5, 1, 12, 6, 5, 12, 9, 6, 12 }, { 2, 0, 1, 5, 3, 12, 6, 5, 12, 9, 6, 12, 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12, 7, 11, 12, 3, 7, 12 }, { 5, 3, 7, 12, 10, 4, 12, 4, 0, 12, 0, 1, 12, 1, 6, 12, 6, 11, 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10 }, { 8, 10, 4, 12, 11, 9, 12, 9, 2, 12, 2, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 1, 12, 1, 6, 12, 6, 11 }, { 5, 3, 7, 12, 0, 1, 12, 1, 6, 12, 6, 11, 12, 11, 10, 12, 10, 4, 12, 4, 8, 12, 8, 9, 12, 9, 2, 12, 2, 0 }, { 11, 9, 6, 8, 10, 12, 2, 8, 12, 1, 2, 12, 5, 1, 12, 7, 5, 12, 3, 7, 12, 0, 3, 12, 4, 0, 12, 10, 4, 12 }, { 7, 5, 3, 0, 1, 12, 4, 0, 12, 10, 4, 12, 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12, 2, 8, 12, 1, 2, 12 } } }; static const char triangles13_4[2][4][36] = { { { 12, 5, 7, 12, 7, 10, 12, 10, 11, 12, 11, 6, 12, 6, 9, 12, 9, 8, 12, 8, 2, 12, 2, 1, 12, 1, 0, 12, 0, 4, 12, 4, 3, 12, 3, 5 }, { 6, 1, 12, 11, 6, 12, 9, 11, 12, 2, 9, 12, 8, 2, 12, 10, 8, 12, 4, 10, 12, 0, 4, 12, 3, 0, 12, 7, 3, 12, 5, 7, 12, 1, 5, 12 }, { 4, 3, 12, 8, 4, 12, 10, 8, 12, 7, 10, 12, 11, 7, 12, 9, 11, 12, 6, 9, 12, 5, 6, 12, 1, 5, 12, 2, 1, 12, 0, 2, 12, 3, 0, 12 }, { 12, 0, 2, 12, 2, 9, 12, 9, 8, 12, 8, 4, 12, 4, 10, 12, 10, 11, 12, 11, 7, 12, 7, 3, 12, 3, 5, 12, 5, 6, 12, 6, 1, 12, 1, 0 } }, { { 12, 1, 6, 12, 6, 11, 12, 11, 9, 12, 9, 2, 12, 2, 8, 12, 8, 10, 12, 10, 4, 12, 4, 0, 12, 0, 3, 12, 3, 7, 12, 7, 5, 12, 5, 1 }, { 2, 0, 12, 9, 2, 12, 8, 9, 12, 4, 8, 12, 10, 4, 12, 11, 10, 12, 7, 11, 12, 3, 7, 12, 5, 3, 12, 6, 5, 12, 1, 6, 12, 0, 1, 12 }, { 7, 5, 12, 10, 7, 12, 11, 10, 12, 6, 11, 12, 9, 6, 12, 8, 9, 12, 2, 8, 12, 1, 2, 12, 0, 1, 12, 4, 0, 12, 3, 4, 12, 5, 3, 12 }, { 12, 3, 4, 12, 4, 8, 12, 8, 10, 12, 10, 7, 12, 7, 11, 12, 11, 9, 12, 9, 6, 12, 6, 5, 12, 5, 1, 12, 1, 2, 12, 2, 0, 12, 0, 3 } } }; static const char triangles13_5_1[2][4][18] = { { { 9, 11, 6, 3, 0, 4, 7, 1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 6, 7, 5, 3, 10, 7, 3, 4, 10, 3, 10, 4, 8, 2, 8, 4, 0, 2, 4, 2, 0, 1, 3, 1, 0, 1, 3, 5 }, { 0, 1, 2, 11, 9, 6, 11, 6, 5, 11, 5, 7, 3, 7, 5, 7, 3, 4, 7, 4, 10, 10, 4, 8, 10, 8, 11, 9, 11, 8 } } }; /** * Triangle table for unique cube case 14. No ambiguity. */ static const char triangles14[12][12] = { { 10, 4, 2, 10, 2, 5, 10, 5, 11, 1, 5, 2 }, { 5, 3, 10, 5, 10, 2, 5, 2, 6, 8, 2, 10 }, { 4, 8, 11, 4, 11, 1, 4, 1, 3, 6, 1, 11 }, { 3, 6, 7, 3, 8, 6, 3, 0, 8, 9, 6, 8 }, { 2, 5, 0, 2, 10, 5, 2, 9, 10, 7, 5, 10 }, { 0, 9, 1, 0, 7, 9, 0, 4, 7, 11, 9, 7 }, { 0, 1, 9, 0, 9, 7, 0, 7, 4, 11, 7, 9 }, { 2, 0, 5, 2, 5, 10, 2, 10, 9, 7, 10, 5 }, { 3, 7, 6, 3, 6, 8, 3, 8, 0, 9, 8, 6 }, { 4, 11, 8, 4, 1, 11, 4, 3, 1, 6, 11, 1 }, { 5, 10, 3, 5, 2, 10, 5, 6, 2, 8, 10, 2 }, { 10, 2, 4, 10, 5, 2, 10, 11, 5, 1, 2, 5 } }; class marching_cubes_table { std::vector> m_classicCubeCases; public: /** * Populates the tables. */ marching_cubes_table(); /** * Performs a face test for the cube to determine the correct subcase. A negative sign on * the face code means to invert the result of the test, to account for inverted cube cases. * The face test essentially seeks to determine whether opposing corners of the same sign. * are connected on the face plane. * * @param face The code of the face test to perform. * @param cubeCorners The signed distance values at the corners of the cube. */ bool test_face( char face, const float cubeCorners[8] ) const; /** * Performs a test on the interior of a cube to determine the correct subcase. A negative sign on * the flag means to invert the result of the test, to account for inverted cube cases. The interior test * essentially seeks to find a plane that cuts through the cube to join opposing corners of the same sign. * Interior tests are only performed for cases with such opposing corners that have similar signs, and only * for those where a face test fails to disambiguate the case. * * @param flag A flag indicating whether the test outcome needs to be inverted. Negative means *to invert. * @param cubeCase The cubecase for the cube being tested. * @param config The configuration of the cubecase for the cube being tested. * @param subconfig The subconfiguration of the cubecase for the cube being tested. * @param cubeCorners The signed distance values at the corners of the cube. */ bool test_interior( char flag, char cubeCase, char config, char subconfig, const float cubeCorners[8] ) const; /** * Pulls faces from a triangle table. * * @param table The table to pull the faces from. * @param n The number of faces to pull. * @param outFaces A reference to a vector to put the faces in. */ void get_faces_from_table( const char* table, int n, std::vector& outFaces ) const; /** * Dumps a the given cube corners to the given output stream. Will throw if the * vector doesn't have 8 corners. * * @param cubeCorners A vector of 8 cube corners. * @param o An output stream to dump to. */ void dump_cube( const float cubeCorners[8], std::ostream& o ) const; /** * Fetches the faces from the "classic" cube case table for the given cube case. * * @param cubeCase One of the 255 possible cube cases. See the above cube conventions for details. * @return A vector for vector3s where the faces will be placed. */ const std::vector& get_cubecase_faces( unsigned char cubeCase ) const; /** * Fetches the faces from the "disambiguated" cube case table. This requires a copy of * the cube corner data for testing. Returns true if an additional vertex needs to be added. * * @param cubeCase One of the 255 possible cube cases. * @param cubeCorners A vector of floats of cube corner values. See the above cube conventions for details. * @param faces A vector for vector3s where the faces will be placed. */ // bool get_cubecase_faces( unsigned char cubeCase, std::vector& cubeCorners, // std::vector& faces, frantic::graphics::vector3& cubeCaseDebug ) const; bool get_cubecase_faces( unsigned char cubeCase, const float cubeCorners[8], std::vector& faces ) const; /** * Given the CubeCases along the previous axes, and the sign of the extreme positive corner, * computes the new CubeCase. * * @param prevCubeCaseX The previous cube case in the x direction. * @param prevCubeCaseY The previous cube case in the y direction. * @param prevCubeCaseZ The previous cube case in the z direction. * @param cornerSign The sign of the extreme positive corner. * @return The new cube case. */ static unsigned char combine_cube_cases( unsigned char prevCubeCaseX, unsigned char prevCubeCaseY, unsigned char prevCubeCaseZ, bool cornerSign ) { return ( ( prevCubeCaseZ & 0xf0 ) >> 4 ) | ( ( prevCubeCaseY & 0xc0 ) >> 2 ) | ( ( prevCubeCaseX & 0x80 ) >> 1 ) | ( cornerSign ? 0x80 : 0x00 ); } /** * Given the CubeCases along the previous axes, and the sign of the extreme positive corner, * computes the new CubeCase. * * @param prevCubeCaseX The previous cube case in the x direction. * @param prevYCornerSign The sign of corner number 6 (negative: true). * @param prevCubeCaseZ The previous cube case in the z direction. * @param cornerSign The sign of the extreme positive corner. * @return The new cube case. */ static unsigned char combine_cube_cases( unsigned char prevCubeCaseX, bool prevYCornerSign, unsigned char prevCubeCaseZ, bool cornerSign ) { return ( ( prevCubeCaseZ & 0xf0 ) >> 4 ) | ( prevYCornerSign ? 0x20 : 0x00 ) | ( ( prevCubeCaseX & 0xa0 ) >> 1 ) | ( cornerSign ? 0x80 : 0x00 ); } /** * When a cube case is created by adding the new corner vertex, up to 3 vertices may be added. * These vertices are added on edges 37, 57, and 67. This function detemines which edges * will require a vertex based on the cube case, and uses the input vertex index to compute * the indices of these verts for the return vector3. A -1 means no new vertex. * * @param cubeCase The cube case to get the new verts for. * @param vertBase The vertex index to offset the new vertex indices by. * @return A vector3 of indices for the new verts. */ static frantic::graphics::vector3 get_new_verts( unsigned char cubeCase, int vertBase ) { frantic::graphics::vector3 result; // Edge 67 (along X axis) if( ( 0x40 & ( ( cubeCase >> 1 ) ^ cubeCase ) ) != 0x00 ) result.x = vertBase++; else result.x = -1; // Edge 57 (along Y axis) if( ( 0x20 & ( ( cubeCase >> 2 ) ^ cubeCase ) ) != 0x00 ) result.y = vertBase++; else result.y = -1; // Edge 37 (along Z axis) if( ( 0x08 & ( ( cubeCase >> 4 ) ^ cubeCase ) ) != 0x00 ) result.z = vertBase++; else result.z = -1; return result; } /** * When a cube case is created by adding the new corner vertex, up to 3 vertices may be added. * These vertices are added on edges 37, 57, and 67. This function detemines which edges * will require a vertex based on the cube case, and uses the input vertex index to compute * the indices of these verts for the return vector3. A -1 means no new vertex. Returns * the number of new verts. * * @param cubeCase The cube case to get the new verts for. * @param vertBase The vertex index to offset the new vertex indices by. * @param[out] newVerts A vector3 of indices for the new verts to be populated as output. * @return The number of new verts. */ static int get_new_verts( unsigned char cubeCase, int vertBase, frantic::graphics::vector3& newVerts ) { int oldVertBase = vertBase; // Edge 67 (along X axis) if( ( 0x40 & ( ( cubeCase >> 1 ) ^ cubeCase ) ) != 0x00 ) newVerts.x = vertBase++; else newVerts.x = -1; // Edge 57 (along Y axis) if( ( 0x20 & ( ( cubeCase >> 2 ) ^ cubeCase ) ) != 0x00 ) newVerts.y = vertBase++; else newVerts.y = -1; // Edge 37 (along Z axis) if( ( 0x08 & ( ( cubeCase >> 4 ) ^ cubeCase ) ) != 0x00 ) newVerts.z = vertBase++; else newVerts.z = -1; return vertBase - oldVertBase; } static int get_added_vert_count( unsigned char cubeCase ) { int addedVertCount = 0; // Edge 67 (along X axis) if( ( 0x40 & ( ( cubeCase >> 1 ) ^ cubeCase ) ) != 0x00 ) ++addedVertCount; // Edge 57 (along Y axis) if( ( 0x20 & ( ( cubeCase >> 2 ) ^ cubeCase ) ) != 0x00 ) ++addedVertCount; // Edge 37 (along Z axis) if( ( 0x08 & ( ( cubeCase >> 4 ) ^ cubeCase ) ) != 0x00 ) ++addedVertCount; return addedVertCount; } /** * This function sets the flags for any edge verts in the vertFlags array as true, if they are * required by the given cubeCase, and false otherwise. * * @param cubeCase The cube case to determine the flags for * @param vertFlags A vector of length 12 whose required edge vert entries will be flagged as true, * and unrequired edge verts will be flagged as false. */ static void get_required_vert_flags( unsigned char cubeCase, char vertFlags[12] ) { vertFlags[0] = 0x01 == ( 0x01 & ( ( cubeCase >> 1 ) ^ cubeCase ) ); // edge 01 vertFlags[1] = 0x01 == ( 0x01 & ( ( cubeCase >> 2 ) ^ cubeCase ) ); // edge 02 vertFlags[2] = 0x01 == ( 0x01 & ( ( cubeCase >> 4 ) ^ cubeCase ) ); // edge 04 vertFlags[3] = 0x02 == ( 0x02 & ( ( cubeCase >> 2 ) ^ cubeCase ) ); // edge 13 vertFlags[4] = 0x02 == ( 0x02 & ( ( cubeCase >> 4 ) ^ cubeCase ) ); // edge 15 vertFlags[5] = 0x04 == ( 0x04 & ( ( cubeCase >> 1 ) ^ cubeCase ) ); // edge 23 vertFlags[6] = 0x04 == ( 0x04 & ( ( cubeCase >> 4 ) ^ cubeCase ) ); // edge 26 vertFlags[7] = 0x08 == ( 0x08 & ( ( cubeCase >> 4 ) ^ cubeCase ) ); // edge 37 vertFlags[8] = 0x10 == ( 0x10 & ( ( cubeCase >> 1 ) ^ cubeCase ) ); // edge 45 vertFlags[9] = 0x10 == ( 0x10 & ( ( cubeCase >> 2 ) ^ cubeCase ) ); // edge 46 vertFlags[10] = 0x20 == ( 0x20 & ( ( cubeCase >> 2 ) ^ cubeCase ) ); // edge 57 vertFlags[11] = 0x40 == ( 0x40 & ( ( cubeCase >> 1 ) ^ cubeCase ) ); // edge 67 } // void get_required_vert_flags( unsigned char cubeCase, char * vertFlags ) const; /** * Using all the previous cube cases and vertex base indices, this constructs the list of vertices needed by * the given cube case. */ static void fill_verts( boost::uint8_t cubeCase, boost::int32_t vertBase, boost::uint8_t prevCubeCaseX, boost::uint8_t prevCubeCaseY, boost::uint8_t prevCubeCaseZ, boost::uint8_t prevCubeCaseXY, boost::uint8_t prevCubeCaseXZ, boost::uint8_t prevCubeCaseYZ, boost::int32_t prevVertBaseX, boost::int32_t prevVertBaseY, boost::int32_t prevVertBaseZ, boost::int32_t prevVertBaseXY, boost::int32_t prevVertBaseXZ, boost::int32_t prevVertBaseYZ, std::vector& outVerts ) { using frantic::graphics::vector3; outVerts.resize( 12 ); // Edges -,46,26 vector3 prevVertsX = get_new_verts( prevCubeCaseX, prevVertBaseX ); // Edges 45,-,15 vector3 prevVertsY = get_new_verts( prevCubeCaseY, prevVertBaseY ); // Edges 23,13,- vector3 prevVertsZ = get_new_verts( prevCubeCaseZ, prevVertBaseZ ); // Edges -,-,04 vector3 prevVertsXY = get_new_verts( prevCubeCaseXY, prevVertBaseXY ); // Edges -,02,- vector3 prevVertsXZ = get_new_verts( prevCubeCaseXZ, prevVertBaseXZ ); // Edges 01,-,- vector3 prevVertsYZ = get_new_verts( prevCubeCaseYZ, prevVertBaseYZ ); // Edges 67,57,37 vector3 newVerts = get_new_verts( cubeCase, vertBase ); // Edges 01,02,04, 13,15,23, 26,37,45, 46,57,67 outVerts[0] = prevVertsYZ.x; outVerts[1] = prevVertsXZ.y; outVerts[2] = prevVertsXY.z; outVerts[3] = prevVertsZ.y; outVerts[4] = prevVertsY.z; outVerts[5] = prevVertsZ.x; outVerts[6] = prevVertsX.z; outVerts[7] = newVerts.z; outVerts[8] = prevVertsY.x; outVerts[9] = prevVertsX.y; outVerts[10] = newVerts.y; outVerts[11] = newVerts.x; } }; } // namespace volumetrics } // namespace frantic