code wiki / _hdl_build / nx_fab_slice.nx
nx_fab_slice.nx
buildroot/runtime/_hdl_build/nx_fab_slice.nx
about
nx_fab_slice.nx -- L0 FAB SUBSTRATE, rung 1 of the electronics-fab arc (hardware layer up):
binary STL in -> fixed-point micrometer geometry -> z-plane slice -> G-code out. This is the team's
first machine-DRIVER capability (charter layer-0: deterministic + a machine driver -> real outcome):
G-code is the wire format every FDM printer motion controller (Marlin/Klipper class) consumes.
LAWS HONORED: struct-free (NxDirent law), integer-only fixed point (1 unit = 1 micrometer, so 1.000mm
= 1000), no variable shifts (pow2 by loop), exact-integer KATs in nx_fab_slice_test.nx.
HONEST SCOPE: slices ONE triangle per call + emits a single polyline; contour chaining across a full
mesh, perimeter offsetting, infill, and the C-oracle differential are the documented NEXT rungs --
flagged, not faked. license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls.nx
imported by: nx_fab_slice_test.nxnx_stl_view_demo.nxnx_stl_view_html.nxnx_stl_view_html_test.nx
structs
| none |
consts
| 11 | const FAB_MAGIC_65536: i64 = 65536 |
| 12 | const FAB_MAGIC_16777216: i64 = 16777216 |
| 13 | const FAB_MAGIC_2147483648: i64 = 2147483648 |
| 14 | const FAB_MAGIC_8388608: i64 = 8388608 |
| 17 | const FAB_UM_BAD: i64 = -888888888888888 // NaN/Inf input -> caller must reject (defensive at the boundary) |
| 18 | const FAB_UM_MAX: i64 = 888888888888888 // clamp for absurd-magnitude floats (no silent overflow) |
functions
| 21 | func fab_pow2(k: i64) -> i64 { var p: i64 = 1; var i: i64 = 0; while i < k { p = p * 2; i = i + 1 } return p } called by 1: ff32_to_um |
| 24 | func fab_u32le(b: *u8, off: i64) -> i64 |
| 33 | func fab_div_round(num: i64, den: i64) -> i64 called by 1: fslice_tri |
| 43 | func ff32_to_um(bits: i64) -> i64 |
| 67 | func fstl_tri_count(b: *u8) -> i64 { return fab_u32le(b, 80) } |
| 70 | func fstl_vert_um(b: *u8, t: i64, v: i64, ax: i64) -> i64 |
| 76 | func fstl_tri_um(b: *u8, t: i64, out: *i64) -> i64 |
| 91 | func fslice_tri(tri: *i64, zc: i64, out: *i64) -> i64 |
| 115 | func fgc_puts(out: *u8, off: i64, s: *u8) -> i64 called by 1: fgcode_emit |
| 122 | func fgc_putd(out: *u8, o: i64, vin: i64) -> i64 |
| 142 | func fgcode_emit(pts: *i64, n: i64, out: *u8) -> i64 |