diff --git a/bins/index.html b/bins/index.html index b1583e1..b4bf8ae 100644 --- a/bins/index.html +++ b/bins/index.html @@ -3957,6 +3957,30 @@

Your drawers

corner, its inner corner rounded, never taller than BOSS_H. Named because mountLimits has to know how much room a boss leaves around its pocket. */ const BOSS_W = 12.5, BOSS_R = 3.5, BOSS_H = 2.6; +/* How tall a corner boss is built: enough for its pocket and a layer, up to BOSS_H. */ +const bossHeight = (cfg) => Math.min(BOSS_H, Math.max( + cfg.magnets ? cfg.magnetH + 0.8 : 0, + cfg.screws ? cfg.screwHeadDepth + 1.0 : 0)); + +/* The floor a joint houses itself in: keys in the floor, and the puzzle's lobes, whose + notch runs up into it. None for the rest. */ +function jointFloor(cfg) { + const keyedConn = ['bowtie', 'snap', 'puzzlekey'].includes(cfg.connector); + if (keyedConn && cfg.keyMount !== 'wall') return cfg.key.depth + 0.8; + return cfg.connector === 'puzzle' ? 2.6 : 0; +} + +/* Whether the corner bosses are built: baseMode 'bosses', and nothing under them. A boss + stands on the bed, up to 2.6 mm, with its pocket opening below it or on top of it. A + floor under the sockets, the one a joint houses itself in (2.8 mm for keys, 2.6 for the + puzzle's lobes) or one asked for, would stand round it as tall or taller: the bosses + were buried in it and their pockets with them, sealed in solid or cut short by it, and + no magnet could go in (#70). A floor is what a solid base is, so with one the plate is + built as a solid base builds it, its pockets cut into the floor and the floor grown to + suit them; a boss would only have stood inside it. */ +function cornerBosses(cfg) { + return cfg.baseMode === 'bosses' && !(cfg.bottomPad > 0) && !(jointFloor(cfg) > 0); +} /* How thick the solid floor under the sockets is: what was asked for, raised to whatever the plate is carrying needs. A pocket cut into the floor — a magnet from either side, a @@ -3969,16 +3993,13 @@

Your drawers

/* Rounded to the micron, because 2.6 + 0.2 is 2.8000000000000003 and that is not a reason to move every face of a plate that was 2.8 before. */ const under = (depth) => Math.round((depth + MOUNT_SKIN) * 1e6) / 1e6; - if ((cfg.magnets || cfg.screws) && cfg.baseMode !== 'bosses') { + if ((cfg.magnets || cfg.screws) && !cornerBosses(cfg)) { pad = Math.max(pad, cfg.magnetBase || 2.8); if (cfg.magnets) pad = Math.max(pad, under(cfg.magnetH)); if (cfg.screws && cfg.screwHeadD > cfg.screwHoleD) pad = Math.max(pad, under(cfg.screwHeadDepth)); } - const keyedConn = ['bowtie', 'snap', 'puzzlekey'].includes(cfg.connector); - if (keyedConn && cfg.keyMount !== 'wall') pad = Math.max(pad, cfg.key.depth + 0.8); - if (cfg.connector === 'puzzle') pad = Math.max(pad, 2.6); - return pad; + return Math.max(pad, jointFloor(cfg)); } /* Plastic left round a mounting cut, to whatever holds it. 1 mm rather than a token @@ -3991,6 +4012,10 @@

Your drawers

level, and how near its walls may come to any joint's cut without breaking into it. See mountLimits. */ const MOUNT_LEVEL = 0.05, MOUNT_SEAM = 0.01; +/* How far a cut is moved, 1.7 microns along each axis, when it is taken again for coming + out open or with a face turned over (cutAgain, in buildPiece). A corner boss's cut from + beneath is moved two of them along each axis, off where the cell's stands. */ +const NUDGE = 0.0017; /* How far a mounting bore about (x, y) can grow before it meets any of `segs`, as the radius of the circle through its corners: the polygon cylinder() cuts, `sides` flats with a corner at every 2πk/sides from +x. A point is in that polygon when it stands no @@ -4068,7 +4093,7 @@

Your drawers

const inCell = half - off - MOUNT_WALL; const s = half - off; // the site's distance in from the cell's edges const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL; - const bosses = cfg.baseMode === 'bosses'; + const bosses = cornerBosses(cfg); const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell; const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // a cap is given in tenths, rounded down /* A cell's four sites are 2 × holeOffset apart, 26 mm, so past a pitch of about 50 mm @@ -4090,8 +4115,10 @@

Your drawers

Measured off the solids buildPiece cuts, at the sites it cuts pockets at: whole cells only, so a housing beside a half cell or a margin is measured from the whole cell on - the other side of it, which is the only one with pockets. A corner boss is left out: - its pocket is cut in the boss, a shell of its own that no joint is cut from. + the other side of it, which is the only one with pockets. A corner boss's pocket is at + the same site, and the joint is cut out of the boss too (#70), so it counts the same + way; a pocket from above in a boss has its floor the pocket's depth under the boss's + top rather than the floor's. Issue #64: a bowtie in the floor at 42 mm, with magnets from beneath, built 12 bad edges at 7.9 mm and 19 at 10, with Download on; puzzle tabs at 36 to 40 mm built 26 @@ -4148,7 +4175,7 @@

Your drawers

plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this is a few milliseconds, on every redraw. */ const reach = Math.max(fit(top), fit(under)); - if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { + if (layout && !again && cfg.connector !== 'none' && reach > 0) { const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, for each seam it can be cut from, and the part's that goes in it: the key's half, @@ -4237,6 +4264,17 @@

Your drawers

const own = { magnetD: fit(cfg.magnetSide === 'top' ? top : under), screwHoleD: fit(top), screwHeadD: fit(under) }; // a dovetail's notch takes a pocket from beneath that breaks into it; every other cut does not const notch = cfg.connector === 'dovetail'; + /* The cuts are measured where they stand in the cells, and a corner boss's stands two + NUDGEs along each axis off that (buildPiece), up to 2·NUDGE·√2 (4.8 microns) nearer a + pocket: one MOUNT_SEAM short of the cell's cut was 0.0051 to 0.0055 mm short of an + H-clip's recess in the boss, and 0.0057 to 0.0070 of a key's in the walls. So in a + boss a pocket stops that much further off, MOUNT_SEAM short of the boss's cut as + well. Counting a design's magnet, screw hole and screw head apart, at every 0.01 mm + of pitch from 30 to 60 with the five joints that reach the bosses, it lowers 2,676 + of the 33,430 caps a joint sets (8%), all by a tenth but 6 of a dovetail's by a + hundredth, and starts a dovetail's refused sizes (`near`) a hundredth lower in 5,392 + of its 24,008. Without corner bosses nothing moves. */ + const seam = MOUNT_SEAM + (bosses ? 2 * NUDGE * Math.SQRT2 : 0); /* What the joint's cuts leave one size, as { cap, why, near }: the largest size, and what stops it: 'cut', a pocket that would break into a key's recess or a puzzle tab's notch; 'floor', one from above that leaves no layer of floor over a cut; 'level', one from @@ -4252,8 +4290,9 @@

Your drawers

let cap = Infinity, why = false; const near = []; for (const c of jointCuts) { - // a pocket from above clears a cut whose ceiling it leaves a layer of floor over - if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; + /* a pocket from above clears a cut whose ceiling it leaves a layer of floor over; in + a corner boss its floor is the pocket's depth under the boss's top */ + if (above && !(c.top + MOUNT_SKIN > (bosses ? bossHeight(cfg) : pad) - cfg.magnetH + 1e-6)) continue; /* Level within MOUNT_LEVEL, measured to the micron, so a pocket that far above the notch's ceiling and one that far below it are taken alike: 2.35 and 2.45 mm deep against a notch 2.4 mm high, which both build clean. Unrounded, 2.45 counted as @@ -4261,7 +4300,7 @@

Your drawers

const level = Math.round(Math.abs(ceiling - c.top) * 1e6) / 1e6 < MOUNT_LEVEL; const stop = above ? 'floor' : !notch ? 'cut' : level ? 'level' : 'part'; for (const s of c.sites) { - const short = fits(s.bore[sides] - MOUNT_SEAM); + const short = fits(s.bore[sides] - seam); const size = stop === 'part' ? 2 * s.body : short; if (size < cap) { cap = size; why = stop; } if (stop === 'part') near.push([short, fits(s.bore[sides])]); @@ -4479,7 +4518,7 @@

Your drawers

and bloated 0.05mm so shells overlap; slicers union overlapping shells. */ function buildPiece(cfg, layout, piece, onStatus) { const pitch = cfg.pitch, half = pitch/2; - const solidBase = cfg.baseMode !== 'bosses'; + const solidBase = !cornerBosses(cfg); // with a floor under them, bosses are a solid base const pad = platePad(cfg); const isHclip = cfg.connector === 'hclip'; const topInsert = cfg.keyInsert === 'top'; @@ -4766,13 +4805,12 @@

Your drawers

* So the cut is taken again as the pockets' is, as other trees over the same solids: * the cutters in the other order, the solid's faces in the other order, the faces * started a third and two thirds of the way round (which puts another of its planes at - * the root), the cutters moved 1.7 microns, the jitter the notch cutters already + * the root), the cutters moved 1.7 microns (NUDGE), the jitter the notch cutters already * carry, two ways, and last each cutter on its own, one after another, since two in * one cut split each other's faces and lose a sliver the same way. The first result * that is closed and has nothing turned over is kept; a cut that comes out right first * time, which is nearly every one, is built exactly as before. A try that throws is * passed over. */ - const NUDGE = 0.0017; // the cutters in a cut, each solid on its own (polygons that share a corner go together) const apart = (cut) => { const up = cut.map((_, i) => i), at = new Map(); @@ -5359,15 +5397,79 @@

Your drawers

const bossW = BOSS_W, rIn = BOSS_R; // never more than BOSS_H, so a pocket deeper than BOSS_H − MOUNT_SKIN would come out // through the top: mountLimits refuses one rather than this growing past it - const bossH = Math.min(BOSS_H, Math.max( - cfg.magnets ? cfg.magnetH + 0.8 : 0, - cfg.screws ? cfg.screwHeadDepth + 1.0 : 0)); + const bossH = bossHeight(cfg); const bossFastener = fastenerCutter(cfg, bossH - cfg.magnetH, bossH + 0.5, bossH + 0.5); + /* The joint's cuts from beneath are taken out of the bosses as well, after their + pockets: the same solids the cells are cut with. A wall key's recess, an H-clip's + and a dovetail's notch sit where four cells meet, which is where four bosses meet, + and they were cut from the cells only. The bosses stood in every one of them, the + whole housing, and the key, the clip or the other piece's tab could not go in (#70). + * + Cut as they are, a boss and the cell under it share faces, and the cut put the same + edges in both: the housing's outline on the bed, where both stand, and on the + piece's edge, where both end; and two bosses that meet on a cell's edge, as they all + do (quarantined in test/plate-audit.js), shared the housing's outline across it too. + An H-clip at 42 mm went from 40 edges used four times a piece to 59 and 68. So a + boss a housing reaches stops a BLOAT short of the piece's edge, where the cell's + rim stands in for it; the two that meet on either side of the same housing are one + solid, the pair's outline drawn whole; and the cut is moved two NUDGEs (3.4 microns) + one way along each axis, so its walls stand in the boss a hair from where they stand + in the cell. Two, because a cut is taken again a NUDGE along a diagonal when it comes + out open (cutAgain), the cell's and the boss's alike: moved one NUDGE, the boss's + could come back to where the cell's stood, or go where the cell's had gone, and a + wall puzzle key at 36.13 mm with screws and a margin had 52 more edges used four + times than the base. Two keep them a NUDGE apart or more along each axis while at + most one of the two is taken again. That is all they promise: with both taken + again, a wall square to x can stand where the cell's does (cutAgain's nudges both + go up y, so one square to y cannot), and a wall that runs along the diagonal the cut + is moved on is not moved off the cell's at all. None of that touches a boss no + housing reaches. */ + const fromBelow = [...notches, ...pnotches].map((nb) => tabNotch(cfg, nb, pad)); + if (keyKind === 'recess') + for (const bo of keyed) + if (!(plan.junction && offJunction(bo, pitch, piece))) + fromBelow.push(keySiteOps(keyKind, keyShape, keyPrm, keyClr, bo.edge, bo.e, bo.s, H).cut); + const flatBox = (polys) => { + const b = [Infinity, Infinity, -Infinity, -Infinity]; + for (const p of polys) for (const v of p.verts) { + b[0] = Math.min(b[0], v[0]); b[1] = Math.min(b[1], v[1]); + b[2] = Math.max(b[2], v[0]); b[3] = Math.max(b[3], v[1]); + } + return b; + }; + const cutBoxes = fromBelow.map(flatBox); + const cutTops = fromBelow.map((polys) => Math.max(...polys.flatMap((p) => p.verts.map((v) => v[2])))); + const meets = (a, b) => a[0] < b[2] && b[0] < a[2] && a[1] < b[3] && b[1] < a[3]; // whole cells only: a half cell has no mounting sites (see the fastener cut above) + const all = []; for (let i = 0; i < piece.nx; i++) for (let j = 0; j < piece.ny; j++) { const ccx = gx0 + i*pitch + half, ccy = gy0 + j*pitch + half; for (const sx of [-1, 1]) for (const sy of [-1, 1]) { const cxr = ccx + sx*half, cyr = ccy + sy*half; // cell corner + const box = [Math.min(cxr, cxr - sx*bossW), Math.min(cyr, cyr - sy*bossW), + Math.max(cxr, cxr - sx*bossW), Math.max(cyr, cyr - sy*bossW)]; + all.push({ ccx, ccy, sx, sy, cxr, cyr, cuts: cutBoxes.flatMap((a, k) => meets(a, box) ? [k] : []) }); + } + } + // the bosses either side of one housing, as one + const group = all.map((_, n) => n); + const root = (n) => { while (group[n] !== n) n = group[n] = group[group[n]]; return n; }; + fromBelow.forEach((_, k) => { + const reached = all.flatMap((bs, n) => bs.cuts.includes(k) ? [n] : []); + for (const n of reached.slice(1)) group[root(n)] = root(reached[0]); + }); + const arc = []; + for (let k = 1; k <= 6; k++) { + const a = k * (Math.PI/2) / 6; + arc.push([bossW - rIn + rIn*Math.cos(a), bossW - rIn + rIn*Math.sin(a)]); + } + const onEdge = (x, lim) => Math.abs(x) < 1e-6 || Math.abs(x - lim) < 1e-6; + for (let n = 0; n < all.length; n++) { + if (root(n) !== n) continue; + const { ccx, ccy, sx, sy, cxr, cyr } = all[n]; + const members = all.filter((_, m) => root(m) === n); + const ks = [...new Set(members.flatMap((bs) => bs.cuts))]; + if (!ks.length) { // quarter boss with rounded inner corner, oriented into the cell const pts = []; pts.push([0, 0], [bossW, 0], [bossW, bossW - rIn]); @@ -5378,8 +5480,108 @@

Your drawers

pts.push([0, bossW]); const world = pts.map(([u, v]) => [cxr - sx*u, cyr - sy*v]); let boss = extrudePoly(world, 0, bossH); - if (bossFastener) - boss = csgSubtract(boss, movePolys(bossFastener, ccx + sx*off, ccy + sy*off)); + /* A boss's pocket is a lottery of its own, so it is cut again (cutAgain) when it + comes out open. Default screws in one-cell pieces left 3 to 6 open edges on a + boss's underside at 22 of the 901 pitches from 34 to 60 mm that take them, and a + 9.1 mm magnet at 39.46 mm left 12 a piece; cut again, none of those leaks. Open + only: a pocket that comes out closed with a face turned over (13 more of those + pitches) has the fold unfoldFinished lays out again, and every one of those + pieces came out watertight and oriented, so it is kept as it was, as is every + pocket that comes out closed. */ + if (bossFastener) { + const pocket = movePolys(bossFastener, ccx + sx*off, ccy + sy*off); + const first = csgSubtract(boss, pocket); + boss = first.open ? cutAgain(boss, pocket, first) : first; + } + shells.push(boss); + continue; + } + /* In the boss's own frame u runs into the cell along x from its corner and v along + y, and a side on the piece's edge starts a BLOAT in. Two that meet on the cell + edge through their corner are mirror images across it: the pair's outline is the + one quarter's run back mirrored, without the edge between them. */ + const u0 = onEdge(cxr, W) ? BLOAT : 0, v0 = onEdge(cyr, D) ? BLOAT : 0; + const other = members.length === 2 ? members.find((bs) => bs !== all[n]) : null; + const pair = other && Math.abs(other.cxr - cxr) < 1e-6 && Math.abs(other.cyr - cyr) < 1e-6 && + (other.sx === sx) !== (other.sy === sy) ? (other.sx === sx ? 'v' : 'u') : null; + const solids = []; + if (pair) { + const lo = pair === 'v' ? u0 : v0; + const run = [[lo, -bossW], ...arc.slice().reverse().map(([p, q]) => [p, -q]), + [bossW, -(bossW - rIn)], [bossW, bossW - rIn], ...arc, [lo, bossW]]; + const pts = pair === 'v' ? run : run.map(([p, q]) => [q, p]); + solids.push({ outline: pts.map(([u, v]) => [cxr - sx*u, cyr - sy*v]), sites: members }); + } else { + for (const bs of members) { + const a0 = onEdge(bs.cxr, W) ? BLOAT : 0, b0 = onEdge(bs.cyr, D) ? BLOAT : 0; + const pts = [[a0, b0], [bossW, b0], [bossW, bossW - rIn], ...arc, [a0, bossW]]; + solids.push({ outline: pts.map(([u, v]) => [bs.cxr - bs.sx*u, bs.cyr - bs.sy*v]), sites: [bs] }); + } + } + /* The pockets are cut again when they come out open, as a whole boss's are (above), + or with a face turned over, as the joint's cut below is: this boss is new, with no + bytes of its own to keep. A boss cut short of the piece's edge draws their lottery + at other pitches: four one-cell pieces with dovetails, whose notches reach the + bosses from 34 to 36.4 mm, left it at 34.64 and 34.72 mm, where the whole boss had + built closed. + * + A boss whose top stands level with the ceiling of a cut that reaches it came out + open there, the cut's ceiling and its top in one plane: a dovetail's notch is + 2.4 mm tall, an H-clip's recess 2.3 and a wall key's 2.0, and a boss is its + pocket's depth and 0.8 (a magnet) or 1.0 (a screw head), up to 2.6. Level, a + boss left open edges at every pitch the cut reaches it: 4 to 13 a piece beside a + dovetail (a 1.6 mm magnet or a 1.4 mm head), 9 to 30 beside an H-clip, and 4 to + 8, 9 to 18 and 25 to 74 beside a bowtie, a snap clip and a puzzle key in the + walls; beside the dovetail, 0.01 mm off the level either way, none. So such a + boss stands MOUNT_LEVEL over the ceiling, as one with a deeper pocket does, and a + pocket from above is cut from that top. mountLimits measures it from bossHeight, + which can only refuse sooner, and a pocket from above that the cut reaches is + refused at either height. + * + Level here is not rounded to the micron, as mountLimits' is: exactly MOUNT_LEVEL + off, a boss is raised or not as the difference comes out in floating point, a + 2.25 mm one under an H-clip's 2.3 and a 2.45 mm one over a dovetail's 2.4 raised, + a 2.35 mm one under the dovetail's not. Both ways build clean. Rounded, the bosses + raised now at exactly MOUNT_LEVEL would not be, and their bytes would change: 2.25 + mm beside an H-clip, 2.05 beside a key in the walls, 2.45 beside a dovetail. */ + const level = ks.filter((k) => Math.abs(cutTops[k] - bossH) < MOUNT_LEVEL); + const top = level.length ? Math.max(...level.map((k) => cutTops[k])) + MOUNT_LEVEL : bossH; + const fastener = top === bossH ? bossFastener : fastenerCutter(cfg, top - cfg.magnetH, top + 0.5, top + 0.5); + for (const { outline, sites } of solids) { + let boss = extrudePoly(outline, 0, top); + if (fastener) { + const pockets = [].concat(...sites.map((bs) => + movePolys(fastener, bs.ccx + bs.sx*off, bs.ccy + bs.sy*off))); + boss = cutAgain(boss, pockets, csgSubtract(boss, pockets)); + } + /* cutAgain's tries are not always enough here. A wall puzzle key at 36.92 mm with + screws (a 2 mm hole, a 7.1 x 0.8 head), four cells square, kept a cut with a + face turned over in the pair of bosses by the front edge's key, of A2 and of B2, + after every try: three folds on the bed a piece, about one build in 3,600 of + bosses a joint reaches. Moved two NUDGEs the other way along y it came out + clean. So a cut that every try leaves open or turned is taken again moved two + NUDGEs the other way along one axis, then the other, then both, and the first + that comes out closed with nothing turned over is kept; if none does, the first + stands. Two NUDGEs, not more: each stands as far from the cell's walls as the + first, and none nearer the pockets (see mountLimits). A cut that comes out right + is built exactly as before. */ + const b = flatBox(boss); + const cutAt = (a, c) => ks.flatMap((k) => + meets(cutBoxes[k], b) ? movePolys(fromBelow[k], -a*sx*NUDGE, -c*sy*NUDGE) : []); + const cut = cutAt(2, 2); + if (cut.length) { + const solid = boss; + boss = cutAgain(solid, cut, csgSubtract(solid, cut)); + for (const [a, c] of [[2, -2], [-2, 2], [-2, -2]]) { + if (!boss.open && !boss.turned) break; + let again; + try { + const alt = cutAt(a, c); + again = cutAgain(solid, alt, csgSubtract(solid, alt)); + } catch (e) { continue; } // the first cut stands + if (!again.open && !again.turned) boss = again; + } + } shells.push(boss); } } @@ -6052,7 +6254,7 @@

Your drawers

if (typeof module !== 'undefined') { module.exports = { computeLayout, gridCells, halfStrips, pieceConnectors, keysMeet, jointsThatFit, buildPiece, buildTestTile, buildFitSample, jointKind, keyOutline, buildKey, puzzleShape, keyHalf, hclipPrm, snapTopClip, snapTopParts, snapTopPrm, keySiteOps, topPocketCup, snapTopPocket, build3mfXML, packPlates, optimizeForPlates, transformPolys, stlBinary, checkManifold, DEFAULTS, csgSubtract, csgUnion, extrudePoly, socketCutter, polysToTriangles, - platePad, mountLimits, pieceColumn, compositions, PLATE_RANGES, PLATE_MAX_CELLS, MOUNT_SKIN, + platePad, cornerBosses, mountLimits, pieceColumn, compositions, PLATE_RANGES, PLATE_MAX_CELLS, MOUNT_SKIN, connClrCeiling, fitClearances, PRINT_LAYER, // shared mesh primitives — also used by the bins tool makePoly, triangulateRing, earTriangulate, roundedSquareRing, roundedRectRing, clampZ, profilePrism, diff --git a/docs/ENGINE.md b/docs/ENGINE.md index 4072c14..cfbf5ea 100644 --- a/docs/ENGINE.md +++ b/docs/ENGINE.md @@ -385,6 +385,56 @@ the cell boundary instead of overlapping by `BLOAT`, so every shared face is cou twice, and no edge is ever used once. Bloating the bosses would fix it, at the cost of changing their footprint. Far better than it was (2964 and 8332), still not fixed. +Corner bosses are built only on an open underside (`cornerBosses`). A floor under the +sockets, a key housed in the floor (2.8 mm), the puzzle's lobes (2.6) or Extra floor, +stood round the 2.6 mm bosses and sealed their pockets in it (#70); with one, the plate is +built as a solid floor builds it, pockets and the floor's growth included, and Checks says +so. A joint cut from beneath where four cells meet (a wall key's recess, an H-clip's or a +dovetail's notch; the puzzle's lobes always have their floor, so no boss stands by them) +is taken out of the bosses as well as the cells, after their pockets; the bosses used to +stand in the whole housing. Cut plainly, the housing's outline went into the boss and +into the cell it shares faces with, and into both of two bosses meeting across a cell +edge: an H-clip at 42 mm went from 40 edges used four times a piece to 59 and 68. So a +boss a housing reaches stops a `BLOAT` short of the piece's edge, the two either side of +one housing are built as one solid, and the cut is moved two `NUDGE`s into its own boss, +so its walls stand off the cell's. (One `NUDGE` is not enough: a cut that comes out open +is taken again a `NUDGE` along a diagonal, the cell's and the boss's alike, and that could +put the boss's walls back on the cell's: 52 more four-use edges in a piece, on a wall +puzzle key at 36.13 mm.) That leaves fewer four-use edges than before (31 a piece for that +H-clip) and none used once. Two `NUDGE`s keep the walls a `NUDGE` apart or more along +each axis while at most one of the two cuts is taken again, and that is all they promise: +with both taken again, a wall square to x can stand where the cell's does (both of +`cutAgain`'s nudges go up y, so one square to y cannot), and a wall that runs along the +diagonal the cut is moved on is not moved off the cell's at all. A boss is its pocket's +depth and 0.8 mm (a magnet) or 1.0 (a screw head) tall, up to 2.6, and one whose top +stood level with the ceiling of the cut that reaches it (a dovetail's notch 2.4 mm, an +H-clip's recess 2.3, a wall key's 2.0) came out open there, at every pitch the cut +reaches it: 4 to 13 open edges a piece beside a dovetail (a 1.6 mm magnet or a 1.4 mm +head), 9 to 30 beside an H-clip, and 4 to 8, 9 to 18 and 25 to 74 beside a bowtie, a snap +clip and a puzzle key in the walls. Beside the dovetail, 0.01 mm off the level either way, +none did. Such a boss stands `MOUNT_LEVEL` over the ceiling, with a pocket from above +cut from that top. + +A boss's pocket is a lottery of its own: default screws in a one-cell piece left 3 to 6 +open edges on a boss's underside at 22 of the 901 pitches from 34 to 60 mm that take +them, and a 9.1 mm magnet at 39.46 mm 12 a piece, with no joint at all. So every boss's +pockets are cut again (`cutAgain`) when they come out open. A boss no housing reaches is +cut again only then, and is otherwise built byte for byte as it was: a pocket that comes +out closed with a face turned over (13 more of those pitches) has the fold +`unfoldFinished` lays out again, and every one of those pieces was watertight and +oriented. A boss a housing reaches is new, and is cut again when a pocket comes out +turned over too, as the joint's cut is; the shorter boss draws the lottery at other +pitches (34.64 and 34.72 mm, in four one-cell pieces with dovetails). + +The joint's cut in a boss is a lottery too, and `cutAgain` does not always win it: a wall +puzzle key at 36.92 mm with screws (a 2 mm hole, a 7.1 × 0.8 mm head), four cells +square, kept a cut with a face turned over in two of its four pieces after every try, +three folds on the bed a piece, about one build in 3,600 of bosses a joint reaches. So +such a cut is taken again moved two `NUDGE`s the other way along one axis, then the +other, then both, and the first that comes out clean is kept; if none does, the first +stands. Each stands as far off the cell's walls as the first, and none nearer the +pockets. + `connector: 'puzzle'` used to be listed here as the first kind, and it is **no longer open anywhere**. It is worth reading how, because it needed two unrelated fixes and the lesson generalises: **an even count and an odd count on the same case are two separate @@ -776,8 +826,11 @@ currently installed): 0.24 mm clear of the tab. 2.4 mm thick it is level, built 96 bad edges, and is refused. - **A pocket from above** meets any of them unless its floor stands a layer over the cut's ceiling. The housings a key is dropped into from above start 1.3 mm over the - socket floor and nothing reaches them, and a pocket in a corner boss is left out: the - boss is a shell of its own, and no joint is cut from it. + socket floor and nothing reaches them. + - **A pocket in a corner boss counts the same way**, since the joint is cut from the + boss too (#70), and from above its floor is measured from the boss's top: wall keys + and the dovetail reach a boss's pocket up to about 39 mm, the H-clip up to about 34.5, + and nothing at 42. A pocket that stops short of a cut stops 0.01 mm short (`MOUNT_SEAM`): the weld in `healCsgSeams` takes points `VTOL` apart for one, and a thinner wall can come out welded @@ -787,7 +840,14 @@ currently installed): that breaks in, about 0.02 mm wide and rounded out to the hundredth either side, as the field takes them: at 36 mm on the page's design 5.59, 5.6, 5.73 and 5.74 mm are refused, and 5.58, 5.61, 5.72 and 5.75 are taken. The page says so at the field and names the - sizes taken either side. Past the weld's reach there is still the + sizes taken either side. A corner boss's cut stands two `NUDGE`s along each axis off the + cell's, up to 4.8 microns nearer a pocket (one 0.01 mm short of the cell's was 0.0051 to + 0.0070 mm short of the boss's), so in a boss a pocket stops that much further off. + Counting a design's magnet, screw hole and screw head apart, at every 0.01 mm of pitch + from 30 to 60 with the five joints that reach the bosses, that lowers 2,676 of the + 33,430 caps a joint sets (8%), all by a tenth but 6 of a dovetail's by a hundredth, and + starts a dovetail's refused sizes a hundredth lower in 5,392 of its 24,008; nothing + without corner bosses moves. Past the weld's reach there is still the lottery the room cannot see, about one design in a thousand, single sizes with clean ones on either side, and it needs the pocket and the cut together: a 14.1 mm counterbore 2.4 to 3 mm deep, 0.09 mm short of a dovetail's notch at 43.17 mm, loose, diff --git a/index.html b/index.html index 2a876bf..d783bd4 100644 --- a/index.html +++ b/index.html @@ -3744,6 +3744,30 @@

Your drawers

corner, its inner corner rounded, never taller than BOSS_H. Named because mountLimits has to know how much room a boss leaves around its pocket. */ const BOSS_W = 12.5, BOSS_R = 3.5, BOSS_H = 2.6; +/* How tall a corner boss is built: enough for its pocket and a layer, up to BOSS_H. */ +const bossHeight = (cfg) => Math.min(BOSS_H, Math.max( + cfg.magnets ? cfg.magnetH + 0.8 : 0, + cfg.screws ? cfg.screwHeadDepth + 1.0 : 0)); + +/* The floor a joint houses itself in: keys in the floor, and the puzzle's lobes, whose + notch runs up into it. None for the rest. */ +function jointFloor(cfg) { + const keyedConn = ['bowtie', 'snap', 'puzzlekey'].includes(cfg.connector); + if (keyedConn && cfg.keyMount !== 'wall') return cfg.key.depth + 0.8; + return cfg.connector === 'puzzle' ? 2.6 : 0; +} + +/* Whether the corner bosses are built: baseMode 'bosses', and nothing under them. A boss + stands on the bed, up to 2.6 mm, with its pocket opening below it or on top of it. A + floor under the sockets, the one a joint houses itself in (2.8 mm for keys, 2.6 for the + puzzle's lobes) or one asked for, would stand round it as tall or taller: the bosses + were buried in it and their pockets with them, sealed in solid or cut short by it, and + no magnet could go in (#70). A floor is what a solid base is, so with one the plate is + built as a solid base builds it, its pockets cut into the floor and the floor grown to + suit them; a boss would only have stood inside it. */ +function cornerBosses(cfg) { + return cfg.baseMode === 'bosses' && !(cfg.bottomPad > 0) && !(jointFloor(cfg) > 0); +} /* How thick the solid floor under the sockets is: what was asked for, raised to whatever the plate is carrying needs. A pocket cut into the floor — a magnet from either side, a @@ -3756,16 +3780,13 @@

Your drawers

/* Rounded to the micron, because 2.6 + 0.2 is 2.8000000000000003 and that is not a reason to move every face of a plate that was 2.8 before. */ const under = (depth) => Math.round((depth + MOUNT_SKIN) * 1e6) / 1e6; - if ((cfg.magnets || cfg.screws) && cfg.baseMode !== 'bosses') { + if ((cfg.magnets || cfg.screws) && !cornerBosses(cfg)) { pad = Math.max(pad, cfg.magnetBase || 2.8); if (cfg.magnets) pad = Math.max(pad, under(cfg.magnetH)); if (cfg.screws && cfg.screwHeadD > cfg.screwHoleD) pad = Math.max(pad, under(cfg.screwHeadDepth)); } - const keyedConn = ['bowtie', 'snap', 'puzzlekey'].includes(cfg.connector); - if (keyedConn && cfg.keyMount !== 'wall') pad = Math.max(pad, cfg.key.depth + 0.8); - if (cfg.connector === 'puzzle') pad = Math.max(pad, 2.6); - return pad; + return Math.max(pad, jointFloor(cfg)); } /* Plastic left round a mounting cut, to whatever holds it. 1 mm rather than a token @@ -3778,6 +3799,10 @@

Your drawers

level, and how near its walls may come to any joint's cut without breaking into it. See mountLimits. */ const MOUNT_LEVEL = 0.05, MOUNT_SEAM = 0.01; +/* How far a cut is moved, 1.7 microns along each axis, when it is taken again for coming + out open or with a face turned over (cutAgain, in buildPiece). A corner boss's cut from + beneath is moved two of them along each axis, off where the cell's stands. */ +const NUDGE = 0.0017; /* How far a mounting bore about (x, y) can grow before it meets any of `segs`, as the radius of the circle through its corners: the polygon cylinder() cuts, `sides` flats with a corner at every 2πk/sides from +x. A point is in that polygon when it stands no @@ -3855,7 +3880,7 @@

Your drawers

const inCell = half - off - MOUNT_WALL; const s = half - off; // the site's distance in from the cell's edges const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL; - const bosses = cfg.baseMode === 'bosses'; + const bosses = cornerBosses(cfg); const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell; const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // a cap is given in tenths, rounded down /* A cell's four sites are 2 × holeOffset apart, 26 mm, so past a pitch of about 50 mm @@ -3877,8 +3902,10 @@

Your drawers

Measured off the solids buildPiece cuts, at the sites it cuts pockets at: whole cells only, so a housing beside a half cell or a margin is measured from the whole cell on - the other side of it, which is the only one with pockets. A corner boss is left out: - its pocket is cut in the boss, a shell of its own that no joint is cut from. + the other side of it, which is the only one with pockets. A corner boss's pocket is at + the same site, and the joint is cut out of the boss too (#70), so it counts the same + way; a pocket from above in a boss has its floor the pocket's depth under the boss's + top rather than the floor's. Issue #64: a bowtie in the floor at 42 mm, with magnets from beneath, built 12 bad edges at 7.9 mm and 19 at 10, with Download on; puzzle tabs at 36 to 40 mm built 26 @@ -3935,7 +3962,7 @@

Your drawers

plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this is a few milliseconds, on every redraw. */ const reach = Math.max(fit(top), fit(under)); - if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { + if (layout && !again && cfg.connector !== 'none' && reach > 0) { const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, for each seam it can be cut from, and the part's that goes in it: the key's half, @@ -4024,6 +4051,17 @@

Your drawers

const own = { magnetD: fit(cfg.magnetSide === 'top' ? top : under), screwHoleD: fit(top), screwHeadD: fit(under) }; // a dovetail's notch takes a pocket from beneath that breaks into it; every other cut does not const notch = cfg.connector === 'dovetail'; + /* The cuts are measured where they stand in the cells, and a corner boss's stands two + NUDGEs along each axis off that (buildPiece), up to 2·NUDGE·√2 (4.8 microns) nearer a + pocket: one MOUNT_SEAM short of the cell's cut was 0.0051 to 0.0055 mm short of an + H-clip's recess in the boss, and 0.0057 to 0.0070 of a key's in the walls. So in a + boss a pocket stops that much further off, MOUNT_SEAM short of the boss's cut as + well. Counting a design's magnet, screw hole and screw head apart, at every 0.01 mm + of pitch from 30 to 60 with the five joints that reach the bosses, it lowers 2,676 + of the 33,430 caps a joint sets (8%), all by a tenth but 6 of a dovetail's by a + hundredth, and starts a dovetail's refused sizes (`near`) a hundredth lower in 5,392 + of its 24,008. Without corner bosses nothing moves. */ + const seam = MOUNT_SEAM + (bosses ? 2 * NUDGE * Math.SQRT2 : 0); /* What the joint's cuts leave one size, as { cap, why, near }: the largest size, and what stops it: 'cut', a pocket that would break into a key's recess or a puzzle tab's notch; 'floor', one from above that leaves no layer of floor over a cut; 'level', one from @@ -4039,8 +4077,9 @@

Your drawers

let cap = Infinity, why = false; const near = []; for (const c of jointCuts) { - // a pocket from above clears a cut whose ceiling it leaves a layer of floor over - if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; + /* a pocket from above clears a cut whose ceiling it leaves a layer of floor over; in + a corner boss its floor is the pocket's depth under the boss's top */ + if (above && !(c.top + MOUNT_SKIN > (bosses ? bossHeight(cfg) : pad) - cfg.magnetH + 1e-6)) continue; /* Level within MOUNT_LEVEL, measured to the micron, so a pocket that far above the notch's ceiling and one that far below it are taken alike: 2.35 and 2.45 mm deep against a notch 2.4 mm high, which both build clean. Unrounded, 2.45 counted as @@ -4048,7 +4087,7 @@

Your drawers

const level = Math.round(Math.abs(ceiling - c.top) * 1e6) / 1e6 < MOUNT_LEVEL; const stop = above ? 'floor' : !notch ? 'cut' : level ? 'level' : 'part'; for (const s of c.sites) { - const short = fits(s.bore[sides] - MOUNT_SEAM); + const short = fits(s.bore[sides] - seam); const size = stop === 'part' ? 2 * s.body : short; if (size < cap) { cap = size; why = stop; } if (stop === 'part') near.push([short, fits(s.bore[sides])]); @@ -4266,7 +4305,7 @@

Your drawers

and bloated 0.05mm so shells overlap; slicers union overlapping shells. */ function buildPiece(cfg, layout, piece, onStatus) { const pitch = cfg.pitch, half = pitch/2; - const solidBase = cfg.baseMode !== 'bosses'; + const solidBase = !cornerBosses(cfg); // with a floor under them, bosses are a solid base const pad = platePad(cfg); const isHclip = cfg.connector === 'hclip'; const topInsert = cfg.keyInsert === 'top'; @@ -4553,13 +4592,12 @@

Your drawers

* So the cut is taken again as the pockets' is, as other trees over the same solids: * the cutters in the other order, the solid's faces in the other order, the faces * started a third and two thirds of the way round (which puts another of its planes at - * the root), the cutters moved 1.7 microns, the jitter the notch cutters already + * the root), the cutters moved 1.7 microns (NUDGE), the jitter the notch cutters already * carry, two ways, and last each cutter on its own, one after another, since two in * one cut split each other's faces and lose a sliver the same way. The first result * that is closed and has nothing turned over is kept; a cut that comes out right first * time, which is nearly every one, is built exactly as before. A try that throws is * passed over. */ - const NUDGE = 0.0017; // the cutters in a cut, each solid on its own (polygons that share a corner go together) const apart = (cut) => { const up = cut.map((_, i) => i), at = new Map(); @@ -5146,15 +5184,79 @@

Your drawers

const bossW = BOSS_W, rIn = BOSS_R; // never more than BOSS_H, so a pocket deeper than BOSS_H − MOUNT_SKIN would come out // through the top: mountLimits refuses one rather than this growing past it - const bossH = Math.min(BOSS_H, Math.max( - cfg.magnets ? cfg.magnetH + 0.8 : 0, - cfg.screws ? cfg.screwHeadDepth + 1.0 : 0)); + const bossH = bossHeight(cfg); const bossFastener = fastenerCutter(cfg, bossH - cfg.magnetH, bossH + 0.5, bossH + 0.5); + /* The joint's cuts from beneath are taken out of the bosses as well, after their + pockets: the same solids the cells are cut with. A wall key's recess, an H-clip's + and a dovetail's notch sit where four cells meet, which is where four bosses meet, + and they were cut from the cells only. The bosses stood in every one of them, the + whole housing, and the key, the clip or the other piece's tab could not go in (#70). + * + Cut as they are, a boss and the cell under it share faces, and the cut put the same + edges in both: the housing's outline on the bed, where both stand, and on the + piece's edge, where both end; and two bosses that meet on a cell's edge, as they all + do (quarantined in test/plate-audit.js), shared the housing's outline across it too. + An H-clip at 42 mm went from 40 edges used four times a piece to 59 and 68. So a + boss a housing reaches stops a BLOAT short of the piece's edge, where the cell's + rim stands in for it; the two that meet on either side of the same housing are one + solid, the pair's outline drawn whole; and the cut is moved two NUDGEs (3.4 microns) + one way along each axis, so its walls stand in the boss a hair from where they stand + in the cell. Two, because a cut is taken again a NUDGE along a diagonal when it comes + out open (cutAgain), the cell's and the boss's alike: moved one NUDGE, the boss's + could come back to where the cell's stood, or go where the cell's had gone, and a + wall puzzle key at 36.13 mm with screws and a margin had 52 more edges used four + times than the base. Two keep them a NUDGE apart or more along each axis while at + most one of the two is taken again. That is all they promise: with both taken + again, a wall square to x can stand where the cell's does (cutAgain's nudges both + go up y, so one square to y cannot), and a wall that runs along the diagonal the cut + is moved on is not moved off the cell's at all. None of that touches a boss no + housing reaches. */ + const fromBelow = [...notches, ...pnotches].map((nb) => tabNotch(cfg, nb, pad)); + if (keyKind === 'recess') + for (const bo of keyed) + if (!(plan.junction && offJunction(bo, pitch, piece))) + fromBelow.push(keySiteOps(keyKind, keyShape, keyPrm, keyClr, bo.edge, bo.e, bo.s, H).cut); + const flatBox = (polys) => { + const b = [Infinity, Infinity, -Infinity, -Infinity]; + for (const p of polys) for (const v of p.verts) { + b[0] = Math.min(b[0], v[0]); b[1] = Math.min(b[1], v[1]); + b[2] = Math.max(b[2], v[0]); b[3] = Math.max(b[3], v[1]); + } + return b; + }; + const cutBoxes = fromBelow.map(flatBox); + const cutTops = fromBelow.map((polys) => Math.max(...polys.flatMap((p) => p.verts.map((v) => v[2])))); + const meets = (a, b) => a[0] < b[2] && b[0] < a[2] && a[1] < b[3] && b[1] < a[3]; // whole cells only: a half cell has no mounting sites (see the fastener cut above) + const all = []; for (let i = 0; i < piece.nx; i++) for (let j = 0; j < piece.ny; j++) { const ccx = gx0 + i*pitch + half, ccy = gy0 + j*pitch + half; for (const sx of [-1, 1]) for (const sy of [-1, 1]) { const cxr = ccx + sx*half, cyr = ccy + sy*half; // cell corner + const box = [Math.min(cxr, cxr - sx*bossW), Math.min(cyr, cyr - sy*bossW), + Math.max(cxr, cxr - sx*bossW), Math.max(cyr, cyr - sy*bossW)]; + all.push({ ccx, ccy, sx, sy, cxr, cyr, cuts: cutBoxes.flatMap((a, k) => meets(a, box) ? [k] : []) }); + } + } + // the bosses either side of one housing, as one + const group = all.map((_, n) => n); + const root = (n) => { while (group[n] !== n) n = group[n] = group[group[n]]; return n; }; + fromBelow.forEach((_, k) => { + const reached = all.flatMap((bs, n) => bs.cuts.includes(k) ? [n] : []); + for (const n of reached.slice(1)) group[root(n)] = root(reached[0]); + }); + const arc = []; + for (let k = 1; k <= 6; k++) { + const a = k * (Math.PI/2) / 6; + arc.push([bossW - rIn + rIn*Math.cos(a), bossW - rIn + rIn*Math.sin(a)]); + } + const onEdge = (x, lim) => Math.abs(x) < 1e-6 || Math.abs(x - lim) < 1e-6; + for (let n = 0; n < all.length; n++) { + if (root(n) !== n) continue; + const { ccx, ccy, sx, sy, cxr, cyr } = all[n]; + const members = all.filter((_, m) => root(m) === n); + const ks = [...new Set(members.flatMap((bs) => bs.cuts))]; + if (!ks.length) { // quarter boss with rounded inner corner, oriented into the cell const pts = []; pts.push([0, 0], [bossW, 0], [bossW, bossW - rIn]); @@ -5165,8 +5267,108 @@

Your drawers

pts.push([0, bossW]); const world = pts.map(([u, v]) => [cxr - sx*u, cyr - sy*v]); let boss = extrudePoly(world, 0, bossH); - if (bossFastener) - boss = csgSubtract(boss, movePolys(bossFastener, ccx + sx*off, ccy + sy*off)); + /* A boss's pocket is a lottery of its own, so it is cut again (cutAgain) when it + comes out open. Default screws in one-cell pieces left 3 to 6 open edges on a + boss's underside at 22 of the 901 pitches from 34 to 60 mm that take them, and a + 9.1 mm magnet at 39.46 mm left 12 a piece; cut again, none of those leaks. Open + only: a pocket that comes out closed with a face turned over (13 more of those + pitches) has the fold unfoldFinished lays out again, and every one of those + pieces came out watertight and oriented, so it is kept as it was, as is every + pocket that comes out closed. */ + if (bossFastener) { + const pocket = movePolys(bossFastener, ccx + sx*off, ccy + sy*off); + const first = csgSubtract(boss, pocket); + boss = first.open ? cutAgain(boss, pocket, first) : first; + } + shells.push(boss); + continue; + } + /* In the boss's own frame u runs into the cell along x from its corner and v along + y, and a side on the piece's edge starts a BLOAT in. Two that meet on the cell + edge through their corner are mirror images across it: the pair's outline is the + one quarter's run back mirrored, without the edge between them. */ + const u0 = onEdge(cxr, W) ? BLOAT : 0, v0 = onEdge(cyr, D) ? BLOAT : 0; + const other = members.length === 2 ? members.find((bs) => bs !== all[n]) : null; + const pair = other && Math.abs(other.cxr - cxr) < 1e-6 && Math.abs(other.cyr - cyr) < 1e-6 && + (other.sx === sx) !== (other.sy === sy) ? (other.sx === sx ? 'v' : 'u') : null; + const solids = []; + if (pair) { + const lo = pair === 'v' ? u0 : v0; + const run = [[lo, -bossW], ...arc.slice().reverse().map(([p, q]) => [p, -q]), + [bossW, -(bossW - rIn)], [bossW, bossW - rIn], ...arc, [lo, bossW]]; + const pts = pair === 'v' ? run : run.map(([p, q]) => [q, p]); + solids.push({ outline: pts.map(([u, v]) => [cxr - sx*u, cyr - sy*v]), sites: members }); + } else { + for (const bs of members) { + const a0 = onEdge(bs.cxr, W) ? BLOAT : 0, b0 = onEdge(bs.cyr, D) ? BLOAT : 0; + const pts = [[a0, b0], [bossW, b0], [bossW, bossW - rIn], ...arc, [a0, bossW]]; + solids.push({ outline: pts.map(([u, v]) => [bs.cxr - bs.sx*u, bs.cyr - bs.sy*v]), sites: [bs] }); + } + } + /* The pockets are cut again when they come out open, as a whole boss's are (above), + or with a face turned over, as the joint's cut below is: this boss is new, with no + bytes of its own to keep. A boss cut short of the piece's edge draws their lottery + at other pitches: four one-cell pieces with dovetails, whose notches reach the + bosses from 34 to 36.4 mm, left it at 34.64 and 34.72 mm, where the whole boss had + built closed. + * + A boss whose top stands level with the ceiling of a cut that reaches it came out + open there, the cut's ceiling and its top in one plane: a dovetail's notch is + 2.4 mm tall, an H-clip's recess 2.3 and a wall key's 2.0, and a boss is its + pocket's depth and 0.8 (a magnet) or 1.0 (a screw head), up to 2.6. Level, a + boss left open edges at every pitch the cut reaches it: 4 to 13 a piece beside a + dovetail (a 1.6 mm magnet or a 1.4 mm head), 9 to 30 beside an H-clip, and 4 to + 8, 9 to 18 and 25 to 74 beside a bowtie, a snap clip and a puzzle key in the + walls; beside the dovetail, 0.01 mm off the level either way, none. So such a + boss stands MOUNT_LEVEL over the ceiling, as one with a deeper pocket does, and a + pocket from above is cut from that top. mountLimits measures it from bossHeight, + which can only refuse sooner, and a pocket from above that the cut reaches is + refused at either height. + * + Level here is not rounded to the micron, as mountLimits' is: exactly MOUNT_LEVEL + off, a boss is raised or not as the difference comes out in floating point, a + 2.25 mm one under an H-clip's 2.3 and a 2.45 mm one over a dovetail's 2.4 raised, + a 2.35 mm one under the dovetail's not. Both ways build clean. Rounded, the bosses + raised now at exactly MOUNT_LEVEL would not be, and their bytes would change: 2.25 + mm beside an H-clip, 2.05 beside a key in the walls, 2.45 beside a dovetail. */ + const level = ks.filter((k) => Math.abs(cutTops[k] - bossH) < MOUNT_LEVEL); + const top = level.length ? Math.max(...level.map((k) => cutTops[k])) + MOUNT_LEVEL : bossH; + const fastener = top === bossH ? bossFastener : fastenerCutter(cfg, top - cfg.magnetH, top + 0.5, top + 0.5); + for (const { outline, sites } of solids) { + let boss = extrudePoly(outline, 0, top); + if (fastener) { + const pockets = [].concat(...sites.map((bs) => + movePolys(fastener, bs.ccx + bs.sx*off, bs.ccy + bs.sy*off))); + boss = cutAgain(boss, pockets, csgSubtract(boss, pockets)); + } + /* cutAgain's tries are not always enough here. A wall puzzle key at 36.92 mm with + screws (a 2 mm hole, a 7.1 x 0.8 head), four cells square, kept a cut with a + face turned over in the pair of bosses by the front edge's key, of A2 and of B2, + after every try: three folds on the bed a piece, about one build in 3,600 of + bosses a joint reaches. Moved two NUDGEs the other way along y it came out + clean. So a cut that every try leaves open or turned is taken again moved two + NUDGEs the other way along one axis, then the other, then both, and the first + that comes out closed with nothing turned over is kept; if none does, the first + stands. Two NUDGEs, not more: each stands as far from the cell's walls as the + first, and none nearer the pockets (see mountLimits). A cut that comes out right + is built exactly as before. */ + const b = flatBox(boss); + const cutAt = (a, c) => ks.flatMap((k) => + meets(cutBoxes[k], b) ? movePolys(fromBelow[k], -a*sx*NUDGE, -c*sy*NUDGE) : []); + const cut = cutAt(2, 2); + if (cut.length) { + const solid = boss; + boss = cutAgain(solid, cut, csgSubtract(solid, cut)); + for (const [a, c] of [[2, -2], [-2, 2], [-2, -2]]) { + if (!boss.open && !boss.turned) break; + let again; + try { + const alt = cutAt(a, c); + again = cutAgain(solid, alt, csgSubtract(solid, alt)); + } catch (e) { continue; } // the first cut stands + if (!again.open && !again.turned) boss = again; + } + } shells.push(boss); } } @@ -5839,7 +6041,7 @@

Your drawers

if (typeof module !== 'undefined') { module.exports = { computeLayout, gridCells, halfStrips, pieceConnectors, keysMeet, jointsThatFit, buildPiece, buildTestTile, buildFitSample, jointKind, keyOutline, buildKey, puzzleShape, keyHalf, hclipPrm, snapTopClip, snapTopParts, snapTopPrm, keySiteOps, topPocketCup, snapTopPocket, build3mfXML, packPlates, optimizeForPlates, transformPolys, stlBinary, checkManifold, DEFAULTS, csgSubtract, csgUnion, extrudePoly, socketCutter, polysToTriangles, - platePad, mountLimits, pieceColumn, compositions, PLATE_RANGES, PLATE_MAX_CELLS, MOUNT_SKIN, + platePad, cornerBosses, mountLimits, pieceColumn, compositions, PLATE_RANGES, PLATE_MAX_CELLS, MOUNT_SKIN, connClrCeiling, fitClearances, PRINT_LAYER, // shared mesh primitives — also used by the bins tool makePoly, triangulateRing, earTriangulate, roundedSquareRing, roundedRectRing, clampZ, profilePrism, @@ -7640,7 +7842,12 @@

Your drawers

/* Why `field` stops where it does. A joint's cut stops it in one of the ways mountLimits' `joint` names: a pocket from beneath as deep as a dovetail's notch, a magnet or screw that would reach the tab in one, a pocket any wider coming too near the notch's edge, - or any other hole breaking into the cut. */ + or any other hole breaking into the cut. The hint about keys put in from above is not + given with corner pockets: there is no solid floor under them, and such a key's cup + stands into a boss's pocket (#75). Nor where the bosses are buried in the floor a + joint needs (cornerBosses): a key put in from above, in the walls, needs none, so + taking the hint would stand them up again, and the cup in their pockets. Only a floor + asked for (bottomPad) keeps them buried whatever the joint. */ const mountWhy = (opens, field) => { const joint = mount().joint[field]; const cuts = cutsNamed(); @@ -7653,16 +7860,18 @@

Your drawers

: joint === 'near' ? `a pocket any wider would come too near the edge of the ${cuts} to cut cleanly` : joint ? `a hole has to stay out of the ${cuts}` : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' - : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' + : cornerBosses(state) ? 'a pocket has to stay inside its corner boss' : opens ? 'a cut open to the socket has to stay on the socket floor' : 'a pocket under the floor has to stay inside its cell') + - (joint && KEYED.includes(state.connector) && !keyFromTop() + (joint && KEYED.includes(state.connector) && !keyFromTop() && + !(state.baseMode === 'bosses' && !(state.bottomPad > 0)) ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above ` + 'keep out of the solid floor under these pockets' : ''); }; // why a size under the largest is refused (mountLimits' `gaps`) const nearWhy = () => `${atPitch()} — its pocket would come too near the edge of the ${cutsNamed()} to cut cleanly`; -const bossDepth = () => state.baseMode === 'bosses' +// corner bosses only where they stand: over a floor the pockets are the floor's (cornerBosses) +const bossDepth = () => cornerBosses(state) ? 'with corner pockets — a boss is 2.6 mm tall, while the solid floor grows to suit' : ''; const LIMITS = { drawerW: { min: 1, max: 2000, label: 'Drawer width' }, @@ -8205,6 +8414,13 @@

Your drawers

state.connector === 'snap' ? 'the snap clips' : 'the keys'; out.push({ t: `This joint adds a ${Math.max(state.bottomPad, padV).toFixed(1)} mm solid floor to house ${what}. Prefer no floor? Pick a keyed joint and set Key housing to "Inside the walls".` }); } + /* Corner pockets over a floor. The bosses would stand inside it, their pockets sealed or + cut short (#70), so core.js builds the plate as a solid floor builds it (cornerBosses), + and says so here: the menu still reads "Corner pockets only". */ + if (state.baseMode === 'bosses' && (state.magnets || state.screws) && !cornerBosses(state)) + out.push({ t: `Corner pockets need an open underside, and ${jointFloor(state) > 0 + ? 'this joint is housed in a floor' : 'Extra floor closes it'}, so the plate is built with a solid floor and the ${ + state.magnets && state.screws ? 'magnet and screw' : state.magnets ? 'magnet' : 'screw'} pockets are cut into it.` }); if (keyInWall() && layout.seams.some(s => s.junctions.some(j => Math.abs(j - Math.round(j)) > 0.25))) out.push({ t: 'One seam overlaps by a single cell — wall-housed keys need a wall junction, so that seam gets no connector. The neighbouring joints still hold the assembly.' }); diff --git a/src/core.js b/src/core.js index fbbb341..e3dd24b 100644 --- a/src/core.js +++ b/src/core.js @@ -2351,6 +2351,30 @@ const MOUNT_SKIN = PRINT_LAYER; corner, its inner corner rounded, never taller than BOSS_H. Named because mountLimits has to know how much room a boss leaves around its pocket. */ const BOSS_W = 12.5, BOSS_R = 3.5, BOSS_H = 2.6; +/* How tall a corner boss is built: enough for its pocket and a layer, up to BOSS_H. */ +const bossHeight = (cfg) => Math.min(BOSS_H, Math.max( + cfg.magnets ? cfg.magnetH + 0.8 : 0, + cfg.screws ? cfg.screwHeadDepth + 1.0 : 0)); + +/* The floor a joint houses itself in: keys in the floor, and the puzzle's lobes, whose + notch runs up into it. None for the rest. */ +function jointFloor(cfg) { + const keyedConn = ['bowtie', 'snap', 'puzzlekey'].includes(cfg.connector); + if (keyedConn && cfg.keyMount !== 'wall') return cfg.key.depth + 0.8; + return cfg.connector === 'puzzle' ? 2.6 : 0; +} + +/* Whether the corner bosses are built: baseMode 'bosses', and nothing under them. A boss + stands on the bed, up to 2.6 mm, with its pocket opening below it or on top of it. A + floor under the sockets, the one a joint houses itself in (2.8 mm for keys, 2.6 for the + puzzle's lobes) or one asked for, would stand round it as tall or taller: the bosses + were buried in it and their pockets with them, sealed in solid or cut short by it, and + no magnet could go in (#70). A floor is what a solid base is, so with one the plate is + built as a solid base builds it, its pockets cut into the floor and the floor grown to + suit them; a boss would only have stood inside it. */ +function cornerBosses(cfg) { + return cfg.baseMode === 'bosses' && !(cfg.bottomPad > 0) && !(jointFloor(cfg) > 0); +} /* How thick the solid floor under the sockets is: what was asked for, raised to whatever the plate is carrying needs. A pocket cut into the floor — a magnet from either side, a @@ -2363,16 +2387,13 @@ function platePad(cfg) { /* Rounded to the micron, because 2.6 + 0.2 is 2.8000000000000003 and that is not a reason to move every face of a plate that was 2.8 before. */ const under = (depth) => Math.round((depth + MOUNT_SKIN) * 1e6) / 1e6; - if ((cfg.magnets || cfg.screws) && cfg.baseMode !== 'bosses') { + if ((cfg.magnets || cfg.screws) && !cornerBosses(cfg)) { pad = Math.max(pad, cfg.magnetBase || 2.8); if (cfg.magnets) pad = Math.max(pad, under(cfg.magnetH)); if (cfg.screws && cfg.screwHeadD > cfg.screwHoleD) pad = Math.max(pad, under(cfg.screwHeadDepth)); } - const keyedConn = ['bowtie', 'snap', 'puzzlekey'].includes(cfg.connector); - if (keyedConn && cfg.keyMount !== 'wall') pad = Math.max(pad, cfg.key.depth + 0.8); - if (cfg.connector === 'puzzle') pad = Math.max(pad, 2.6); - return pad; + return Math.max(pad, jointFloor(cfg)); } /* Plastic left round a mounting cut, to whatever holds it. 1 mm rather than a token @@ -2385,6 +2406,10 @@ const MOUNT_WALL = 1.0; level, and how near its walls may come to any joint's cut without breaking into it. See mountLimits. */ const MOUNT_LEVEL = 0.05, MOUNT_SEAM = 0.01; +/* How far a cut is moved, 1.7 microns along each axis, when it is taken again for coming + out open or with a face turned over (cutAgain, in buildPiece). A corner boss's cut from + beneath is moved two of them along each axis, off where the cell's stands. */ +const NUDGE = 0.0017; /* How far a mounting bore about (x, y) can grow before it meets any of `segs`, as the radius of the circle through its corners: the polygon cylinder() cuts, `sides` flats with a corner at every 2πk/sides from +x. A point is in that polygon when it stands no @@ -2462,7 +2487,7 @@ function mountLimits(cfg, layout, known) { const inCell = half - off - MOUNT_WALL; const s = half - off; // the site's distance in from the cell's edges const inBoss = Math.min(roomIn(BOSS_W, BOSS_R, s), s) - MOUNT_WALL; - const bosses = cfg.baseMode === 'bosses'; + const bosses = cornerBosses(cfg); const top = bosses ? inBoss : onFloor, under = bosses ? inBoss : inCell; const r10 = (x) => Math.floor(x * 10 + 1e-9) / 10; // a cap is given in tenths, rounded down /* A cell's four sites are 2 × holeOffset apart, 26 mm, so past a pitch of about 50 mm @@ -2484,8 +2509,10 @@ function mountLimits(cfg, layout, known) { Measured off the solids buildPiece cuts, at the sites it cuts pockets at: whole cells only, so a housing beside a half cell or a margin is measured from the whole cell on - the other side of it, which is the only one with pockets. A corner boss is left out: - its pocket is cut in the boss, a shell of its own that no joint is cut from. + the other side of it, which is the only one with pockets. A corner boss's pocket is at + the same site, and the joint is cut out of the boss too (#70), so it counts the same + way; a pocket from above in a boss has its floor the pocket's depth under the boss's + top rather than the floor's. Issue #64: a bowtie in the floor at 42 mm, with magnets from beneath, built 12 bad edges at 7.9 mm and 19 at 10, with Download on; puzzle tabs at 36 to 40 mm built 26 @@ -2542,7 +2569,7 @@ function mountLimits(cfg, layout, known) { plate the page will build has at most 900 cells; at 30 × 30 with puzzle tabs this is a few milliseconds, on every redraw. */ const reach = Math.max(fit(top), fit(under)); - if (layout && !again && !bosses && cfg.connector !== 'none' && reach > 0) { + if (layout && !again && cfg.connector !== 'none' && reach > 0) { const plan = keyPlan(cfg), H = pad + cfg.plateHeight; /* A cut's footprint, as the segments its walls stand on, its extent and its ceiling, for each seam it can be cut from, and the part's that goes in it: the key's half, @@ -2631,6 +2658,17 @@ function mountLimits(cfg, layout, known) { const own = { magnetD: fit(cfg.magnetSide === 'top' ? top : under), screwHoleD: fit(top), screwHeadD: fit(under) }; // a dovetail's notch takes a pocket from beneath that breaks into it; every other cut does not const notch = cfg.connector === 'dovetail'; + /* The cuts are measured where they stand in the cells, and a corner boss's stands two + NUDGEs along each axis off that (buildPiece), up to 2·NUDGE·√2 (4.8 microns) nearer a + pocket: one MOUNT_SEAM short of the cell's cut was 0.0051 to 0.0055 mm short of an + H-clip's recess in the boss, and 0.0057 to 0.0070 of a key's in the walls. So in a + boss a pocket stops that much further off, MOUNT_SEAM short of the boss's cut as + well. Counting a design's magnet, screw hole and screw head apart, at every 0.01 mm + of pitch from 30 to 60 with the five joints that reach the bosses, it lowers 2,676 + of the 33,430 caps a joint sets (8%), all by a tenth but 6 of a dovetail's by a + hundredth, and starts a dovetail's refused sizes (`near`) a hundredth lower in 5,392 + of its 24,008. Without corner bosses nothing moves. */ + const seam = MOUNT_SEAM + (bosses ? 2 * NUDGE * Math.SQRT2 : 0); /* What the joint's cuts leave one size, as { cap, why, near }: the largest size, and what stops it: 'cut', a pocket that would break into a key's recess or a puzzle tab's notch; 'floor', one from above that leaves no layer of floor over a cut; 'level', one from @@ -2646,8 +2684,9 @@ function mountLimits(cfg, layout, known) { let cap = Infinity, why = false; const near = []; for (const c of jointCuts) { - // a pocket from above clears a cut whose ceiling it leaves a layer of floor over - if (above && !(c.top + MOUNT_SKIN > pad - cfg.magnetH + 1e-6)) continue; + /* a pocket from above clears a cut whose ceiling it leaves a layer of floor over; in + a corner boss its floor is the pocket's depth under the boss's top */ + if (above && !(c.top + MOUNT_SKIN > (bosses ? bossHeight(cfg) : pad) - cfg.magnetH + 1e-6)) continue; /* Level within MOUNT_LEVEL, measured to the micron, so a pocket that far above the notch's ceiling and one that far below it are taken alike: 2.35 and 2.45 mm deep against a notch 2.4 mm high, which both build clean. Unrounded, 2.45 counted as @@ -2655,7 +2694,7 @@ function mountLimits(cfg, layout, known) { const level = Math.round(Math.abs(ceiling - c.top) * 1e6) / 1e6 < MOUNT_LEVEL; const stop = above ? 'floor' : !notch ? 'cut' : level ? 'level' : 'part'; for (const s of c.sites) { - const short = fits(s.bore[sides] - MOUNT_SEAM); + const short = fits(s.bore[sides] - seam); const size = stop === 'part' ? 2 * s.body : short; if (size < cap) { cap = size; why = stop; } if (stop === 'part') near.push([short, fits(s.bore[sides])]); @@ -2873,7 +2912,7 @@ function jointsThatFit(cfg, layout) { and bloated 0.05mm so shells overlap; slicers union overlapping shells. */ function buildPiece(cfg, layout, piece, onStatus) { const pitch = cfg.pitch, half = pitch/2; - const solidBase = cfg.baseMode !== 'bosses'; + const solidBase = !cornerBosses(cfg); // with a floor under them, bosses are a solid base const pad = platePad(cfg); const isHclip = cfg.connector === 'hclip'; const topInsert = cfg.keyInsert === 'top'; @@ -3160,13 +3199,12 @@ function buildPiece(cfg, layout, piece, onStatus) { * So the cut is taken again as the pockets' is, as other trees over the same solids: * the cutters in the other order, the solid's faces in the other order, the faces * started a third and two thirds of the way round (which puts another of its planes at - * the root), the cutters moved 1.7 microns, the jitter the notch cutters already + * the root), the cutters moved 1.7 microns (NUDGE), the jitter the notch cutters already * carry, two ways, and last each cutter on its own, one after another, since two in * one cut split each other's faces and lose a sliver the same way. The first result * that is closed and has nothing turned over is kept; a cut that comes out right first * time, which is nearly every one, is built exactly as before. A try that throws is * passed over. */ - const NUDGE = 0.0017; // the cutters in a cut, each solid on its own (polygons that share a corner go together) const apart = (cut) => { const up = cut.map((_, i) => i), at = new Map(); @@ -3753,15 +3791,79 @@ function buildPiece(cfg, layout, piece, onStatus) { const bossW = BOSS_W, rIn = BOSS_R; // never more than BOSS_H, so a pocket deeper than BOSS_H − MOUNT_SKIN would come out // through the top: mountLimits refuses one rather than this growing past it - const bossH = Math.min(BOSS_H, Math.max( - cfg.magnets ? cfg.magnetH + 0.8 : 0, - cfg.screws ? cfg.screwHeadDepth + 1.0 : 0)); + const bossH = bossHeight(cfg); const bossFastener = fastenerCutter(cfg, bossH - cfg.magnetH, bossH + 0.5, bossH + 0.5); + /* The joint's cuts from beneath are taken out of the bosses as well, after their + pockets: the same solids the cells are cut with. A wall key's recess, an H-clip's + and a dovetail's notch sit where four cells meet, which is where four bosses meet, + and they were cut from the cells only. The bosses stood in every one of them, the + whole housing, and the key, the clip or the other piece's tab could not go in (#70). + * + Cut as they are, a boss and the cell under it share faces, and the cut put the same + edges in both: the housing's outline on the bed, where both stand, and on the + piece's edge, where both end; and two bosses that meet on a cell's edge, as they all + do (quarantined in test/plate-audit.js), shared the housing's outline across it too. + An H-clip at 42 mm went from 40 edges used four times a piece to 59 and 68. So a + boss a housing reaches stops a BLOAT short of the piece's edge, where the cell's + rim stands in for it; the two that meet on either side of the same housing are one + solid, the pair's outline drawn whole; and the cut is moved two NUDGEs (3.4 microns) + one way along each axis, so its walls stand in the boss a hair from where they stand + in the cell. Two, because a cut is taken again a NUDGE along a diagonal when it comes + out open (cutAgain), the cell's and the boss's alike: moved one NUDGE, the boss's + could come back to where the cell's stood, or go where the cell's had gone, and a + wall puzzle key at 36.13 mm with screws and a margin had 52 more edges used four + times than the base. Two keep them a NUDGE apart or more along each axis while at + most one of the two is taken again. That is all they promise: with both taken + again, a wall square to x can stand where the cell's does (cutAgain's nudges both + go up y, so one square to y cannot), and a wall that runs along the diagonal the cut + is moved on is not moved off the cell's at all. None of that touches a boss no + housing reaches. */ + const fromBelow = [...notches, ...pnotches].map((nb) => tabNotch(cfg, nb, pad)); + if (keyKind === 'recess') + for (const bo of keyed) + if (!(plan.junction && offJunction(bo, pitch, piece))) + fromBelow.push(keySiteOps(keyKind, keyShape, keyPrm, keyClr, bo.edge, bo.e, bo.s, H).cut); + const flatBox = (polys) => { + const b = [Infinity, Infinity, -Infinity, -Infinity]; + for (const p of polys) for (const v of p.verts) { + b[0] = Math.min(b[0], v[0]); b[1] = Math.min(b[1], v[1]); + b[2] = Math.max(b[2], v[0]); b[3] = Math.max(b[3], v[1]); + } + return b; + }; + const cutBoxes = fromBelow.map(flatBox); + const cutTops = fromBelow.map((polys) => Math.max(...polys.flatMap((p) => p.verts.map((v) => v[2])))); + const meets = (a, b) => a[0] < b[2] && b[0] < a[2] && a[1] < b[3] && b[1] < a[3]; // whole cells only: a half cell has no mounting sites (see the fastener cut above) + const all = []; for (let i = 0; i < piece.nx; i++) for (let j = 0; j < piece.ny; j++) { const ccx = gx0 + i*pitch + half, ccy = gy0 + j*pitch + half; for (const sx of [-1, 1]) for (const sy of [-1, 1]) { const cxr = ccx + sx*half, cyr = ccy + sy*half; // cell corner + const box = [Math.min(cxr, cxr - sx*bossW), Math.min(cyr, cyr - sy*bossW), + Math.max(cxr, cxr - sx*bossW), Math.max(cyr, cyr - sy*bossW)]; + all.push({ ccx, ccy, sx, sy, cxr, cyr, cuts: cutBoxes.flatMap((a, k) => meets(a, box) ? [k] : []) }); + } + } + // the bosses either side of one housing, as one + const group = all.map((_, n) => n); + const root = (n) => { while (group[n] !== n) n = group[n] = group[group[n]]; return n; }; + fromBelow.forEach((_, k) => { + const reached = all.flatMap((bs, n) => bs.cuts.includes(k) ? [n] : []); + for (const n of reached.slice(1)) group[root(n)] = root(reached[0]); + }); + const arc = []; + for (let k = 1; k <= 6; k++) { + const a = k * (Math.PI/2) / 6; + arc.push([bossW - rIn + rIn*Math.cos(a), bossW - rIn + rIn*Math.sin(a)]); + } + const onEdge = (x, lim) => Math.abs(x) < 1e-6 || Math.abs(x - lim) < 1e-6; + for (let n = 0; n < all.length; n++) { + if (root(n) !== n) continue; + const { ccx, ccy, sx, sy, cxr, cyr } = all[n]; + const members = all.filter((_, m) => root(m) === n); + const ks = [...new Set(members.flatMap((bs) => bs.cuts))]; + if (!ks.length) { // quarter boss with rounded inner corner, oriented into the cell const pts = []; pts.push([0, 0], [bossW, 0], [bossW, bossW - rIn]); @@ -3772,8 +3874,108 @@ function buildPiece(cfg, layout, piece, onStatus) { pts.push([0, bossW]); const world = pts.map(([u, v]) => [cxr - sx*u, cyr - sy*v]); let boss = extrudePoly(world, 0, bossH); - if (bossFastener) - boss = csgSubtract(boss, movePolys(bossFastener, ccx + sx*off, ccy + sy*off)); + /* A boss's pocket is a lottery of its own, so it is cut again (cutAgain) when it + comes out open. Default screws in one-cell pieces left 3 to 6 open edges on a + boss's underside at 22 of the 901 pitches from 34 to 60 mm that take them, and a + 9.1 mm magnet at 39.46 mm left 12 a piece; cut again, none of those leaks. Open + only: a pocket that comes out closed with a face turned over (13 more of those + pitches) has the fold unfoldFinished lays out again, and every one of those + pieces came out watertight and oriented, so it is kept as it was, as is every + pocket that comes out closed. */ + if (bossFastener) { + const pocket = movePolys(bossFastener, ccx + sx*off, ccy + sy*off); + const first = csgSubtract(boss, pocket); + boss = first.open ? cutAgain(boss, pocket, first) : first; + } + shells.push(boss); + continue; + } + /* In the boss's own frame u runs into the cell along x from its corner and v along + y, and a side on the piece's edge starts a BLOAT in. Two that meet on the cell + edge through their corner are mirror images across it: the pair's outline is the + one quarter's run back mirrored, without the edge between them. */ + const u0 = onEdge(cxr, W) ? BLOAT : 0, v0 = onEdge(cyr, D) ? BLOAT : 0; + const other = members.length === 2 ? members.find((bs) => bs !== all[n]) : null; + const pair = other && Math.abs(other.cxr - cxr) < 1e-6 && Math.abs(other.cyr - cyr) < 1e-6 && + (other.sx === sx) !== (other.sy === sy) ? (other.sx === sx ? 'v' : 'u') : null; + const solids = []; + if (pair) { + const lo = pair === 'v' ? u0 : v0; + const run = [[lo, -bossW], ...arc.slice().reverse().map(([p, q]) => [p, -q]), + [bossW, -(bossW - rIn)], [bossW, bossW - rIn], ...arc, [lo, bossW]]; + const pts = pair === 'v' ? run : run.map(([p, q]) => [q, p]); + solids.push({ outline: pts.map(([u, v]) => [cxr - sx*u, cyr - sy*v]), sites: members }); + } else { + for (const bs of members) { + const a0 = onEdge(bs.cxr, W) ? BLOAT : 0, b0 = onEdge(bs.cyr, D) ? BLOAT : 0; + const pts = [[a0, b0], [bossW, b0], [bossW, bossW - rIn], ...arc, [a0, bossW]]; + solids.push({ outline: pts.map(([u, v]) => [bs.cxr - bs.sx*u, bs.cyr - bs.sy*v]), sites: [bs] }); + } + } + /* The pockets are cut again when they come out open, as a whole boss's are (above), + or with a face turned over, as the joint's cut below is: this boss is new, with no + bytes of its own to keep. A boss cut short of the piece's edge draws their lottery + at other pitches: four one-cell pieces with dovetails, whose notches reach the + bosses from 34 to 36.4 mm, left it at 34.64 and 34.72 mm, where the whole boss had + built closed. + * + A boss whose top stands level with the ceiling of a cut that reaches it came out + open there, the cut's ceiling and its top in one plane: a dovetail's notch is + 2.4 mm tall, an H-clip's recess 2.3 and a wall key's 2.0, and a boss is its + pocket's depth and 0.8 (a magnet) or 1.0 (a screw head), up to 2.6. Level, a + boss left open edges at every pitch the cut reaches it: 4 to 13 a piece beside a + dovetail (a 1.6 mm magnet or a 1.4 mm head), 9 to 30 beside an H-clip, and 4 to + 8, 9 to 18 and 25 to 74 beside a bowtie, a snap clip and a puzzle key in the + walls; beside the dovetail, 0.01 mm off the level either way, none. So such a + boss stands MOUNT_LEVEL over the ceiling, as one with a deeper pocket does, and a + pocket from above is cut from that top. mountLimits measures it from bossHeight, + which can only refuse sooner, and a pocket from above that the cut reaches is + refused at either height. + * + Level here is not rounded to the micron, as mountLimits' is: exactly MOUNT_LEVEL + off, a boss is raised or not as the difference comes out in floating point, a + 2.25 mm one under an H-clip's 2.3 and a 2.45 mm one over a dovetail's 2.4 raised, + a 2.35 mm one under the dovetail's not. Both ways build clean. Rounded, the bosses + raised now at exactly MOUNT_LEVEL would not be, and their bytes would change: 2.25 + mm beside an H-clip, 2.05 beside a key in the walls, 2.45 beside a dovetail. */ + const level = ks.filter((k) => Math.abs(cutTops[k] - bossH) < MOUNT_LEVEL); + const top = level.length ? Math.max(...level.map((k) => cutTops[k])) + MOUNT_LEVEL : bossH; + const fastener = top === bossH ? bossFastener : fastenerCutter(cfg, top - cfg.magnetH, top + 0.5, top + 0.5); + for (const { outline, sites } of solids) { + let boss = extrudePoly(outline, 0, top); + if (fastener) { + const pockets = [].concat(...sites.map((bs) => + movePolys(fastener, bs.ccx + bs.sx*off, bs.ccy + bs.sy*off))); + boss = cutAgain(boss, pockets, csgSubtract(boss, pockets)); + } + /* cutAgain's tries are not always enough here. A wall puzzle key at 36.92 mm with + screws (a 2 mm hole, a 7.1 x 0.8 head), four cells square, kept a cut with a + face turned over in the pair of bosses by the front edge's key, of A2 and of B2, + after every try: three folds on the bed a piece, about one build in 3,600 of + bosses a joint reaches. Moved two NUDGEs the other way along y it came out + clean. So a cut that every try leaves open or turned is taken again moved two + NUDGEs the other way along one axis, then the other, then both, and the first + that comes out closed with nothing turned over is kept; if none does, the first + stands. Two NUDGEs, not more: each stands as far from the cell's walls as the + first, and none nearer the pockets (see mountLimits). A cut that comes out right + is built exactly as before. */ + const b = flatBox(boss); + const cutAt = (a, c) => ks.flatMap((k) => + meets(cutBoxes[k], b) ? movePolys(fromBelow[k], -a*sx*NUDGE, -c*sy*NUDGE) : []); + const cut = cutAt(2, 2); + if (cut.length) { + const solid = boss; + boss = cutAgain(solid, cut, csgSubtract(solid, cut)); + for (const [a, c] of [[2, -2], [-2, 2], [-2, -2]]) { + if (!boss.open && !boss.turned) break; + let again; + try { + const alt = cutAt(a, c); + again = cutAgain(solid, alt, csgSubtract(solid, alt)); + } catch (e) { continue; } // the first cut stands + if (!again.open && !again.turned) boss = again; + } + } shells.push(boss); } } @@ -4446,7 +4648,7 @@ const DEFAULTS = { if (typeof module !== 'undefined') { module.exports = { computeLayout, gridCells, halfStrips, pieceConnectors, keysMeet, jointsThatFit, buildPiece, buildTestTile, buildFitSample, jointKind, keyOutline, buildKey, puzzleShape, keyHalf, hclipPrm, snapTopClip, snapTopParts, snapTopPrm, keySiteOps, topPocketCup, snapTopPocket, build3mfXML, packPlates, optimizeForPlates, transformPolys, stlBinary, checkManifold, DEFAULTS, csgSubtract, csgUnion, extrudePoly, socketCutter, polysToTriangles, - platePad, mountLimits, pieceColumn, compositions, PLATE_RANGES, PLATE_MAX_CELLS, MOUNT_SKIN, + platePad, cornerBosses, mountLimits, pieceColumn, compositions, PLATE_RANGES, PLATE_MAX_CELLS, MOUNT_SKIN, connClrCeiling, fitClearances, PRINT_LAYER, // shared mesh primitives — also used by the bins tool makePoly, triangulateRing, earTriangulate, roundedSquareRing, roundedRectRing, clampZ, profilePrism, diff --git a/src/ui.js b/src/ui.js index 23ac4d9..244b710 100644 --- a/src/ui.js +++ b/src/ui.js @@ -101,7 +101,12 @@ const cutsNamed = () => `${['dovetail', 'puzzle'].includes(state.connector) ? 'n /* Why `field` stops where it does. A joint's cut stops it in one of the ways mountLimits' `joint` names: a pocket from beneath as deep as a dovetail's notch, a magnet or screw that would reach the tab in one, a pocket any wider coming too near the notch's edge, - or any other hole breaking into the cut. */ + or any other hole breaking into the cut. The hint about keys put in from above is not + given with corner pockets: there is no solid floor under them, and such a key's cup + stands into a boss's pocket (#75). Nor where the bosses are buried in the floor a + joint needs (cornerBosses): a key put in from above, in the walls, needs none, so + taking the hint would stand them up again, and the cup in their pockets. Only a floor + asked for (bottomPad) keeps them buried whatever the joint. */ const mountWhy = (opens, field) => { const joint = mount().joint[field]; const cuts = cutsNamed(); @@ -114,16 +119,18 @@ const mountWhy = (opens, field) => { : joint === 'near' ? `a pocket any wider would come too near the edge of the ${cuts} to cut cleanly` : joint ? `a hole has to stay out of the ${cuts}` : mount().beside[field] ? 'a cell\'s four holes have to stay clear of each other' - : state.baseMode === 'bosses' ? 'a pocket has to stay inside its corner boss' + : cornerBosses(state) ? 'a pocket has to stay inside its corner boss' : opens ? 'a cut open to the socket has to stay on the socket floor' : 'a pocket under the floor has to stay inside its cell') + - (joint && KEYED.includes(state.connector) && !keyFromTop() + (joint && KEYED.includes(state.connector) && !keyFromTop() && + !(state.baseMode === 'bosses' && !(state.bottomPad > 0)) ? `; keys ${keyInWall() ? '' : 'housed inside the walls and '}put in from above ` + 'keep out of the solid floor under these pockets' : ''); }; // why a size under the largest is refused (mountLimits' `gaps`) const nearWhy = () => `${atPitch()} — its pocket would come too near the edge of the ${cutsNamed()} to cut cleanly`; -const bossDepth = () => state.baseMode === 'bosses' +// corner bosses only where they stand: over a floor the pockets are the floor's (cornerBosses) +const bossDepth = () => cornerBosses(state) ? 'with corner pockets — a boss is 2.6 mm tall, while the solid floor grows to suit' : ''; const LIMITS = { drawerW: { min: 1, max: 2000, label: 'Drawer width' }, @@ -666,6 +673,13 @@ function warningsList() { state.connector === 'snap' ? 'the snap clips' : 'the keys'; out.push({ t: `This joint adds a ${Math.max(state.bottomPad, padV).toFixed(1)} mm solid floor to house ${what}. Prefer no floor? Pick a keyed joint and set Key housing to "Inside the walls".` }); } + /* Corner pockets over a floor. The bosses would stand inside it, their pockets sealed or + cut short (#70), so core.js builds the plate as a solid floor builds it (cornerBosses), + and says so here: the menu still reads "Corner pockets only". */ + if (state.baseMode === 'bosses' && (state.magnets || state.screws) && !cornerBosses(state)) + out.push({ t: `Corner pockets need an open underside, and ${jointFloor(state) > 0 + ? 'this joint is housed in a floor' : 'Extra floor closes it'}, so the plate is built with a solid floor and the ${ + state.magnets && state.screws ? 'magnet and screw' : state.magnets ? 'magnet' : 'screw'} pockets are cut into it.` }); if (keyInWall() && layout.seams.some(s => s.junctions.some(j => Math.abs(j - Math.round(j)) > 0.25))) out.push({ t: 'One seam overlaps by a single cell — wall-housed keys need a wall junction, so that seam gets no connector. The neighbouring joints still hold the assembly.' }); diff --git a/sw.js b/sw.js index 487f1bf..661b5d4 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 = "87e3541175b2"; +const VERSION = "a8545a50ba92"; const FILES = [ "./", "bins/", diff --git a/test/plate-audit.js b/test/plate-audit.js index 70873cf..8c7ea47 100644 --- a/test/plate-audit.js +++ b/test/plate-audit.js @@ -2204,6 +2204,190 @@ console.log('\nthe other limits, built at their ends:'); bad += open.length + (holds ? 0 : 1); } +/* Corner bosses beside a joint cut from beneath (#70). A boss stands where four cells + meet, and so does a wall key's recess, an H-clip's, and the notch a dovetail's or a + puzzle's tab goes into from the next piece. The joint was cut from the cells and not + from the bosses, so they stood in the whole of each housing and nothing could go in, + with Download on: a housing filled in is watertight, and the bosses' own edges were + there already. And a joint that houses itself in a floor, keys at 2.8 mm and the + puzzle's lobes at 2.6, stood that floor round the 2.6 mm bosses and sealed their + pockets in it, as an extra floor did. + * + So each is built two pieces side by side at 42 mm, with magnets from beneath, from + above and screws, and read along vertical lines 0.3 mm apart. The housing is what the + joint takes out of the plate without its mountings (solid with no joint, empty with + one), and none of it may be solid with the bosses on, and solid 5 microns round: a + boss's cut stands two NUDGEs off the cell's (see buildPiece), and the sliver of boss + that leaves in a housing, 3.4 microns thick, is not a fill. Every pocket has to be empty + from its mouth to its floor. And the edges two bosses share where they meet, used four + times (quarantined above), may not be more than the same plate has with no joint. */ +console.log('\ncorner bosses beside a joint cut from beneath:'); +{ + // along a vertical line, the faces above a height, each counted by which way it faces, + // add up to how many shells that height is inside + const columns = (polys) => { + const cells = new Map(), key = (i, j) => i * 100003 + j; + for (const t of G.polysToTriangles(polys)) { + const xs = t.map((v) => v[0]), ys = t.map((v) => v[1]); + for (let i = Math.floor(Math.min(...xs)); i <= Math.floor(Math.max(...xs)); i++) + for (let j = Math.floor(Math.min(...ys)); j <= Math.floor(Math.max(...ys)); j++) { + if (!cells.has(key(i, j))) cells.set(key(i, j), []); + cells.get(key(i, j)).push(t); + } + } + return (x, y) => { + const cross = []; + for (const [a, b, c] of cells.get(key(Math.floor(x), Math.floor(y))) || []) { + const n = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); + if (Math.abs(n) < 1e-12) continue; + const d = (b[1] - c[1]) * (a[0] - c[0]) + (c[0] - b[0]) * (a[1] - c[1]); + const l1 = ((b[1] - c[1]) * (x - c[0]) + (c[0] - b[0]) * (y - c[1])) / d; + const l2 = ((c[1] - a[1]) * (x - c[0]) + (a[0] - c[0]) * (y - c[1])) / d; + if (l1 < 0 || l2 < 0 || l1 + l2 > 1) continue; + cross.push([l1 * a[2] + l2 * b[2] + (1 - l1 - l2) * c[2], Math.sign(n)]); + } + return (z) => cross.reduce((w, [zc, s]) => zc > z ? w + s : w, 0); + }; + }; + const h = 0.3, dz = 0.1; + const zs = Array.from({ length: 40 }, (_, k) => (k + 0.5) * dz); + const at = { pitch: 42, drawerW: 168, drawerD: 84, bedW: 100, bedD: 400 }; + const JOINTS = [ + ['keys in the floor', { connector: 'bowtie' }], + ['keys in the wall', { connector: 'bowtie', keyMount: 'wall' }], + ['H-clip', { connector: 'hclip' }], + ['dovetail', { connector: 'dovetail' }], + ['puzzle tabs', { connector: 'puzzle' }], + ['extra floor, no joint', { connector: 'none', bottomPad: 1 }], + ]; + const MOUNTS = [ + ['magnets below', { magnets: true }], + ['magnets above', { magnets: true, magnetSide: 'top' }], + ['screws', { screws: true }], + ]; + for (const [jn, j] of JOINTS) + for (const [mn, m] of MOUNTS) { + const r = buildAll({ ...at, baseMode: 'bosses', ...j, ...m }); + const cfg = r.cfg, pad = G.platePad(cfg); + const plain = buildAll({ ...at, baseMode: 'bosses', ...j, ...m, connector: 'none', bottomPad: 0 }); + const without = buildAll({ ...at, ...j, bottomPad: pad }); + const solidBefore = buildAll({ ...at, ...j, connector: 'none', bottomPad: pad }); + let housing = 0, filled = 0, pts = 0, buried = 0; + r.pieces.forEach((polys, pi) => { + const pc = r.L.pieces[pi]; + const A = columns(polys), B = columns(without.pieces[pi]), C = columns(solidBefore.pieces[pi]); + if (cfg.connector !== 'none') { + const W = pc.mL + pc.nx * cfg.pitch + pc.mR, D = pc.mF + pc.ny * cfg.pitch + pc.mB; + for (let x = h / 2 + 0.000731; x < W; x += h) + for (let y = h / 2 + 0.000419; y < D; y += h) { + const a = A(x, y), b = B(x, y), c = C(x, y); + let round = null; + for (const z of zs) + if (c(z) >= 1 && b(z) <= 0) { + housing++; + if (a(z) < 1) continue; + round = round || [[1, 1], [1, -1], [-1, 1], [-1, -1]].map(([u, v]) => A(x + u * 0.005, y + v * 0.005)); + if (round.every((f) => f(z) >= 1)) filled++; + } + } + } + // each pocket's sides and middle, from its mouth to its floor: a standing boss's + // top is its own height, and a floor's the floor's + const top = G.cornerBosses(cfg) ? Math.min(2.6, Math.max(cfg.magnets ? cfg.magnetH + 0.8 : 0, + cfg.screws ? cfg.screwHeadDepth + 1 : 0)) : pad; + const spans = []; + if (cfg.magnets) spans.push(cfg.magnetSide === 'top' + ? [cfg.magnetD / 2 - 0.3, top - cfg.magnetH, top] : [cfg.magnetD / 2 - 0.3, 0, cfg.magnetH]); + if (cfg.screws) spans.push([cfg.screwHeadD / 2 - 0.3, 0, cfg.screwHeadDepth], [cfg.screwHoleD / 2 - 0.3, 0, top]); + for (let i = 0; i < pc.nx; i++) for (let k = 0; k < pc.ny; k++) + for (const sx of [-1, 1]) for (const sy of [-1, 1]) { + const px = pc.mL + (i + 0.5) * cfg.pitch + sx * cfg.holeOffset; + const py = pc.mF + (k + 0.5) * cfg.pitch + sy * cfg.holeOffset; + for (const [rad, z0, z1] of spans) + for (let q = 0; q < 8; q++) for (const rr of [0, rad / 2, rad]) { + const col = A(px + rr * Math.cos(q * Math.PI / 4) + 0.000731, py + rr * Math.sin(q * Math.PI / 4) + 0.000419); + for (let z = z0 + 0.1; z <= z1 - 0.1 + 1e-9; z += 0.2) { pts++; if (col(z) >= 1) buried++; } + } + } + }); + const mm3 = (n) => (n * h * h * dz).toFixed(1); + const good = !filled && !buried && !r.open && r.bad <= plain.bad && (cfg.connector === 'none' || housing > 0); + console.log(` ${`${jn}, ${mn}`.padEnd(36)} ` + + (cfg.connector === 'none' ? 'no housing' : !housing ? 'NO HOUSING CUT' + : `housing ${mm3(housing)} mm³, ${filled ? `${mm3(filled)} mm³ OF IT FILLED` : 'none filled'}`) + + `; ${buried ? `${buried} of ${pts} pocket points SOLID` : `pockets open (${pts} points)`}; ` + + `${leakText(r)}${r.bad ? `, ${plain.bad} with no joint` : ''}${good ? '' : ' FAIL'}`); + if (!good) bad++; + } + /* A boss a housing reaches stops short of the piece's edge, and its pockets are a + lottery of their own: four one-cell pieces with dovetails, whose notches reach the + bosses from 34 to 36.4 mm, left 3 open edges under a boss with default screws at + these two pitches, where the whole boss had built closed, until the pockets were cut + again where they come out open (buildPiece). */ + for (const p of [34.64, 34.72]) { + const r = buildAll({ pitch: p, drawerW: 2 * p, drawerD: 2 * p, bedW: p + 5, bedD: p + 5, + baseMode: 'bosses', screws: true }); + console.log(` ${`dovetail, one-cell pieces at ${p} mm, screws`.padEnd(36)} ${r.L.pieces.length} pieces; ${leakText(r)}` + + `${r.bad ? ' FAIL' : ''}`); + if (r.bad) bad++; + } + /* A boss no housing reaches has its pockets cut again too when they come out open: default + screws in a one-cell drawer left 6 open edges under a boss at 37.7 mm (one of 22 + pitches from 34 to 60 mm), and a 9.1 mm magnet at 39.46 mm 12 a piece, with no joint. */ + for (const [name, over] of [ + ['one cell at 37.7 mm, screws', { pitch: 37.7, drawerW: 37.7, drawerD: 37.7, bedW: 57.7, bedD: 57.7, screws: true }], + ['no joint at 39.46 mm, 9.1 magnet', { pitch: 39.46, drawerW: 157.84, drawerD: 78.92, bedW: 94.92, bedD: 400, + magnets: true, magnetD: 9.1 }]]) { + const r = buildAll({ ...over, baseMode: 'bosses', connector: 'none' }); + console.log(` ${name.padEnd(36)} ${r.L.pieces.length} piece${r.L.pieces.length > 1 ? 's' : ''}; ${leakText(r)}` + + `${r.open ? ' FAIL' : ''}`); + if (r.open) bad++; + } + /* And a boss's cut moved one NUDGE could stand where the cell's stands, when one or the + other was taken again (cutAgain): a wall puzzle key at 36.13 mm with screws and a margin + had 73 edges used four times in a piece, against 26 with no joint. */ + { + const p = 36.13, at = { pitch: p, drawerW: 4 * p + 7.3, drawerD: 2 * p + 5.1, mLeft: 3.1, mRight: 4.2, mFront: 2.5, + mBack: 2.6, bedW: 2 * p + 16, bedD: 400, baseMode: 'bosses', screws: true }; + const r = buildAll({ ...at, connector: 'puzzlekey', keyMount: 'wall', keyInsert: 'bottom' }); + const plain = buildAll({ ...at, connector: 'none' }); + const good = !r.open && r.bad <= plain.bad; + console.log(` ${'wall puzzle keys at 36.13 mm, screws'.padEnd(36)} ${leakText(r)}, ${plain.bad} with no joint${good ? '' : ' FAIL'}`); + if (!good) bad++; + } + /* A boss is its pocket's depth and 0.8 (a magnet) or 1.0 (a screw head) tall, and one + whose top stood level with the ceiling of the cut that reaches it came out open there: + a dovetail's notch is 2.4 mm tall, an H-clip's recess 2.3 and a wall key's 2.0. These + left 4 to 13 open edges a piece until such a boss stood MOUNT_LEVEL over the ceiling + (buildPiece). */ + for (const [name, over] of [ + ['dovetail at 36.13 mm, 1.6 mm magnet', { pitch: 36.13, connector: 'dovetail', magnets: true, magnetH: 1.6 }], + ['dovetail at 34.04 mm, 1.4 mm head', { pitch: 34.04, connector: 'dovetail', screws: true, screwHeadD: 4, screwHeadDepth: 1.4 }], + ['H-clip at 33.5 mm, 1.5 mm magnet', { pitch: 33.5, connector: 'hclip', magnets: true, magnetD: 4, magnetH: 1.5 }], + ['wall bowtie at 36.13 mm, 1 mm head', { pitch: 36.13, connector: 'bowtie', keyMount: 'wall', screws: true, screwHeadDepth: 1 }]]) { + const p = over.pitch; + const r = buildAll({ drawerW: 4 * p, drawerD: 2 * p, bedW: 2 * p + 16, bedD: 400, baseMode: 'bosses', ...over }); + console.log(` ${name.padEnd(36)} ${leakText(r)}${r.open ? ' FAIL' : ''}`); + if (r.open) bad++; + } + /* And a boss's cut can come out with a face turned over after every one of cutAgain's + tries: a wall puzzle key at 36.92 mm with screws (a 2 mm hole, a 7.1 x 0.8 head), four + 2 x 2 pieces, left three folds on the bed in two of them, by the front edge's key, with + no edge open, until such a cut was taken again moved the other way (buildPiece). So + folds as well, which an edge count cannot see. */ + { + const p = 36.92; + const r = buildAll({ pitch: p, drawerW: 4 * p, drawerD: 4 * p, bedW: 2 * p + 16, bedD: 2 * p + 16, + connector: 'puzzlekey', keyMount: 'wall', keyInsert: 'bottom', baseMode: 'bosses', + screws: true, screwHoleD: 2, screwHeadD: 7.1, screwHeadDepth: 0.8 }); + const folds = r.pieces.reduce((s, pp) => s + checkOrientation(pp).folds, 0); + const good = !r.open && !folds; + console.log(` ${'wall puzzle keys at 36.92 mm, screws'.padEnd(36)} ${r.L.pieces.length} pieces; ${leakText(r)}` + + `${folds ? `, ${folds} FOLDS` : ''}${good ? '' : ' FAIL'}`); + if (!good) bad++; + } +} + /* The fit clearance at its ceiling, for every joint and every pitch band. * * connClrCeiling's answer depends on the joint, which way its key goes in and the pitch, diff --git a/test/ui/plates-robustness.spec.js b/test/ui/plates-robustness.spec.js index 7ee84cf..a50307f 100644 --- a/test/ui/plates-robustness.spec.js +++ b/test/ui/plates-robustness.spec.js @@ -130,6 +130,12 @@ test.describe('ranges on the geometry fields', () => { /Magnet Ø of 11\.93 mm is refused at a 41\.49 mm pitch — .* Use 11\.89 mm or less, 11\.92 mm, or 11\.95 mm or more\./], ['#pi=31&cl=0&mg=1&md=1', 'errMagnet', /Magnet Ø of 1 mm is refused at a 31 mm pitch — .* Use 1\.01 mm, or 1\.04 mm or more\./], + /* #70: the joint is cut from the corner bosses now, so a boss's pocket can reach it as + a cell's can. A bowtie key in the walls at 36.13 mm took a 7.9 mm magnet, and with + the recess cut from the bosses it would have built 19 open edges a piece. */ + ['#pi=36.13&w=144.52&d=72.26&mm=custom&ml=0&mr=0&mf=0&mb=0&bw=88.26&bd=400&cn=bowtie&km=wall&ki=bottom' + + '&bm=bosses&mg=1&md=7.9', 'errMagnet', + /Magnet Ø must be 6\.1 mm or less at a 36\.13 mm pitch — .* the recesses the bowtie keys fit into/], ]; for (const [hash, errId, msg] of CASES) { test(`${hash} is refused at the field`, async ({ page }) => { @@ -171,6 +177,56 @@ test.describe('ranges on the geometry fields', () => { expect(errors).toEqual([]); }); + /* #70: corner pockets over a floor. A bowtie housed in the floor stood its 2.8 mm floor + round the 2.6 mm bosses and sealed their pockets in it, with Download on, and an extra + floor did the same. Such a plate is built as a solid floor builds it now, and Checks + says so; the floor grows to suit, so a 3 mm magnet goes in where a boss stops at 2.4. + With the key in the walls the underside is open and the bosses stand again. */ + test('corner pockets over a floor are cut into the floor, and Checks says so', async ({ page }) => { + const errors = await openAt(page, `${BOWTIE_42}&bm=bosses&mg=1&mh=3`); + const note = /Corner pockets need an open underside, and this joint is housed in a floor, so the plate is built with a solid floor and the magnet pockets are cut into it\./; + expect(await text(page, 'warnings')).toMatch(note); + expect(await shown(page, 'errMagnet')).toBe(false); + expect(await text(page, 'pieceTail')).toMatch(/ready/); + expect(await exportOff(page)).toBe(false); + await page.selectOption('#keyMount', 'wall'); + await page.waitForFunction((re) => new RegExp(re).test( + document.getElementById('pieceTail').textContent), SETTLED.source, { timeout: 30000 }); + expect(await text(page, 'warnings')).not.toMatch(/Corner pockets need an open underside/); + expect(await text(page, 'errMagnet')).toMatch(/Magnet depth must be 2\.4 mm or less with corner pockets/); + expect(await exportOff(page)).toBe(true); + expect(errors).toEqual([]); + }); + /* #79's review: a refused pocket over a floored key went on to say that keys inside the + walls, put in from above, keep out of the solid floor under it. With corner pockets + that is the way back to #75: such a key needs no floor, so the bosses stand again + and its cup stands in their pockets. An extra floor keeps them buried, and there the + hint holds, as it does for a solid base. */ + test('corner pockets over a floored key are not pointed at keys put in from above', async ({ page }) => { + const at = '#pi=37.98&w=151.92&d=75.96&mm=custom&ml=0&mr=0&mf=0&mb=0&bw=91.96&bd=400&cn=bowtie&km=floor' + + '&ki=bottom&bm=bosses&mg=1&md=5.81'; + const errors = await openAt(page, at); + const refusal = /Magnet Ø must be 3\.8 mm or less at a 37\.98 mm pitch — .* the recesses the bowtie keys fit into/; + const hint = /put in from above keep out of the solid floor/; + expect(await text(page, 'errMagnet')).toMatch(refusal); + expect(await text(page, 'errMagnet')).not.toMatch(hint); + expect(await text(page, 'warnings')).not.toMatch(hint); + expect(await exportOff(page)).toBe(true); + await page.goto('about:blank'); + await openAt(page, at.replace('&bm=bosses', '&bm=bosses&bp=1')); + expect(await text(page, 'errMagnet')).toMatch(refusal); + expect(await text(page, 'errMagnet')).toMatch(hint); + expect(errors).toEqual([]); + }); + test('corner pockets under an extra floor are cut into it, and Checks says so', async ({ page }) => { + const errors = await openAt(page, '#cn=none&bm=bosses&sc=1&bp=1'); + expect(await text(page, 'warnings')).toMatch( + /Corner pockets need an open underside, and Extra floor closes it, so the plate is built with a solid floor and the screw pockets are cut into it\./); + expect(await text(page, 'pieceTail')).toMatch(/ready/); + expect(await exportOff(page)).toBe(false); + expect(errors).toEqual([]); + }); + /* The half-inch magnet on the default dovetail at 42 mm: its pocket breaks 0.04 to 0.09 mm into the notches, the magnet 0.24 mm clear of the tabs, and it builds clean, so the field takes it; 2.4 mm deep, level with the notch, it would not. */