@rulecad/printcheck 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,15 +19,21 @@ triangulated.
19
19
  What it checks:
20
20
 
21
21
  - **Fits the bed** (`bed`, mm) and **sits on it**: lowest point at z = 0, with faces flat on the bed.
22
- - **Overhangs** steeper than `overhang` degrees from vertical.
22
+ - **Overhangs** steeper than `overhang` degrees from vertical (with half a degree to spare: a boolean tips a 45°
23
+ chamfer by hundredths of a degree).
24
+ - **Inside out**: a mesh whose faces all point inwards (corners running clockwise seen from outside) fails as that,
25
+ before anything else is read from it.
23
26
  - **Flat undersides above the bed**: each must start on something. Either it rests on a built-in **breakaway support**
24
27
  (one `support_gap` below a surface), or it **bridges** no wider than `bridge` mm. The bridge is the widest circle that
25
28
  fits in the underside, measured to the edges held up by material below. An underside held by nothing starts in
26
- mid-air. One held on one side only, further out than a print line, is a **ledge**: nothing bridges it, each line
27
- is laid past the last in the air, and it droops (slant its underside in at 45° to the wall instead).
29
+ mid-air. One held on one side only (its supports all within a half turn of it, and a little), further out than a
30
+ print line, is a **ledge**: nothing bridges it, each line is laid past the last in the air, and it droops (slant its
31
+ underside in at 45° to the wall instead). What lies within a breakaway gap or two layers of the bed, or of a
32
+ surface below it, rests on it. Undersides within a layer of each other are one height; what starts in mid-air
33
+ and what hangs as a ledge is said once per height, with how many and the worst, and where.
28
34
  Each underside is taken on its own (the faces at a height joined where they touch), and an edge is held wherever
29
35
  it lies along the top edge of a wall below (booleans leave T-junctions; they don't matter). An underside no wider
30
- than a print line (`line`, 0.4 mm unless given) anywhere is a step of a slope printed in layers, or a sliver the
36
+ than a print line (`line`, 0.42 mm unless given) anywhere is a step of a slope printed in layers, or a sliver the
31
37
  slicer lays nothing on, and is not counted.
32
38
  - **The first layer**: two parts printed in place must stand `print_gap` plus twice `foot` apart on the bed (`foot`
33
39
  is how far the first layer spreads each side as it is squashed on: elephant's foot); nearer, they print as one.
@@ -45,6 +51,10 @@ What it checks:
45
51
  misses a tip like this, because each of its faces may slope at 45° or less. A shallow dip in a smoothed underside
46
52
  spreads wide, so it doesn't count.
47
53
 
54
+ The layer checks (islands, the first layer, overhang as sliced) are the slow part, seconds on a curved part:
55
+ `check(triangles, printer, { slice: false })` leaves them out and says so (`print.unsliced`), for a page that shows
56
+ a part at once and slices it off its own thread (the viewer does).
57
+
48
58
  Several parts printed together (a keycap with an inlaid legend in another colour): pass
49
59
  `{ parts: [{ triangles, role }] }`. Then one part resting on another isn't an overhang, and each part must be closed on
50
60
  its own. A part with `role: 'support'` is printed and then removed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulecad/printcheck",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Is this mesh printable? Bed fit, flat base, overhangs, bridges, breakaway supports and watertightness, for any FDM printer.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,6 +30,10 @@
30
30
  "url": "git+https://github.com/JoniBach/rulecad.git",
31
31
  "directory": "packages/printcheck"
32
32
  },
33
+ "homepage": "https://github.com/JoniBach/rulecad/tree/main/packages/printcheck#readme",
34
+ "bugs": {
35
+ "url": "https://github.com/JoniBach/rulecad/issues"
36
+ },
33
37
  "scripts": {
34
38
  "test": "node --test"
35
39
  },
package/printcheck.d.mts CHANGED
@@ -8,8 +8,8 @@
8
8
  /** @typedef {{ bed: number, overhang: number, layer?: number, support_gap?: number, bridge?: number, line?: number, print_gap?: number, foot?: number }} Printer mm and degrees; layer and line drive the sliced-layer island check; print_gap and foot (how far the first layer spreads each side) the first-layer check */
9
9
  /**
10
10
  * A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
11
- * it is when that's known (the box round the faces it's about, in mm).
12
- * @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
11
+ * it is when that's known: at, a point (the middle of it), and box, the box round the faces it's about, in mm.
12
+ * @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: number[], box?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
13
13
  */
14
14
  export function bounds(polys: any): {
15
15
  lo: number[];
@@ -23,7 +23,7 @@ export function bounds(polys: any): {
23
23
  * @param {{ eps?: number, parts?: { triangles: Face[], role?: 'part' | 'support' }[] }} [options]
24
24
  * @returns {Finding[]}
25
25
  */
26
- export function check(polys: Face[], printer: Printer, { eps, parts }?: {
26
+ export function check(polys: Face[], printer: Printer, { eps, parts, slice }?: {
27
27
  eps?: number;
28
28
  parts?: {
29
29
  triangles: Face[];
@@ -105,14 +105,15 @@ export type Printer = {
105
105
  };
106
106
  /**
107
107
  * A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
108
- * it is when that's known (the box round the faces it's about, in mm).
108
+ * it is when that's known: at, a point (the middle of it), and box, the box round the faces it's about, in mm.
109
109
  */
110
110
  export type Finding = {
111
111
  level: "pass" | "warn" | "fail" | "info";
112
112
  text: string;
113
113
  code?: string;
114
114
  values?: Record<string, any>;
115
- at?: {
115
+ at?: number[];
116
+ box?: {
116
117
  lo: number[];
117
118
  hi: number[];
118
119
  };
package/printcheck.mjs CHANGED
@@ -20,6 +20,8 @@ function areaNormal(poly) {
20
20
  }
21
21
 
22
22
  const OVERHANG_SLACK = 0.5; // degrees
23
+ const LINE = 0.42; // mm: the line width when the printer gives none (a 0.4 mm nozzle's usual line)
24
+ const LEDGE_SLACK = (15 * Math.PI) / 180; // a point's supports all within a half turn and this: a ledge
23
25
 
24
26
  /**
25
27
  * The box around faces.
@@ -31,8 +33,8 @@ const OVERHANG_SLACK = 0.5; // degrees
31
33
  /** @typedef {{ bed: number, overhang: number, layer?: number, support_gap?: number, bridge?: number, line?: number, print_gap?: number, foot?: number }} Printer mm and degrees; layer and line drive the sliced-layer island check; print_gap and foot (how far the first layer spreads each side) the first-layer check */
32
34
  /**
33
35
  * A finding: its level and words, and for programs a code (print.bridge, fit.gap, …), the numbers behind it, and where
34
- * it is when that's known (the box round the faces it's about, in mm).
35
- * @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
36
+ * it is when that's known: at, a point (the middle of it), and box, the box round the faces it's about, in mm.
37
+ * @typedef {{ level: 'pass' | 'warn' | 'fail' | 'info', text: string, code?: string, values?: Record<string, any>, at?: number[], box?: { lo: number[], hi: number[] }, refs?: Record<string, any> }} Finding
36
38
  */
37
39
 
38
40
  export function bounds(polys) {
@@ -51,8 +53,9 @@ export function bounds(polys) {
51
53
  * @param {{ eps?: number, parts?: { triangles: Face[], role?: 'part' | 'support' }[] }} [options]
52
54
  * @returns {Finding[]}
53
55
  */
54
- export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
55
- const out = [], f = (level, text, code, values, at) => out.push({ level, text, code, ...(values && { values }), ...(at && { at }) });
56
+ export function check(polys, printer, { eps = 1e-3, parts = null, slice = true } = {}) {
57
+ // (a finding's at is a point, the middle of where it is; box is the box round it: one shape across the kit)
58
+ const out = [], f = (level, text, code, values, box) => out.push({ level, text, code, ...(values && { values }), ...(box && Number.isFinite(box.lo?.[0]) ? { at: box.lo.map((x, k) => (x + box.hi[k]) / 2), box } : {}) });
56
59
  // What can't be checked is said at the door, not found out deep inside
57
60
  for (const k of ['bed', 'overhang']) if (!(Number(printer?.[k]) > 0)) throw new Error(`check(model, printer): the printer's "${k}" is needed, a number above 0 (got ${JSON.stringify(printer?.[k])}): { bed: 256, overhang: 45, layer: 0.2 }`);
58
61
  for (const k of ['layer', 'line', 'bridge', 'support_gap']) if (printer[k] != null && !(Number(printer[k]) > 0)) throw new Error(`check(model, printer): the printer's "${k}" must be a number above 0 (got ${JSON.stringify(printer[k])})`);
@@ -79,6 +82,13 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
79
82
  const over = size.filter((s) => s > printer.bed);
80
83
  f(over.length ? 'fail' : 'pass', `${size.map(mm).join(' × ')} mm${over.length ? `: bigger than the ${printer.bed} mm bed` : ', fits the bed'}`, 'print.bed', { size, bed: printer.bed });
81
84
 
85
+ // Faces the wrong way round: a closed solid's faces all point out, so the volume they enclose (signed, by the way
86
+ // their corners run) is positive. Negative, every face points in, and nothing below reads right (the base faces up,
87
+ // the top faces down): say that, not what follows from it
88
+ let signed = 0;
89
+ for (const p of polys) for (let i = 1; i < p.length - 1; i++) { const [a, b, c] = [p[0], p[i], p[i + 1]]; signed += (a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0])) / 6; }
90
+ if (signed < -eps) { f('fail', `the faces point inwards (their corners run clockwise seen from outside): the solid is inside out. Reverse every face's corners, or the exporter's winding`, 'print.inside-out', { volume: signed }); return out; }
91
+
82
92
  // Flat on the bed: the lowest point is z = 0, and faces there point straight down.
83
93
  let base = 0, down = 0, support = 0, zs = [];
84
94
  // Where a finding is: the box round the faces it's about, { lo, hi } (for a reader to point at)
@@ -118,10 +128,18 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
118
128
  return true;
119
129
  };
120
130
  const centroid = (p) => [0, 1].map((k) => p.reduce((s, v) => s + v[k], 0) / p.length);
121
- const held = flatDown.filter((d) => flatUp.some((u) => d.z - u.z > eps && d.z - u.z <= gap * 1.5 + eps && inside(centroid(d.p), u.p)));
131
+ // (a breakaway gap, or two layers: a part printed in place rests on what is two layers under it as it does on the bed)
132
+ const nearBed = Math.max(gap * 1.5, 2 * (printer.layer ?? 0.2));
133
+ const held = flatDown.filter((d) => flatUp.some((u) => d.z - u.z > eps && d.z - u.z <= nearBed + eps && inside(centroid(d.p), u.p)));
122
134
  if (held.length) f('pass', `${mm(held.reduce((s, d) => s + d.area, 0))} mm² rests on a breakaway support (${mm(gap)} mm gap): snip it off after printing`, 'print.breakaway', { area: held.reduce((s, d) => s + d.area, 0), gap });
135
+ // And the bed is a support too: an underside within a breakaway gap of it (a smoothed base's facets a hair up) is
136
+ // squashed on to it with the first layer, not printed in the air
137
+ const onBed = flatDown.filter((d) => !held.includes(d) && d.z - lo[2] <= nearBed + eps);
138
+ if (onBed.length) f('pass', `${mm(onBed.reduce((s, d) => s + d.area, 0))} mm² lies within ${mm(nearBed)} mm of the bed: laid down with the first layers`, 'print.bed-near', { area: onBed.reduce((s, d) => s + d.area, 0) });
123
139
  const levels = new Map();
124
- for (const d of flatDown) if (!held.includes(d)) { const k = d.z.toFixed(2); levels.set(k, [...(levels.get(k) || []), d.p]); }
140
+ // (undersides within a layer of each other are one height: a smoothed surface's facets sit a hair apart)
141
+ const layerH = printer.layer ?? 0.2;
142
+ for (const d of flatDown) if (!held.includes(d) && !onBed.includes(d)) { const k = (Math.round(d.z / layerH) * layerH).toFixed(2); levels.set(k, [...(levels.get(k) || []), d.p]); }
125
143
  // A point on a segment (in the plane), within eps; and a segment lying along another, overlapping it
126
144
  const onSeg = (pt, a, b) => { const dx = b[0] - a[0], dy = b[1] - a[1], l = dx * dx + dy * dy; if (l < eps * eps) return Math.hypot(pt[0] - a[0], pt[1] - a[1]) <= eps; const t = ((pt[0] - a[0]) * dx + (pt[1] - a[1]) * dy) / l; return t >= -eps && t <= 1 + eps && Math.hypot(pt[0] - a[0] - t * dx, pt[1] - a[1] - t * dy) <= eps; };
127
145
  const along = (a, b, c, d) => { // c–d lies on the line of a–b and overlaps it (an edge matched exactly, or by a part of it: a T-junction)
@@ -130,7 +148,7 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
130
148
  const t0 = ((c[0] - a[0]) * dx + (c[1] - a[1]) * dy) / (l * l), t1 = ((d[0] - a[0]) * dx + (d[1] - a[1]) * dy) / (l * l);
131
149
  return Math.min(t0, t1) < 1 - eps && Math.max(t0, t1) > eps;
132
150
  };
133
- const bridgeMax = printer.bridge ?? 5, line = printer.line ?? 0.4;
151
+ const bridgeMax = printer.bridge ?? 5, line = printer.line ?? LINE;
134
152
  // Each underside on its own: the faces at a level joined where they touch, edge to edge or a corner on another's
135
153
  // edge (a T-junction, which a boolean leaves plenty of). Two pockets' ceilings at one height are two bridges, each
136
154
  // measured to its own held edges, not to the other's across the part
@@ -150,21 +168,31 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
150
168
  return [...out.values()];
151
169
  };
152
170
  // The top edges of walls that reach a level from below: an underside's edge lying along one is held up there
153
- const wallsAt = (z) => polys.filter((p) => Math.min(...p.map((v) => v[2])) < z - eps).flatMap((p) => p.flatMap((a, i) => { const b = p[(i + 1) % p.length]; return Math.abs(a[2] - z) <= eps && Math.abs(b[2] - z) <= eps ? [[a, b]] : []; }));
171
+ const wallsAt = (z, tol = eps) => polys.filter((p) => Math.min(...p.map((v) => v[2])) < z - tol).flatMap((p) => p.flatMap((a, i) => { const b = p[(i + 1) % p.length]; return Math.abs(a[2] - z) <= tol && Math.abs(b[2] - z) <= tol ? [[a, b]] : []; }));
172
+ // (a smoothed surface has many small undersides at a height: what starts in mid-air and what hangs as a ledge are
173
+ // said once per height, with how many and the worst; each bridge on its own)
154
174
  for (const [z, level] of levels) {
155
- const walls = wallsAt(Number(z));
175
+ const walls = wallsAt(Number(z), layerH / 2 + eps), midAir = [], ledges = []; // (the level's faces lie within half a layer of it)
156
176
  for (const group of regions(level)) {
157
177
  const at = boxOf(group);
158
178
  if (Math.min(at.hi[0] - at.lo[0], at.hi[1] - at.lo[1]) < line - eps) continue; // a sliver narrower than a print line: the slicer lays nothing there
159
179
  if (widest(group) < line - eps) continue; // no wider than a line anywhere (a step of a slope cut in layers, a chamfer's tread): one layer's overhang, which the perimeter takes in its stride
160
180
  const held = (a, b) => walls.some(([c, d]) => along(a, b, c, d));
161
- const under = flatUp.filter((u) => Number(z) - u.z > eps && Number(z) - u.z <= gap * 1.5 + eps).map((u) => u.p); // breakaway supports' tops
162
- const measured = spans(group, held, under), span = measured?.span ?? null;
163
- if (span == null) f('warn', `an underside at z ${mm(Number(z))} starts in mid-air: needs support (or a built-in breakaway support one ${mm(gap)} mm layer below)`, 'print.mid-air', { z: Number(z) }, at);
164
- else if (measured.reach > line + eps) f('warn', `a ledge at z ${mm(Number(z))} reaches ${mm(measured.reach)} mm out past what holds it, held on one side only: it droops. Slant its underside in at 45° to the wall, or support it`, 'print.ledge', { reach: measured.reach, z: Number(z) }, at);
181
+ const under = flatUp.filter((u) => Number(z) - u.z > eps && Number(z) - u.z <= nearBed + eps).map((u) => u.p); // breakaway supports' tops, and what a part printed in place rests on
182
+ const measured = spans(group, held, under), span = measured?.span ?? null, groupArea = group.reduce((s, p) => s + Math.hypot(...areaNormal(p)) / 2, 0);
183
+ if (span == null) midAir.push({ at, area: groupArea });
184
+ else if (measured.reach > line + eps) ledges.push({ at, reach: measured.reach, where: measured.where });
165
185
  else if (span > bridgeMax + eps) f('warn', `${mm(span)} mm bridge at z ${mm(Number(z))}: wider than the ${bridgeMax} mm the printer can span, needs supports`, 'print.bridge', { span, max: bridgeMax, z: Number(z) }, at);
166
186
  else f('pass', `bridge ${mm(span)} mm at z ${mm(Number(z))} (up to ${bridgeMax} mm)`, 'print.bridge', { span, max: bridgeMax, z: Number(z) });
167
187
  }
188
+ if (midAir.length) {
189
+ const biggest = midAir.reduce((m, x) => (x.area > m.area ? x : m)), total = midAir.reduce((s, x) => s + x.area, 0);
190
+ f('warn', `${midAir.length === 1 ? 'an underside' : `${midAir.length} undersides (${mm(total)} mm²)`} at z ${mm(Number(z))} start${midAir.length === 1 ? 's' : ''} in mid-air: needs support (or a built-in breakaway support one ${mm(gap)} mm layer below)`, 'print.mid-air', { z: Number(z), count: midAir.length, area: total }, biggest.at);
191
+ }
192
+ if (ledges.length) {
193
+ const worst = ledges.reduce((m, x) => (x.reach > m.reach ? x : m));
194
+ f('warn', `${ledges.length === 1 ? 'a ledge' : `${ledges.length} ledges`} at z ${mm(Number(z))} reach${ledges.length === 1 ? 'es' : ''} ${ledges.length === 1 ? '' : 'up to '}${mm(worst.reach)} mm out past what holds ${ledges.length === 1 ? 'it' : 'them'}, held on one side only: ${ledges.length === 1 ? 'it droops' : 'they droop'}. Slant the underside in at 45° to the wall, or support it`, 'print.ledge', { reach: worst.reach, z: Number(z), count: ledges.length, where: worst.where }, worst.at);
195
+ }
168
196
  }
169
197
 
170
198
  // One piece, and nothing starting in mid-air, part by part (an assembly's parts are apart on purpose)
@@ -176,11 +204,13 @@ export function check(polys, printer, { eps = 1e-3, parts = null } = {}) {
176
204
  const hanging = tips.filter((t) => t[2] - lo[2] > eps && !rests([t, t, t]));
177
205
  if (hanging.length) f('warn', `${hanging.length === 1 ? 'a point starts' : `${hanging.length} points start`} in mid-air (z ${mm(Math.min(...hanging.map((t) => t[2])))}${hanging.length > 1 ? ` to ${mm(Math.max(...hanging.map((t) => t[2])))}` : ''} mm): the lowest points of tips hanging down, with nothing below to print on`, 'print.island', { points: hanging }, hanging.reduce((b, t) => grow(b, [t]), { lo: [Infinity, Infinity, Infinity], hi: [-Infinity, -Infinity, -Infinity] }));
178
206
  else f('pass', 'nothing starts in mid-air', 'print.island', { points: [] });
179
- // And as the slicer sees it: every layer against the one below
207
+ // And as the slicer sees it: every layer against the one below (slice: false leaves this out, the slow part: a page
208
+ // can check a part at once, then slice it off its own thread)
209
+ if (!slice) { f('info', 'not sliced: the layers are checked on their own (islands, the first layer, layer overhang)', 'print.unsliced'); continue; }
180
210
  // (the first layer spreads `foot` each side as it is squashed on to the bed: two parts printed in place must stand
181
211
  // further apart there than the gap that prints apart higher up, or they print as one)
182
212
  const firstGap = printer.foot > 0 && printer.print_gap > 0 ? printer.print_gap + 2 * printer.foot : 0;
183
- const sliced = islands(tris, { layer: printer.layer ?? 0.2, overhang: printer.overhang, line: printer.line ?? 0.42, firstGap }), isl = sliced.islands;
213
+ const sliced = islands(tris, { layer: printer.layer ?? 0.2, overhang: printer.overhang, line: printer.line ?? LINE, firstGap }), isl = sliced.islands;
184
214
  for (const x of sliced.fused) f('warn', `on the first layer, two parts are about ${mm(x.gap)} mm apart at (${mm(x.at[0])}, ${mm(x.at[1])}): the first layer spreads ${printer.foot} mm each side as it is squashed on, so under ${mm(firstGap)} mm they print as one. Keep them ${mm(firstGap)} mm apart on the bed, or lift one off it`, 'print.first-layer', { gap: x.gap, need: firstGap }, { lo: [x.at[0] - 1, x.at[1] - 1, 0], hi: [x.at[0] + 1, x.at[1] + 1, printer.layer ?? 0.2] });
185
215
  if (firstGap && !sliced.fused.length) f('pass', `on the first layer, nothing printed in place stands within ${mm(firstGap)} mm of another part (the first layer spreads ${printer.foot} mm each side)`, 'print.first-layer', { need: firstGap });
186
216
  // Overhang as the printer meets it: layers lying out past the one below, less the flat undersides the bridge check
@@ -234,7 +264,7 @@ function spans(polys, held, under) {
234
264
  return { c, d: Math.hypot(pt[0] - c[0], pt[1] - c[1]) };
235
265
  };
236
266
  const supports = [...outline, ...tops];
237
- let best = 0, reach = 0;
267
+ let best = 0, reach = 0, where = null;
238
268
  const N = 6;
239
269
  for (const p of polys) for (let i = 1; i < p.length - 1; i++) {
240
270
  const [a, b, c] = [p[0], p[i], p[i + 1]];
@@ -250,11 +280,14 @@ function spans(polys, held, under) {
250
280
  const angles = near.filter((x) => x.d > 1e-9).map((x) => Math.atan2(x.c[1] - pt[1], x.c[0] - pt[0])).sort((a, b) => a - b);
251
281
  let gap = angles.length ? angles[0] + 2 * Math.PI - angles.at(-1) : 2 * Math.PI;
252
282
  for (let k = 1; k < angles.length; k++) gap = Math.max(gap, angles[k] - angles[k - 1]);
253
- if (gap > Math.PI + 1e-6) reach = Math.max(reach, first.d);
283
+ // (a bridge between two supports nearly opposite each other, a strap from a wall to a post, leaves a gap a few
284
+ // degrees over a half turn where the post's nearest point is off its line: some slack, LEDGE_SLACK, before it
285
+ // counts as a ledge)
286
+ if (gap > Math.PI + LEDGE_SLACK && first.d > reach) { reach = first.d; where = pt; }
254
287
  }
255
288
  }
256
289
  }
257
- return { span: 2 * best, reach };
290
+ return { span: 2 * best, reach, where };
258
291
  }
259
292
 
260
293
  // seams(polys) -> { gaps, tjunctions, hairlines }: edges not matched by a reverse edge, split into T-junctions (covered
@@ -338,7 +371,7 @@ export function seams(polys, eps = 1e-3) {
338
371
  * undersides included (the bridge check judges those separately)
339
372
  */
340
373
  const SPANS = [5, 20]; // layers: the spans a lean is held over (see islands)
341
- export function islands(polys, { layer = 0.2, overhang = 45, line = 0.42, firstGap = 0, onLayer } = {}) {
374
+ export function islands(polys, { layer = 0.2, overhang = 45, line = LINE, firstGap = 0, onLayer } = {}) {
342
375
  if (!(layer > 0) || !(line > 0) || !(overhang > 0 && overhang < 90)) throw new Error(`islands: layer and line are lengths above 0 and overhang an angle between 0 and 90 (got layer ${layer}, line ${line}, overhang ${overhang})`);
343
376
  if (!polys.length) return { islands: [], layers: 0, overhang: 0 };
344
377
  // The pixel: a quarter of a line, or coarser on a big part so a layer stays under about a million pixels