Credibility pass over the Green Man generator
Turn audit.py into a run() function and drop audit_run.py, which only existed to import it quietly. Remove unused parameters, keys, helpers and imports from draw.py, manifest.py and stl_build.py, and the source file names in stl_build.FILES that pointed at nothing. Keep the brow strip's taper and knob positions in geom.py only. Correct comments and docstrings that disagreed with the code, and the README's claim about counts. The page changes only in markup: no stray spaces in class attributes, and three CSS declarations that did nothing are gone. Guide HTML, templates and print files are byte-identical apart from that. Credibility pass over a7c04e5..HEAD; the next one can scope from here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
b86153a9fd
commit
f2bb87caeb
15 files changed
+148
-151
No files matched your search
+12
-17
@@ -22,12 +22,11 @@ PARTS = OrderedDict([
|
||||
('TWIG', ('Forked twig', 'twig_forked.stl', 'print')),
|
||||
('AL', ('Acorn, large half', 'acorn_large_half.stl', 'print')),
|
||||
('AS', ('Acorn, small half', 'acorn_small_half.stl', 'print')),
|
||||
('AF', ('Acorn, full (hangs on a line)', 'acorn_full.stl', 'print')),
|
||||
('AF', ('Acorn, full (hangs on a line)', 'acorn_full.stl', 'print')),
|
||||
('SPIRAL',('Tendril spiral', 'tendril_spiral.stl', 'print')),
|
||||
('STRAP', ('Elastic strap, 19-25 mm wide', 'flat elastic, about 45 cm', 'other')),
|
||||
('WIRE', ('Hanging line, 8 cm', 'fishing line or thin wire', 'other')),
|
||||
('WIRE', ('Hanging line, 8 cm', 'fishing line or thin wire', 'other')),
|
||||
])
|
||||
TOOLS = OrderedDict([('STAMP', ('Leaf vein stamp', 'leaf_vein_stamp.stl'))])
|
||||
SPARES = {'M': 1, 'S': 2} # cut and keep UNSEALED as repair stock; the only parts not placed
|
||||
|
||||
# Assembly steps in order. 'after' lists (step, reason): the reason is printed in the guide.
|
||||
@@ -46,23 +45,19 @@ STEPS = OrderedDict([
|
||||
('nose', dict(title='Nose leaf', view='front', after=[('strip', 'its stem sits just under the brow strip')])),
|
||||
])
|
||||
|
||||
def _pair(fn):
|
||||
out = []
|
||||
for s in (-1, 1): out += fn(s)
|
||||
return out
|
||||
|
||||
def build_placements():
|
||||
P = []
|
||||
def add(pid, part, step, face, glue, shape, footprint, z, x=None, y=None, note='', onto=(), ang=0.0, flip=False, variant=0, count=1):
|
||||
P.append(dict(id=pid, part=part, step=step, face=face, glue=glue, shape=shape, footprint=footprint, z=z, x=x, y=y, note=note,
|
||||
def add(pid, part, step, face, glue, shape, footprint, z, x=None, y=None, onto=(), ang=0.0, flip=False, variant=0, count=1):
|
||||
P.append(dict(id=pid, part=part, step=step, face=face, glue=glue, shape=shape, footprint=footprint, z=z, x=x, y=y,
|
||||
onto=tuple(onto), ang=ang, flip=flip, variant=variant, count=count))
|
||||
side = {-1: 'R', 1: 'L'} # wearer's right is at -x in the front view
|
||||
|
||||
# --- strap: around the outer edge onto the front, through the slit front-to-back, tail glued to the underside of the strap
|
||||
patches = G.base_glasses()['patches']
|
||||
for s in (-1, 1):
|
||||
run = box(min(s*G.SLIT_X, s*(G.FRAME_W/2+23)), G.SLIT_Y0, max(s*G.SLIT_X, s*(G.FRAME_W/2+23)), G.SLIT_Y1)
|
||||
add(f'STRAP-front-{side[s]}', 'STRAP', 'strap', 'front', 'none', run, run, 12, s*G.SLIT_X, (G.SLIT_Y0+G.SLIT_Y1)/2, count=1 if s < 0 else 0) # one strap, two ends
|
||||
add(f'PATCH-{side[s]}', 'PATCH', 'strap', 'back', 'contact', G._common()['patches'][(s+1)//2], G._common()['patches'][(s+1)//2], 1, s*G.SLIT_X, (G.SLIT_Y0+G.SLIT_Y1)/2)
|
||||
add(f'PATCH-{side[s]}', 'PATCH', 'strap', 'back', 'contact', patches[(s+1)//2], patches[(s+1)//2], 1, s*G.SLIT_X, (G.SLIT_Y0+G.SLIT_Y1)/2)
|
||||
# --- brow strip and knot
|
||||
sp = G.place(G.strip_poly(), 0, G.STRIP_Y)
|
||||
add('STRIP', 'STRIP', 'strip', 'front', 'contact', sp, sp, 20, 0, G.STRIP_Y)
|
||||
@@ -97,7 +92,7 @@ def build_placements():
|
||||
for k, (x0, y0, ang) in enumerate([(24, TOP+41, 12), (42, TOP+39, 27), (58, TOP+37, 42)]):
|
||||
for s in (-1, 1):
|
||||
add(f'M-front-{side[s]}{k+1}', 'M', 'front', 'front', 'hot', G.place(G.oak('M', k % 2), s*x0, y0, s*ang, flip=s < 0),
|
||||
G.place(G.stem_tab('M'), s*x0, y0, s*ang), 30+k, s*x0, y0, note=f'{ang} deg out', ang=s*ang, flip=s < 0, variant=k % 2)
|
||||
G.place(G.stem_tab('M'), s*x0, y0, s*ang), 30+k, s*x0, y0, ang=s*ang, flip=s < 0, variant=k % 2)
|
||||
# --- hanging acorns: wire glued to the top of the cheek tab, later covered by the medium cheek leaf stem
|
||||
for s in (-1, 1):
|
||||
anchor = Point(s*88, 13).buffer(3)
|
||||
@@ -118,7 +113,7 @@ def build_placements():
|
||||
# --- nose leaf
|
||||
add('S-nose', 'S', 'nose', 'front', 'hot', G.place(G.oak('S', 1), 0, TOP-8, 180), G.place(G.stem_tab('S'), 0, TOP-8, 180), 46, 0, TOP-8, ang=180, variant=1)
|
||||
order = list(STEPS)
|
||||
P.sort(key=lambda p: (order.index(p['step']),)) # stable: keeps authoring order inside a step
|
||||
P.sort(key=lambda p: order.index(p['step'])) # stable: keeps authoring order inside a step
|
||||
for i, p in enumerate(P): p['seq'] = i
|
||||
return P
|
||||
|
||||
@@ -127,7 +122,7 @@ PLACEMENTS = build_placements()
|
||||
def counts():
|
||||
"""Number of each part actually placed."""
|
||||
c = Counter()
|
||||
for p in PLACEMENTS: c[p['part']] += p.get('count', 1)
|
||||
for p in PLACEMENTS: c[p['part']] += p['count']
|
||||
return c
|
||||
|
||||
def make_list():
|
||||
@@ -166,9 +161,9 @@ def validate(verbose=True):
|
||||
if b is a or b['face'] != a['face'] or b['shape'] is None: continue
|
||||
if b['seq'] < a['seq'] and b['shape'].intersection(a['footprint']).area > 1.0 and b['id'] not in a['onto']:
|
||||
errs.append(f"{a['id']} is glued after {b['id']}, which already covers its glue area")
|
||||
# 5. glue areas sit on foam: leaf stems fully, rigid printed parts at least 55%
|
||||
# 5. glue areas sit on foam: fully, except the knot and the acorn halves, which need at least 55%
|
||||
for p in glued:
|
||||
if p['part'] in ('STRAP',): continue
|
||||
if p['part'] == 'STRAP': continue
|
||||
ground = unary_union([outline] + [q['shape'] for q in PLACEMENTS if q['id'] in p['onto']])
|
||||
frac = p['footprint'].intersection(ground).area / max(p['footprint'].area, 1e-6)
|
||||
need = 0.97 if p['part'] in ('L', 'M', 'S', 'PATCH', 'WIRE', 'SPIRAL', 'TWIG', 'STRIP') else 0.55
|
||||
@@ -208,7 +203,7 @@ def validate(verbose=True):
|
||||
if sl.distance(o.exterior) < 8: errs.append(f"{b['kind']} base: strap slit is {sl.distance(o.exterior):.0f} mm from an edge")
|
||||
if not pt.buffer(-4).contains(sl): errs.append(f"{b['kind']} base: patch does not cover its slit with 4 mm to spare")
|
||||
for h in b['holes']:
|
||||
d = h.distance(o.exterior) if not o.interiors else min(h.exterior.distance(o.exterior), 99)
|
||||
d = h.exterior.distance(o.exterior)
|
||||
if d < 10: errs.append(f"{b['kind']} base: eye hole is {d:.0f} mm from the outer edge")
|
||||
notes.append(f"{b['kind']} base: {o.bounds[2]-o.bounds[0]:.0f} x {o.bounds[3]-o.bounds[1]:.0f} mm, one piece, min neck >= 8 mm")
|
||||
ml = make_list()
|
||||
|
||||
Reference in new issue
Block a user