From aeac2e26ad23de37ee82c2d615a3d818dc041c47 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 3 Dec 2026 09:02:11 +0100 Subject: [PATCH] tests/live/kitbash_cage.py: a narrow plate's wall throws no needle and a hexagon's thin wall folds no face plain-wall-no-needle: a crown-skirt-centre plate 0.13 x 1.2 m, wall 0.04, bevel 0.01, levels 2, stands 0.95 thicknesses beyond its cage's bounds; at even offset (W1) 3.28; bound 1.77. plain-wall-folds: the 1.2 m hexagon at 0.015 folds 0 of 168 inner faces; W1 20; the count + 1 bounded at 4.6. W1 in the operator fails both. Cut aetheria-release:cut_spec:cut-shell-plain-wall.r1. Co-Authored-By: Claude Fable 5.2 --- surfaces/blender/tests/live/kitbash_cage.py | 60 ++++++++++++++++++- .../tests/live/kitbash_cage.result.json | 14 +++++ 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/surfaces/blender/tests/live/kitbash_cage.py b/surfaces/blender/tests/live/kitbash_cage.py index e3a2724..8976977 100644 --- a/surfaces/blender/tests/live/kitbash_cage.py +++ b/surfaces/blender/tests/live/kitbash_cage.py @@ -1,6 +1,7 @@ """Live proof, in a background Blender, of brokkr_kitbash.shell's free cage through run_intent: a cage of triangles and quads with declared poles becomes a shell whose subdivided face count is the reported one at each level, takes a -wall, counts folds and is cut; a mirrored cage closes over its seam; a loft shell is rebuilt in place as a free cage +wall, counts folds and is cut; a narrow plate's wall throws no needle and a hexagon's thin wall does not fold; a +mirrored cage closes over its seam; a loft shell is rebuilt in place as a free cage under its cutters; the pole gate refuses without writing; tools/cage_export.py reads a cage back, an open one included, as its maker's Subdivision draws it; and tools/cage_score.py ranks a near copy, a moved vertex, an over-creased and a creaseless cage in that order. Not part of the unittest run: it needs Blender. @@ -72,6 +73,13 @@ SAME = 1.3e-2 # Keep Corners, read here by setting it) 7.7; the geometric mean, separation 670 each side. A closed cage does not tell # the two apart, and a hand-modelled hull's own round trip is 0.28 (its seam snap): the open plate stands inside that. OPEN = 1.1e-2 +# Wall thicknesses: how far the furthest vertex of a narrow plate, as evaluated, stands beyond its cage's bounds. +# Shipped 0.95; mutant W1 (Kit Solidify at even offset, read here by setting it: a pinned corner's vertex moves the +# thickness over the cosine of its crease's half-angle) 3.28; the geometric mean, separation 1.86 each side. +NEEDLE = 1.77 +# Inner faces of a hexagon plate's wall that fold, read as the count + 1. Shipped 0, read 1; W1 20, read 21; the +# geometric mean, separation 4.6 each side. +FOLDS = 4.6 # A tent: four triangles round an apex of valence 4 with two ridges creased, and a quad hung under one edge: 7 @@ -82,6 +90,9 @@ TENT = {"verts": [[0.0, 0.0, 0.5], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [-1.0, 0.0, HULL = {"verts": [[0.0, -1.0, 0.0], [0.004, 0.0, 0.3], [0.0, 1.0, 0.0], [0.0, 0.0, -0.3], [0.6, 0.0, 0.0]], "faces": [[0, 4, 1], [1, 4, 2], [2, 4, 3], [3, 4, 0]], "creases": [[0, 4, 1.0], [4, 2, 1.0]], "mirror": True} LOFT = {"rings": [[[0.3 * j - 0.45, 0.02 * j * j, 0.3 * i] for j in range(4)] for i in range(3)], "flip": True} +# Two crowns, each the outline of a plate's raised face in the plane y = 0: a strip 0.13 m wide and 1.2 m long, and a hexagon 1.2 m across. +STRIP = [[-0.06, 0.0, 0.6], [-0.07, 0.0, -0.6], [0.07, 0.0, -0.6], [0.06, 0.0, 0.6]] +HEXAGON = [[-0.5, 0.0, 0.6], [-0.62, 0.0, 0.1], [-0.4, 0.0, -0.7], [0.4, 0.0, -0.7], [0.62, 0.0, 0.1], [0.5, 0.0, 0.6]] CUTS = [{"name": "TentLine", "part": "slab", "params": "gap=0.02; length=0.4; depth=0.03", "origin": [0.3, -0.35, 3.0], "direction": [0, 0, -1]}] @@ -132,6 +143,31 @@ def sharpest(obj): return worst +def crown_plate(crown, flare=0.06, drop=0.07, dome=0.03): + """The cage of a plate as the mech experiments block one, facing -y: the crown ring with its sides creased, a skirt + ring flared out of it and dropped back, one centre vertex domed, every ring corner pinned: 2N + 1 vertices.""" + P = np.array(crown, dtype=float) + N = len(P) + normal = np.cross(P, np.roll(P, -1, axis=0)).sum(axis=0) + if normal[1] > 0: + P, normal = P[::-1].copy(), -normal + normal, centre = normal / np.linalg.norm(normal), P.mean(axis=0) + out = (P - centre) - np.outer((P - centre) @ normal, normal) + skirt = P + flare * out / np.linalg.norm(out, axis=1)[:, None] - drop * normal + return {"verts": np.vstack([P, skirt, centre + dome * normal]).round(5).tolist(), + "faces": [[i, (i + 1) % N, 2 * N] for i in range(N)] + [[N + i, N + (i + 1) % N, (i + 1) % N, i] for i in range(N)], + "creases": [[i, (i + 1) % N, 1.0] for i in range(N)], "corners": [[i, 1.0] for i in range(2 * N)], "poles": [] if N == 4 else [2 * N], "rim": 0.0} + + +def beyond(obj, sheet): + """Metres: how far the furthest vertex of an object, as evaluated, stands outside its cage's bounds along an axis.""" + bm = evaluated(obj) + at = np.array([v.co[:] for v in bm.verts]) + bm.free() + cage = np.array(sheet["verts"]) + return float(max((cage.min(axis=0) - at).max(), (at - cage.max(axis=0)).max(), 0.0)) + + def state(): return {o.name: (sorted(k for k in o.keys() if k.startswith("kit_")), len(o.data.vertices) if o.type == "MESH" else None, [m.name for m in o.modifiers]) for o in bpy.data.objects}, sorted(m.name for m in bpy.data.meshes) @@ -161,6 +197,28 @@ try: [tuple(p.vertices) for p in tent.data.polygons] == [tuple(f) for f in TENT["faces"]] and np.abs(np.array([v.co[:] for v in tent.data.vertices]) - built.V).max() < 1e-6 and json.loads(tent["kit_shell"])["sheet"] == TENT, tent["kit_shell"]) + # --- plain-wall: the Solidify's plain offset --------------------------------------------------------------------------- + section("plain-wall") + strip, hexagon = crown_plate(STRIP), crown_plate(HEXAGON) + receipt, report = send("brokkr_kitbash.shell", object_name="Strip", sheet=json.dumps(strip), thickness=0.04, levels=2, bevel=0.01) + plate = bpy.data.objects.get("Strip") + needle = beyond(plate, strip) / 0.04 + plate.modifiers["Kit Solidify"].use_even_offset = True # W1 + R["readings"].update({"needleThicknesses": needle, "needleThicknessesW1": beyond(plate, strip) / 0.04}) + check(f"plain-wall-no-needle: a plate 0.13 m wide with a wall of 0.04 stands under {NEEDLE} thicknesses beyond its cage's bounds, and over that at even offset", + receipt["status"] == "accepted" and report["cageVerts"] == 9 and needle < NEEDLE < R["readings"]["needleThicknessesW1"], [receipt["message"], R["readings"]]) + receipt, report = send("brokkr_kitbash.shell", object_name="Hexagon", sheet=json.dumps(hexagon), thickness=0.015, levels=2, count_folds=True) + plate = bpy.data.objects.get("Hexagon") + plate.modifiers["Kit Solidify"].use_even_offset = True # W1 + even = sys.modules["brokkr_kitbash"].BROKKR_KITBASH_OT_shell.folded_faces(bpy.context, plate, report["subdividedFaces"]) + R["readings"].update({"foldedPlusOne": report["folded"] + 1, "foldedPlusOneW1": even + 1}) + check(f"plain-wall-folds: a hexagon plate 1.2 m across with a wall of 0.015 folds no inner face of its 168 (the count + 1 under {FOLDS}), and over that at even offset", + receipt["status"] == "accepted" and (report["cageVerts"], report["subdividedFaces"], report["poles"]) == (13, 168, {"6": 1}) and report["folded"] + 1 < FOLDS < even + 1, [receipt["message"], report, even]) + for name in ("Strip", "Hexagon"): + mesh = bpy.data.objects[name].data + bpy.data.objects.remove(bpy.data.objects[name]) + bpy.data.meshes.remove(mesh) + # --- the creases reach the surface ----------------------------------------------------------------------------------- section("free-cage-crisp") crisp = sharpest(tent) diff --git a/surfaces/blender/tests/live/kitbash_cage.result.json b/surfaces/blender/tests/live/kitbash_cage.result.json index 4f40224..236e084 100644 --- a/surfaces/blender/tests/live/kitbash_cage.result.json +++ b/surfaces/blender/tests/live/kitbash_cage.result.json @@ -41,6 +41,16 @@ "ok": true, "detail": null }, + { + "name": "plain-wall-no-needle: a plate 0.13 m wide with a wall of 0.04 stands under 1.77 thicknesses beyond its cage's bounds, and over that at even offset", + "ok": true, + "detail": null + }, + { + "name": "plain-wall-folds: a hexagon plate 1.2 m across with a wall of 0.015 folds no inner face of its 168 (the count + 1 under 4.6), and over that at even offset", + "ok": true, + "detail": null + }, { "name": "the creased ridge stays an edge under subdivision: over 34.0 degrees, and under it with crease_edge cleared", "ok": true, @@ -144,6 +154,10 @@ "costSelf": 0.28, "crispDegrees": 71.0, "crispDegreesK1": 16.0, + "foldedPlusOne": 1.0, + "foldedPlusOneW1": 21.0, + "needleThicknesses": 0.95, + "needleThicknessesW1": 3.3, "openRoundTripPct": 1.7e-05, "openRoundTripPctB1": 7.7, "scoreLiftedHausdorffPct": 3.3,