Question about the cases table of the marching cube

Hello,

There is a question regarding the cases table used in the marching cube algorithm. This file (VTK/vtkMarchingCubesTriangleCases.cxx at master · Kitware/VTK · GitHub) list all 256 cases. I’m wondering why each case contains 16 values. It looks that only the first 15 values are useful for describing the triangles, and the last value is always -1 for all cases.

Thanks!

Depending on the particular case, it’s possible to generate 0->5 triangles. The algorithm is coded so that triangles are generated (three indices at a time) until a -1 termination value is encountered. When 5 cases are generated, this is three triangles or 3x5=15 indices plus the -1 termination index for a total of 16 indices. When Bill Lorensen defined the table, he also made it a “rectangular” 2D array so it’s basically a table of 256x16 values. Due to symmetries the cases can be represented by 16 basic cases, but in order to produce watertight/manifold triangle meshes, it’s easier to index into 256 consistent cases and avoid the messiness of transforming the basic 16 cases via rotations etc.

Note that there are other algorithms in VTK that transform this case table into a different representation, for example flying edges uses a slightly more computational efficient representation of : triangle count + triangles (3 indices at a time).

1 Like