QCAD - 2D CAD System.
Please search for existing tasks (also closed ones) before opening a new task.
FS#805 - Create tool radius compensation / tool path generation
Opened by Matthias Melcher (matthiaswm) - Friday, 03 May 2013, 23:45 GMT+1
This is how I would implement this:
This would be a modification tool. Parts are selected, a toolpath is generated, and a dialog pops up to allow putting the tool path into an existing layer, a new layer, or replace all drawings in an existing layer.
This is how the toolpath is generated:
We iterate through all elements and explode everything but text into line segments. Then we connect the line segments into chains wherever the line endpoints are less than some tolerance away from each other. The chains can be very chaotic, but at least we have separate entities for now.
For every chain, we need to find the largest complete loop. A good drawing would only contain non-overlapping loops, but we can’t expect that. Everything that is not on this loop can not be defined as a part or as a hole, so we will merely create a tool path segment that is equivalent to the line segment. Every segment that *IS* on a loop is either an outside edge (part outline), or an inside edge (hole outline), (or overlapping, in which case it is neither, and we have an operator problem).
In a perfect world, we need to find exactly which shape is inside which other shape, and then create alternating tool offsets from the outmost loop (part edge) to the second outmost (hole), to the next (part) etc. .
In a simplified world, we can used the bounding box of the loop instead. This works OK for rectangular shapes, but a circle next to an “L” shape could be seen as inside the L’s bounding box, hence inside the L, wrongly accused of being a hole, not a part.
Now all that is left to do is to create a new loop, offset by the tool radius. Oh, and since we have the connections from line segment to line segment in the correct order already, we can use the opportunity to order all cutting loops from inner to outer, or from small to large, and order non-loop edges by travel distance.
The new drawing in the new layer can now be exported without further hassle to create a nice laser cut file.
PS: of course, a user could create multiple layers for marking, cutting, enraging, etc. . Additional Layer attributes for cutting speed and laser power (and a few more) would be needed.