Files
make-cad/examples/lh20_hand_r04/render.py
T
Jerry 8d3415602f DECISION: Refine the complete five-finger exterior from physical reference photos
DECISION: Refine R0.3 into a separate R0.4 exterior using the user's physical-hand photographs, preserving all five four-axis finger chains, including the little finger removed from the photographed sample.

WHY: On 2026-11-17 the user supplied five close-ups and asked for a comparison-based improvement, explicitly explaining the missing little finger. The photographs reveal curved shells, fork openings, stepped joint caps, black contact pads and a spatial thumb root more clearly than the earlier website screenshot. design-docs/lh20-r04-photo-refinement.md records the interpretation, assumptions, rejected alternatives and checks. No scale marker or internal section was supplied, so the existing dimension baseline remains an original design input and the internal drive remains pending.

ALTERNATIVE CONSIDERED AND REJECTED: Merely changing colours, duplicating the missing-finger state, or presenting a concept image would not improve the actual complete CAD model. Reusing earlier verification reports would conceal new geometry and motion failures.

WHAT CHANGES: Add curved shells and removable covers, nested fork ears, stepped three-fastener caps, wraparound black pads, segmented flex-circuit placeholders and a canted thumb mounting frame. Preserve native articulated source, binding geometry checks and previews to captured packages. A small export adapter uses the native writer's existing metadata_properties=False option and saves complete descriptive records in a hashed sidecar because >22 kB constraint strings overflow the OCCT STEP reader; geometry and assembly structure remain intact, and the shared SDK is unchanged.

Checked: Single finger and complete hand passed positive-volume, BREP validity, constraint and exact interference checks in straight and specified light-flex poses. Diagnosed and removed a 0.256 mm3 knuckle overlap without changing the 0.01 mm3 threshold. All five fingers retain four axes. STEP reimport retained 245 solids with relative volume error 4.03e-7. URDF has 21 links, 20 joints and 84 mesh files. Reviewed actual front/back/oblique/side CAD views and the R0.3 comparison. Packaging verified 102 files, relative mesh paths, source hashes and independent-finger versus nested-finger volumes. Python compilation passed. Full travel, actuator integration, continuous flex routing, manufacturing and hardware performance are not qualified.

Co-Authored-By: Codex <noreply@openai.com>
2026-11-17 10:38:37 +08:00

90 lines
2.8 KiB
Python

"""Orthographic and oblique inspection images, always rendered from CAD BREP."""
import argparse, hashlib, json
import numpy as np
from PIL import Image, ImageDraw, ImageFont
from simplecadapi._cpp import _native
from parts.common import placed
from model_io import read_model, flatten
from parameters import OUT
def panel(leaves, view, width=1000, height=1300):
scene = _native.RenderScene()
for path, p, m in leaves:
scene.add_shape(
placed(p.body, m),
color=tuple(p.material.color)[:3],
studio_material=p.material.material_id in ("frame", "joint"),
linear_deflection=0.07,
angular_deflection=0.15,
edges=False,
ink=False,
)
result = _native.render_scene(
scene,
width,
height,
supersample=2,
style="standard",
zoom=1.4 if len(leaves) > 50 else 1.15,
views=[(*view, "")],
view_up=(0, 1, 0),
show_axes=False,
edge_width_scale=0,
background_top=(0.94, 0.95, 0.96),
background_bottom=(0.86, 0.89, 0.91),
)
return Image.fromarray(np.asarray(result.rgba)[:, :, :3].copy())
def font(size):
return ImageFont.truetype("/System/Library/Fonts/Helvetica.ttc", size)
def main(name):
leaves = flatten(read_model(name))
image = Image.new("RGB", (3000, 1550), "#f1f3f5")
draw = ImageDraw.Draw(image)
draw.text((65, 40), "LH20 / EXTERIOR REDESIGN", font=font(52), fill="#23343c")
draw.text(
(65, 110),
"R0.4 | Real parametric CAD | Actuator integration pending",
font=font(26),
fill="#566973",
)
for i, (v, title) in enumerate(
(
((90, 0), "PALMAR"),
((-90, 180), "DORSAL"),
((35, 35), "THREE-QUARTER / PROFILE"),
)
):
print("Rendering", title, flush=True)
shot = panel(leaves, v)
shot.save(OUT / f"{name}_{('front', 'back', 'profile')[i]}.png")
image.paste(shot, (i * 1000, 200))
draw.text((i * 1000 + 35, 168), title, font=font(23), fill="#41555e")
path = OUT / f"{name}_overview.png"
image.save(path)
panel(leaves, (0, 0)).save(OUT / f"{name}_side.png")
path.with_suffix(".json").write_text(
json.dumps(
dict(
package_sha256=hashlib.sha256(
(OUT / f"{name}.scadpkg").read_bytes()
).hexdigest(),
image_sha256=hashlib.sha256(path.read_bytes()).hexdigest(),
scope="Actual exterior CAD; not a complete internal mechanism",
),
indent=2,
)
)
print(path, flush=True)
if __name__ == "__main__":
ap = argparse.ArgumentParser()
ap.add_argument("--name", default="hand")
main(ap.parse_args().name)