code wiki / _hdl_build / nx_meshdist.nx

nx_meshdist.nx

buildroot/runtime/_hdl_build/nx_meshdist.nx

35829 B904 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_meshdist.nx -- THE METRIC GAP RULER (form ladder 1785935557; operator 2026-08-05: measure the gap between two objects below the millimetre -- bodies today, screw-to-screw tomorrow). Bidirectional point-to-surface distance between two NXMSH2 meshes, the METRO / DTU convention done sovereignly: candidate->oracle = ACCURACY, oracle->candidate = COMPLETENESS (one direction alone is gameable: a sphere inside the body has perfect accuracy and no completeness). Reported per direction: mean / rms / p95 (the medical HD95) / max, in MICROMETRES, plus F-score-style fractions within 1mm and 0.5mm (the Tanks-and-Temples F@tau shape). All integer math in 10um quanta -- products stay inside i64 by construction (coords <= ~2e5 q, near-cell evaluation bounds |p-a|), so the quantisation floor is 10um, declared in the output. Screws and finer work pass a tighter unit via a future scale arg. ALIGNMENT (declared, never silent): candidate is translated centroid-to-centroid and uniformly scaled by the bbox-height ratio (permil printed). No rotation search in v1 -- both estates' bodies stand y-up. Sampling v1: every k-th triangle CENTROID, k chosen to cap samples (bias declared; area-weighted sampling is the named v2 rung). nx_meshdist <cand.nxmesh> <oracle.nxmesh> [samples] | selftest license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_meshdist.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main md_selftest md_fix sys_mmap sys_openat_wr sys_write sys_close hw sys_write ↻ md_run sys_mmap ↻ md_load sys_openat_rd sys_mmap ↻ sys_read sys_close ↻ md_u32 md_f32q md_refuse hw ↻ md_grid md_cell sys_mmap ↻ hw ↻ pn sys_mmap ↻ sys_write ↻ md_dir sys_mmap ↻ md_near md_cell ↻ md_pt md_isqrt hw ↻ pn ↻ pn ↻ sys_exit hw ↻ md_paint md_refuse ↻

structs

none

consts

18const MD_CAP: i64 = 16777216
19const MD_MAXTRI: i64 = 400000
20const MD_GRID: i64 = 48
21const MD_MAXSAMP: i64 = 16384
22const MD_HISTMAX: i64 = 65536
23const MD_Q_PER_MM: i64 = 100
24const MD_UM_PER_Q: i64 = 10
25const MD_M8388607: i64 = 8388607
26const MD_M8388608: i64 = 8388608
27const MD_FARQ: i64 = 60000
28const MD_BIG: i64 = 4611686018427387903

functions

30func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
31func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 }
32func md_u32(b: *u8, o: i64) -> i64 { return (b[o] as i64) + ((b[o+1] as i64)<<8) + ((b[o+2] as i64)<<16) + ((b[o+3] as i64)<<24) }
34func md_f32q(w: i64) -> i64
48func md_isqrt(x: i64) -> i64
55func md_refuse(reason: *u8) -> i64 { hw("MESHDIST REFUSED: " as *u8); hw(reason); hw("\n" as *u8); return 0 }
called by 3: md_runmd_paintmd_parts calls 1: hw
58func md_load(path: *u8, vx: *i64) -> i64
89func md_pt(px: i64, py: i64, pz: i64, v: *i64, o: i64) -> i64
called by 1: md_near
185func md_cell(v: i64, g0: i64) -> i64
called by 2: md_gridmd_near
192func md_grid(v: *i64, nt: i64, start: *i64, refs: *i64, maxrefs: i64) -> i64
316func md_near(px: i64, py: i64, pz: i64, v: *i64, start: *i64, refs: *i64) -> i64
called by 3: md_dirmd_paintmd_parts calls 2: md_cellmd_pt
366func md_dir(label: *u8, src: *i64, ns: i64, dst: *i64, ndst: i64, start: *i64, refs: *i64, want: i64) -> i64
called by 1: md_run calls 5: sys_mmapmd_nearmd_isqrthwpn
418func md_run(candp: *u8, oracp: *u8, want: i64) -> i64
495func md_enc(v: i64, scale: i64) -> i64
called by 1: md_paint
510func md_w32(b: *u8, o: i64, v: i64) -> i64
called by 1: md_paint
518func md_paint(candp: *u8, oracp: *u8, outp: *u8, band_um: i64) -> i64
653func md_parts(candp: *u8, oracp: *u8, want: i64) -> i64
800func md_fix(path: *u8, zoff_f32: i64) -> i64
830func md_selftest() -> i64
called by 1: main calls 4: md_fixhwmd_runpn
844func main(argc: i64, argv: *i64) -> i64