code wiki / _hdl_build / nx_fab_slice.nx

nx_fab_slice.nx

buildroot/runtime/_hdl_build/nx_fab_slice.nx

6774 B155 linesdepth 2pulls 2 transitivereach 4 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_fab_slice.nx nx_fab_slice_test.nx nx_stl_view_demo.nx nx_stl_view_html.nx nx_stl_view_html_test.nx

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

11const FAB_MAGIC_65536: i64 = 65536
12const FAB_MAGIC_16777216: i64 = 16777216
13const FAB_MAGIC_2147483648: i64 = 2147483648
14const FAB_MAGIC_8388608: i64 = 8388608
17const FAB_UM_BAD: i64 = -888888888888888 // NaN/Inf input -> caller must reject (defensive at the boundary)
18const FAB_UM_MAX: i64 = 888888888888888 // clamp for absurd-magnitude floats (no silent overflow)

functions

21func 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
24func fab_u32le(b: *u8, off: i64) -> i64
33func fab_div_round(num: i64, den: i64) -> i64
called by 1: fslice_tri
43func ff32_to_um(bits: i64) -> i64
called by 2: fstl_vert_ummain calls 1: fab_pow2
67func fstl_tri_count(b: *u8) -> i64 { return fab_u32le(b, 80) }
called by 2: mainnx_stl_view_emit calls 1: fab_u32le
70func fstl_vert_um(b: *u8, t: i64, v: i64, ax: i64) -> i64
76func fstl_tri_um(b: *u8, t: i64, out: *i64) -> i64
called by 1: main calls 1: fstl_vert_um
91func fslice_tri(tri: *i64, zc: i64, out: *i64) -> i64
called by 1: main calls 1: fab_div_round
115func fgc_puts(out: *u8, off: i64, s: *u8) -> i64
called by 1: fgcode_emit
122func fgc_putd(out: *u8, o: i64, vin: i64) -> i64
called by 1: fgcode_emit calls 1: sys_mmap
142func fgcode_emit(pts: *i64, n: i64, out: *u8) -> i64
called by 1: main calls 2: fgc_putsfgc_putd