3D Tool path generation

I needed for a project to create a parallel finishing tool path similar what many CAM software does. There is nothing wrong with existing CAM software but what fun would be to just buy and use the software.

The basic idea is that you can use a swipe plane across the mesh representing your volume and get the top part of each slice to be the tool path. A similar idea is used for 3D printing, but there the swipe plane is an horizontal one and object is built from the bottom up.

The problem is that you cannot use the slice you just obtain from the mesh as milling bit (or extruded filament if 3D printing) has a non-null dimension. Because of that, just following the contour of the object will create a smaller result than the model.

For 2.5D milling you can do a waterline finishing, doing flat passes on XY-plane. Thus a simple polygon offsetting operation can help you get the part dimensions right. But for 3D milling, the tool compensation becomes more difficult.

The solution I opted for was to perform a mesh offsetting. Three different ideas can be used for the operation:

  1. Facets can be offset following the normal direction.  Mesh becomes full of gaps
  2. Edges can be offset following the a combination of the two normals of the two triangles sharing that edge.
  3. Vertices can be offset too. The question is that what is the better way of combining the normals of the three triangles each vertex shares. 
A quick look at the vertex normals calculation available in Meshlab gives four different methods. Before committing to code anything, a quick test would be welcome. 

I have done a simple test, that proved useful: after calculating vertex normals, I can export the file from Meshlab. Using PLY format instead of STL allows me to output each vertex's normal. If now I do some math with a script I can do the offset and test the result. 

Most time was lost due to a particular "feature" of awk in OSX. Once this was fixed I was able to offset the vertices of the mesh and prepare the correct tool path.


Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Arduino mood light