diff --git a/bins/index.html b/bins/index.html index b4927b6..b1583e1 100644 --- a/bins/index.html +++ b/bins/index.html @@ -1807,7 +1807,7 @@

Your drawers

instrument, not a correctness one, and it was choosing the worse number. */ const VTOL = 2e-3; -function healCsgSeams(polys) { +function healCsgSeams(polys, again) { if (!polys.length) return polys; /* ---- one vertex table for the whole soup, bucketed as it is built ---- @@ -1908,16 +1908,18 @@

Your drawers

* * Inserting can expose a further T-junction on a longer edge, hence the loop. Two * passes is the most anything here has needed; the cap is headroom, and it THROWS if - * it is ever reached with work still to do rather than quietly returning a mesh with - * holes in it. Silent partial success is the failure this project keeps rediscovering - * — earTriangulate does it, and it shipped bins with 218 boundary edges. + * it is ever reached with work still to do (after the one more go described where it + * is reached) rather than quietly returning a mesh with holes in it. Silent partial + * success is the failure this project keeps rediscovering — earTriangulate does it, + * and it shipped bins with 218 boundary edges. * * The distance tolerance is VTOL and not something tighter: the collapse above may * just have moved a vertex that far, and a weld that cannot reach it would leave the * T-junction it was meant to close. */ const PASSES = 6; - let pass = 0; + let pass = 0, put = []; // the points this pass put into edges, and the edges' ends for (; pass < PASSES; pass++) { + put = []; /* Count polygon edges, not triangle edges — a fan's diagonals always pair up inside the fan, so the two counts differ only by matched pairs. */ const use = new Map(); @@ -1976,7 +1978,8 @@

Your drawers

} if (!hits.length) continue; hits.sort((x, y) => x[0] - y[0]); - for (const [, q] of hits) grown.push(q); + for (const [, q] of hits) { grown.push(q); put.push(q); } + put.push(ia, ib); touched = true; } if (!touched) continue; @@ -1984,7 +1987,63 @@

Your drawers

} if (!changed) break; } - if (pass === PASSES) throw new Error('healCsgSeams: T-junctions still appearing after ' + PASSES + ' passes'); + /* Out of passes with the same few points still going into each other's edges. Three cut + lines that cross a face within a couple of microns of one point leave a triangle a + couple of microns on a side there. Each corner is just over VTOL from the other two, + so the collapse keeps all three, and each is within VTOL of the line through the other + two, so this loop puts one corner into the edge between the others, then a second + corner back into the edge that made, and so on for as many passes as it is given. + That was #76, a dovetail plate at 39.07 mm with a 2.34 mm counterbore: two facets of + the socket's sloped wall at the cell's corner, carried down from 5.3 mm by the cell's + tree, cross the counterbore's ceiling 2 microns from an edge of the ceiling's own, and + 40 passes do not settle it any more than 6 do. + + At that size the three corners are one point, and the collapse would have said so + had they been a hair closer: it already makes one point of two that are each within + VTOL of a third, up to two VTOL apart. So the points the last pass was still putting + in, and the ends of the edges it put them in, that lie within two VTOL of each other + become one; every vertex of the input that collapsed onto one of them goes with it; + and the repair runs once more from the start. Only here: a soup that settles inside + the passes never comes this way and is repaired exactly as before. That is nearly + every soup, but not every one. None of 1,100 random plates of every joint and mount + ran out; the turned cutters of a cell cut again do on a few engine-only cells (see + the fastener cut in buildPiece), and so does a jigsaw plate at 41.24 mm with magnets + from above and a 3.126 mm counterbore, on the first cut of both its pieces. + + The second run is kept only if it comes out closed, and that jigsaw plate is why. + The merge lets its repair settle, but open, and returned that was 55 bad edges on + each piece with Download on, where before the same pieces failed to build and the + page said so; with a 2.264 mm magnet the cut was open by four edges and the piece + came out closed but folded. So a second run that does not settle throws, as does one + that settles open, or one with nothing close enough to merge. Faces it turned over + are no reason to throw: #76 with an 8.3 mm head turns six and builds watertight, + every shell facing outwards. */ + if (pass === PASSES) { + if (!again) { + const ids = [...new Set(put)], up = new Map(ids.map((i) => [i, i])); + const top = (i) => { while (up.get(i) !== i) i = up.get(i); return i; }; + for (let x = 0; x < ids.length; x++) + for (let y = x + 1; y < ids.length; y++) { + const v = verts[ids[x]], w = verts[ids[y]]; + if (Math.hypot(v[0] - w[0], v[1] - w[1], v[2] - w[2]) > 2 * VTOL) continue; + const ra = top(ids[x]), rb = top(ids[y]); + if (ra !== rb) up.set(ra, rb); + } + const size = new Map(); + for (const i of ids) size.set(top(i), (size.get(top(i)) || 0) + 1); + const onto = new Map(); // an input vertex's id -> where it goes + for (let i = 0; i < verts.length; i++) { + const r = find(i); + if (up.has(r) && size.get(top(r)) > 1 && top(r) !== i) onto.set(i, verts[top(r)]); + } + if (onto.size) { + const res = healCsgSeams(polys.map((p) => ({ verts: p.verts.map((v) => onto.get(idOf(v)) || v), + plane: p.plane })), true); + if (!res.open) return res; // open, it fails as it did before the merge + } + } + throw new Error('healCsgSeams: T-junctions still appearing after ' + PASSES + ' passes'); + } /* Welding creates the other kind of fold. A sliver triangle D-C-B whose corners are nearly collinear really does have its third corner sitting on the opposite edge, so @@ -5155,9 +5214,14 @@

Your drawers

screw head to sit against; a nudge moves every plane off the crossing that lost the sliver. The first closed result is kept; a cell that comes out closed first time, which is nearly every one, is - built exactly as before. A try that throws (healCsgSeams' T-junction pass limit, - which the turned cutters reach on a few engine-only cells) is passed over and - the first cut stands, open as it was rather than a failed build. + built exactly as before. A try that throws is passed over and the first cut + stands, open as it was rather than a failed build. The turned cutters reach + healCsgSeams' T-junction pass limit on a few engine-only cells, and they threw + there until #76; now the repair makes one point of the few it was still + putting into edges and runs once more, so such a try can come back closed and + be kept where the nudged one after it used to be (the audit's "a retry that + throws": every piece's bytes change, and every piece is still watertight). One + whose second run comes out open still throws, and is passed over. Only a cell open by a sliver or a few is cut again, at most 24 edges: six at each of its four pockets. Cells cut again have been open by anything from 1 to diff --git a/docs/ENGINE.md b/docs/ENGINE.md index cc15ae4..4072c14 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -842,3 +842,18 @@ currently installed): a fraction of a micron from a corner and read, to `checkManifold`'s thousandths, as the face's own edges a second time (a puzzle key in the wall from beneath with magnets from above at 42 mm: four edges used four times). Such a face goes out as it is. +- **A weld that never settles is three points, not a loop.** Three cut lines that cross a + face within a couple of microns of one point leave a triangle a couple of microns on a + side there. Each corner is just over `VTOL` from the other two, so the collapse keeps all + three, and each is within `VTOL` of the line through the other two, so the T-junction + pass puts them into each other's edges in turn and never finishes: it threw at six + passes, and forty do no better. When the passes run out, `healCsgSeams` makes one point + of those the last pass was still putting in that lie within two `VTOL` of each other, + and repairs once more from the start; a soup that settles inside the passes never comes + that way. #76 was this: a dovetail plate at 39.07 mm with a 3 mm shank and a 2.34 mm + counterbore, where two facets of the socket's sloped wall at the cell's corner cross the + counterbore's ceiling 2 microns from an edge of its own. Every piece with a seam on its + left failed to build, for heads from 7.3 mm to the cap; 2.339 and 2.341 mm built. The + second run is kept only if it comes out closed: a jigsaw plate at 41.24 mm with magnets + from above settles open after the merge, and fails to build as it did before rather + than going out with holes. diff --git a/index.html b/index.html index 20920a6..2a876bf 100644 --- a/index.html +++ b/index.html @@ -1594,7 +1594,7 @@

Your drawers

instrument, not a correctness one, and it was choosing the worse number. */ const VTOL = 2e-3; -function healCsgSeams(polys) { +function healCsgSeams(polys, again) { if (!polys.length) return polys; /* ---- one vertex table for the whole soup, bucketed as it is built ---- @@ -1695,16 +1695,18 @@

Your drawers

* * Inserting can expose a further T-junction on a longer edge, hence the loop. Two * passes is the most anything here has needed; the cap is headroom, and it THROWS if - * it is ever reached with work still to do rather than quietly returning a mesh with - * holes in it. Silent partial success is the failure this project keeps rediscovering - * — earTriangulate does it, and it shipped bins with 218 boundary edges. + * it is ever reached with work still to do (after the one more go described where it + * is reached) rather than quietly returning a mesh with holes in it. Silent partial + * success is the failure this project keeps rediscovering — earTriangulate does it, + * and it shipped bins with 218 boundary edges. * * The distance tolerance is VTOL and not something tighter: the collapse above may * just have moved a vertex that far, and a weld that cannot reach it would leave the * T-junction it was meant to close. */ const PASSES = 6; - let pass = 0; + let pass = 0, put = []; // the points this pass put into edges, and the edges' ends for (; pass < PASSES; pass++) { + put = []; /* Count polygon edges, not triangle edges — a fan's diagonals always pair up inside the fan, so the two counts differ only by matched pairs. */ const use = new Map(); @@ -1763,7 +1765,8 @@

Your drawers

} if (!hits.length) continue; hits.sort((x, y) => x[0] - y[0]); - for (const [, q] of hits) grown.push(q); + for (const [, q] of hits) { grown.push(q); put.push(q); } + put.push(ia, ib); touched = true; } if (!touched) continue; @@ -1771,7 +1774,63 @@

Your drawers

} if (!changed) break; } - if (pass === PASSES) throw new Error('healCsgSeams: T-junctions still appearing after ' + PASSES + ' passes'); + /* Out of passes with the same few points still going into each other's edges. Three cut + lines that cross a face within a couple of microns of one point leave a triangle a + couple of microns on a side there. Each corner is just over VTOL from the other two, + so the collapse keeps all three, and each is within VTOL of the line through the other + two, so this loop puts one corner into the edge between the others, then a second + corner back into the edge that made, and so on for as many passes as it is given. + That was #76, a dovetail plate at 39.07 mm with a 2.34 mm counterbore: two facets of + the socket's sloped wall at the cell's corner, carried down from 5.3 mm by the cell's + tree, cross the counterbore's ceiling 2 microns from an edge of the ceiling's own, and + 40 passes do not settle it any more than 6 do. + + At that size the three corners are one point, and the collapse would have said so + had they been a hair closer: it already makes one point of two that are each within + VTOL of a third, up to two VTOL apart. So the points the last pass was still putting + in, and the ends of the edges it put them in, that lie within two VTOL of each other + become one; every vertex of the input that collapsed onto one of them goes with it; + and the repair runs once more from the start. Only here: a soup that settles inside + the passes never comes this way and is repaired exactly as before. That is nearly + every soup, but not every one. None of 1,100 random plates of every joint and mount + ran out; the turned cutters of a cell cut again do on a few engine-only cells (see + the fastener cut in buildPiece), and so does a jigsaw plate at 41.24 mm with magnets + from above and a 3.126 mm counterbore, on the first cut of both its pieces. + + The second run is kept only if it comes out closed, and that jigsaw plate is why. + The merge lets its repair settle, but open, and returned that was 55 bad edges on + each piece with Download on, where before the same pieces failed to build and the + page said so; with a 2.264 mm magnet the cut was open by four edges and the piece + came out closed but folded. So a second run that does not settle throws, as does one + that settles open, or one with nothing close enough to merge. Faces it turned over + are no reason to throw: #76 with an 8.3 mm head turns six and builds watertight, + every shell facing outwards. */ + if (pass === PASSES) { + if (!again) { + const ids = [...new Set(put)], up = new Map(ids.map((i) => [i, i])); + const top = (i) => { while (up.get(i) !== i) i = up.get(i); return i; }; + for (let x = 0; x < ids.length; x++) + for (let y = x + 1; y < ids.length; y++) { + const v = verts[ids[x]], w = verts[ids[y]]; + if (Math.hypot(v[0] - w[0], v[1] - w[1], v[2] - w[2]) > 2 * VTOL) continue; + const ra = top(ids[x]), rb = top(ids[y]); + if (ra !== rb) up.set(ra, rb); + } + const size = new Map(); + for (const i of ids) size.set(top(i), (size.get(top(i)) || 0) + 1); + const onto = new Map(); // an input vertex's id -> where it goes + for (let i = 0; i < verts.length; i++) { + const r = find(i); + if (up.has(r) && size.get(top(r)) > 1 && top(r) !== i) onto.set(i, verts[top(r)]); + } + if (onto.size) { + const res = healCsgSeams(polys.map((p) => ({ verts: p.verts.map((v) => onto.get(idOf(v)) || v), + plane: p.plane })), true); + if (!res.open) return res; // open, it fails as it did before the merge + } + } + throw new Error('healCsgSeams: T-junctions still appearing after ' + PASSES + ' passes'); + } /* Welding creates the other kind of fold. A sliver triangle D-C-B whose corners are nearly collinear really does have its third corner sitting on the opposite edge, so @@ -4942,9 +5001,14 @@

Your drawers

screw head to sit against; a nudge moves every plane off the crossing that lost the sliver. The first closed result is kept; a cell that comes out closed first time, which is nearly every one, is - built exactly as before. A try that throws (healCsgSeams' T-junction pass limit, - which the turned cutters reach on a few engine-only cells) is passed over and - the first cut stands, open as it was rather than a failed build. + built exactly as before. A try that throws is passed over and the first cut + stands, open as it was rather than a failed build. The turned cutters reach + healCsgSeams' T-junction pass limit on a few engine-only cells, and they threw + there until #76; now the repair makes one point of the few it was still + putting into edges and runs once more, so such a try can come back closed and + be kept where the nudged one after it used to be (the audit's "a retry that + throws": every piece's bytes change, and every piece is still watertight). One + whose second run comes out open still throws, and is passed over. Only a cell open by a sliver or a few is cut again, at most 24 edges: six at each of its four pockets. Cells cut again have been open by anything from 1 to @@ -7993,6 +8057,19 @@

Your drawers

// nothing below can — every check after this one is reasoning about the clamped value for (const msg of fieldErrors.values()) out.push({ err: true, stop: true, t: msg }); for (const msg of noRoom.values()) out.push({ err: true, stop: true, t: msg }); + /* A piece the engine threw on. runBuild stops there, and the piece table, the preview and + the Download button's tooltip said so, but the checks, which are where a design is read + for what is wrong with it, said nothing: #76's B1 left Download off with no reason + under the cut map. Drawn as an error but not flagged `err`, which would stop the next + build as well, and the next build, on any change, is what clears it. It says Download + is off, not that nothing can be downloaded: the pieces built before it keep their own + STL buttons in the piece table. And it promises no size that gets past it: the 41.24 mm + jigsaw plate in plate-audit.js fails with a 7.504 mm head and builds with holes at + 7.502 mm, on main as well. */ + if (buildFailed) + out.push({ failed: true, t: `Piece ${buildFailed} could not be built, so the build stopped ` + + 'there and Download is off. That is a fault in this tool, not in the design; moving a cut ' + + 'through the piece or picking another joint may get past it.' }); if (layout.nx * layout.ny > MAX_CELLS) out.push({ err: true, stop: true, t: `A ${layout.nx} × ${layout.ny} grid is ` + `${layout.nx * layout.ny} cells, past the ${MAX_CELLS} this tool will build in one ` + @@ -8144,7 +8221,7 @@

Your drawers

const hasErrors = () => warningsList().some(w => w.err); function drawWarnings() { const ws = warningsList(); - $('warnings').innerHTML = ws.map(w => `
${w.t}
`).join(''); + $('warnings').innerHTML = ws.map(w => `
${w.t}
`).join(''); /* The Download button stops being the primary action when there is nothing behind it. It was enabled through all of this: type -50 into the drawer width and the page said "resolve the errors above to generate" and offered you the download in the diff --git a/src/core.js b/src/core.js index 944947a..fbbb341 100644 --- a/src/core.js +++ b/src/core.js @@ -201,7 +201,7 @@ class BspNode { instrument, not a correctness one, and it was choosing the worse number. */ const VTOL = 2e-3; -function healCsgSeams(polys) { +function healCsgSeams(polys, again) { if (!polys.length) return polys; /* ---- one vertex table for the whole soup, bucketed as it is built ---- @@ -302,16 +302,18 @@ function healCsgSeams(polys) { * * Inserting can expose a further T-junction on a longer edge, hence the loop. Two * passes is the most anything here has needed; the cap is headroom, and it THROWS if - * it is ever reached with work still to do rather than quietly returning a mesh with - * holes in it. Silent partial success is the failure this project keeps rediscovering - * — earTriangulate does it, and it shipped bins with 218 boundary edges. + * it is ever reached with work still to do (after the one more go described where it + * is reached) rather than quietly returning a mesh with holes in it. Silent partial + * success is the failure this project keeps rediscovering — earTriangulate does it, + * and it shipped bins with 218 boundary edges. * * The distance tolerance is VTOL and not something tighter: the collapse above may * just have moved a vertex that far, and a weld that cannot reach it would leave the * T-junction it was meant to close. */ const PASSES = 6; - let pass = 0; + let pass = 0, put = []; // the points this pass put into edges, and the edges' ends for (; pass < PASSES; pass++) { + put = []; /* Count polygon edges, not triangle edges — a fan's diagonals always pair up inside the fan, so the two counts differ only by matched pairs. */ const use = new Map(); @@ -370,7 +372,8 @@ function healCsgSeams(polys) { } if (!hits.length) continue; hits.sort((x, y) => x[0] - y[0]); - for (const [, q] of hits) grown.push(q); + for (const [, q] of hits) { grown.push(q); put.push(q); } + put.push(ia, ib); touched = true; } if (!touched) continue; @@ -378,7 +381,63 @@ function healCsgSeams(polys) { } if (!changed) break; } - if (pass === PASSES) throw new Error('healCsgSeams: T-junctions still appearing after ' + PASSES + ' passes'); + /* Out of passes with the same few points still going into each other's edges. Three cut + lines that cross a face within a couple of microns of one point leave a triangle a + couple of microns on a side there. Each corner is just over VTOL from the other two, + so the collapse keeps all three, and each is within VTOL of the line through the other + two, so this loop puts one corner into the edge between the others, then a second + corner back into the edge that made, and so on for as many passes as it is given. + That was #76, a dovetail plate at 39.07 mm with a 2.34 mm counterbore: two facets of + the socket's sloped wall at the cell's corner, carried down from 5.3 mm by the cell's + tree, cross the counterbore's ceiling 2 microns from an edge of the ceiling's own, and + 40 passes do not settle it any more than 6 do. + + At that size the three corners are one point, and the collapse would have said so + had they been a hair closer: it already makes one point of two that are each within + VTOL of a third, up to two VTOL apart. So the points the last pass was still putting + in, and the ends of the edges it put them in, that lie within two VTOL of each other + become one; every vertex of the input that collapsed onto one of them goes with it; + and the repair runs once more from the start. Only here: a soup that settles inside + the passes never comes this way and is repaired exactly as before. That is nearly + every soup, but not every one. None of 1,100 random plates of every joint and mount + ran out; the turned cutters of a cell cut again do on a few engine-only cells (see + the fastener cut in buildPiece), and so does a jigsaw plate at 41.24 mm with magnets + from above and a 3.126 mm counterbore, on the first cut of both its pieces. + + The second run is kept only if it comes out closed, and that jigsaw plate is why. + The merge lets its repair settle, but open, and returned that was 55 bad edges on + each piece with Download on, where before the same pieces failed to build and the + page said so; with a 2.264 mm magnet the cut was open by four edges and the piece + came out closed but folded. So a second run that does not settle throws, as does one + that settles open, or one with nothing close enough to merge. Faces it turned over + are no reason to throw: #76 with an 8.3 mm head turns six and builds watertight, + every shell facing outwards. */ + if (pass === PASSES) { + if (!again) { + const ids = [...new Set(put)], up = new Map(ids.map((i) => [i, i])); + const top = (i) => { while (up.get(i) !== i) i = up.get(i); return i; }; + for (let x = 0; x < ids.length; x++) + for (let y = x + 1; y < ids.length; y++) { + const v = verts[ids[x]], w = verts[ids[y]]; + if (Math.hypot(v[0] - w[0], v[1] - w[1], v[2] - w[2]) > 2 * VTOL) continue; + const ra = top(ids[x]), rb = top(ids[y]); + if (ra !== rb) up.set(ra, rb); + } + const size = new Map(); + for (const i of ids) size.set(top(i), (size.get(top(i)) || 0) + 1); + const onto = new Map(); // an input vertex's id -> where it goes + for (let i = 0; i < verts.length; i++) { + const r = find(i); + if (up.has(r) && size.get(top(r)) > 1 && top(r) !== i) onto.set(i, verts[top(r)]); + } + if (onto.size) { + const res = healCsgSeams(polys.map((p) => ({ verts: p.verts.map((v) => onto.get(idOf(v)) || v), + plane: p.plane })), true); + if (!res.open) return res; // open, it fails as it did before the merge + } + } + throw new Error('healCsgSeams: T-junctions still appearing after ' + PASSES + ' passes'); + } /* Welding creates the other kind of fold. A sliver triangle D-C-B whose corners are nearly collinear really does have its third corner sitting on the opposite edge, so @@ -3549,9 +3608,14 @@ function buildPiece(cfg, layout, piece, onStatus) { screw head to sit against; a nudge moves every plane off the crossing that lost the sliver. The first closed result is kept; a cell that comes out closed first time, which is nearly every one, is - built exactly as before. A try that throws (healCsgSeams' T-junction pass limit, - which the turned cutters reach on a few engine-only cells) is passed over and - the first cut stands, open as it was rather than a failed build. + built exactly as before. A try that throws is passed over and the first cut + stands, open as it was rather than a failed build. The turned cutters reach + healCsgSeams' T-junction pass limit on a few engine-only cells, and they threw + there until #76; now the repair makes one point of the few it was still + putting into edges and runs once more, so such a try can come back closed and + be kept where the nudged one after it used to be (the audit's "a retry that + throws": every piece's bytes change, and every piece is still watertight). One + whose second run comes out open still throws, and is passed over. Only a cell open by a sliver or a few is cut again, at most 24 edges: six at each of its four pockets. Cells cut again have been open by anything from 1 to diff --git a/src/ui.js b/src/ui.js index 21d5ab1..23ac4d9 100644 --- a/src/ui.js +++ b/src/ui.js @@ -518,6 +518,19 @@ function warningsList() { // nothing below can — every check after this one is reasoning about the clamped value for (const msg of fieldErrors.values()) out.push({ err: true, stop: true, t: msg }); for (const msg of noRoom.values()) out.push({ err: true, stop: true, t: msg }); + /* A piece the engine threw on. runBuild stops there, and the piece table, the preview and + the Download button's tooltip said so, but the checks, which are where a design is read + for what is wrong with it, said nothing: #76's B1 left Download off with no reason + under the cut map. Drawn as an error but not flagged `err`, which would stop the next + build as well, and the next build, on any change, is what clears it. It says Download + is off, not that nothing can be downloaded: the pieces built before it keep their own + STL buttons in the piece table. And it promises no size that gets past it: the 41.24 mm + jigsaw plate in plate-audit.js fails with a 7.504 mm head and builds with holes at + 7.502 mm, on main as well. */ + if (buildFailed) + out.push({ failed: true, t: `Piece ${buildFailed} could not be built, so the build stopped ` + + 'there and Download is off. That is a fault in this tool, not in the design; moving a cut ' + + 'through the piece or picking another joint may get past it.' }); if (layout.nx * layout.ny > MAX_CELLS) out.push({ err: true, stop: true, t: `A ${layout.nx} × ${layout.ny} grid is ` + `${layout.nx * layout.ny} cells, past the ${MAX_CELLS} this tool will build in one ` + @@ -669,7 +682,7 @@ function warningsList() { const hasErrors = () => warningsList().some(w => w.err); function drawWarnings() { const ws = warningsList(); - $('warnings').innerHTML = ws.map(w => `
${w.t}
`).join(''); + $('warnings').innerHTML = ws.map(w => `
${w.t}
`).join(''); /* The Download button stops being the primary action when there is nothing behind it. It was enabled through all of this: type -50 into the drawer width and the page said "resolve the errors above to generate" and offered you the download in the diff --git a/sw.js b/sw.js index 3af8f97..487f1bf 100644 --- a/sw.js +++ b/sw.js @@ -52,7 +52,7 @@ load from this site, and the app's icons and manifest, as paths from the root. VERSION is a hash of all of those files, names and bytes, and of this script as it is served, FILES filled in and everything else but VERSION itself. */ -const VERSION = "d4d7bc3b8d8c"; +const VERSION = "87e3541175b2"; const FILES = [ "./", "bins/", diff --git a/test/plate-audit.js b/test/plate-audit.js index ba25df4..70873cf 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -327,11 +327,16 @@ const CASES = [ tab: { ...G.DEFAULTS.tab, clr: 0.98 }, puzzle: { ...G.DEFAULTS.puzzle, clr: 0.98 }, key: { ...G.DEFAULTS.key, clr: 0.93 }, hclip: { ...G.DEFAULTS.hclip, clr: 0.93 } }, /* A cell whose pockets come out open is cut again (see the fastener cut in buildPiece), - and here the turned cutters' cut throws: healCsgSeams' T-junction pass limit. Taken - unguarded, that one try made the whole plate fail to build, where main builds it open. - The throw is passed over, and the cutters nudged 1.7 microns, the try after it, close - every cell left open here (3 to 9 edges a piece; main has 9 and folds on every piece). - Engine-only again: the sites 2.5 mm in, at 15.5 mm. */ + and here the turned cutters' cut reaches healCsgSeams' T-junction pass limit, ten + times over the five pieces. Taken unguarded, that one try made the whole plate fail to + build, where main builds it open. Until #76 it threw there: the throw was passed over, + and the cutters nudged 1.7 microns, the try after it, closed every cell left open here + (3 to 9 edges a piece; main has 9 and folds on every piece). Now the repair makes one + point of those it was still putting into edges and settles, closed, so the turned try + is kept itself: every piece's bytes change, and every piece is still watertight and + oriented. So the row is named for what it was found as: it no longer reaches the catch + that passes over a try that throws, and no row here does. Engine-only again: the + sites 2.5 mm in, at 15.5 mm. */ { name: 'a retry that throws', pitch: 15.5, drawerW: 3 * 15.5, drawerD: 5 * 15.5, bedW: 400, bedD: 400, splitMode: 'manual', rowCuts: [1, 2], colCuts: [[], [], [1, 2]], connector: 'snap', keyType: 'snap', keyInsert: 'top', magnets: true, screws: true, @@ -1437,6 +1442,72 @@ function sectionArea(polys, z, dy) { return area; } +/* #76: a counterbore whose ceiling three cut lines cross at one point. + * + * At 39.07 mm, with a dovetail joint, a 3 mm shank and a counterbore 2.34 mm deep, every + * piece with a seam on its left threw in healCsgSeams and was never built: B1 on the page's + * two-piece plate, B1 to D1 on a four-piece one. Two facets of the socket's sloped wall at + * the cell's corner, carried down by the cell's tree, cross the counterbore's ceiling about + * 2 microns from an edge of the ceiling's own, and the weld's T-junction pass flipped + * between the three corners of the triangle that leaves until it ran out of passes. It + * was a point and not a band: 2.339 and 2.341 mm built, as did 39.06 and 39.08 mm, a + * 2.5 or 3.4 mm shank, and heads up to 7.2 mm; from 7.3 mm to the 9.4 cap every head threw. + * The repair now makes one point of the three and runs again (see healCsgSeams). So the + * plate as filed, the other drawer the issue names, three seams, the smallest head that + * threw and the cap, and the step either side in depth and pitch: every piece built, + * watertight, and with every shell facing outwards. The last is asked as well as the edge + * count because a merge can close a hole with a fold. + * + * And where the merge does not help. A jigsaw plate at 41.24 mm, with magnets from above + * and a counterbore 3.126 mm deep under a 7.504 mm head, runs out of passes on the first + * cut of both its pieces, and threw there before the merge. The merge lets that repair + * settle, but open; kept as it came, the page built both pieces with 55 bad edges and + * Download on, and with the magnet 2.264 mm deep, closed but folded twice, with NaN normals + * in the STL. A second run that comes out open throws now, so the plate fails to build, as + * it did before, and the checks say so. These two rows are built as the page builds them + * (its clearances and margins), and hold "threw in the seam repair, or watertight and + * oriented": whatever builds them later has to build them whole. */ +console.log('\na counterbore whose ceiling three cut lines cross at one point (#76):'); +{ + const PLATE = { pitch: 39.07, drawerW: 170, drawerD: 90, bedW: 100, bedD: 400, marginMode: 'auto', + connector: 'dovetail', screws: true, screwHoleD: 3, screwHeadDepth: 2.34, screwHeadD: 8 }; + const ROWS = [ + ['as filed: B1 threw', {}], + ['164 mm wide: B1 threw', { drawerW: 164 }], + ['three seams: B1, C1, D1 threw', { drawerW: 280 }], + ['7.3 mm head, the smallest that threw', { screwHeadD: 7.3 }], + ['9.4 mm head, the cap', { screwHeadD: 9.4 }], + ['7.2 mm head', { screwHeadD: 7.2 }], + ['2.33 mm deep', { screwHeadDepth: 2.33 }], + ['2.35 mm deep', { screwHeadDepth: 2.35 }], + ['39.06 mm', { pitch: 39.06 }], + ['39.08 mm', { pitch: 39.08 }], + ]; + const build = (over) => { + let r = null, err = null; + try { r = buildAll(over); } catch (e) { err = e.message; } + const turned = r ? r.pieces.map(checkOrientation).filter((o) => !o.ok) : []; + const text = err ? `THREW: ${err}` : `${r.pieces.length} pieces, ${leakText(r)}, ` + + (turned.length ? `${turned.length} pieces: ${orientationNote(turned[0])}` : 'oriented'); + return { r, err, whole: r && !r.bad && !turned.length, text }; + }; + for (const [label, over] of ROWS) { + const b = build({ ...PLATE, ...over }); + console.log(` ${label.padEnd(38)} ${b.text}`); + if (!b.whole) bad++; + } + const JIGSAW = { pitch: 41.24, drawerW: 84.79, drawerD: 60.96, bedW: 53.61, bedD: 400, marginMode: 'auto', + connector: 'puzzle', clr: 0.2, screws: true, screwHoleD: 3, screwHeadDepth: 3.126, + screwHeadD: 7.504, magnets: true, magnetSide: 'top', magnetD: 7.3, magnetH: 2.25 }; + for (const [label, over] of [['41.24 mm jigsaw: 55 bad edges a piece', {}], + ['2.264 mm magnet: folded twice', { magnetH: 2.264 }]]) { + const b = build({ ...JIGSAW, ...over }); + const held = b.whole || /^healCsgSeams/.test(b.err || ''); + console.log(` ${label.padEnd(38)} ${b.text}${held ? '' : ' NEITHER THREW NOR BUILT WHOLE'}`); + if (!held) bad++; + } +} + /* A margin of any width beside a corner, square or rounded. * * A margin is a region of its own, cut from the plate's outline beside the cells it runs diff --git a/test/ui/plates-robustness.spec.js b/test/ui/plates-robustness.spec.js index 0e8ea58..7ee84cf 100644 --- a/test/ui/plates-robustness.spec.js +++ b/test/ui/plates-robustness.spec.js @@ -491,7 +491,13 @@ test.describe('the clearance ceiling is the joint\'s and the pitch\'s', () => { }); }); -test('a failed build says so in the table and the dialog, and Download goes off', +/* The checks name the piece as well (#76). The table, the preview and Download's tooltip + said so already, but the list under the cut map, where a design is read for what is + wrong with it, was empty, so Download was off with no reason given there. The failure is + forced rather than taken from a design that fails, which would tie this test to an engine + bug a later fix should remove: #76's plate builds now (below), and the 41.24 mm jigsaw + plate in plate-audit.js still fails in the seam repair, as it does on main. */ +test('a failed build says so in the checks, the table and the dialog, and Download goes off', async ({ page }) => { const pageErrors = []; page.on('pageerror', (e) => pageErrors.push(String(e))); @@ -516,8 +522,13 @@ test('a failed build says so in the table and the dialog, and Download goes off' zipOff: document.querySelector('#exFiles [data-ex="zip"]').disabled, off: document.getElementById('openExport').disabled, failed: buildFailed, + checks: [...document.querySelectorAll('#warnings .w.err')].map((w) => w.textContent), })); expect(s.tail).toMatch(new RegExp(`build failed at piece ${s.failed}`)); + expect(s.checks.join(' '), 'the checks name the piece that failed') + .toMatch(new RegExp(`Piece ${s.failed} could not be built`)); + // Download, not every file: the pieces built before it keep their own STL buttons + expect(s.checks.join(' ')).toMatch(/Download is off/); expect(s.rows).toMatch(/failed/); expect(s.fit).toMatch(new RegExp(`Piece ${s.failed} could not be built`)); expect(s.zipOff).toBe(true); @@ -530,6 +541,20 @@ test('a failed build says so in the table and the dialog, and Download goes off' await page.waitForFunction(() => /ready/.test(document.getElementById('pieceTail').textContent), null, { timeout: 30000 }); expect(await exportOff(page)).toBe(false); + expect(await text(page, 'warnings')).not.toMatch(/could not be built/); + }); + +/* #76: B1 of this plate threw in the engine's seam repair (healCsgSeams), so only A1 was + ever listed and Download stayed off. At 2.33 or 2.35 mm it built; plate-audit.js has the + rows either side. */ +test('#76: the 39.07 mm dovetail plate with a 2.34 mm counterbore builds both pieces', + async ({ page }) => { + const errors = await openAt(page, '#pi=39.07&w=170&d=90&bw=100&bd=400&cn=dovetail&sc=1&sh=3&se=2.34&sd=8', + 60000); + expect(await text(page, 'pieceTail')).toMatch(/2 ready/); + expect(await text(page, 'warnings')).not.toMatch(/could not be built/); + expect(await exportOff(page)).toBe(false); + expect(errors).toEqual([]); }); /* ---- #20: spacing on the print plate ---------------------------------------------- */