fix: drop glare holes before the margin and never auto-pick specks

Filtering holes after the margin let -2 mm grow 1 mm specks past the
3 mm cutoff, and could drop real holes shrunk by a positive margin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
immortaly007andClaude Opus 5.5 committed 2026-10-15 15:07:16 +02:00
1 parent abef0f982b
commit 41baa25a01
7 files changed
+59 -25

No files matched your search

+3 -14
View File
@@ -53,20 +53,9 @@ describe('prepareForExport', () => {
expect(mm.outer).toHaveLength(4);
});
it('drops holes smaller than 3 mm in both directions (glare/speckle)', () => {
const shapePx = {
outer: denseSquare(0, 0, 400),
holes: [denseSquare(100, 100, 8), denseSquare(200, 200, 40)], // 2 mm and 10 mm at 4 px/mm
};
const mm = prepareForExport(shapePx, 4)!;
expect(mm.holes).toHaveLength(1);
expect(shapeSize({ outer: mm.holes[0], holes: [] }).width).toBeCloseTo(10);
});
it('keeps a long thin hole that is under 3 mm in only one direction', () => {
const slot: Point[] = [{ x: 100, y: 100 }, { x: 300, y: 100 }, { x: 300, y: 104 }, { x: 100, y: 104 }];
const mm = prepareForExport({ outer: denseSquare(0, 0, 400), holes: [slot] }, 4)!;
expect(mm.holes).toHaveLength(1);
it('keeps every hole, however small (speck filtering happens before the margin)', () => {
const shapePx = { outer: denseSquare(0, 0, 400), holes: [denseSquare(100, 100, 8), denseSquare(200, 200, 40)] };
expect(prepareForExport(shapePx, 4)!.holes).toHaveLength(2);
});
it('returns null when the outer ring degenerates', () => {