Adaptive Path Drop Cutter
July 2, 2026 ยท View on GitHub
This spec defines adaptive projection of source paths onto a mesh.
Purpose
Adaptive path drop-cutter adds samples only where the projected cutter-location curve changes enough to need them. This provides smoother 3D finishing paths without globally tiny sample spacing.
Dependencies
Inputs
type AdaptivePathDropInput = {
targetSelection: CamTargetSelection;
paths: Array<{ id: string; spans: SerializedCamSpan[] }>;
cutter: CamCutter;
triangles: CamTriangle[];
driveFaceRegions?: CamFaceRegion[];
sampleSpacing: number;
minSampleSpacing: number;
flatnessCosLimit: number;
floorZ: number;
maxDepth?: number;
};
Output
Same output shape as uniform path drop-cutter, with extra summary fields:
acceptedIntervalCountsubdivisionCountmaxObservedDepth
Algorithm
Use an explicit stack rather than recursive calls.
For each span:
- Drop
pointAt(0)andpointAt(1). - Push interval
{ t0: 0, t1: 1, p0, p1, depth: 0 }. - While stack is not empty:
- Pop interval.
- Compute
tmid = (t0 + t1) / 2. - Drop
pointAt(tmid). - Compute projected chord length between
p0andp1. - Compute flatness using vectors
p0 -> pmidandpmid -> p1. - Subdivide if:
- chord length is greater than
sampleSpacing, or - not flat and chord length is greater than
minSampleSpacing.
- chord length is greater than
- Also subdivide if span parameter length is large but projected chord collapses due to steep geometry, using a source-span distance guard.
- If subdividing and
depth < maxDepth, push right then left intervals for stable output order. - Otherwise accept interval endpoint
p1.
- Emit the span start point once, then accepted endpoints in order.
Face-Selected Projection
driveFaceRegionsmay constrain which source paths are generated or accepted for finishing.- Point drops always query the full protected target mesh supplied in
triangles. - The selected face can be the intended contact surface, but the cutter must not penetrate adjacent faces or any other part of the target solid.
- If all samples for a selected face fail safety checks, return a generation error instead of a blank path.
Flatness Predicate
- Normalize vectors
p0 -> pmidandpmid -> p1. - If either vector length is below tolerance, treat as flat only if source interval length is also below tolerance.
- Flat if dot product >=
flatnessCosLimit. - Default
flatnessCosLimitshould be high, for example0.999.
Termination
Stop subdividing when any is true:
- Projected chord length <=
minSampleSpacing. - Source interval length <=
minSampleSpacing. depth >= maxDepth.
If max depth is reached while still not flat, emit warning and accept the interval to avoid hanging.
Performance
- Reuse the same triangle index for every point drop.
- Optional point cache key:
spanId + rounded(t). - Yield after a configurable number of dropped midpoint evaluations.
Progress Phases
adaptive-path-startadaptive-path-sampleadaptive-path-dropadaptive-path-complete
Detailed diagnostic phases may also be emitted:
adaptive-path-indexadaptive-path-spanadaptive-path-subdivide
Tests
- Planar horizontal path produces only endpoints when sample spacing permits.
- Sloped or curved mesh produces inserted midpoint samples.
- Smaller
flatnessCosLimitproduces fewer points than larger limit. - Max depth warning fires on a pathological non-flat fixture.
- Output point order follows source path direction.
- Face-selected projection protects the owning solid outside the selected faces.