Repository navigation
Flat: contour-parallel offset passes, area by area, with arc entries (#38) - #359
Conversation
The passes run outside in, so the stock still to cut lies inward of each ring: outer loops now run clockwise and holes counter-clockwise, putting that stock on the right of travel (climb with a clockwise spindle). Before, the outer-loop-CCW orientation of pocket walls made most flat cutting conventional (stepped part: 40 mm climb against 199 mm conventional). refit_arcs also refits runs that mix straight chords with micro-arcs on one circle (the island part's 258 sub-0.01 mm cuts at Z5), and straight stubs under ARC_MOVE_SAGITTA are absorbed into a straight neighbour (the corner grid-snap stubs). Island 899 -> 644 motions, stepped 451 -> 449.
|
The doubled stepped part (48 × 32 mm, 4 mm tool, 1.5 mm stepover, zero radial allowance) reproduced the reported refusal. A six-vertex mixed boundary independently reproduced the false overlap. The geometry regression accepts monotone adjacent straight edges and still rejects a true backtrack. A second stepped fixture exposed a debug assertion in the arc library when it subtracted overlapping sweeps individually. Flat now subtracts all capsules of a retained ring together through the existing bounded integer kernel. It keeps narrow unswept floor available to later passes. The independent checks follow the actual arc/helix and measure coverage against finite arcs. All 17 flat-offset tests passed locally on Linux with debug assertions. The release benchmark on the revised code matched every committed flat expectation: 197 moves, 3 plunges, 38.895 s tangent cycle and zero certain overcut. |
Closes #38. The CAD floor-boundary input and optional final wall pass are tracked in #371.
Flatnow finishes each level with contour-parallel offset passes instead of raster rows. Every pass keeps the exact per-facet proof the rows had, and no entry plunges into stock.What changes
Passes
stepover_mm, 2·stepover_mm, ... are the passes, cut outside in, with climb milling (outer loops CW, hole loops CCW).dropped_length_mm.Entries (in this order; nothing is ever plunged into stock)
RampEntryangle above the stock, a straight leg at that angle, and an arc of the tool radius onto the pass. The stock is never met steeper than the declared angle, and the whole descent starts at most four tool radii back. Where the cells beside a wall are too tall to ramp along the pass, the arc ramp comes down beside the pass start on its open side, followed by a level arc lead-in. A closed loop with no room at its start is entered the same way at the middle of a straight side, and the loop starts and ends there.Every plunge that ends on a finished face stops one radius high and turns to horizontal on a quarter circle, so it leaves no plunge mark. Each chain ends with a tangent quarter-circle lead-out where its end is clear.
API and report
radial_stock_to_leave_mm(default 0): the radial stock left on the walls. Passes stay that much farther than the cutter radius from everything standing above a flat. This is a stock declaration, not a switch.axisis still accepted so old jobs load, but it no longer orders anything and is unused.loops,rows(loops cut, counting the open pieces of a split loop),links_at_depth,arc_lead_ins,arc_lead_outs,rounded_plungesandarc_ramps(also counted inramped_entries).Existing tests changed
python/tests/test_flat.py: only the stock in the two ramp tests. Their blank had exactly the part's footprint, so every open side was air outside the stock. The new side and arc lead-ins enter there, and the tests stopped exercising a ramp. The stock now extends 10 mm beyond the part, so the chains still have to ramp:roughed()takes amarginargument: the blank is (24 + 2m) × (16 + 2m), shifted by (−m, −m). The 3-degree ramp test usesroughed(margin=10).test_a_ramp_that_does_not_fit_is_refused_not_plungeduses aStockSpec((-10, -10, 0), (34, 26, 8), 0.25)for both of its simulations.The asserts and the expected refusal messages are unchanged.
New tests
python/tests/test_flat_offset.pychecks the output against the part geometry and the stock, independently of the planner:Measured
macOS arm64, release. Only the
flatworkload changes, and every other workload matches its expectations.bench/expectations/flat.jsonis updated withbench/expectations.pyin a separate commit.flat(flats)Possible overcut. The upper bound rises from 24.40 to 48.00 mm³ because the last ring now runs tangent to the boss wall, so the cells on both sides of the wall face count as possible overcut. Main stops its rows about 0.005 mm short of the wall and leaves a 0.1 mm rim there (the 0.95 mm³ certain leftover, now 0). It is a cell-resolution bound with no definite cells. All 256 cells lie on the boss wall's cell band, and the bound halves with the cell size: 24.00 mm³ at 0.125 mm, 12.00 at 0.0625 mm (main: 11.81, 5.86). A separate check sampled every feed move every 0.01 mm against the exact box geometry. No cut move enters the part, and the closest approach is 0.0011 mm off the boss wall (main: 0.0051 mm).
Limits and costs
Checks run
cargo fmt --checkand ruff (check and format) are clean. clippy shows only the 2src/surface/spline_bounds.rslints from the local toolchain, which this branch doesn't touch and which main also shows. Both examples export with--accept-unchecked-machine, and without it each refuses in a fresh directory and writes no NC file.