It is also useful for visualizing the layers using the drawLayersGeneral.pde Processing sketch.
createTable() - This function saves a CSV file with info that is useful for debugging.
If 100 µm is too thick of a layer, it says, how about 95 µm? If yes, build it, if not, how about 90 µm? This goes until a layer thickess is good enough, or if we're using the thinnest layer thickness we will consider. It asks itself, given a certain maximum stepover (like 0.05 mm, which is the pixel size on the Ember projector) is the current layer thickness good enough? If it is good enough, it records this at the thickness for the first layer and moves the z-value up to 0.100 and starts the process again. It then finds the slope of all of these triangles and looks at only the lowest slope (the most horizontal). The function finds every triangle in the range of z = 0 to z = 0.100 mm. We start at the bottom (z=0) of the STL, and start with the thickest layer thickness we are considering (e.g. It selects the appropriate layer thickness one layer at a time, starting at the bottom.
buildLayers() - This is the main algorithm that determines the layer thicknesses.
This function is useful for debugging but not necessary for the overall program. The slope should always be less than 90°. The slope is equal to the angle of a Triangle's normal vector and the Z axis (either the positive or negative direction, whichever is the smaller angle).
calcSlopeHeight() - a simple calculation that iterates through an array of every Triangle object and finds the minimum and maximum slope of the entire Triangle array.
It identifies triangles (or "facets") in the STLs and saves the XYZ coordinates of each triangle's vertices in a Triangle object.
parseTheBunny() - loads the ASCII STL as an array of Strings.