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 <noreply@anthropic.com>
This commit is contained in:
parent
191927e928
commit
f5674a00dd
3 changed files with 28 additions and 18 deletions
|
|
@ -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)):
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue