Files
mechanical-compiler/legacy/openscad
civicus-build c7e32d8e07 Seed repository: rev-8.0.0 reference, frozen oracle, toolchain, test harness
Reference implementation of the strap-beam generators at revision 8.0.0, kept
so the acceptance oracle can be regenerated. Not a live target; the running
application has no OpenSCAD dependency.

The oracle holds 123 frozen cases, 113 accepted and 10 rejected, produced by
OpenSCAD 2021.01 with BOSL2 at 92d697c2. The ten rejections are part of the
contract: a port that accepts them is wrong.

tests/test_oracle.py specifies the port API and was written before the port,
so the interface follows from what must be verified rather than what is
convenient to implement. Proven by adversarial stub: a build() that rejects
everything passes all 10 rejection tests and fails all 226 acceptance tests.
2026-08-18 07:30:17 -05:00
..

Reference implementation — OpenSCAD, revision 8.0.0

This is not a live target. It is kept so the acceptance oracle in fixtures/strap-beam-8.0.0/ can be regenerated, and so the port has something to be checked against. The running application has no OpenSCAD dependency, and none of this is installed on an instance host.

What it produces

Eleven profiles across two generators. A profile is a cross-section swept along a longitudinal axis; a "member" is the end view of one strap bundle, so its length in the cross-section is the strap's width, never the beam's length.

Generator Profiles
strap-beam-3x.scad Equilateral Triangle, General Triangle, A Frame, Y, T, Three-Fin
strap-beam-4x.scad Square, Rectangle, Diamond, Cross, Four-Fin

4x is the end of the N-strap family. Higher polygon counts compose from triangles and squares rather than getting their own generators.

The shared library

Everything reusable is in lib/, written for N members and used unchanged by both generators:

File Contents
sb-geom.scad GEO and MEMBER records, path construction, exact polyline distance, the monotone solver
sb-join.scad butt joints, hull caps, concave-corner fillets, ring envelopes and bores, polygon fitting
sb-report.scad value-based checks, section metrics, the SB_KEY=value report
sb-profiles.scad three complete N-generic arrangements: ring, spokes, fins
sb-core.scad umbrella include and the PROFILE record

strap-beam-4x.scad is 210 lines and contains no geometry — five one-line calls into the shared library. The same three calls with N=3 produce the triangles, the Y and the Three-Fin. That is the evidence the split is real.

Design rules the library enforces

  1. Declared webs are cavity-to-cavity. A stated 1.2 mm web is 1.2 mm of plastic.
  2. Placement that cannot be derived exactly is solved numerically against the measured quantity, not approximated with a closed form.
  3. Junctions are structural before they are decorative: members butt through their neighbours, and fillets are applied on top of that overlap.
  4. A member with no enclosed side takes the outside wall on both faces, so asymmetric wall settings never make a symmetric profile chiral.
  5. Validation measures the finished section. Connectivity is necessary and never sufficient — revision 7 passed cross-sections joined by 0.13 mm.

Running it

Requires OpenSCAD 2021.01 and BOSL2 at 92d697c2. Use the pinned image:

docker run --rm -v "$PWD:/repo" mechcomp/reference-toolchain:8.0.0 \
    openscad -o /dev/null --export-format=asciistl \
    -Dprofile_type='"Three-Fin"' /repo/legacy/openscad/strap-beam-3x.scad

Every render emits a flat SB_KEY=value block on stderr, terminated by SB_END=1. render_mode="Section" emits the 2D region instead of the swept solid, which is what --export-format=svg consumes.

Three BOSL2 behaviours worth knowing

Found the hard way; the library works around all three:

  • Boolean functions return a bare [] rather than an empty region.
  • offset() on a single-part region returns a bare path rather than a region.
  • round_corners() raises rather than reporting when a radius will not fit.

sb_as_region(), sb_area()/sb_nparts() and sb_path_max_round() exist for exactly these.