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.


Peter said...

Would you happen to have the latest source available, again? (or you could e-mail it to me, jansenpa at mcmaster /dot/ ca). Porting it from VB to C would probably lower its execution time substantially, as well. :) I had planned on doing this with the first version you sent me, but then decided to start rewriting it from scratch for the joy of figuring out how everything works on ones own. :)

well done! :)

Allan C. Ecker said...

I second the motion for a release of Slice and Dice. Judging from the screen shots and images of sliced objects it's a fine tool as-is, and doesn't need any more polish before it'd be a value to the community.

Forrest Higgs said...

I've got this new feature working as a second set of buttons. Let me meld this new approach into the regular processing stream so that it's a little smoother for a newbie to use and I'll do another release.

Give me about a week to make sure I've got the bugs out of this and then I'll upload a new version.