Wednesday, August 04, 2010
Applying VTEC to Slice and Dice
In which your narrator lowers the execution time of Slice and Dice by upwards 90%.
Now that I am well into designing the hand for my telepresence project, I am running into the limits on the processing speed of Slice and Dice in the design cycle. In the past, I could run the code through a good wash and brush up and reduce the execution time by 90%. That would take about a man-week that I don't want to spend. Instead, I chose to take advantage of a characteristic of the parts I design to achieve faster execution speeds.
Typically, I have been designing parts that look somewhat like this.
When you look at it closely, you notice that there are really only two different cross sections through the vertical axis.
Now Slice and Dice as I wrote it is not particularly bright code. I wrote it to be simple, not efficient. When you slice this object into 0.25 mm wafers you get 39 slices that look something like this.
Slice and Dice tediously processes each slice as if it were unique. I took a day off to see if I could take advantage of the geometric repetitiveness of my parts. To do that I initially thought to simply match each image with succeeding image and throw out the duplicates.
Life wasn't quite that simple. While the slices looked identical, miniscule differences in the way the slicing routine interacted with triangles showed up in the flooded pictures seen above. I did find, however, that if I allowed flaws in the pixels of up to 0.2% of the total in the flooded images the 39 images were reduced to exactly 2...
Which is what you would have expected if the slicing had been geometrically perfect. Thus I had to do cpu intensive processing on two slices instead of 39. That saved about 94% of the processing time that I had previously been using and got my processing speed into the range I was used to seeing with Skeinforge.
As an added advantage, the reduction routine picks up broken slices very nicely.
This approach would not, I think, work with a programme like Skeinforge or, unless I misunderstand how it works, Netfabb. It could, however, easily be applied to Adrian's host code for Reprap.