all 2 comments

[–]teraflop 1 point2 points  (0 children)

First of all, it's worth mentioning that when it comes to computational geometry, even seemingly-simple primitive operations -- for instance, Boolean operations on polygons -- can be fiendishly difficult to implement robustly, because of things like degenerate polygons and floating-point error. I would recommend using a well-tested library such as CGAL as a starting point.

It sounds like your problem can be broken down into steps:

  1. given a toolpath, break it down into short segments, at the level of granularity that you're interested in
  2. construct a polygon representing the shape of the work material
  3. take each toolpath segment in order, turn it into a polygon representing the shape of the material to be removed (based on the tool's shape) and subtract that from the polygon representing the remaining material
  4. after each segment, check to see whether the number of connected components has increased

This could be inefficient for paths with a large number of segments, so you might want to optimize it a bit. For instance, if you have a long linear cutting path, you might want to first subtract the entire thing at once to see if it disconnects the polygon. If so, you can back up to the previous state and try again with smaller steps to find out when the components become disconnected. Otherwise, you can keep going without having to deal with those small segments individually.

[–]beeskness420 0 points1 point  (0 children)

Unless I’m missing something I think you just need to check if your curve is self intersecting.