//****************************************************************************** // (above is 80 chars long) // VoxLimitMCACornerConnections.cpp // // This file contains a 256 entry table each of which is a list of eight bytes. // Each of the 256 table entries represents one case of the Limit MCA. // Each of the eight list entries represents one of the corners of that case. // The N'th bit of those bytes flags whether the corresponding corner is // connected to the corner corresponding to the byte as a whole by a triangle // edge after Limit MCA triangulation. // // Notes: // // Copyright (C) 2000 by Andrew H. Cox. All rights reserved worldwide. // #if defined(_MSC_VER) //#pragma warning( disable : 4786 ) #endif // defined(_MSC_VER) #include "Util/UtilBitOps.h" #include "VoxConfig.h" #include "VoxLimitMCATable.h" namespace Vox_1F9D { namespace vox = Vox_1F9D; using Util_E26EF::bit_ops::set_bit; //using Util_E26EF::bit_ops::clear_bit; extern unsigned char g_limitMCA_connections[256][8]; //****************************************************************************** // triangles_to_corner_connections() // VOX_NEVER_INLINE_CALL(void, triangles_to_corner_connections, (const unsigned char src[256][16], unsigned char dst[256][8])){ const unsigned char * tri_corner = &src[0][0u]; unsigned char * dst_corner; for(unsigned ccase = 0u; ccase < 256u; ++ccase){ tri_corner = &src[ccase][0u]; dst_corner = &dst[ccase][0u]; if(*tri_corner != LIMIT_MCA_TABLE_ENTRY_TERMINATOR){ unsigned edge_head, edge_tail; unsigned connections[8]; connections[0] = 0u; connections[1] = 0u; connections[2] = 0u; connections[3] = 0u; connections[4] = 0u; connections[5] = 0u; connections[6] = 0u; connections[7] = 0u; while (*tri_corner != LIMIT_MCA_TABLE_ENTRY_TERMINATOR){ const unsigned char* tri_start = tri_corner; // First 2 edges of triangle: edge_head = *tri_corner; for(unsigned i = 0u; i < 2u; ++i){ edge_tail = edge_head; ++tri_corner; edge_head = *tri_corner; set_bit(connections[edge_tail], edge_head); set_bit(connections[edge_head], edge_tail); } // Edge from last corner to first: edge_tail = edge_head; edge_head = *tri_start; set_bit(connections[edge_tail], edge_head); set_bit(connections[edge_head], edge_tail); ++tri_corner; VOX_DEBUG_ASSERT(tri_corner == tri_start + 3u && "Logic Error (BUG)."); } // Store out the connections to the destination table: for(unsigned i = 0u; i < 8u; ++i){ *dst_corner = static_cast (connections[i]); ++dst_corner; } } else { // Clear the corresponding entries of the destination table: for(unsigned i = 0u; i < 8u; ++i){ *dst_corner = 0u; ++dst_corner; } } } } //****************************************************************************** // Setup the table at boot time based on the hand coded cases in the limit MCA // triangulation table: struct LimitMCAConnectionsInitialiser { LimitMCAConnectionsInitialiser() { //unsigned char* dst = const_cast (&g_limitMCA_connections[0][0]); unsigned char* dst = &g_limitMCA_connections[0][0]; //triangles_to_corner_connections(g_limit_mca_table, dst); triangles_to_corner_connections(g_limit_mca_table, g_limitMCA_connections); } } g_LimitMCAConnectionsInitialiser; extern unsigned char g_limitMCA_connections[256][8] = { {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255}, {255,255,255,255,255,255,255,255} }; } // namespace Vox_1F9D