Computer Graphics
CSCI 490, CSCI 630
Marching Cubes
Write a program that will implement the marching cubes algorithm.
Program
Your program should read in a 3D array of binary floating point values and
generate a PolySet as output. The coordinate system of the PolySet should
correspond to the index positions of the data, with x in the direction of
increasing columns, y in the direction of increasing rows, and z in the direction
of increasing planes. Your program should take a threshold value from the user
which will be used to generate the appropriate isosurface in the data. Your
program should also ask the user (or take as a command line argument) a flag
to determine if surface normals should be generated for each vertex in the
polyset.
Data File Format
Data files for this project will be in the following format: 3 text integers,
representing the number of columns, rows, and planes in the data set. After the
number of planes, there will be exactly one byte of whitespace. After that come
the data values in plane major, row major order. The data values are binary
values, stored in little-endian order (perfect for a PC), in standard format for a
float.
Implementation Points
It is strongly recommended that you use a table-based approach to drive the
transition from tagged voxel vertices to triangles on voxel edges.
Making a full table is extremely time consuming. For this assignment, you are
only required to handle the 102 cases needed to represent spheres of arbitrary
radii.
A suggested implementation order is
NIU – CSCI 490/630
1 of 2
Read in the data set and store it in memory.
Print out the data as a check of input, and also to give you some
infrastructure for stepping through the array.
Step through the array, computing how the vertices of each voxel compare
with the threshold (+ and -) Pick a pattern of + and – and generate the
polygons necessary for that type of voxel.
As you complete a particular type of voxel, your program should be able to
generate partial solutions. Just add new voxel types one at a time until your
program can generate a full solution
Save normal generation for last.
Below is a list of functions (not required) that may make life easier. Argument
lists are not exclusive. Add other arguments as needed.
A function that takes the data indices of a voxel and returns the gradient at
that data point
A function that takes the data indices of the two endpoints of an edge and
returns the surface normal at the threshold point along the edge
A function that takes 3 integers (the polyset vertices) and adds a triangle
to the growing face list of vertices.
A function that takes the edge number associated with the edge of a voxel,
and the data indices of the base corner of the voxel and returns (or stores)
the x, y, z values of the threshold point along the edge.
A function that takes the data indices of edge endpoints of a voxel and
returns the interpolation parameter where the threshold occurs on