OpenCAMLib machining simulation, v.2

This is my second attempt at a machining simulation where a moving milling tool cuts away voxels from the stock material. To save space an octree data structure is used to store the voxels, and to produce a nice looking surface you store the signed distance to the exact surface in each vertex of the octree. You then use marching-cubes to extract triangles for a distance=0 isosurface in order to draw the stock.

Unlike my first attempt, this works well enough to warrant further experiments (on the to-do list are: differently shaped tools, colouring triangles based on which tool cut the voxel, lathe operations, material removal-rate, etc.). It should be straightforward to hook this up to the EMC2 G-code interpreter so that any G-code, not just densely sampled CL-points from OCL, can be simulated. You could also flip the sign of all the numbers, and simulate an additive process, like 3D printing (reprap / makerbot).

This approach to machining simulation is described in a 2005 paper by Yau, Tsou, and Tong.

Links - 2010 Aug 12

Octree with Marching Cubes

Update 3: this leads slowly towards a better and faster cutting simulation. Here's an example with Tux:

Update2: this looks slightly better now (a ball translated in a few steps towards the right). Image and c++ code by fellow OCLer Jiang from China.

Update: in a cutting simulation the stock is updated by removing voxels which fall inside the cutter. Here I'm trying it with a spherical shape positioned at (0,0), and then moved slightly along the X-axis. The white dots are corners of octree nodes, and the cyan triangles are produced by marching cubes. It works quite well, but on the border between the two cutter instances the distance-field is somehow wrong, and marching-cubes doesn't come up with the right triangles, leaving gaps instead.

Earlier I was building an octree volume-representation of a shape using a simple bool isInside(Point p) predicate function to determine which cubes are in and which are out. If instead a distance-function double distance(Point p) which is negative inside the volume, zero exactly on the surface, and positive outside, is used, then the Marching Cubes algorithm (this is a better explanation, someone should make the wikipedia page as good!) can be used to triangulate the octree. This leads to much more visually pleasing results at reasonable maximum tree-depths.

The same Hong-Tzong Yau of Taiwan who wrote a very reasonable drop-cutter paper in 2004 has more recently come out with a 2009 paper on cutting simulation using an octree and Marching Cubes.


The weave point-order problem

weave_input_output

When creating waterlines or 2D offsets using a "sampling" or "CL-point based" approach the result is a grid or weave such as that shown in black above. The black lines can in principle be unevenly spaced, and don't necessarily have to be aligned with the X/Y-axis. The desired output of the operation is shown in red/orage, i.e. a loop around/inside this weave/grid, which connects all the "loose ends" of the graph.

My first approach was to start at any CL-vertex and do a breadth_first_search from there to find the closest neighboring vertices. If there are many candidates equally close you then need to decide where to jump forward, and do the next breadth_first_search. This is not very efficient, since breadth_first_search runs a lot of times (you could stop the search at a depth or 5-6 to make it faster).

The other idea I had was some kind of 'surface tension', or edge removal/relaxation where you would start at an arbitrary point deep inside the black portion of the graph and work your way to the outside as far as possible to find the output. I haven't implemented this so I'm not sure if it will work.

What's the best/fastest way of finding the output? Comments ?!

Update: I am now solving this by first creating a planar embedding of the graph and then running planar_face_traversal with a visitor that records in which order the CL-points were visited. The initial results look good:

tux_waterlines

tux_offsets

Faster waterlines with OpenMP

This example has three times more fibers, and thus also CL-points, than the original one, but it still runs in a reasonable time of ~15s because (1) I hard-coded the matrix-determinant expressions everywhere instead of relying on a slow general purpose function and (2) the batch-processing of the fibers now uses OpenMP in order to put all those multi-cores to work.

(red=vertex contacts, green=facet contacts, blue=edge contacts)

My initial point-ordering scheme based on a complete breadth-first-search at each CL-point is a bit naive and slow (that's not included in the 15s time), so that still needs more work.

2010 Finnish MicroMagic Open

22 skippers with guests from RUS, SWE, and NED, in addition to FIN skippers came to this two-day event in Espoo. For me it was a non-event since I don't own the smaller MicroMagic rigs that were required during the first day with steady 7-8m/s and up to 11-12m/s of wind in the gusts.

At times you hear voices out there who mutter that the IOM sort of "fails" as a one-design because there isn't a minimum fin thickness, and the minimum weight is so low it is really difficult to DIY build a competitive boat on your own kitchen table. In contrast, the MicroMagic seems to do a reasonably good job of "pure one-design" with the hull and appendages, although people do play around with combinations of MkI and MkII fins and rudders.

But compared to the IOM, the MicroMagic rigs are a completely wild jungle! Although the biggest no1 (or should we call it "A"?) rig is limited to the stock size sails which come with the kit, there are little or no limitations on the smaller rigs. When there is this much freedom, people are bound to explore the design envelope, and unlike a pure one-design where everyone has the same equipment it will take some experience, time, and money to converge on rig designs for the smaller sails which are competitive. People seemed to use either no2 or no3 rigs yesterday, and I photographed some of them below. The top NED and SWE boats led the field along with FIN-111 who had obviously invested in the right kind of carbon-sticks, ball-bearing thingys, and sails. It looks like it is advantageous to get both the main and jib booms as close to the deck as possible.

All of this leads to a slight illusion then when you gladly advise the newcomer that the class is cheap and uncomplicated, "you get the kit for 170eur and you are done", when in fact the competitive people swap out fins and rudders right away, and spend 4-500 euros on a set of the latest carbon-ballbearing-super-mainsail-roach-rigs. Anyone with more experience in the MicroMagic class care to comment?