Here's an example of what I've been working toward. Until now I've been printing out vectors and spot checking to try to get the basic algorithm working. I trapped most of the issues and now have drawn out the results for some tool path segments.

I implemented it poorly, and instead of adding all line segments to a Shape and then showing that, I iterated my edge-returns taking forever if I select many segments. Calculations for all tool path segments shown takes about 7-8 seconds. Showing the edge added 10 seconds, and is only an iterative step. Attached are two images--only difference that one is wire-frame, showing the Mesh edges explicityly.

- MeshParsing000.png (110.51 KiB) Viewed 207 times

- MeshParsing001.png (307.21 KiB) Viewed 207 times

The basic idea I've mentioned previously. determine intersection points of all facet edges with planes generated tangent to the tool path segments, and typically for many CNC vertical with the Z axis.

- The red line-segments lie in the plane formed with tool path Edge14.

Each resulted from the calculation of the intersection point geometric LINE and PLANE.

Mesh.Facets were iterated, and the 3 Points used to form 3 line-segments, the Facet edges.

Each Facet edge lies in a LINE. The LINE is either Parallel to, or Intersects with the PLANE at some point.

If Parallel, the LINE is either in the PLANE, or disjointed.

Exclusions cases must ignore all results where both points are beyond the tool tip radius, or above where above, below, beyond the tool path plus tool tip radius, etc...

Facet edges that approach the PLANE within the tool tip radius along the PLANE normal vector but don't intersect are trimmed to where that offset distance is met.

The tool tip radial offset is used with the tip type for squaremill, ballmill, or chamfer.

These are Interference line segments. Easier to see with a ZOOM in here:

- MeshParsing002.png (265.23 KiB) Viewed 207 times

They are stored in a sorted list of tuples, along with their linear sort length from the Start Point of the tool path segment. Conceptually, the goal is to create a slot around each tool path line segment and account for any facet intersection with that slot. With all those points sorted, the result loses no detail in the Mesh. Lots of small lines where a PLANE crosses a fillet or spheroid. All Facets are sampled.

What I haven't done yet, is generate the "envelope" function to generate a wire that follows the upper-most line-segments, ignoring bottom. These don't represent lines that must all be milled--each line-segment represents a minimum allowable z-depth as the tool tip passes that portion of the plane. I also have to bound cases where only one point of the interference line lies within the tool radius to the PLANE. Among other things... But, I think it's promising.

While I'm focusing on this for zig-zag, z-axis milling, it's not entirely tied to that.

--With regard to tool path pattern, any linear pattern is efficient for parsing a mesh this way. It's also possible to invert this and treat each Facet as a PLANE, and find the bounds of intersection of that with tool path planes. I'm not sure if it makes a difference.

--With regard to z-axis, at the moment, I've tied it that way, but there's no additional burden to shifting the PLANE--defined by a Point and a normal vector--to any arbitrary "slice" angle--allowing calculation of arbitrary tool-angle/work-angle.