From 5ea7e95937041750b8281e103bb9c8a3500c66fa Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 17:37:40 +0100 Subject: [PATCH 1/8] kits/fittings.v0.json: bolt, slot, pit, vents, access_port, port_bolts, handle, eye, louvres (cut plate-fittings-kit) Nine parts that stand on a hard plate's face, each on +z from z = 0, one material a part, no sockets: the mech tracks' own points as kit data. The access port is two parts (its body and its bolts), so the heads take their own material. Co-Authored-By: Claude Fable 5.2 --- .../brokkr_kitbash/kits/fittings.v0.json | 144 ++++++++++++++++++ surfaces/blender/tests/test_kitbash.py | 57 ++++++- surfaces/blender/tests/test_ram.py | 2 +- 3 files changed, 200 insertions(+), 3 deletions(-) create mode 100644 surfaces/blender/brokkr_kitbash/kits/fittings.v0.json diff --git a/surfaces/blender/brokkr_kitbash/kits/fittings.v0.json b/surfaces/blender/brokkr_kitbash/kits/fittings.v0.json new file mode 100644 index 0000000..0557683 --- /dev/null +++ b/surfaces/blender/brokkr_kitbash/kits/fittings.v0.json @@ -0,0 +1,144 @@ +{ + "schema": "brokkr.kit.v0", + "kit": "fittings", + "doc": "What stands on a hard plate's face (brokkr_kitbash.plate's fit rows): each part stands on +z from z = 0 in its own frame, whose origin is the fit's place on the face, z the face's normal and y the face's up; metres. One material a part; no sockets.", + "socketTypes": {}, + "parts": [ + { + "name": "bolt", + "doc": "A hex head on a washer: a rim bolt, and what a bolts row stands along a slab's outline.", + "params": [ + {"name": "r", "type": "number", "min": 0.004, "max": 0.1, "default": 0.017, "doc": "the head's radius to its corners; the washer is 1.55 r"} + ], + "shapes": [ + {"shape": "tube", "r0": "1.55*r", "r1": "1.55*r", "length": 0.004, "segments": 14, "at": [0, 0, -0.0005], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "r", "r1": "r", "length": "0.7*r", "segments": 6, "at": [0, 0, 0.0035], "rot": [0, 0, 90]} + ], + "sockets": [] + }, + { + "name": "slot", + "doc": "The raised rim of a w by h slot: four bars around the opening. The opening's dark floor is a pit row under it.", + "params": [ + {"name": "w", "type": "number", "min": 0.01, "max": 2, "default": 0.2, "doc": "the opening across (x)"}, + {"name": "h", "type": "number", "min": 0.005, "max": 2, "default": 0.04, "doc": "the opening along up (y)"} + ], + "shapes": [ + {"shape": "box", "size": ["w+0.06", 0.032, 0.028], "at": [0, "h/2+0.016", 0.014]}, + {"shape": "box", "size": ["w+0.06", 0.032, 0.028], "at": [0, "-h/2-0.016", 0.014]}, + {"shape": "box", "size": [0.032, "h", 0.028], "at": ["w/2+0.016", 0, 0.014]}, + {"shape": "box", "size": [0.032, "h", 0.028], "at": ["-w/2-0.016", 0, 0.014]} + ], + "sockets": [] + }, + { + "name": "pit", + "doc": "The dark box that reads as the hole under a slot or behind a vent: w by h, depth tall, count of them pitch apart along y, centred. A slot's is 0.012 deep; a vents row's is 0.01 deep with the vents' count and a pitch of 2.7 h.", + "params": [ + {"name": "w", "type": "number", "min": 0.005, "max": 2, "default": 0.2, "doc": "across (x)"}, + {"name": "h", "type": "number", "min": 0.005, "max": 2, "default": 0.04, "doc": "along up (y)"}, + {"name": "depth", "type": "number", "min": 0.001, "max": 0.2, "default": 0.012, "doc": "how far it stands off the face"}, + {"name": "count", "type": "integer", "min": 1, "max": 64, "default": 1, "doc": "copies along y, centred"}, + {"name": "pitch", "type": "number", "min": 0, "max": 4, "default": 0, "doc": "distance between copies"} + ], + "shapes": [ + {"shape": "repeat", "count": "count", "step": [0, "pitch", 0], "of": {"shape": "box", "size": ["w", "h", "depth"], "at": [0, "-(count-1)*pitch/2", "depth/2"]}} + ], + "sockets": [] + }, + { + "name": "vents", + "doc": "A stack of louvre lips tilted 28 degrees over w by h openings, 2.7 h apart along y, centred. The openings' dark floors are a pit row under it.", + "params": [ + {"name": "w", "type": "number", "min": 0.01, "max": 2, "default": 0.3, "doc": "an opening across (x)"}, + {"name": "h", "type": "number", "min": 0.005, "max": 0.5, "default": 0.03, "doc": "an opening along up (y)"}, + {"name": "count", "type": "integer", "min": 1, "max": 64, "default": 4, "doc": "lips"} + ], + "shapes": [ + {"shape": "repeat", "count": "count", "step": [0, "2.7*h", 0], "of": {"shape": "box", "size": ["w+0.04", "0.9*h", 0.012], "at": [0, "0.75*h-(count-1)*2.7*h/2", 0.014], "rot": [-28, 0, 0]}} + ], + "sockets": [] + }, + { + "name": "access_port", + "doc": "A round access port's body: a turned ring of radius r around a sunk cover with a raised boss. Its eight bolts are a port_bolts row at the same place.", + "params": [ + {"name": "r", "type": "number", "min": 0.02, "max": 1, "default": 0.12, "doc": "the port's radius"} + ], + "shapes": [ + {"shape": "lathe", "segments": 28, "profile": [[0, 0], ["r", 0], ["r", 0.035], ["0.82*r", 0.05], ["0.82*r", 0.022], ["0.34*r", 0.022], ["0.34*r", 0.045], [0, 0.045]]} + ], + "sockets": [] + }, + { + "name": "port_bolts", + "doc": "The eight hex heads on an access port's rim, on a circle 0.91 r, standing from the rim's shoulder (z 0.035): a row of its own, so the heads take their own material.", + "params": [ + {"name": "r", "type": "number", "min": 0.02, "max": 1, "default": 0.12, "doc": "the port's radius"} + ], + "shapes": [ + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.91*r", 0, 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.6434671708797584*r", "0.6434671708797584*r", 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": [0, "0.91*r", 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.6434671708797584*r", "0.6434671708797584*r", 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.91*r", 0, 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["-0.6434671708797584*r", "-0.6434671708797584*r", 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": [0, "-0.91*r", 0.035], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.07*r", "r1": "0.07*r", "length": 0.012, "segments": 6, "at": ["0.6434671708797584*r", "-0.6434671708797584*r", 0.035], "rot": [0, 0, 90]} + ], + "sockets": [] + }, + { + "name": "handle", + "doc": "A grab handle along y: a square bar of side 2 r on two posts, bent over at lift, each post on a washer and a hex foot. Roll 90 lays it along the face's a.", + "params": [ + {"name": "length", "type": "number", "min": 0.05, "max": 2, "default": 0.3, "doc": "between the posts"}, + {"name": "lift", "type": "number", "min": 0.02, "max": 0.5, "default": 0.065, "doc": "the bar's centre over the face"}, + {"name": "r", "type": "number", "min": 0.004, "max": 0.05, "default": 0.016, "doc": "half the bar's side"} + ], + "shapes": [ + {"shape": "extrude", "section": "box", "w": "2*r", "h": "2*r", "t": "r", "path": [[0, "-length/2", -0.004], [0, "-length/2", "lift-min(0.4*lift,0.2*length)"], [0, "-length/2+0.1339745962155613*min(0.4*lift,0.2*length)", "lift-0.5*min(0.4*lift,0.2*length)"], [0, "-length/2+0.5*min(0.4*lift,0.2*length)", "lift-0.1339745962155613*min(0.4*lift,0.2*length)"], [0, "-length/2+min(0.4*lift,0.2*length)", "lift"], [0, "length/2-min(0.4*lift,0.2*length)", "lift"], [0, "length/2-0.5*min(0.4*lift,0.2*length)", "lift-0.1339745962155613*min(0.4*lift,0.2*length)"], [0, "length/2-0.1339745962155613*min(0.4*lift,0.2*length)", "lift-0.5*min(0.4*lift,0.2*length)"], [0, "length/2", "lift-min(0.4*lift,0.2*length)"], [0, "length/2", -0.004]], "up": [1, 0, 0]}, + {"shape": "tube", "r0": "2.3*r", "r1": "2.3*r", "length": 0.008, "segments": 12, "at": [0, "-length/2", 0], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "2.3*r", "r1": "2.3*r", "length": 0.008, "segments": 12, "at": [0, "length/2", 0], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "1.5*r", "r1": "1.5*r", "length": 0.008, "segments": 6, "at": [0, "-length/2", 0.008], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "1.5*r", "r1": "1.5*r", "length": 0.008, "segments": 6, "at": [0, "length/2", 0.008], "rot": [0, 0, 90]} + ], + "sockets": [] + }, + { + "name": "eye", + "doc": "A lifting eye: a bolted pad, a neck, and a ring standing in the plane of y and z.", + "params": [ + {"name": "size", "type": "number", "min": 0.03, "max": 0.5, "default": 0.1, "doc": "the ring's outer diameter is 1.1 size"} + ], + "shapes": [ + {"shape": "box", "size": ["1.1*size", "2*size", 0.012], "at": [0, 0, 0.004]}, + {"shape": "tube", "r0": "0.11*size", "r1": "0.11*size", "length": 0.008, "segments": 6, "at": [0, "-0.72*size", 0.01], "rot": [0, 0, 90]}, + {"shape": "tube", "r0": "0.11*size", "r1": "0.11*size", "length": 0.008, "segments": 6, "at": [0, "0.72*size", 0.01], "rot": [0, 0, 90]}, + {"shape": "box", "size": ["0.34*size", "0.5*size", "0.24*size"], "at": [0, 0, "0.012+0.1*size"]}, + {"shape": "lathe", "segments": 20, "loop": true, "profile": [["0.55*size", 0], ["0.5119238815542512*size", "0.09192388155425119*size"], ["0.42*size", "0.13*size"], ["0.3280761184457488*size", "0.09192388155425119*size"], ["0.29*size", 0], ["0.3280761184457488*size", "-0.09192388155425119*size"], ["0.42*size", "-0.13*size"], ["0.5119238815542512*size", "-0.09192388155425119*size"]], "at": [0, 0, "0.012+0.62*size"], "rot": [0, 90, 0]} + ], + "sockets": [] + }, + { + "name": "louvres", + "doc": "A framed bank of n slanted slats, w by h between the frame's middles: x along the slats, y up.", + "params": [ + {"name": "w", "type": "number", "min": 0.1, "max": 4, "default": 0.6, "doc": "across (x), between the side bars' middles"}, + {"name": "h", "type": "number", "min": 0.1, "max": 4, "default": 0.72, "doc": "along up (y), between the top and bottom bars' middles"}, + {"name": "n", "type": "integer", "min": 1, "max": 64, "default": 6, "doc": "slats"}, + {"name": "depth", "type": "number", "min": 0.01, "max": 0.5, "default": 0.05, "doc": "how far the frame stands"}, + {"name": "frame", "type": "number", "min": 0.01, "max": 0.5, "default": 0.07, "doc": "the frame bars' width, under w and h"}, + {"name": "slant", "type": "number", "min": 0, "max": 80, "default": 25, "doc": "degrees a slat is tilted about x"} + ], + "shapes": [ + {"shape": "box", "size": ["w+frame", "frame", "depth"], "at": [0, "-0.5*h", "0.5*depth"]}, + {"shape": "box", "size": ["w+frame", "frame", "depth"], "at": [0, "0.5*h", "0.5*depth"]}, + {"shape": "box", "size": ["frame", "h+frame", "depth"], "at": ["-0.5*w", 0, "0.5*depth"]}, + {"shape": "box", "size": ["frame", "h+frame", "depth"], "at": ["0.5*w", 0, "0.5*depth"]}, + {"shape": "repeat", "count": "n", "step": [0, "(h-frame)/n", 0], "of": {"shape": "box", "size": ["w-frame", "0.75*(h-frame)/n", "0.25*depth"], "at": [0, "-0.5*(h-frame)+0.5*(h-frame)/n", "0.3*depth"], "rot": ["slant", 0, 0]}} + ], + "sockets": [] + } + ] +} diff --git a/surfaces/blender/tests/test_kitbash.py b/surfaces/blender/tests/test_kitbash.py index 7f6b933..ab7448b 100644 --- a/surfaces/blender/tests/test_kitbash.py +++ b/surfaces/blender/tests/test_kitbash.py @@ -245,7 +245,7 @@ class CheckKitTests(unittest.TestCase): for name in ("../x", "mechanical.v0", "Mechanical", "", "a/b", "x" * 33, 3): with self.assertRaisesRegex(core.KitError, "must be 1 to 32 of"): core.load_kit(name) - with self.assertRaisesRegex(core.KitError, "no kit named 'absent'; kits: cutters, frame, mechanical"): + with self.assertRaisesRegex(core.KitError, "no kit named 'absent'; kits: cutters, fittings, frame, mechanical"): core.load_kit("absent") with self.assertRaisesRegex(core.KitError, "has no part 'wing'; its parts: nozzle, tank"): core.part(core.load_kit("mechanical"), "wing") @@ -923,6 +923,59 @@ class FrameKitTests(unittest.TestCase): @unittest.skipIf(np is None, "numpy is not installed") +class FittingsKitTests(unittest.TestCase): + """kits/fittings.v0.json: what brokkr_kitbash.plate stands on a face.""" + PARTS = ["bolt", "slot", "pit", "vents", "access_port", "port_bolts", "handle", "eye", "louvres"] + + @classmethod + def setUpClass(cls): + cls.kit = core.load_kit("fittings") + + def shells(self, built): + """Each shape's faces as a Built of their own: a part's shells stand through each other, and each is held closed.""" + counts = built.counts.tolist() + starts = np.concatenate([[0], np.cumsum(counts)[:-1]]) + for index in sorted(set(built.shape.tolist())): + own = [k for k in range(len(counts)) if built.shape[k] == index] + yield built._replace(faces=np.concatenate([built.faces[starts[k]:starts[k] + counts[k]] for k in own]), counts=np.array([counts[k] for k in own])) + + def test_the_kit_is_its_nine_parts_and_no_sockets(self): + self.assertEqual(list(self.kit["parts"]), self.PARTS) + self.assertEqual(self.kit["socketTypes"], {}) + self.assertEqual([part["sockets"] for part in self.kit["parts"].values()], [[]] * 9) + + def test_every_part_builds_closed_and_wound_out_from_the_face(self): + for name, part in self.kit["parts"].items(): + rng = random.Random(f"fittings.{name}") + draws = [{}] + [{p["name"]: rng.randint(p["min"], p["max"]) if p["type"] == "integer" else rng.uniform(p["min"], p["max"]) for p in part["params"]} for _ in range(16)] + for draw in draws: + if name == "louvres" and draw and draw["frame"] >= min(draw["w"], draw["h"]): + with self.assertRaises(core.KitError): + core.build(part, draw) + continue + if name == "handle" and draw and draw["r"] > 0.25 * min(0.4 * draw["lift"], 0.2 * draw["length"]): + try: # a bar thick against its bend may fold on the inside of a turn: core refuses it by name + core.build(part, draw) + except core.KitError as error: + self.assertIn("the section folds there", str(error)) + continue + built = core.build(part, draw) + self.assertTrue(closed_and_oriented(built), (name, draw)) + for shell in self.shells(built): + self.assertGreater(signed_volume(shell), 0, (name, draw)) + self.assertGreater(float(built.V[:, 2].max()), 0.0, (name, draw)) + floor = float(core.build(part).V[:, 2].min()) + self.assertGreaterEqual(floor, {"bolt": -0.0005, "handle": -0.004, "eye": -0.002, "louvres": -0.008}.get(name, 0.0), name) # what a part sinks into the face at its defaults + + def test_the_bolt_is_the_tracks_washer_and_head(self): + built = core.build(self.kit["parts"]["bolt"], {"r": 0.017}) + washer, head = built.V[:28], built.V[28:] + self.assertLess(float(np.abs(np.linalg.norm(washer[:, :2], axis=1) - 1.55 * 0.017).max()), 1e-15) + self.assertLess(float(np.abs(np.linalg.norm(head[:, :2], axis=1) - 0.017).max()), 1e-15) + self.assertEqual(sorted(set(np.round(built.V[:, 2], 12).tolist())), [-0.0005, 0.0035, 0.0035 + 0.7 * 0.017]) + self.assertLess(abs(float(head[0, 0])), 1e-15) # a corner on +y, as the tracks' heads stand + + class SurfaceFrameTests(unittest.TestCase): """surface-frame: the frame brokkr_kitbash.cut gives a cutter. Bounds: a shipped reading is float rounding (worst 4.4e-16 over the draws) and the least mutant's is 0.31 (S4, the roll dropped, at roll 18); 1e-9 separates them by @@ -2509,7 +2562,7 @@ class OwnershipTests(unittest.TestCase): return {p.name: p.read_text(encoding="utf-8") for p in sorted((SURFACE / "brokkr_kitbash").rglob("*")) if p.suffix in (".py", ".json")} def test_no_pattern_matches(self): - self.assertEqual(sorted(self.sources()), ["__init__.py", "brokkr_actions.json", "core.py", "cutters.v0.json", "frame.v0.json", "mechanical.v0.json", "plate.py", "ram.py", "route.py"]) + self.assertEqual(sorted(self.sources()), ["__init__.py", "brokkr_actions.json", "core.py", "cutters.v0.json", "fittings.v0.json", "frame.v0.json", "mechanical.v0.json", "plate.py", "ram.py", "route.py"]) for pattern in self.PACKAGE: for name, text in self.sources().items(): if pattern is self.PACKAGE[2] and name == "__init__.py": diff --git a/surfaces/blender/tests/test_ram.py b/surfaces/blender/tests/test_ram.py index a0cc7b4..5a34ea9 100644 --- a/surfaces/blender/tests/test_ram.py +++ b/surfaces/blender/tests/test_ram.py @@ -546,7 +546,7 @@ SPAN_RAM = 0.848 # the ram's span with its base 0.1 from the rocker's piv SMALL = (0.009, 0.015) # the sides of a turned-over bar welded along a unit cube's edge whose regions hold 6.75e-5 and 1.93e-4 of the extent cubed: THIN, 1.1e-4, is 1.63 and 1.75 from them MECH_SAMPLE = (17, 4, 3, 89, 12) # the mech sample's rows: inside out, crossing, open, pass; and the mirrored among them -KIT_VARIANTS = 316 # kit parts built over the corners of their params +KIT_VARIANTS = 386 # kit parts built over the corners of their params @unittest.skipIf(np is None, "numpy is not installed") -- 2.47.3 From 06a7f59e0f5cf986c716723c734bfc55cdd048d4 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 17:37:40 +0100 Subject: [PATCH 2/8] brokkr_kitbash.plate: fit rows part, bolts and step, built onto the face (cut plate-fittings-kit) build's entries gain fits {mat: (V, faces)} and report.fits. A part row is a fittings part placed by the fit's frame on the face's top; a bolts row stands bolts along a slab's outline on the bare face; a step is plate.panel on an outline. The hash holds a row of every kind at both sides. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/plate.py | 165 ++++++++++++++--- surfaces/blender/tests/test_plate.py | 214 +++++++++++++++++++++-- 2 files changed, 342 insertions(+), 37 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/plate.py b/surfaces/blender/brokkr_kitbash/plate.py index be0150c..87d21ab 100644 --- a/surfaces/blender/brokkr_kitbash/plate.py +++ b/surfaces/blender/brokkr_kitbash/plate.py @@ -2,13 +2,17 @@ numpy and the standard library only, tested without Blender (tests/test_plate.py); docs/kitbash.md, Hard plates, states the format in full. A hard plate is a convex faceted solid: every facet flat, every edge a chamfer the -caller's Bevel makes. This module turns one table into each plate's solid, its detail panels, their corner bolts -and the frames of its anchors. The table alone decides the result: coordinates are metres in the table's own frame +caller's Bevel makes. This module turns one table into each plate's solid, its detail panels, their corner bolts, +the frames of its anchors and the fittings that stand on its face. The table and kits/fittings.v0.json decide the result: coordinates are metres in the table's own frame (no host and no world reach this module), every clad carries its seed as data, and facets are ordered by a rule on the solid as built in the table frame. A row: name, mat, bevel, sides ("one" or "both"), mirror, exactly one solid form, clad, face, fits. +Fits, each standing on the row's face: the anchors mark and hose_port (a frame), and the fittings part (a part of +the fittings kit at a place, built by core.build), bolts (bolt parts along a slab's outline) and step (a raised +panel on an outline). + Solid forms, each a set of points whose convex hull is the plate: faces [{at, normal} | {through: [a, b, c], out}, ...]: the corners of what the half-spaces bound slab {at, normal, up, right, outline, thick, taper, back, gap}: an outline drawn on the outer face, the @@ -20,7 +24,7 @@ Solid forms, each a set of points whose convex hull is the plate: check(document) returns the table with every default written in, or raises PlateError naming the path. build(table, side=1) returns one entry per plate built: name, solid (V, faces), facets, panels (V, faces), -bolts (V, faces), anchors, report. Both are pure: nothing is cached and nothing is written. +bolts (V, faces), fits {mat: (V, faces)}, anchors, report. Both are pure: nothing is cached and nothing is written. """ from __future__ import annotations @@ -54,7 +58,10 @@ PANEL_MIN = (0.25, 0.02) # a panel under this share of its facet, or under this SINK, CHAMFER = 0.02, 0.02 # a panel starts this far under its facet; its far rim is chamfered this much BOLT = 0.028 RANGES = {"thick": (0.001, 2.0), "taper": (0.0, 0.5), "back": (0.1, 1.5), "gap": (0.0, 0.5), "lift": (0.0, 1.0)} -KINDS = ("mark", "hose_port") +KINDS = ("mark", "hose_port", "part", "bolts", "step") +ANCHORS = KINDS[:2] # a fit that is a frame; the others are geometry +KIT = "fittings" # the kit a part row's part is of, and the bolt of a bolts row +PARAMS = 256 # the most characters a fit's params may run class PlateError(ValueError): @@ -236,7 +243,28 @@ def _name(value: Any, path: str, most: int, pattern: str | None) -> str: return value -def _check_row(row: Any, path: str) -> dict: +def _fittings(kit: dict) -> dict: + """The fittings kit's parts, read into `kit` the first time a call wants them.""" + if not kit: + kit.update(core.load_kit(KIT)) + return kit["parts"] + + +def _part_params(kit: dict, part: Any, text: Any, path: str) -> str: + """A fit's params text, checked against the part's bounds by core.""" + parts = _fittings(kit) + if not isinstance(part, str) or part not in parts: + raise PlateError(f"{path}.part: {part!r} is no part of the {KIT} kit (its parts: {', '.join(parts)})") + if not isinstance(text, str) or len(text) > PARAMS: + raise PlateError(f"{path}.params: wants 'name=value; ...' of at most {PARAMS} characters") + try: + core.resolve_params(parts[part], core.parse_params(text)) + except core.KitError as error: + raise PlateError(f"{path}.params: {error}") from None + return text + + +def _check_row(row: Any, path: str, kit: dict) -> dict: forms = ("faces", "slab", "sections", "points") _object(row, path, ("name", "mat"), ("bevel", "sides", "mirror", "clad", "face", "fits") + forms) out = {"name": _name(row["name"], f"{path}.name", 48, r"[A-Za-z0-9_.]+"), "mat": _name(row["mat"], f"{path}.mat", 63, None), @@ -287,13 +315,32 @@ def _check_row(row: Any, path: str) -> dict: if kind == "mark": _object(fit, at, ("kind", "id", "at", "height")) entry = {"kind": kind, "id": _name(fit["id"], f"{at}.id", 63, None), "at": _vector(fit["at"], f"{at}.at", 2), "height": _number(fit["height"], f"{at}.height", 1e-4, 100.0)} - else: + elif kind == "hose_port": _object(fit, at, ("kind", "name", "at"), ("lift",)) entry = {"kind": kind, "name": _name(fit["name"], f"{at}.name", 63, None), "at": _vector(fit["at"], f"{at}.at", 2), "lift": _number(fit.get("lift", 0.0), f"{at}.lift", -1.0, 1.0)} - name = entry.get("id", entry.get("name")) - if name in names: - raise PlateError(f"{at}: a second anchor named {name!r} in this row") - names.add(name) + elif kind == "part": + _object(fit, at, ("kind", "part", "at", "mat"), ("roll", "lift", "params")) + entry = {"kind": kind, "part": fit["part"], "at": _vector(fit["at"], f"{at}.at", 2), "roll": _number(fit.get("roll", 0.0), f"{at}.roll", -360.0, 360.0), + "lift": _number(fit.get("lift", 0.0), f"{at}.lift", -1.0, 1.0), "params": _part_params(kit, fit["part"], fit.get("params", ""), at)} + elif kind == "bolts": + if form != "slab": + raise PlateError(f"{at}: a bolts row stands along a slab's outline; this row is no slab") + _object(fit, at, ("kind", "inset", "spacing", "mat"), ("lift", "params")) + entry = {"kind": kind, "inset": _number(fit["inset"], f"{at}.inset", 0.0, 10.0), "spacing": _number(fit["spacing"], f"{at}.spacing", 1e-3, 100.0), + "lift": _number(fit.get("lift", 0.0), f"{at}.lift", -1.0, 1.0), "params": _part_params(kit, "bolt", fit.get("params", ""), at)} + else: + _object(fit, at, ("kind", "outline", "at", "lift", "mat"), ("bolt_mat",)) + entry = {"kind": kind, "outline": [_vector(p, f"{at}.outline[{k}]", 2) for k, p in enumerate(_list(fit["outline"], f"{at}.outline", OUTLINE))], + "at": _vector(fit["at"], f"{at}.at", 2), "lift": _number(fit["lift"], f"{at}.lift", 0.0, 1.0)} + _check_ring(np.array(entry["outline"]), f"{at}.outline") + entry["bolt_mat"] = _name(fit.get("bolt_mat", "gunmetal"), f"{at}.bolt_mat", 63, None) + if kind in ANCHORS: + name = entry.get("id", entry.get("name")) + if name in names: + raise PlateError(f"{at}: a second anchor named {name!r} in this row") + names.add(name) + else: + entry["mat"] = _name(fit["mat"], f"{at}.mat", 63, None) fits.append(entry) out["fits"] = fits return out @@ -303,20 +350,23 @@ def check(document: Any) -> dict: """The table with every default written in. Raises PlateError naming the path of what breaks the format, and of a row that bounds no solid: every row's solid and anchors are made here once, at side +1, and build makes them the same way, so build meets no refusal check has not.""" - table = _read(document) + kit: dict = {} + table = _read(document, kit) for i, row in enumerate(table["plates"]): points, face = _row_points(row, f"plates[{i}]") hull(_mirrored(points, row["mirror"]), f"plates[{i}]") for j, fit in enumerate(row["fits"]): - _frame(face[0], face[3], (0.0, 0.0, 1.0) if fit["kind"] == "mark" else face[2], f"plates[{i}].fits[{j}]") + if fit["kind"] in ANCHORS: + _frame(face[0], face[3], (0.0, 0.0, 1.0) if fit["kind"] == "mark" else face[2], f"plates[{i}].fits[{j}]") + fit_meshes(row, face, 0.0, 1, kit, f"plates[{i}]") return table -def _read(document: Any) -> dict: +def _read(document: Any, kit: dict) -> dict: _object(document, "document", ("schema", "plates")) if document["schema"] != SCHEMA: raise PlateError(f"document.schema: {document['schema']!r} is not {SCHEMA}") - rows = [_check_row(row, f"plates[{i}]") for i, row in enumerate(_list(document["plates"], "plates", ROWS))] + rows = [_check_row(row, f"plates[{i}]", kit) for i, row in enumerate(_list(document["plates"], "plates", ROWS))] built: dict[str, int] = {} for i, row in enumerate(rows): for name in ((row["name"] + ".R", row["name"] + ".L") if row["sides"] == "both" else (row["name"],)): @@ -327,9 +377,9 @@ def _read(document: Any) -> dict: # --- points of a solid form ----------------------------------------------------------------------------------------- -def _frame(point, normal, up, path: str) -> np.ndarray: +def _frame(point, normal, up, path: str, roll: float = 0.0) -> np.ndarray: try: - return core.surface_frame(point, normal, up) + return core.surface_frame(point, normal, up, roll) except core.KitError as error: raise PlateError(f"{path}: {error}") from None @@ -879,6 +929,71 @@ def clad_layout(V: np.ndarray, faces, facets, clad: dict, seed: int, face_n, sid return panels.done(), bolts.done(), made, on_face +# --- fittings --------------------------------------------------------------------------------------------------------- +def _slab_ring(slab: dict, face) -> np.ndarray: + """A slab's outline as drawn on its face, counter-clockwise in the face's (a, b): the outline, in by its gap.""" + origin, a, b, _ = face + if "corners" in slab: + corners = np.array(slab["corners"]) + ring = np.column_stack(((corners - origin) @ a, (corners - origin) @ b)) + else: + ring = np.array(outline_points(slab["outline"]), dtype=np.float64) + if _area2(ring) < 0: + ring = ring[::-1] + return inset2d(ring, slab["gap"]) if slab["gap"] else ring + + +def fit_meshes(row: dict, face, top: float, side: int, kit: dict, path: str): + """({mat: (V, faces)}, count): the fittings of one checked row at `side`, merged by material in row order, and + how many stand. A part's frame is the face's at the fit's place: z the normal, y the face's b, turned by roll; at + side -1 the place, normal and b are mirrored, the frame made right-handed and the roll negated. A part row and + a step stand on the face's top (the face plus `top`, the clad's lift there); a bolts row fastens the plate + itself and stands on the bare face. Raises PlateError for what the kit refuses at these params and for a row + that makes nothing.""" + held: dict[str, _Mesh] = {} + count = 0 + if face is None: + return {}, 0 + origin, a, b, n = face + flip = np.array([float(side), 1.0, 1.0]) + + def part(name: str, params: str, at: str): + try: + built = core.build(_fittings(kit)[name], core.parse_params(params)) + except core.KitError as error: + raise PlateError(f"{at}: {error}") from None + ends = np.cumsum(built.counts) + return built.V, [built.faces[end - size:end].tolist() for end, size in zip(ends, built.counts)] + + def stand(mesh, x: float, y: float, z: float, roll: float, mat: str, at: str) -> None: + frame = _frame((origin + a * x + b * y + n * z) * flip, n * flip, b * flip, at, -roll if side < 0 else roll) + held.setdefault(mat, _Mesh()).add(mesh[0] @ frame[:3, :3].T + frame[:3, 3], mesh[1]) + + for j, fit in enumerate(row["fits"]): + at = f"{path}.fits[{j}]" + if fit["kind"] == "part": + stand(part(fit["part"], fit["params"], at), *fit["at"], top + fit["lift"], fit["roll"], fit["mat"], at) + count += 1 + elif fit["kind"] == "bolts": + slab = row["slab"] + ring = inset2d(_slab_ring(slab, face), fit["inset"] + slab["taper"]) + if not _area2(ring) > 0: + raise PlateError(f"{at}.inset: {fit['inset']} and the slab's taper leave nothing of the outline") + bolt = part("bolt", fit["params"], at) + for k in range(len(ring)): + p, q = ring[k], ring[(k + 1) % len(ring)] + along = max(1, int(float(np.linalg.norm(q - p)) / fit["spacing"])) + for m in range(along): + stand(bolt, *(p + (q - p) * ((m + 0.5) / along)), fit["lift"], 0.0, fit["mat"], at) + count += along + elif fit["kind"] == "step": + polygon = [(origin + a * (fit["at"][0] + x) + b * (fit["at"][1] + y) + n * top) * flip for x, y in fit["outline"]] + if not panel(held.setdefault(fit["mat"], _Mesh()), held.setdefault(fit["bolt_mat"], _Mesh()), polygon, n * flip, fit["lift"], 0.0, BOLT): + raise PlateError(f"{at}.outline: under {PANEL_MIN[1]} m2: too small for a panel") + count += 1 + return {mat: mesh.done() for mat, mesh in held.items() if mesh.faces}, count + + # --- build ------------------------------------------------------------------------------------------------------------ def _across(mesh): """A mesh (V, faces) mirrored across x = 0, its faces wound outward still and starting where they did.""" @@ -894,10 +1009,12 @@ def build(table: Any, side: int = 1) -> list[dict]: every point before the hull, and facets, ties and draws are those of the mirrored solid as built, which is not the mirror of side +1's panels; a clad selector's direction is mirrored with it. Each entry: {name, row (its index in the table), mat, bevel, side, solid: (V, faces), facets, panels: (V, faces), bolts: (V, faces), - anchors: [{kind, name, matrix, mirrored, height?}], report: {corners, facets, panels, bolts}}.""" + fits: {mat: (V, faces)}, anchors: [{kind, name, matrix, mirrored, height?}], report: {corners, facets, panels, + bolts, fits}}. fits are drawn where the panels are, so a mirrored .L's are the mirror of its .R's.""" if side not in (1, -1): raise PlateError(f"side: {side!r} is not 1 or -1") - table = _read(table) + kit: dict = {} + table = _read(table, kit) built = [] for i, row in enumerate(table["plates"]): path = f"plates[{i}]" @@ -917,13 +1034,15 @@ def build(table: Any, side: int = 1) -> list[dict]: if clad is not None: seed = clad["seed"][0 if where > 0 else 1] if pair else clad["seed"] panels, bolts, made, top = clad_layout(V, faces, facets, clad, seed, None if face is None else face[3] * turn, where) - drawn[where] = ((V, faces), facets, panels, bolts, made, top) - solid, facets, panels, bolts, made, top = drawn[where] + drawn[where] = ((V, faces), facets, panels, bolts, made, top, *fit_meshes(row, face, top, where, kit, path)) + solid, facets, panels, bolts, made, top, fits, stood = drawn[where] if where != s: - solid, panels, bolts = _across(solid), _across(panels), _across(bolts) + solid, panels, bolts, fits = _across(solid), _across(panels), _across(bolts), {mat: _across(mesh) for mat, mesh in fits.items()} facets = [{"normal": f["normal"] * flip, "area": f["area"], "centre": f["centre"] * flip} for f in facets] anchors = [] for j, fit in enumerate(row["fits"]): + if fit["kind"] not in ANCHORS: + continue origin, a, b, n = face at = (origin + a * fit["at"][0] + b * fit["at"][1] + n * (top + fit.get("lift", 0.0))) * flip up = (0.0, 0.0, 1.0) if fit["kind"] == "mark" else b * flip @@ -932,6 +1051,6 @@ def build(table: Any, side: int = 1) -> list[dict]: anchor["height"] = fit["height"] anchors.append(anchor) built.append({"name": row["name"] + ((".R" if s > 0 else ".L") if row["sides"] == "both" else ""), "row": i, "mat": row["mat"], "bevel": row["bevel"], "side": s, - "solid": solid, "facets": facets, "panels": panels, "bolts": bolts, "anchors": anchors, - "report": {"corners": len(solid[0]), "facets": len(solid[1]), "panels": made, "bolts": len(bolts[0]) // 12}}) + "solid": solid, "facets": facets, "panels": panels, "bolts": bolts, "fits": fits, "anchors": anchors, + "report": {"corners": len(solid[0]), "facets": len(solid[1]), "panels": made, "bolts": len(bolts[0]) // 12, "fits": stood}}) return built diff --git a/surfaces/blender/tests/test_plate.py b/surfaces/blender/tests/test_plate.py index e331030..15801d0 100644 --- a/surfaces/blender/tests/test_plate.py +++ b/surfaces/blender/tests/test_plate.py @@ -36,6 +36,7 @@ if np is not None: package.__path__ = [str(SURFACE / "brokkr_kitbash")] sys.modules["brokkr_kitbash_plates"] = package plate = importlib.import_module("brokkr_kitbash_plates.plate") + core = importlib.import_module("brokkr_kitbash_plates.core") BOX = [{"at": [1, 0, 0], "normal": [1, 0, 0]}, {"at": [-1, 0, 0], "normal": [-1, 0, 0]}, {"at": [0, 1, 0], "normal": [0, 1, 0]}, {"at": [0, -1, 0], "normal": [0, -1, 0]}, {"at": [0, 0, 1], "normal": [0, 0, 1]}, {"through": [[0, 0, -1], [1, 0, -1], [0, 1, -1]], "out": [0, 0, -1]}] @@ -485,9 +486,9 @@ class CheckTests(unittest.TestCase): def test_unknown_fit_kind(self): with self.assertRaises(plate.PlateError) as caught: - plate.check(doc(row(slab=SLAB, fits=[{"kind": "bolts", "at": [0, 0]}]))) + plate.check(doc(row(slab=SLAB, fits=[{"kind": "rivets", "at": [0, 0]}]))) self.assertIn("plates[0].fits[0].kind", str(caught.exception)) - self.assertIn("mark, hose_port", str(caught.exception)) + self.assertIn("mark, hose_port, part, bolts, step", str(caught.exception)) def test_duplicate_anchor_name(self): fits = [{"kind": "mark", "id": "a", "at": [0, 0], "height": 0.3}, {"kind": "hose_port", "name": "a", "at": [0.1, 0]}] @@ -514,7 +515,7 @@ class CheckTests(unittest.TestCase): class SolidTests(unittest.TestCase): def test_a_cube_from_six_faces(self): made = plate.build(doc(row()))[0] - self.assertEqual(made["report"], {"corners": 8, "facets": 6, "panels": 0, "bolts": 0}) + self.assertEqual(made["report"], {"corners": 8, "facets": 6, "panels": 0, "bolts": 0, "fits": 0}) self.assertEqual(sorted(map(tuple, np.round(made["solid"][0]).astype(int).tolist())), sorted((x, y, z) for x in (-1, 1) for y in (-1, 1) for z in (-1, 1))) self.assertAlmostEqual(volume(made["solid"]), 8.0, places=12) @@ -822,7 +823,7 @@ class CladTests(unittest.TestCase): def test_a_split_facet_takes_two_panels_and_a_whole_one_a_panel(self): made = plate.build(doc(row(clad=dict(CLAD, facets=[{"n": [0, 0, 1], "cos": 0.9}], split=2.2))))[0] - self.assertEqual(made["report"], {"corners": 8, "facets": 6, "panels": 2, "bolts": 8}) + self.assertEqual(made["report"], {"corners": 8, "facets": 6, "panels": 2, "bolts": 8, "fits": 0}) self.assertEqual((len(made["panels"][0]), len(made["bolts"][0])), (24, 96)) self.assertGreater(volume(made["panels"]), 0) self.assertAlmostEqual(volume(made["bolts"]), 8 * 1.5 * math.sqrt(3) * 0.028 ** 2 * 0.6 * 0.028, places=12) @@ -904,6 +905,182 @@ class AnchorTests(unittest.TestCase): self.assertLess(float(np.abs(np.array(made["anchors"][0]["matrix"])[:3, 3] - np.array([0.2, 1.01, 0.3])).max()), 1e-12) +def placed(part, params, frame): + """A fittings part's vertices at params, placed by a 4x4 frame.""" + V = core.build(core.load_kit("fittings")["parts"][part], core.parse_params(params)).V + return V @ frame[:3, :3].T + frame[:3, 3] + + +RIM = {"at": [0.5, 1.0, 0.2], "normal": [0.06, 1, 0.05], "right": [1, 0, 0], "outline": {"w": 1.0, "h": 0.6, "clip": 0.0}, "thick": 0.2, "taper": 0.04} +PIT = {"kind": "part", "part": "pit", "at": [0.1, -0.05], "roll": 30, "lift": 0.01, "params": "w=0.2; h=0.05", "mat": "pit"} +STEP = {"kind": "step", "outline": [[-0.15, -0.1], [0.15, -0.1], [0.2, 0.1], [-0.15, 0.1]], "at": [0.05, 0.02], "lift": 0.03, "mat": "olive_light"} +# One row of each fit kind, on a clad slab built on both sides: what the hash holds of fits. +FITTED = {"name": "Fitted", "mat": "olive", "sides": "both", "slab": RIM, "clad": dict(CLAD, split=99), "fits": [ + {"kind": "bolts", "inset": 0.04, "spacing": 0.2, "mat": "gunmetal"}, PIT, STEP, + {"kind": "part", "part": "slot", "at": [0.1, -0.05], "roll": 30, "lift": 0.01, "params": "w=0.2; h=0.05", "mat": "olive"}, + {"kind": "part", "part": "vents", "at": [-0.25, 0.0], "mat": "olive"}, {"kind": "part", "part": "access_port", "at": [0.3, 0.12], "params": "r=0.08", "mat": "machine"}, + {"kind": "part", "part": "port_bolts", "at": [0.3, 0.12], "params": "r=0.08", "mat": "gunmetal"}, {"kind": "part", "part": "handle", "at": [0.0, 0.2], "roll": 90, "mat": "gunmetal"}, + {"kind": "part", "part": "eye", "at": [-0.3, -0.18], "mat": "gunmetal"}, {"kind": "part", "part": "louvres", "at": [0.0, 0.0], "params": "w=0.2; h=0.2; n=3", "mat": "olive"}]} + + +@unittest.skipIf(np is None, "numpy is not installed") +class FitTests(unittest.TestCase): + """Fit rows that are geometry. A reading is how far the built points stand from the stated ones (apart, metres); + each bound is the geometric mean of the shipped reading and the mutant's (lodur:ruling:deterministic-bound-margin).""" + # fit-frames: shipped 0.0 here, held as 2.2e-16 (a float's spacing at 1 m); the roll not negated at side -1 reads 0.10, the clad top + # left out 0.05: the bound is 3e-9, 1e7 each side of both + HELD = 3e-9 + + def frame(self, at, lift, roll, side=1, slab=RIM): + a, b, n = plate.plane_basis(slab["normal"], (0, 0, 1), slab.get("right")) + flip = np.array([side, 1.0, 1.0]) + return core.surface_frame((np.array(slab["at"]) + a * at[0] + b * at[1] + n * lift) * flip, n * flip, b * flip, -roll if side < 0 else roll) + + def test_a_part_stands_in_the_fits_frame(self): + made = plate.build(doc(row(slab=RIM, fits=[PIT])))[0] + self.assertEqual((list(made["fits"]), made["report"]["fits"]), (["pit"], 1)) + V, faces = made["fits"]["pit"] + self.assertLess(apart(V, placed("pit", PIT["params"], self.frame(PIT["at"], 0.01, 30))), self.HELD) + self.assertEqual([len(f) for f in faces], [4] * 6) + self.assertGreater(volume((V, faces)), 0) + + def test_right_handed_at_side_minus_one_with_the_roll_negated(self): + """fit-frames. Mutant: roll not negated at side -1.""" + made = plate.build(doc(row(slab=RIM, fits=[PIT])), -1)[0] + frame = self.frame(PIT["at"], 0.01, 30, -1) + a, b, n = plate.plane_basis(RIM["normal"], (0, 0, 1), RIM["right"]) + self.assertAlmostEqual(float(np.linalg.det(frame[:3, :3])), 1.0, places=12) + self.assertLess(float(np.abs(frame[:3, 2] - n * (-1, 1, 1)).max()), 1e-12) + self.assertLess(apart(made["fits"]["pit"][0], placed("pit", PIT["params"], frame)), self.HELD) + self.assertGreater(volume(made["fits"]["pit"]), 0) # wound outward still + mirror = plate.build(doc(row(slab=RIM, fits=[PIT])), 1)[0]["fits"]["pit"][0] * (-1, 1, 1) + self.assertLess(apart(made["fits"]["pit"][0], mirror), self.HELD) # a part the same across its x: side -1 is the mirror + + def test_a_part_and_a_step_stand_on_the_clad_top_and_bolts_on_the_bare_face(self): + fits = [{"kind": "bolts", "inset": 0.04, "spacing": 0.2, "lift": 0.002, "mat": "gunmetal"}, PIT, STEP] + bare = plate.build(doc(row(slab=RIM, fits=fits)))[0]["fits"] + clad = plate.build(doc(row(slab=RIM, fits=fits, clad=dict(CLAD, mat="clad", lifts=[0.05, 0.05], split=99))))[0]["fits"] + n = plate.plane_basis(RIM["normal"])[2] + for mat in ("pit", "olive_light"): + self.assertLess(apart(clad[mat][0], bare[mat][0] + n * 0.05), self.HELD, mat) + self.assertLess(apart(clad["pit"][0], placed("pit", PIT["params"], self.frame(PIT["at"], 0.06, 30))), self.HELD) + bolts, step = len(placed("bolt", "", np.eye(4))) * 12, 12 * 4 + self.assertEqual(len(bare["gunmetal"][0]), bolts + step) + self.assertEqual(float(np.abs(clad["gunmetal"][0][:bolts] - bare["gunmetal"][0][:bolts]).max()), 0.0) # the rim's bolts fasten the plate, under its cladding + self.assertLess(apart(bare["gunmetal"][0][:40], placed("bolt", "", self.frame([-0.42 + 0.105, -0.22], 0.002, 0))), self.HELD) + + def bolts_by_edge(self, spacing, counts): + made = plate.build(doc(row(slab=RIM, fits=[{"kind": "bolts", "inset": 0.04, "spacing": spacing, "mat": "gunmetal"}])))[0] + a, b, n = plate.plane_basis(RIM["normal"], (0, 0, 1), RIM["right"]) + each = len(placed("bolt", "", np.eye(4))) + V = made["fits"]["gunmetal"][0].reshape(-1, each, 3) + self.assertEqual((len(V), made["report"]["fits"]), (sum(counts), sum(counts))) + ring = np.array([[-0.42, -0.22], [0.42, -0.22], [0.42, 0.22], [-0.42, 0.22]]) # the outline in 0.04 + the taper 0.04, counter-clockwise from where the row's runs + want = [ring[k] + (ring[(k + 1) % 4] - ring[k]) * (j + 0.5) / count for k, count in enumerate(counts) for j in range(count)] + # a bolt's own points: its washer's 28 and its head's 12 are each centred on its axis + got = [[float((bolt[:28].mean(axis=0) - RIM["at"]) @ a), float((bolt[:28].mean(axis=0) - RIM["at"]) @ b)] for bolt in V] + return float(np.abs(np.array(got) - np.array(want)).max()) + + def test_bolts_stand_along_the_outline_moved_in(self): + """bolt-rim: 0.84 and 0.44 edges. At spacing 0.2, 4, 2, 4, 2; at 0.15 (5.6 and 2.9 to an edge), 5, 2, 5, 2. + Mutant int -> round: 6, 3, 6, 3 at 0.15 (the count differs; at 0.2 it gives the same 4, 2, 4, 2).""" + self.assertLess(self.bolts_by_edge(0.2, [4, 2, 4, 2]), 1e-12) + self.assertLess(self.bolts_by_edge(0.15, [5, 2, 5, 2]), 1e-12) + self.assertLess(self.bolts_by_edge(5.0, [1, 1, 1, 1]), 1e-12) + + def test_bolts_follow_a_gapped_outline_of_either_winding(self): + slab = dict(RIM, outline=[[-0.5, -0.3], [-0.5, 0.3], [0.5, 0.3], [0.5, -0.3]], gap=0.05) + made = plate.build(doc(row(slab=slab, fits=[{"kind": "bolts", "inset": 0.04, "spacing": 5.0, "mat": "gunmetal"}])))[0] + a, b, n = plate.plane_basis(RIM["normal"], (0, 0, 1), RIM["right"]) + V = made["fits"]["gunmetal"][0].reshape(4, -1, 3) + got = sorted([round(float((bolt[:28].mean(axis=0) - RIM["at"]) @ a), 9), round(float((bolt[:28].mean(axis=0) - RIM["at"]) @ b), 9)] for bolt in V) + self.assertEqual(got, [[-0.37, 0.0], [0.0, -0.17], [0.0, 0.17], [0.37, 0.0]]) + self.assertGreater(volume(made["fits"]["gunmetal"]), 0) + + def test_a_step_is_a_panel_on_its_outline(self): + made = plate.build(doc(row(slab=RIM, fits=[STEP])))[0] + a, b, n = plate.plane_basis(RIM["normal"], (0, 0, 1), RIM["right"]) + panels, bolts = plate._Mesh(), plate._Mesh() + polygon = [np.array(RIM["at"]) + a * (0.05 + x) + b * (0.02 + y) for x, y in STEP["outline"]] + self.assertTrue(plate.panel(panels, bolts, polygon, n, 0.03, 0.0, plate.BOLT)) + self.assertEqual(list(made["fits"]), ["olive_light", "gunmetal"]) + for mat, mesh in (("olive_light", panels), ("gunmetal", bolts)): + self.assertEqual(float(np.abs(made["fits"][mat][0] - mesh.done()[0]).max()), 0.0) + self.assertEqual(made["fits"][mat][1], mesh.done()[1]) + named = plate.build(doc(row(slab=RIM, fits=[dict(STEP, bolt_mat="steel")])))[0] + self.assertEqual(list(named["fits"]), ["olive_light", "steel"]) + + def test_the_left_of_a_one_seed_row_is_the_right_mirrored(self): + """mirror. Mutant: the .L's fits drawn at side -1 (right-handed frames) and not mirrored.""" + for clad in (None, dict(CLAD, split=99)): + right, left = plate.build(doc(dict(FITTED, clad=clad))) + self.assertEqual((right["name"], left["name"], left["report"]["fits"]), ("Fitted.R", "Fitted.L", right["report"]["fits"])) + self.assertEqual(list(left["fits"]), list(right["fits"])) + for mat in right["fits"]: + V, faces = across(right["fits"][mat]) + self.assertEqual(float(np.abs(left["fits"][mat][0] - V).max()), 0.0, mat) + self.assertEqual(left["fits"][mat][1], faces) + self.assertGreater(volume(left["fits"][mat]), 0, mat) + pair = plate.build(doc(dict(FITTED, clad=dict(CLAD, split=99, seed=[5, 5]))))[1] # a pair of seeds: the left is drawn at side -1 + slot = [f for f in FITTED["fits"] if f.get("part") == "slot"][0] + self.assertLess(apart(pair["fits"]["olive"][0][:32], placed("slot", slot["params"], self.frame(slot["at"], CLAD["lifts"][0] + 0.01, 30, -1))), self.HELD) + + def test_fits_of_one_material_merge_in_row_order(self): + made = plate.build(doc(row(slab=RIM, fits=[PIT, {"kind": "mark", "id": "m", "at": [0, 0], "height": 0.1}, dict(PIT, at=[-0.2, 0.1], roll=0, lift=0)])))[0] + self.assertEqual((made["report"]["fits"], len(made["anchors"]), len(made["fits"]["pit"][0]), made["fits"]["pit"][1][6]), (2, 1, 16, [8, 11, 10, 9])) + self.assertLess(apart(made["fits"]["pit"][0][8:], placed("pit", PIT["params"], self.frame([-0.2, 0.1], 0.0, 0))), self.HELD) + + def test_every_part_stands_on_a_face_at_its_defaults(self): + for name in core.load_kit("fittings")["parts"]: + made = plate.build(doc(row(face={"at": [0, 1, 0], "normal": [0, 1, 0]}, fits=[{"kind": "part", "part": name, "at": [0.1, 0.2], "mat": "m"}])))[0] + V = made["fits"]["m"][0] + self.assertLess(apart(V, placed(name, "", core.surface_frame([-0.1, 1.0, 0.2], [0, 1, 0], [0, 0, 1]))), self.HELD, name) # a is b cross n: -x here + self.assertGreater(float(V[:, 1].max()), 1.01, name) + self.assertGreater(float(V[:, 1].min()), 0.99, name) + + def refused(self, fit, *wants, slab=RIM, **more): + with self.assertRaises(plate.PlateError) as caught: + plate.check(doc(row(fits=[fit], **({"slab": slab} if slab else {}), **more))) + for want in wants: + self.assertIn(want, str(caught.exception)) + + def test_refusals_name_the_path(self): + part = {"kind": "part", "part": "pit", "at": [0, 0], "mat": "pit"} + self.refused(dict(part, part="rivet"), "plates[0].fits[0].part: 'rivet' is no part of the fittings kit", "bolt, slot, pit, vents, access_port, port_bolts, handle, eye, louvres") + self.refused(dict(part, part=["pit"]), "plates[0].fits[0].part") + self.refused(dict(part, params="w=9"), "plates[0].fits[0].params: kit 'fittings' part 'pit' param 'w' = 9.0 is outside [0.005, 2]") + self.refused(dict(part, params="wide=1"), "plates[0].fits[0].params", "has no param 'wide'") + self.refused(dict(part, params="w"), "plates[0].fits[0].params", "is not name=value") + self.refused(dict(part, params="w=0.1;" + " " * 256), "plates[0].fits[0].params: wants") + self.refused(dict(part, params=3), "plates[0].fits[0].params: wants") + self.refused(dict(part, mat="m" * 64), "plates[0].fits[0].mat") + self.refused({k: v for k, v in part.items() if k != "mat"}, "plates[0].fits[0].mat: missing") + self.refused(dict(part, roll=361), "plates[0].fits[0].roll") + self.refused(dict(part, height=1), "plates[0].fits[0].height: unknown key") + self.refused(part, "plates[0].fits[0]: a fit stands on a face", slab=None) + self.refused(dict(part, part="louvres", params="w=0.1; frame=0.3"), "plates[0].fits[0]: kit 'fittings' part 'louvres'", "every size must be above 0") + bolts = {"kind": "bolts", "inset": 0.04, "spacing": 0.2, "mat": "gunmetal"} + self.refused(bolts, "plates[0].fits[0]: a bolts row stands along a slab's outline; this row is no slab", slab=None, face={"at": [0, 1, 0], "normal": [0, 1, 0]}) + self.refused(dict(bolts, mat="m" * 64), "plates[0].fits[0].mat") + self.refused(dict(bolts, spacing=0), "plates[0].fits[0].spacing") + self.refused(dict(bolts, params="r=1"), "plates[0].fits[0].params: kit 'fittings' part 'bolt' param 'r'") + self.refused(dict(bolts, inset=0.3), "plates[0].fits[0].inset: 0.3 and the slab's taper leave nothing of the outline") + self.refused(dict(STEP, mat="m" * 64), "plates[0].fits[0].mat") + self.refused(dict(STEP, bolt_mat=""), "plates[0].fits[0].bolt_mat") + self.refused(dict(STEP, outline=STEP["outline"][:2]), "plates[0].fits[0].outline: wants 3 to 64 entries") + self.refused(dict(STEP, outline=[[0, 0], [0.3, 0.3], [0.3, 0], [0, 0.2]]), "plates[0].fits[0].outline: the outline crosses itself") + self.refused(dict(STEP, outline=[[0, 0], [0.1, 0], [0.1, 0.1]]), "plates[0].fits[0].outline: under 0.02 m2") + self.refused({k: v for k, v in STEP.items() if k != "lift"}, "plates[0].fits[0].lift: missing") + plate.check(doc(row(slab=RIM, fits=[part, dict(part), bolts, STEP]))) # geometry fits carry no name: two alike are two fits + + def test_check_writes_a_fit_s_defaults_in(self): + fits = plate.check(doc(row(slab=RIM, fits=[{"kind": "part", "part": "eye", "at": [0, 0], "mat": "g"}, {"kind": "bolts", "inset": 0.04, "spacing": 0.2, "mat": "g"}, STEP])))["plates"][0]["fits"] + self.assertEqual(fits[0], {"kind": "part", "part": "eye", "at": [0.0, 0.0], "roll": 0.0, "lift": 0.0, "params": "", "mat": "g"}) + self.assertEqual(fits[1], {"kind": "bolts", "inset": 0.04, "spacing": 0.2, "lift": 0.0, "params": "", "mat": "g"}) + self.assertEqual(fits[2], dict(STEP, outline=[[float(v) for v in p] for p in STEP["outline"]], bolt_mat="gunmetal")) + self.assertEqual(plate.check({"schema": plate.SCHEMA, "plates": [dict(row(slab=RIM), fits=fits)]})["plates"][0]["fits"], fits) + + @unittest.skipIf(np is None, "numpy is not installed") class DeterminismTests(unittest.TestCase): def test_the_table_and_the_side_are_the_only_inputs(self): @@ -921,15 +1098,23 @@ class DeterminismTests(unittest.TestCase): for mech in ("bastion", "paladin", "raptor"): for case in fixture(mech)["cases"]: for entry in plate.build(fixture(mech)["table"], case["side"]): - made.update(entry["name"].encode()) - for key in ("solid", "panels", "bolts"): - made.update(np.round(entry[key][0] / QUANTUM).astype(" Date: Thu, 3 Dec 2026 17:37:40 +0100 Subject: [PATCH 3/8] brokkr_kitbash.plates: a row's fittings written into N.fit. (cut plate-fittings-kit) Each fits material merges with the panels or bolts of the same material; every material a fit names is checked before anything is written. The live test writes a slab with a fit row of every kind on both sides. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/brokkr_kitbash/__init__.py | 10 +- .../brokkr_kitbash/brokkr_actions.json | 2 +- surfaces/blender/tests/live/kitbash_plates.py | 56 ++++++++++- .../tests/live/kitbash_plates.result.json | 92 ++++++++++++++++++- 4 files changed, 149 insertions(+), 11 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/__init__.py b/surfaces/blender/brokkr_kitbash/__init__.py index 0770c52..5e76075 100644 --- a/surfaces/blender/brokkr_kitbash/__init__.py +++ b/surfaces/blender/brokkr_kitbash/__init__.py @@ -61,8 +61,8 @@ that crosses the same pin (it bends with the pin, so it is measured as an obstac follow-up aetheria-release:follow_up:hose-motion-clearance-from-skinning owes that check). plates writes hard armour plates. plate.py owns the table (brokkr.plates.v0) and every point of a plate, its panels, -bolts and anchor frames, in the table's frame; this file converts its arrays and nothing else. A plate is a mesh -object on its host under an identity parent inverse, with a child per material for its panels and bolts +bolts, fittings and anchor frames, in the table's frame; this file converts its arrays and nothing else. A plate is a mesh +object on its host under an identity parent inverse, with a child per material for its panels, bolts and fittings (.fit.) and an empty per anchor (.mark., .port., kit_anchor on each). plates is the one writer of those objects, their Kit Bevels, plate_kind and kit_plate. kit_plate is the checked row, kept as a record: its presence admits a rebuild in place and nothing reads it to decide geometry. A plate is no kit part: @@ -2698,7 +2698,9 @@ class BROKKR_KITBASH_OT_plates(PolishOperator): rebuild, or None), fits [(name, material, holds panels, meshes)], anchors [(name, record, matrix)], stale (the plate's fit children and anchors this call no longer makes)}. `taken` is every name the call has planned.""" name, path, clad = self.prefix + entry["name"], f"table.plates[{entry['row']}]", row["clad"] - for key, material in (("mat", row["mat"]),) + ((("clad.mat", clad["mat"]), ("clad.bolt_mat", clad["bolt_mat"])) if clad else ()): + named = [("mat", row["mat"])] + ([("clad.mat", clad["mat"]), ("clad.bolt_mat", clad["bolt_mat"])] if clad else []) + named += [(f"fits[{j}].{key}", fit[key]) for j, fit in enumerate(row["fits"]) for key in ("mat", "bolt_mat") if key in fit] + for key, material in named: if material not in bpy.data.materials: raise Refused(f"{path}.{key}: no material named {material!r}; make it first (createMaterial); nothing changed.") obj = bpy.data.objects.get(name) @@ -2713,6 +2715,8 @@ class BROKKR_KITBASH_OT_plates(PolishOperator): if len(mesh[1]): held = fits.setdefault(f"{name}.fit.{material}", [material, False, []]) held[1], held[2] = held[1] or panels, held[2] + [mesh] + for material, mesh in entry["fits"].items(): + fits.setdefault(f"{name}.fit.{material}", [material, False, []])[2].append(mesh) anchors = [] for anchor in entry["anchors"]: record = {"kind": anchor["kind"], "id": anchor["name"], "height": anchor["height"]} if anchor["kind"] == "mark" else {"kind": anchor["kind"], "name": anchor["name"]} diff --git a/surfaces/blender/brokkr_kitbash/brokkr_actions.json b/surfaces/blender/brokkr_kitbash/brokkr_actions.json index 9c35c74..78d2146 100644 --- a/surfaces/blender/brokkr_kitbash/brokkr_actions.json +++ b/surfaces/blender/brokkr_kitbash/brokkr_actions.json @@ -1004,7 +1004,7 @@ }, { "name": "brokkr_kitbash.plates", - "doc": "Write a table of hard armour plates into the scene. table is a brokkr.plates.v0 document as JSON (docs/kitbash.md, Hard plates): {\"schema\": \"brokkr.plates.v0\", \"plates\": [row, ...]}, each row a convex faceted solid with optional clad (raised panels and their bolts) and fits (anchors on its face). The table's coordinates are metres in frame: a JSON 4x4 of rows in the world, rigid; empty, the host's world matrix, or the world with no host. side 1 builds the table as written and -1 mirrored across its x = 0. Each built plate is a mesh object named prefix + its name (.R and .L on a two-sided row), every face flat, parented to host under an identity parent inverse, with material mat, a Kit Bevel of the row's bevel (angle 12 degrees) and the properties plate_kind \"hard\" and kit_plate (its checked row, a record). Its panels are the child .fit. and its bolts .fit., one mesh per material, made only when not empty; a child that holds panels carries a Kit Bevel of clad.bevel (angle 20 degrees, one segment). Each anchor is an empty child at the anchor's frame: .mark. with kit_anchor {kind, id, height}, .port. with kit_anchor {kind, name}; brokkr_kitbash.hose takes a port empty's name as an end and leaves along its z. An object that carries kit_plate under a made name is rebuilt in place: it keeps its identity, its other children and its modifiers; its fit children are rewritten, made or removed, its anchors moved, and one the row no longer names removed. A plate is no kit part: joints and report do not list it, and a roll of its host carries it. Every material must exist (createMaterial). Refuses before it writes anything: a table the format refuses (the path is named), a missing material (named with its path), a host that is missing, scaled, mirrored or sheared, a frame that is not a rigid 4x4, a made name of over 63 bytes or taken by an object that is not this plate's, a frozen plate or one sharing its mesh, and a report over 16000 characters. Reports plates [{name, rebuilt, corners, facets, panels, bolts, anchors (the empties' names)}], host and side.", + "doc": "Write a table of hard armour plates into the scene. table is a brokkr.plates.v0 document as JSON (docs/kitbash.md, Hard plates): {\"schema\": \"brokkr.plates.v0\", \"plates\": [row, ...]}, each row a convex faceted solid with optional clad (raised panels and their bolts) and fits (anchors on its face, and fittings: parts of the fittings kit, rim bolts and steps). The table's coordinates are metres in frame: a JSON 4x4 of rows in the world, rigid; empty, the host's world matrix, or the world with no host. side 1 builds the table as written and -1 mirrored across its x = 0. Each built plate is a mesh object named prefix + its name (.R and .L on a two-sided row), every face flat, parented to host under an identity parent inverse, with material mat, a Kit Bevel of the row's bevel (angle 12 degrees) and the properties plate_kind \"hard\" and kit_plate (its checked row, a record). Its panels are the child .fit., its bolts .fit. and each fitting .fit., one mesh per material, made only when not empty; a child that holds panels carries a Kit Bevel of clad.bevel (angle 20 degrees, one segment). Each anchor is an empty child at the anchor's frame: .mark. with kit_anchor {kind, id, height}, .port. with kit_anchor {kind, name}; brokkr_kitbash.hose takes a port empty's name as an end and leaves along its z. An object that carries kit_plate under a made name is rebuilt in place: it keeps its identity, its other children and its modifiers; its fit children are rewritten, made or removed, its anchors moved, and one the row no longer names removed. A plate is no kit part: joints and report do not list it, and a roll of its host carries it. Every material must exist (createMaterial). Refuses before it writes anything: a table the format refuses (the path is named), a missing material (named with its path), a host that is missing, scaled, mirrored or sheared, a frame that is not a rigid 4x4, a made name of over 63 bytes or taken by an object that is not this plate's, a frozen plate or one sharing its mesh, and a report over 16000 characters. Reports plates [{name, rebuilt, corners, facets, panels, bolts, anchors (the empties' names)}], host and side.", "changesScene": true, "editModeSafe": false, "result": "brokkr_mesh_polish_result", diff --git a/surfaces/blender/tests/live/kitbash_plates.py b/surfaces/blender/tests/live/kitbash_plates.py index 8463e73..47a5bd3 100644 --- a/surfaces/blender/tests/live/kitbash_plates.py +++ b/surfaces/blender/tests/live/kitbash_plates.py @@ -1,8 +1,8 @@ """Live proof, in a background Blender, of brokkr_kitbash.plates through run_intent: a plate table written onto a mechanical-kit link under a pin, each plate's mesh, fit children and anchor empties against plate.build's own answer under the frame, the Kit Bevels, joints unchanged by the plates, a roll of the pin carrying every plate, a hose between -two port empties either side of the pin across its range, a rebuild in place, and each refusal leaving the scene as it -was. Not part of the unittest run: it needs Blender. +two port empties either side of the pin across its range, a rebuild in place, each refusal leaving the scene as it +was, and a slab with a fit row of every kind written into a child per material. Not part of the unittest run: it needs Blender. blender --background --factory-startup --python-exit-code 1 --python surfaces/blender/tests/live/kitbash_plates.py -- @@ -67,7 +67,8 @@ COUNT, SECTION = [0], ["setup"] # origin; X4 a plate written with no parent; X5 the host's inverse as the parent inverse; X6 a kept anchor not moved; X7 # the plate's Kit Bevel at shell's 30 degrees; X8 the panels' at 12; X9 a fit child parented to the host; X10 an # anchor's basis under the frame again; X11 stale children kept; X12 no sharp_face written; X13 no material refusal; -# X14 no refusal of a taken child or anchor name. +# X14 no refusal of a taken child or anchor name; X15 a row's fittings not written (plan leaves entry["fits"] out); X16 no +# refusal of a fit's missing material. # # Metres between a written vertex in the world (the object's matrix_world on its mesh's own coordinates) and the same # vertex of plate.build's answer under the frame this script holds, over every plate and fit child of the suite; inf @@ -183,12 +184,14 @@ def bevel(obj): def fits_of(entry, row): - """{material: [meshes]} of what a built entry's fit children hold, panels before bolts.""" + """{material: [meshes]} of what a built entry's fit children hold: panels, bolts, then the row's fittings.""" held = {} if row["clad"]: for material, mesh in ((row["clad"]["mat"], entry["panels"]), (row["clad"]["bolt_mat"], entry["bolts"])): if len(mesh[1]): held.setdefault(material, []).append(mesh) + for material, mesh in entry["fits"].items(): + held.setdefault(material, []).append(mesh) return held @@ -219,7 +222,7 @@ def proven(label, document, side, prefix, host, frame, report): if child is None or child.parent != obj: facts[f"fit {material}"] = False continue - panels = material == row["clad"]["mat"] + panels = bool(row["clad"]) and material == row["clad"]["mat"] facts[f"fit {material}"] = (reading("written", written(child, frame, parts)) < WRITTEN and np.array_equal(np.array(child.matrix_basis), np.eye(4)) and np.array_equal(np.array(child.matrix_parent_inverse), np.eye(4)) and [s.material.name for s in child.material_slots] == [material] and bevel(child) == ((round(row["clad"]["bevel"], 6), 20.0, 1, "ANGLE") if panels and row["clad"]["bevel"] > 0 else None)) @@ -428,6 +431,49 @@ try: bpy.context.view_layer.update() check("thawed, the plate is rebuilt", receipt["status"] == "accepted" and report["plates"][0]["rebuilt"], [receipt["status"], receipt["message"]]) proven("the thawed plate", THIGH, 1, "Thigh.", thigh, world(thigh), report) + + section("fittings") + for name in ("pit", "machine"): + bpy.data.materials.new(name) + KIT = slab("Kit", [0.0, -0.3, 0.3], ("feed", [0.0, 0.1])) + KIT["sides"] = "both" + KIT["fits"] += [{"kind": "bolts", "inset": 0.012, "spacing": 0.08, "params": "r=0.006", "mat": "gunmetal"}, + {"kind": "part", "part": "slot", "at": [0.0, 0.18], "params": "w=0.08; h=0.02", "mat": "khaki"}, + {"kind": "part", "part": "pit", "at": [0.0, 0.18], "params": "w=0.08; h=0.02", "mat": "pit"}, + {"kind": "part", "part": "vents", "at": [-0.06, 0.03], "params": "w=0.06; h=0.012; count=3", "mat": "khaki"}, + {"kind": "part", "part": "pit", "at": [-0.06, 0.03], "params": "w=0.06; h=0.012; depth=0.01; count=3; pitch=0.0324", "mat": "pit"}, + {"kind": "part", "part": "access_port", "at": [0.07, -0.1], "params": "r=0.03", "mat": "machine"}, + {"kind": "part", "part": "port_bolts", "at": [0.07, -0.1], "params": "r=0.03", "mat": "gunmetal"}, + {"kind": "part", "part": "handle", "at": [-0.07, -0.1], "roll": 90.0, "params": "length=0.1; lift=0.04; r=0.004", "mat": "gunmetal"}, + {"kind": "part", "part": "eye", "at": [0.08, 0.12], "lift": 0.002, "params": "size=0.03", "mat": "gunmetal"}, + {"kind": "part", "part": "louvres", "at": [0.0, -0.18], "params": "w=0.1; h=0.1; n=3; depth=0.02; frame=0.02", "mat": "steel"}, + {"kind": "step", "outline": [[-0.1, -0.06], [0.1, -0.06], [0.1, 0.06], [-0.1, 0.06]], "at": [0.0, 0.0], "lift": 0.012, "mat": "olive_light", "bolt_mat": "steel"}] + FITS = doc(KIT) + before = scene_state() + refused("a fit whose material is not in the file", call(doc({**KIT, "fits": KIT["fits"] + [{"kind": "part", "part": "bolt", "at": [0, 0], "mat": "brass"}]}), prefix="Fit."), "table.plates[0].fits[13].mat: no material named 'brass'") + refused("a step whose bolts' material is not in the file", call(doc({**KIT, "fits": [{**KIT["fits"][-1], "bolt_mat": "brass"}]}), prefix="Fit."), "table.plates[0].fits[0].bolt_mat: no material named 'brass'") + refused("a part the fittings kit does not have", call(doc({**KIT, "fits": [{"kind": "part", "part": "rivet", "at": [0, 0], "mat": "steel"}]}), prefix="Fit."), "table: plates[0].fits[0].part: 'rivet' is no part of the fittings kit") + check("refused, the fittings call left the scene as it was", scene_state() == before) + receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="Fit.", table=json.dumps(FITS)) + bpy.context.view_layer.update() + check("a slab with a fit row of every kind is accepted", receipt["status"] == "accepted", [receipt["status"], receipt["message"]]) + R["reports"]["fittings"] = report + _, fit_built = proven("a row of every fit kind, on both sides", FITS, 1, "Fit.", thigh, world(thigh), report) + mats = ["gunmetal", "khaki", "machine", "olive_light", "pit", "steel"] + for side in "RL": + kit_plate = bpy.data.objects.get(f"Fit.Kit.{side}") + check(f"fits-written: Kit.{side} has a fit child per material, the fittings beside the panels and their bolts", + kit_plate is not None and sorted(c.name for c in kit_plate.children if c.type == "MESH") == [f"Fit.Kit.{side}.fit.{m}" for m in mats] + and bevel(bpy.data.objects[f"Fit.Kit.{side}.fit.olive_light"]) == (0.012, 20.0, 1, "ANGLE") and bevel(bpy.data.objects[f"Fit.Kit.{side}.fit.pit"]) is None, + kit_plate and sorted(c.name for c in kit_plate.children)) + check("the report counts what stands: the rim's bolts, nine parts and a step", report is not None and [row["fits"] for row in report["plates"]] == [fit_built[0]["report"]["fits"]] * 2 + and fit_built[0]["report"]["fits"] > 11, report and [row.get("fits") for row in report["plates"]]) + BARE = doc({**KIT, "fits": KIT["fits"][:3]}) + receipt, report = send("brokkr_kitbash.plates", host="Thigh", prefix="Fit.", table=json.dumps(BARE)) + bpy.context.view_layer.update() + proven("rebuilt with the rim's bolts alone", BARE, 1, "Fit.", thigh, world(thigh), report) + check("a rebuild removes the fit children it no longer makes", sorted(c.name for c in bpy.data.objects["Fit.Kit.R"].children if c.type == "MESH") == ["Fit.Kit.R.fit.gunmetal", "Fit.Kit.R.fit.olive_light"] + and "Fit.Kit.R.fit.pit" not in bpy.data.objects, sorted(c.name for c in bpy.data.objects["Fit.Kit.R"].children)) except Exception: # noqa: BLE001 whatever it was, it is a failed check with a name, not a missing result file check(f"no uncaught error in section: {SECTION[0]}", False, traceback.format_exc().splitlines()[-6:]) finally: diff --git a/surfaces/blender/tests/live/kitbash_plates.result.json b/surfaces/blender/tests/live/kitbash_plates.result.json index be8856e..d85889f 100644 --- a/surfaces/blender/tests/live/kitbash_plates.result.json +++ b/surfaces/blender/tests/live/kitbash_plates.result.json @@ -270,6 +270,61 @@ "name": "written-is-built: the thawed plate", "ok": true, "detail": null + }, + { + "name": "refused, scene unchanged: a fit whose material is not in the file", + "ok": true, + "detail": null + }, + { + "name": "refused, scene unchanged: a step whose bolts' material is not in the file", + "ok": true, + "detail": null + }, + { + "name": "refused, scene unchanged: a part the fittings kit does not have", + "ok": true, + "detail": null + }, + { + "name": "refused, the fittings call left the scene as it was", + "ok": true, + "detail": null + }, + { + "name": "a slab with a fit row of every kind is accepted", + "ok": true, + "detail": null + }, + { + "name": "written-is-built: a row of every fit kind, on both sides", + "ok": true, + "detail": null + }, + { + "name": "fits-written: Kit.R has a fit child per material, the fittings beside the panels and their bolts", + "ok": true, + "detail": null + }, + { + "name": "fits-written: Kit.L has a fit child per material, the fittings beside the panels and their bolts", + "ok": true, + "detail": null + }, + { + "name": "the report counts what stands: the rim's bolts, nine parts and a step", + "ok": true, + "detail": null + }, + { + "name": "written-is-built: rebuilt with the rim's bolts alone", + "ok": true, + "detail": null + }, + { + "name": "a rebuild removes the fit children it no longer makes", + "ok": true, + "detail": null } ], "hostErrors": [], @@ -278,7 +333,7 @@ "carried": 1e-07, "moved": 2.1e-07, "ported": 3.9e-08, - "written": 8.4e-08 + "written": 8.5e-08 }, "reports": { "thigh": { @@ -289,7 +344,8 @@ "corners": 16, "facets": 10, "panels": 1, - "bolts": 4, + "bolts": 8, + "fits": 0, "anchors": [ "Thigh.Guard.port.feed", "Thigh.Guard.mark.num" @@ -341,6 +397,38 @@ 0.056641 ] } + }, + "fittings": { + "plates": [ + { + "name": "Fit.Kit.R", + "rebuilt": false, + "corners": 16, + "facets": 10, + "panels": 1, + "bolts": 8, + "fits": 26, + "anchors": [ + "Fit.Kit.R.port.feed", + "Fit.Kit.R.mark.num" + ] + }, + { + "name": "Fit.Kit.L", + "rebuilt": false, + "corners": 16, + "facets": 10, + "panels": 1, + "bolts": 8, + "fits": 26, + "anchors": [ + "Fit.Kit.L.port.feed", + "Fit.Kit.L.mark.num" + ] + } + ], + "host": "Thigh", + "side": 1 } }, "ok": true -- 2.47.3 From 6220de72defa0fb59316deda1ae580213b6e2e84 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 17:37:41 +0100 Subject: [PATCH 4/8] docs/kitbash.md: Anchors and fits, and the fittings kit (cut plate-fittings-kit) Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/docs/kitbash.md | 88 +++++++++++++++++++++++++++----- 1 file changed, 74 insertions(+), 14 deletions(-) diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index e83da17..cbfc684 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -973,7 +973,7 @@ plates somewhere owns that matrix. The table alone decides the result. A table h | one solid form | `faces`, `slab`, `sections` or `points` (below) | | `clad` | `null` or the detail plating (below) | | `face` | `{at, normal, up, right}`: the face anchors stand on, for a row that is not a slab | -| `fits` | anchors (below) | +| `fits` | anchors and fittings (below) | `mirror` and `sides` are independent. A two-sided row with one seed, or with no clad, is drawn once, at side +1, and its `.L` is the mirror of its `.R`: the same facets in the same order, the same cuts and lifts, every face @@ -1084,25 +1084,56 @@ the inset of a facet or of a facet's part would meet itself, that part takes no panel would, the panel takes no bolts; where the rim would, the rim is the outline. So `build` refuses nothing that `check` passed. -### Anchors +### Anchors and fits -A fit is a frame on the face, at `[a, b]` in the face's (a, b), standing on the face's top: the face, plus -`lifts[0]` where a panel stands on it. Two kinds: +A fit stands on the row's face (a slab's outer face, or the `face` another row names), at `[a, b]` in the face's +(a, b). The face's top is the face, plus `lifts[0]` where a panel stands on it. Up to 64 a row; any other kind is +refused. + +Two kinds are anchors, a frame and no geometry: - `{kind: "mark", id, at, height}`: z is the face's normal and y the table's +z projected off it, so a numeral - stands upright whatever the plate's lean. -- `{kind: "hose_port", name, at, lift}`: z out of the face, y the face's up, `lift` (default 0) further out. + stands upright whatever the plate's lean. On the face's top. +- `{kind: "hose_port", name, at, lift}`: z out of the face, y the face's up, `lift` (default 0) over the top. `build` returns each as `{kind, name, matrix, mirrored}` (and `height` for a mark). At side -1 the position, normal and up are mirrored and the frame is made right-handed again (x = y cross z); `mirrored` says so. What stands on -an anchor is its owner's business; the fittings the mech tracks draw on a face (bolt rows, slots, vents, ports, -handles, eyes, louvres, steps) are not fits of this table yet, and any other kind is refused. +an anchor is its owner's business. + +Three kinds are fittings, geometry `build` makes: + +- `{kind: "part", part, at, roll, lift, params, mat}`: a part of the fittings kit (below) built by `core.build` at + `params` (`"k=v; ..."`, default the part's defaults) and placed by the fit's frame: z the face's normal, y the + face's up, turned `roll` degrees about the normal (default 0, -360 to 360), its origin `lift` (default 0, -1 to + 1) over the face's top. +- `{kind: "bolts", inset, spacing, lift, params, mat}`: the kit's `bolt` along a slab's outline. The outline as + drawn (in by the slab's `gap`) is moved in by `inset` + the slab's `taper` (0 to 10; a sharp corner moves at + most that / 0.3); each edge of that ring takes `max(1, int(length / spacing))` bolts, bolt j at + `(j + 0.5) / count` along it. `params` are the bolt's. A rim bolt fastens the plate, not its cladding: the row + stands on the bare face, `lift` (default 0) over it, whatever panel the face carries. Refused on a row that is + no slab, and where the inset leaves nothing of the outline. +- `{kind: "step", outline, at, lift, mat, bolt_mat}`: a raised panel on `outline` (3 to 64 `[a, b]` points, either + winding, about `at`) on the face's top: the clad's panel with inset 0, from 0.02 under the top to `lift` (0 to + 1) over it, its far rim chamfered 0.02, a hexagonal bolt of radius 0.028 inside each corner in `bolt_mat` + (default `gunmetal`). Refused under 0.02 m2. + +`mat` is the fitting's material, 1 to 63 characters. A part is one material: a fitting of two is two rows at one +place (a slot or a vents row and the `pit` under it; an `access_port` and its `port_bolts`). + +At side -1 a fitting's place, normal and up are mirrored, its frame made right-handed and its roll negated, so a +part that is the same across its own x stands as the mirror of side +1's. On a two-sided row drawn once (one seed, +or no clad) the `.L` fittings are the `.R`'s mirrored across x = 0, as its panels are. + +Refused, naming the path: a part the kit does not have (its parts are listed); params the part does not have or +outside its bounds, and what the part's shapes refuse at those params (`core`'s message); a `mat` over 63 +characters. ### What build returns One entry per plate built, in the table's order: `name`, `row` (its index), `mat`, `bevel`, `side`, `solid: (V, faces)`, `facets` (each face's `normal`, `area`, `centre`), `panels: (V, faces)`, `bolts: (V, faces)`, -`anchors`, and `report: {corners, facets, panels, bolts}`. `V` is an (N, 3) float64 array; faces are lists of +`fits: {mat: (V, faces)}` (the row's fittings, merged by material in row order), `anchors`, and +`report: {corners, facets, panels, bolts, fits}`, `fits` the count that stand (a bolts row counts each bolt). `V` is an (N, 3) float64 array; faces are lists of vertex indices wound outward. `check` returns the table with every default written in. Both are pure functions. Building the three mech fixtures takes 0.5 to 0.9 s each (23 to 50 plates, medians of 5 on Starfire, Python @@ -1118,7 +1149,8 @@ itself, repeats a point or has zero area; `thick`, `taper`, `back` or `gap` outs that is not convex would meet itself; corners that are not a plate; faces that bound nothing; points in one plane; a pair of seeds on a one-sided row, an equal pair, or no seed; an `up` along the normal; a -fit on a row with no face; an unknown fit kind; two anchors of one name in a row. +fit on a row with no face; an unknown fit kind; two anchors of one name in a row; and what Anchors and fits lists +for a fitting. ### Against the mech tracks' builders @@ -1179,9 +1211,12 @@ Per built entry, N = `prefix` + its name: host its world matrix is `frame`. A Kit Bevel of the row's `bevel`, angle 12 degrees. ID properties `plate_kind` = `"hard"` and `kit_plate`: the checked row with `side` and `prefix`, as JSON. `kit_plate` is a record: its presence admits a rebuild and nothing reads it to decide geometry. -- `N.fit.` holds the panels and `N.fit.` the bolts: a child mesh per material (one - child when the two are the same material), identity basis, made only when its mesh is not empty. A child that - holds panels carries a Kit Bevel of `clad.bevel`, angle 20 degrees, one segment. +- `N.fit.` holds the panels, `N.fit.` the bolts and `N.fit.` each fitting of that + `mat` (a step's corner bolts under its `bolt_mat`): a child mesh per material, the panels, then the bolts, + then the fittings in row order where they share one; identity basis, made only when its mesh is not empty. A + child that holds panels carries a Kit Bevel of `clad.bevel`, angle 20 degrees, one segment, and a fitting of + the panels' material is bevelled with them; any other child carries none. Every material a fit names must be + in the file. - One empty per anchor, a child of N at the anchor's matrix: `N.mark.` with `kit_anchor` `{kind, id, height}`, `N.port.` with `kit_anchor` `{kind, name}` (JSON). A port empty is an end `brokkr_kitbash.hose` takes by name: the hose leaves along its z, out of the face. @@ -1648,7 +1683,7 @@ under such load (five runs), and reading a 336-face part takes 27 to 37 ms. | `brokkr_kitbash.ribs` | `object_name` (the cage), `ribs_name`, `planes` (a JSON array of 1 to 64 `{origin, normal}`, up to 16000 characters), `standoff`, `depth`, `thickness`, `step`, `holes`, `posts`, `post_r`, `bridge`, `clearance`, `longerons` (a JSON array of 0 to 16 `{origin, axis, toward}`, up to 8000 characters), `longeron`, `longeron_w`, `longeron_h`, `longeron_t` | Derives ribs, lightening holes, posts and longerons from the cage as it is cut, as one mesh object under it. Refuses before it writes anything, naming the plane or longeron. Reports `object`, `ribs`, `thickness`, `sections: [{plane, chains, pieces, length, open}]`, `posts`, `holes`, `longerons: [{index, stations}]` (trimmed to a receipt, with `longeronsOmitted`), `faces`, `volume` and `nonManifoldEdges`. | | `brokkr_kitbash.shell` | `object_name`, `sheet` (a JSON object `{rings, closed, mirror, creases, rim, flip}`, up to 32000 characters), `thickness`, `offset`, `levels`, `bevel`, `count_folds` | Makes a faceted, hollow armor shell from a loft of rings with crease runs, or rebuilds a shell's cage in place under its cutters and ribs. Refuses before it writes anything, naming the field and index. Reports `object`, `rebuilt`, `rings`, `points`, `cageFaces`, `creases`, `folded` (with `count_folds`, the number of the evaluated wall's inner faces that fold; else null), `corners`, `subdividedFaces`, `facing`, `thickness`, `offset`, `levels` and `children`. | | `brokkr_kitbash.hose` | `object_name`, `start`, `end`, `count`, `radius`, `spread`, `clearance`, `bend`, `step`, `sag`, `clamps` (a JSON array of up to 8 `{socket}`), `joint` (empty, or a JSON object `{socket, standoff}`) | Routes a bundle of hoses between two sockets around every other mesh, over clamps and through a pin's axis across its roll range; on a hose's name, rebuilds it in place. Reports `length`, `lengthChange`, `clearance`, `radii`, `sag`, `voxels`, `seed`, `rolls`, `worstRoll`, `faces`, `nonManifoldEdges`. | -| `brokkr_kitbash.plates` | `table` (a `brokkr.plates.v0` document, JSON), `host`, `frame` (empty, or a JSON 4x4 of rows), `side`, `prefix` | Writes hard plates: each a mesh on its host with `.fit.` children for panels and bolts and an empty per anchor; a plate it made is rebuilt in place. Reports `plates` (`name`, `rebuilt`, `corners`, `facets`, `panels`, `bolts`, `anchors`), `host`, `side`. | +| `brokkr_kitbash.plates` | `table` (a `brokkr.plates.v0` document, JSON), `host`, `frame` (empty, or a JSON 4x4 of rows), `side`, `prefix` | Writes hard plates: each a mesh on its host with `.fit.` children for panels, bolts and fittings and an empty per anchor; a plate it made is rebuilt in place. Reports `plates` (`name`, `rebuilt`, `corners`, `facets`, `panels`, `bolts`, `anchors`), `host`, `side`. | `params` is `name=value; name=value`; a param left out takes the part's default (`place_part`) or keeps its stored value (`set_params`). A value outside its bounds is refused with the bounds in the message. @@ -1692,6 +1727,31 @@ The tank's port is 0.4 of its radius across (0.12 m here), so the tee and the no `pipe_r` and `throat_r`. `set_params` on the tank carries the tee and the nozzle out with its port. The receipts file holds each report in `hostResult`. `tools/turntable_recipe.py` renders the saved `.blend`. +## The fittings kit + +`kits/fittings.v0.json`: nine parts that stand on a hard plate's face, placed by `brokkr_kitbash.plate`'s fit rows +(Hard plates, Anchors and fits). Each stands on +z from z = 0 in its own frame: the origin is the fit's place, z the +face's normal, y the face's up. One material a part and no sockets. The defaults are the mech tracks' sizes. + +| part | params | what it is | +| --- | --- | --- | +| `bolt` | `r` | a hex head (r to its corners, 0.7 r tall) on a washer 1.55 r; the bolt of a `bolts` row | +| `slot` | `w`, `h` | the rim of a w by h slot: four bars 0.032 wide, 0.028 tall | +| `pit` | `w`, `h`, `depth`, `count`, `pitch` | the dark box under an opening, `count` of them `pitch` apart along y, centred. Under a slot: depth 0.012. Under vents: depth 0.01, the vents' count, pitch 2.7 h | +| `vents` | `w`, `h`, `count` | `count` louvre lips tilted 28 degrees, 2.7 h apart along y, centred | +| `access_port` | `r` | a turned ring of radius r around a sunk cover with a raised boss, 28 segments | +| `port_bolts` | `r` | the port's eight hex heads on a circle 0.91 r, standing from the ring's shoulder at z 0.035 | +| `handle` | `length`, `lift`, `r` | a bar along y on two posts, bent over at `lift`, a washer and a hex foot under each post. `roll` 90 lays it along the face's a | +| `eye` | `size` | a lifting eye: a pad with two bolts, a neck, and a ring standing in the plane of y and z | +| `louvres` | `w`, `h`, `n`, `depth`, `frame`, `slant` | a framed bank of n slats tilted `slant` degrees about x; `frame` is under w and h | + +Each part's points are the tracks' own (`surface.py`'s bolt row, grab handle and lifting eye, `hardplate.py`'s +slot, vents and port, `hardpoint.py`'s louvres) within 2e-8 m, float32 against float64, with two differences the +kit format sets: the handle's bar is a square section of side 2 r, mitred at its bends, where the tracks swept an +octagon; and the eye's pad is a plain box where the tracks' was a rounded outline with a chamfered rim. A handle +whose bar is thick against its bend (`r` over about a quarter of `min(0.4 lift, 0.2 length)`) may fold on the +inside of a turn, and is refused. + ## The mechanical kit `kits/mechanical.v0.json`: thirteen parts, each along +z, with socket types `flange` (equal), `mount` (fits), -- 2.47.3 From c283226462329d4773beddeb19384d18f0c6193d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 18:09:18 +0100 Subject: [PATCH 5/8] brokkr_kitbash.plate: a vanished bolt ring stands no bolts, crossed both ways included (cut plate-fittings-kit, Soul s1) Ruling plate-bolts-follow-edge-event: no refusal. The guard is every edge running the way its drawn edge runs, so a square turned half round is caught too. Co-Authored-By: Claude Opus 5.5 --- surfaces/blender/brokkr_kitbash/plate.py | 20 +++++++++++++++----- surfaces/blender/docs/kitbash.md | 5 +++-- surfaces/blender/tests/test_plate.py | 14 +++++++++++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/plate.py b/surfaces/blender/brokkr_kitbash/plate.py index 87d21ab..f140e8b 100644 --- a/surfaces/blender/brokkr_kitbash/plate.py +++ b/surfaces/blender/brokkr_kitbash/plate.py @@ -943,13 +943,22 @@ def _slab_ring(slab: dict, face) -> np.ndarray: return inset2d(ring, slab["gap"]) if slab["gap"] else ring +def _stands(ring: np.ndarray, drawn: np.ndarray) -> bool: + """Whether an outline moved in still stands: every edge runs the way its own edge of the drawn outline does. Moved + in past half the outline's width an edge runs backwards; past it both ways a rectangle turns half round, crossed, + and its area is positive still.""" + n = len(drawn) + return all(float((ring[(k + 1) % n] - ring[k]) @ (drawn[(k + 1) % n] - drawn[k])) > 0 for k in range(n)) + + def fit_meshes(row: dict, face, top: float, side: int, kit: dict, path: str): """({mat: (V, faces)}, count): the fittings of one checked row at `side`, merged by material in row order, and how many stand. A part's frame is the face's at the fit's place: z the normal, y the face's b, turned by roll; at side -1 the place, normal and b are mirrored, the frame made right-handed and the roll negated. A part row and a step stand on the face's top (the face plus `top`, the clad's lift there); a bolts row fastens the plate - itself and stands on the bare face. Raises PlateError for what the kit refuses at these params and for a row - that makes nothing.""" + itself and stands on the bare face; where the outline moved in by its inset and the taper leaves no ring it + stands no bolts. Raises PlateError for what the kit refuses at these params and for a step too small for a + panel.""" held: dict[str, _Mesh] = {} count = 0 if face is None: @@ -976,9 +985,10 @@ def fit_meshes(row: dict, face, top: float, side: int, kit: dict, path: str): count += 1 elif fit["kind"] == "bolts": slab = row["slab"] - ring = inset2d(_slab_ring(slab, face), fit["inset"] + slab["taper"]) - if not _area2(ring) > 0: - raise PlateError(f"{at}.inset: {fit['inset']} and the slab's taper leave nothing of the outline") + drawn = _slab_ring(slab, face) + ring = inset2d(drawn, fit["inset"] + slab["taper"]) + if not _stands(ring, drawn): # a vanished ring stands no bolts (plate-bolts-follow-edge-event) + continue bolt = part("bolt", fit["params"], at) for k in range(len(ring)): p, q = ring[k], ring[(k + 1) % len(ring)] diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index cbfc684..e167f61 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -1110,8 +1110,9 @@ Three kinds are fittings, geometry `build` makes: drawn (in by the slab's `gap`) is moved in by `inset` + the slab's `taper` (0 to 10; a sharp corner moves at most that / 0.3); each edge of that ring takes `max(1, int(length / spacing))` bolts, bolt j at `(j + 0.5) / count` along it. `params` are the bolt's. A rim bolt fastens the plate, not its cladding: the row - stands on the bare face, `lift` (default 0) over it, whatever panel the face carries. Refused on a row that is - no slab, and where the inset leaves nothing of the outline. + stands on the bare face, `lift` (default 0) over it, whatever panel the face carries. Where the inset leaves no + ring (an edge would run backwards, or the ring turn half round) the row stands no bolts: the ruling + plate-bolts-follow-edge-event. Refused on a row that is no slab. - `{kind: "step", outline, at, lift, mat, bolt_mat}`: a raised panel on `outline` (3 to 64 `[a, b]` points, either winding, about `at`) on the face's top: the clad's panel with inset 0, from 0.02 under the top to `lift` (0 to 1) over it, its far rim chamfered 0.02, a hexagonal bolt of radius 0.028 inside each corner in `bolt_mat` diff --git a/surfaces/blender/tests/test_plate.py b/surfaces/blender/tests/test_plate.py index 15801d0..ce49cbb 100644 --- a/surfaces/blender/tests/test_plate.py +++ b/surfaces/blender/tests/test_plate.py @@ -997,6 +997,19 @@ class FitTests(unittest.TestCase): self.assertEqual(got, [[-0.37, 0.0], [0.0, -0.17], [0.0, 0.17], [0.37, 0.0]]) self.assertGreater(volume(made["fits"]["gunmetal"]), 0) + def test_a_vanished_ring_stands_no_bolts(self): + """Ruling plate-bolts-follow-edge-event: a bolts row whose outline, moved in by its inset and the taper, leaves + no ring stands no bolts, and the table checks and builds. Thin: 0.1 wide, in 0.06 + 0.04 across it. Both ways: + a 0.2 square in 0.07 + 0.04 and 0.12 + 0.04 turns half round with its area positive. Mutant: the guard a sign + of the area, the shipped state at 9dd543f (the square stands 4 crossed bolts).""" + bolts = {"kind": "bolts", "inset": 0.06, "spacing": 5.0, "mat": "gunmetal"} + for outline, inset, count in (([0.1, 0.6], 0.06, 0), ([0.2, 0.2], 0.07, 0), ([0.2, 0.2], 0.12, 0), ([0.2, 0.2], 0.05, 4), ([0.1, 0.6], 0.005, 4)): + table = doc(row(slab=dict(RIM, outline={"w": outline[0], "h": outline[1], "clip": 0.0}), fits=[dict(bolts, inset=inset), PIT])) + plate.check(table) + made = plate.build(table)[0] + self.assertEqual((made["report"]["fits"], "gunmetal" in made["fits"]), (count + 1, count > 0), (outline, inset)) + self.assertLess(apart(made["fits"]["pit"][0], placed("pit", PIT["params"], self.frame(PIT["at"], 0.01, 30))), self.HELD) + def test_a_step_is_a_panel_on_its_outline(self): made = plate.build(doc(row(slab=RIM, fits=[STEP])))[0] a, b, n = plate.plane_basis(RIM["normal"], (0, 0, 1), RIM["right"]) @@ -1064,7 +1077,6 @@ class FitTests(unittest.TestCase): self.refused(dict(bolts, mat="m" * 64), "plates[0].fits[0].mat") self.refused(dict(bolts, spacing=0), "plates[0].fits[0].spacing") self.refused(dict(bolts, params="r=1"), "plates[0].fits[0].params: kit 'fittings' part 'bolt' param 'r'") - self.refused(dict(bolts, inset=0.3), "plates[0].fits[0].inset: 0.3 and the slab's taper leave nothing of the outline") self.refused(dict(STEP, mat="m" * 64), "plates[0].fits[0].mat") self.refused(dict(STEP, bolt_mat=""), "plates[0].fits[0].bolt_mat") self.refused(dict(STEP, outline=STEP["outline"][:2]), "plates[0].fits[0].outline: wants 3 to 64 entries") -- 2.47.3 From 191927e928fe30cfe6b3aa25622198a0c4da9db8 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 18:24:14 +0100 Subject: [PATCH 6/8] tests/test_kitbash: the fittings kit's shapes pinned by name, place, size, topology and defaults (cut plate-fittings-kit, Soul s1) Nine kit mutants (Soul's seven, heads on 0.9 r, louvre slant sign) each die in FittingsKitTests, not only by the plate hash. Bound 4.7e-10 by the margin rule. Co-Authored-By: Claude Opus 5.5 --- surfaces/blender/tests/test_kitbash.py | 98 ++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/surfaces/blender/tests/test_kitbash.py b/surfaces/blender/tests/test_kitbash.py index ab7448b..d75a57c 100644 --- a/surfaces/blender/tests/test_kitbash.py +++ b/surfaces/blender/tests/test_kitbash.py @@ -944,6 +944,13 @@ class FittingsKitTests(unittest.TestCase): self.assertEqual(self.kit["socketTypes"], {}) self.assertEqual([part["sockets"] for part in self.kit["parts"].values()], [[]] * 9) + def test_the_defaults_are_the_kits_doc(self): + """What a row that names no params gets, part by part.""" + self.assertEqual({name: {p["name"]: p["default"] for p in part["params"]} for name, part in self.kit["parts"].items()}, { + "bolt": {"r": 0.017}, "slot": {"w": 0.2, "h": 0.04}, "pit": {"w": 0.2, "h": 0.04, "depth": 0.012, "count": 1, "pitch": 0}, + "vents": {"w": 0.3, "h": 0.03, "count": 4}, "access_port": {"r": 0.12}, "port_bolts": {"r": 0.12}, "handle": {"length": 0.3, "lift": 0.065, "r": 0.016}, + "eye": {"size": 0.1}, "louvres": {"w": 0.6, "h": 0.72, "n": 6, "depth": 0.05, "frame": 0.07, "slant": 25}}) + def test_every_part_builds_closed_and_wound_out_from_the_face(self): for name, part in self.kit["parts"].items(): rng = random.Random(f"fittings.{name}") @@ -976,6 +983,97 @@ class FittingsKitTests(unittest.TestCase): self.assertLess(abs(float(head[0, 0])), 1e-15) # a corner on +y, as the tracks' heads stand + # Shapes: each part at params off its defaults, every shell's place and size from the kit's doc. A reading is how + # far a built point or extent stands from the stated one (metres). Shipped: float rounding, held as 2.2e-16 a metre. + # Least claimed mutants: port_bolts' heads on 0.9 r (0.91 shipped) at r 0.1, a slot bar 0.001 off, the port's heads + # 0.001 up: each reads 1e-3. The bound is the geometric mean, 4.7e-10 (lodur:ruling:deterministic-bound-margin). + SHAPED = 4.7e-10 + TOPOLOGY = {"slot": (32, 24, 4), "pit": (24, 18, 3), "vents": (24, 18, 3), "access_port": (170, 196, 1), "port_bolts": (96, 64, 8), + "handle": (112, 82, 5), "eye": (200, 188, 5), "louvres": (64, 48, 8)} + + def pieces(self, built, each=None): + """Each shape's points; a repeat's copies apart, `each` points a copy.""" + counts = built.counts.tolist() + starts = np.concatenate([[0], np.cumsum(counts)[:-1]]).astype(int) + out = [] + for index in sorted(set(built.shape.tolist())): + points = built.V[sorted({int(v) for k in range(len(counts)) if built.shape[k] == index for v in built.faces[starts[k]:starts[k] + counts[k]]})] + out += [points[i:i + each] for i in range(0, len(points), each)] if each else [points] + return out + + def box(self, points, centre, size, slant=0.0): + """How far a box's extents stand from a box of size about centre, turned slant degrees about x.""" + c, s = math.cos(math.radians(slant)), abs(math.sin(math.radians(slant))) + half = np.array([size[0] / 2, size[1] / 2 * c + size[2] / 2 * s, size[1] / 2 * s + size[2] / 2 * c]) + return float(np.abs(np.array([points.min(axis=0), points.max(axis=0)]) - [np.array(centre) - half, np.array(centre) + half]).max()) + + def tube(self, points, axis, radius, low, high): + """How far a tube's points stand from radius about the vertical through axis (x, y), from low to high.""" + return max(float(np.abs(np.linalg.norm(points[:, :2] - axis, axis=1) - radius).max()), abs(float(points[:, 2].min()) - low), abs(float(points[:, 2].max()) - high)) + + def built(self, name, params): + b = core.build(self.kit["parts"][name], core.parse_params(params)) + self.assertEqual((len(b.V), len(b.counts), b.shell_count), self.TOPOLOGY[name], name) + self.assertTrue(closed_and_oriented(b), name) + return b + + def test_slot_and_pit_are_their_boxes(self): + """The slot's four bars around a w by h opening, 0.032 wide and 0.028 tall; the pit's count boxes pitch apart.""" + w, h = 0.3, 0.1 + bars = self.pieces(self.built("slot", "w=0.3; h=0.1")) + for points, centre, size in zip(bars, ([0, h / 2 + 0.016, 0.014], [0, -h / 2 - 0.016, 0.014], [w / 2 + 0.016, 0, 0.014], [-w / 2 - 0.016, 0, 0.014]), + ([w + 0.06, 0.032, 0.028],) * 2 + ([0.032, h, 0.028],) * 2): + self.assertLess(self.box(points, centre, size), self.SHAPED, centre) + for k, points in enumerate(self.pieces(self.built("pit", "w=0.1; h=0.03; depth=0.02; count=3; pitch=0.08"), 8)): + self.assertLess(self.box(points, [0, -0.08 + 0.08 * k, 0.01], [0.1, 0.03, 0.02]), self.SHAPED, k) + + def test_vents_and_louvres_lean_their_own_ways(self): + """A vents lip is tilted 28 degrees with its upper edge down to the face; a louvre slat is turned slant + degrees with its upper edge up off it.""" + h = 0.04 + for k, points in enumerate(self.pieces(self.built("vents", "w=0.2; h=0.04; count=3"), 8)): + self.assertLess(self.box(points, [0, 0.75 * h - 2.7 * h + 2.7 * h * k, 0.014], [0.24, 0.9 * h, 0.012], 28), self.SHAPED, k) + self.assertLess(float(points[np.argmax(points[:, 1]), 2]), 0.014, k) + w, h, n, depth, frame = 0.5, 0.4, 4, 0.06, 0.05 + louvres = self.built("louvres", "w=0.5; h=0.4; n=4; depth=0.06; frame=0.05; slant=30") + for points, centre, size in zip(self.pieces(louvres)[:4], ([0, -h / 2, depth / 2], [0, h / 2, depth / 2], [-w / 2, 0, depth / 2], [w / 2, 0, depth / 2]), + ([w + frame, frame, depth],) * 2 + ([frame, h + frame, depth],) * 2): + self.assertLess(self.box(points, centre, size), self.SHAPED, centre) + pitch = (h - frame) / n + for k, points in enumerate(self.pieces(louvres, 8)[4:]): + self.assertLess(self.box(points, [0, -0.5 * (h - frame) + 0.5 * pitch + pitch * k, 0.3 * depth], [w - frame, 0.75 * pitch, 0.25 * depth], 30), self.SHAPED, k) + self.assertGreater(float(points[np.argmax(points[:, 1]), 2]), 0.3 * depth, k) + + def test_access_port_is_its_profile_turned_and_its_heads_on_the_rim(self): + """The port's 28 turns of its eight profile points; eight hex heads of 0.07 r on 0.91 r at 45 degree steps, + from the shoulder (0.035) up 0.012.""" + r = 0.1 + port = self.built("access_port", "r=0.1") + turned = {(round(float(np.hypot(x, y)) / r, 9), round(float(z), 9)) for x, y, z in port.V} + self.assertEqual(turned, {(0.0, 0.0), (1.0, 0.0), (1.0, 0.035), (0.82, 0.05), (0.82, 0.022), (0.34, 0.022), (0.34, 0.045), (0.0, 0.045)}) + for k, points in enumerate(self.pieces(self.built("port_bolts", "r=0.1"))): + turn = math.radians(45 * k) + self.assertLess(self.tube(points, 0.91 * r * np.array([math.cos(turn), math.sin(turn)]), 0.07 * r, 0.035, 0.047), self.SHAPED, k) + + def test_handle_and_eye_stand_their_shells(self): + """The handle's bar 2 r square from 0.004 under the face to lift + r, its posts length apart on a washer of + 2.3 r and a hex foot of 1.5 r; the eye's pad, two heads 0.72 size off its middle, a neck, and a ring of 0.29 + to 0.55 size about 0.012 + 0.62 size, 0.26 size thick across x.""" + length, lift, r = 0.4, 0.08, 0.012 + bar, *feet = self.pieces(self.built("handle", "length=0.4; lift=0.08; r=0.012")) + self.assertLess(float(np.abs(np.array([bar.min(axis=0), bar.max(axis=0)]) - [[-r, -length / 2 - r, -0.004], [r, length / 2 + r, lift + r]]).max()), self.SHAPED) + for points, y, radius, low in zip(feet, (-1, 1, -1, 1), (2.3 * r, 2.3 * r, 1.5 * r, 1.5 * r), (0.0, 0.0, 0.008, 0.008)): + self.assertLess(self.tube(points, [0, y * length / 2], radius, low, low + 0.008), self.SHAPED, (y, radius)) + size = 0.12 + pad, *heads, neck, ring = self.pieces(self.built("eye", "size=0.12")) + self.assertLess(self.box(pad, [0, 0, 0.004], [1.1 * size, 2 * size, 0.012]), self.SHAPED) + for points, y in zip(heads, (-1, 1)): + self.assertLess(self.tube(points, [0, y * 0.72 * size], 0.11 * size, 0.01, 0.018), self.SHAPED, y) + self.assertLess(self.box(neck, [0, 0, 0.012 + 0.1 * size], [0.34 * size, 0.5 * size, 0.24 * size]), self.SHAPED) + across = np.hypot(ring[:, 1], ring[:, 2] - (0.012 + 0.62 * size)) + self.assertLess(max(abs(float(across.min()) - 0.29 * size), abs(float(across.max()) - 0.55 * size), abs(float(np.abs(ring[:, 0]).max()) - 0.13 * size)), self.SHAPED) + + class SurfaceFrameTests(unittest.TestCase): """surface-frame: the frame brokkr_kitbash.cut gives a cutter. Bounds: a shipped reading is float rounding (worst 4.4e-16 over the draws) and the least mutant's is 0.31 (S4, the roll dropped, at roll 18); 1e-9 separates them by -- 2.47.3 From f5674a00dd6ed8efc01f9fd771924dae69450f03 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 18:48:15 +0100 Subject: [PATCH 7/8] brokkr_kitbash.plate: a bolts row's ring is inset2d's; fewer than 3 corners or one that would meet itself stands no bolts (cut plate-fittings-kit, Soul s2) On main with PR 46, inset2d may drop an edge, so the edge-direction guard (_stands) is gone: len(ring) < 3 is the vanished ring, and NotSimple at the bolt inset is caught and the row stands no bolts. Tests follow main's inset: the step stands 12*2 bolts, FITTED's pair is [5, 9], the not-convex facet's report carries fits: 0, HASH re-pinned. New test pins the clipped square that _stands dropped and the notched outline that refused. Co-Authored-By: Claude Opus 5.5 --- surfaces/blender/brokkr_kitbash/plate.py | 19 +++++++------------ surfaces/blender/docs/kitbash.md | 6 +++--- surfaces/blender/tests/test_plate.py | 21 ++++++++++++++++++--- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/surfaces/blender/brokkr_kitbash/plate.py b/surfaces/blender/brokkr_kitbash/plate.py index f140e8b..d3e721f 100644 --- a/surfaces/blender/brokkr_kitbash/plate.py +++ b/surfaces/blender/brokkr_kitbash/plate.py @@ -943,21 +943,13 @@ def _slab_ring(slab: dict, face) -> np.ndarray: return inset2d(ring, slab["gap"]) if slab["gap"] else ring -def _stands(ring: np.ndarray, drawn: np.ndarray) -> bool: - """Whether an outline moved in still stands: every edge runs the way its own edge of the drawn outline does. Moved - in past half the outline's width an edge runs backwards; past it both ways a rectangle turns half round, crossed, - and its area is positive still.""" - n = len(drawn) - return all(float((ring[(k + 1) % n] - ring[k]) @ (drawn[(k + 1) % n] - drawn[k])) > 0 for k in range(n)) - - def fit_meshes(row: dict, face, top: float, side: int, kit: dict, path: str): """({mat: (V, faces)}, count): the fittings of one checked row at `side`, merged by material in row order, and how many stand. A part's frame is the face's at the fit's place: z the normal, y the face's b, turned by roll; at side -1 the place, normal and b are mirrored, the frame made right-handed and the roll negated. A part row and a step stand on the face's top (the face plus `top`, the clad's lift there); a bolts row fastens the plate - itself and stands on the bare face; where the outline moved in by its inset and the taper leaves no ring it - stands no bolts. Raises PlateError for what the kit refuses at these params and for a step too small for a + itself and stands on the bare face; where the outline moved in by its inset and the taper leaves no ring, or a ring + that would meet itself, it stands no bolts. Raises PlateError for what the kit refuses at these params and for a step too small for a panel.""" held: dict[str, _Mesh] = {} count = 0 @@ -986,8 +978,11 @@ def fit_meshes(row: dict, face, top: float, side: int, kit: dict, path: str): elif fit["kind"] == "bolts": slab = row["slab"] drawn = _slab_ring(slab, face) - ring = inset2d(drawn, fit["inset"] + slab["taper"]) - if not _stands(ring, drawn): # a vanished ring stands no bolts (plate-bolts-follow-edge-event) + try: + ring = inset2d(drawn, fit["inset"] + slab["taper"]) + except NotSimple: # a ring that would meet itself stands no bolts + continue + if len(ring) < 3: # a vanished ring stands no bolts (plate-bolts-follow-edge-event) continue bolt = part("bolt", fit["params"], at) for k in range(len(ring)): diff --git a/surfaces/blender/docs/kitbash.md b/surfaces/blender/docs/kitbash.md index e167f61..7501d96 100644 --- a/surfaces/blender/docs/kitbash.md +++ b/surfaces/blender/docs/kitbash.md @@ -1107,11 +1107,11 @@ Three kinds are fittings, geometry `build` makes: face's up, turned `roll` degrees about the normal (default 0, -360 to 360), its origin `lift` (default 0, -1 to 1) over the face's top. - `{kind: "bolts", inset, spacing, lift, params, mat}`: the kit's `bolt` along a slab's outline. The outline as - drawn (in by the slab's `gap`) is moved in by `inset` + the slab's `taper` (0 to 10; a sharp corner moves at - most that / 0.3); each edge of that ring takes `max(1, int(length / spacing))` bolts, bolt j at + drawn (in by the slab's `gap`) is moved in by `inset` + the slab's `taper` (0 to 10), by `inset2d` as a + panel's bolt ring is, so the ring can have fewer edges than the outline; each edge of that ring takes `max(1, int(length / spacing))` bolts, bolt j at `(j + 0.5) / count` along it. `params` are the bolt's. A rim bolt fastens the plate, not its cladding: the row stands on the bare face, `lift` (default 0) over it, whatever panel the face carries. Where the inset leaves no - ring (an edge would run backwards, or the ring turn half round) the row stands no bolts: the ruling + ring, or a ring that would meet itself (an outline that is not convex), the row stands no bolts: the ruling plate-bolts-follow-edge-event. Refused on a row that is no slab. - `{kind: "step", outline, at, lift, mat, bolt_mat}`: a raised panel on `outline` (3 to 64 `[a, b]` points, either winding, about `at`) on the face's top: the clad's panel with inset 0, from 0.02 under the top to `lift` (0 to diff --git a/surfaces/blender/tests/test_plate.py b/surfaces/blender/tests/test_plate.py index ce49cbb..957706b 100644 --- a/surfaces/blender/tests/test_plate.py +++ b/surfaces/blender/tests/test_plate.py @@ -764,7 +764,7 @@ class CladTests(unittest.TestCase): [-0.5231073349097417, 0.9203597671588255, 0.00622360127002797], [0.8223018952005992, -0.9577282429612575, 0.0028711637754610976], [0.7686109712617415, -0.6216304824437804, 0.007801596935861264]] (entry,) = plate.build(plate.check(sheet(soul)), 1) - self.assertEqual(entry["report"], {"corners": 9, "facets": 8, "panels": 1, "bolts": 3}) + self.assertEqual(entry["report"], {"corners": 9, "facets": 8, "panels": 1, "bolts": 3, "fits": 0}) inset, calls = plate.inset2d, [] def spy(ring, c): @@ -964,7 +964,7 @@ class FitTests(unittest.TestCase): for mat in ("pit", "olive_light"): self.assertLess(apart(clad[mat][0], bare[mat][0] + n * 0.05), self.HELD, mat) self.assertLess(apart(clad["pit"][0], placed("pit", PIT["params"], self.frame(PIT["at"], 0.06, 30))), self.HELD) - bolts, step = len(placed("bolt", "", np.eye(4))) * 12, 12 * 4 + bolts, step = len(placed("bolt", "", np.eye(4))) * 12, 12 * 2 self.assertEqual(len(bare["gunmetal"][0]), bolts + step) self.assertEqual(float(np.abs(clad["gunmetal"][0][:bolts] - bare["gunmetal"][0][:bolts]).max()), 0.0) # the rim's bolts fasten the plate, under its cladding self.assertLess(apart(bare["gunmetal"][0][:40], placed("bolt", "", self.frame([-0.42 + 0.105, -0.22], 0.002, 0))), self.HELD) @@ -1010,6 +1010,21 @@ class FitTests(unittest.TestCase): self.assertEqual((made["report"]["fits"], "gunmetal" in made["fits"]), (count + 1, count > 0), (outline, inset)) self.assertLess(apart(made["fits"]["pit"][0], placed("pit", PIT["params"], self.frame(PIT["at"], 0.01, 30))), self.HELD) + def test_a_ring_that_stands_or_would_meet_itself(self): + """A bolt ring inset2d returns with a corner less still stands its bolts: a 0.4 square clipped 0.05, in 0.11 + + 0.04, loses its clipped edges and stands 4 (mutant: an edge-direction guard against the drawn outline, 34da146, + stands none). A ring that would meet itself stands no bolts, and the table checks and builds: a unit square + notched 0.1 wide and 0.8 deep, in 0.1, 0.15 and 0.25 + 0.02 (mutant: NotSimple not caught, check refuses).""" + bolts = {"kind": "bolts", "inset": 0.11, "spacing": 5.0, "mat": "gunmetal"} + made = plate.build(doc(row(slab=dict(RIM, outline={"w": 0.4, "h": 0.4, "clip": 0.05}), fits=[bolts])))[0] + self.assertEqual(made["report"]["fits"], 4) + notched = [[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [0.05, 0.5], [0.05, -0.3], [-0.05, -0.3], [-0.05, 0.5], [-0.5, 0.5]] + for inset, count in ((0.1, 0), (0.15, 0), (0.25, 0), (0.03, 23)): + table = doc(row(slab=dict(RIM, taper=0.02, outline=notched), fits=[dict(bolts, inset=inset, spacing=0.2), PIT])) + plate.check(table) + made = plate.build(table)[0] + self.assertEqual((made["report"]["fits"], "gunmetal" in made["fits"]), (count + 1, count > 0), inset) + def test_a_step_is_a_panel_on_its_outline(self): made = plate.build(doc(row(slab=RIM, fits=[STEP])))[0] a, b, n = plate.plane_basis(RIM["normal"], (0, 0, 1), RIM["right"]) @@ -1034,7 +1049,7 @@ class FitTests(unittest.TestCase): self.assertEqual(float(np.abs(left["fits"][mat][0] - V).max()), 0.0, mat) self.assertEqual(left["fits"][mat][1], faces) self.assertGreater(volume(left["fits"][mat]), 0, mat) - pair = plate.build(doc(dict(FITTED, clad=dict(CLAD, split=99, seed=[5, 5]))))[1] # a pair of seeds: the left is drawn at side -1 + pair = plate.build(doc(dict(FITTED, clad=dict(CLAD, split=99, seed=[5, 9]))))[1] # a pair of seeds: the left is drawn at side -1 slot = [f for f in FITTED["fits"] if f.get("part") == "slot"][0] self.assertLess(apart(pair["fits"]["olive"][0][:32], placed("slot", slot["params"], self.frame(slot["at"], CLAD["lifts"][0] + 0.01, 30, -1))), self.HELD) -- 2.47.3 From 34ceeca0211aab9b1573d45b0418fdcb0a264fe3 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 18:52:46 +0100 Subject: [PATCH 8/8] tests/live/kitbash_plates.result.json: the run on main's inset2d (65 checks; the step stands 4 bolts); the hash's cross-host difference measured (cut plate-fittings-kit, Soul s2) Co-Authored-By: Claude Opus 5.5 --- surfaces/blender/tests/live/kitbash_plates.result.json | 8 ++++---- surfaces/blender/tests/test_plate.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/surfaces/blender/tests/live/kitbash_plates.result.json b/surfaces/blender/tests/live/kitbash_plates.result.json index d85889f..e2bb566 100644 --- a/surfaces/blender/tests/live/kitbash_plates.result.json +++ b/surfaces/blender/tests/live/kitbash_plates.result.json @@ -333,7 +333,7 @@ "carried": 1e-07, "moved": 2.1e-07, "ported": 3.9e-08, - "written": 8.5e-08 + "written": 8.4e-08 }, "reports": { "thigh": { @@ -344,7 +344,7 @@ "corners": 16, "facets": 10, "panels": 1, - "bolts": 8, + "bolts": 4, "fits": 0, "anchors": [ "Thigh.Guard.port.feed", @@ -406,7 +406,7 @@ "corners": 16, "facets": 10, "panels": 1, - "bolts": 8, + "bolts": 4, "fits": 26, "anchors": [ "Fit.Kit.R.port.feed", @@ -419,7 +419,7 @@ "corners": 16, "facets": 10, "panels": 1, - "bolts": 8, + "bolts": 4, "fits": 26, "anchors": [ "Fit.Kit.L.port.feed", diff --git a/surfaces/blender/tests/test_plate.py b/surfaces/blender/tests/test_plate.py index 957706b..15d4f8c 100644 --- a/surfaces/blender/tests/test_plate.py +++ b/surfaces/blender/tests/test_plate.py @@ -1174,8 +1174,9 @@ EVENT = {("bastion", 1, "Hull.Cheek.R"): (32, 1), ("bastion", 1, "Hull.Cheek.L") ("raptor", 1, "Torso.Lip2.R"): (0, 0), ("raptor", 1, "Torso.Lip2.L"): (0, 0), ("raptor", 1, "Torso.Hood1D.R"): (0, 0), ("raptor", 1, "Torso.Hood1D.L"): (0, 0), ("raptor", 1, "Torso.Hood1F.R"): (7, 0)} # The three fixtures' builds as one sha256, of coordinates rounded to QUANTUM metres and of every face. Starfire (Windows 11, numpy -# 2.5.4) and Yggdrasil (Debian 13, numpy 2.2.4 on the system LAPACK) give this hash; their coordinates differ in 3,221 of 34,359 by up -# to 2.7e-15 m and in no face. The hash also holds FITTED, a row of every fit kind, with one seed and with a pair, at both sides. +# 2.5.4) and Yggdrasil (Debian 13, numpy 2.2.4 on the system LAPACK) give this hash; their numbers (every coordinate and anchor +# matrix entry) differ in 3,318 of 61,965 by up to 2.7e-15 m and in no face. The hash also holds FITTED, a row of every fit kind, +# with one seed and with a pair, at both sides. # QUANTUM is TIE: 3.7e5 times that, and 1e3 under the least difference KNOWN holds (1.06e-6 m). QUANTUM = 1e-9 HELD = (816, 585, 1022) # of 3,000 drawn convex rings: sharp corners held at MITER, rings that lost an edge, rings left empty -- 2.47.3