code wiki / _hdl_build / nx_meshdist.nx
nx_meshdist.nx
buildroot/runtime/_hdl_build/nx_meshdist.nx
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
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
structs
| none |
consts
| 18 | const MD_CAP: i64 = 16777216 |
| 19 | const MD_MAXTRI: i64 = 400000 |
| 20 | const MD_GRID: i64 = 48 |
| 21 | const MD_MAXSAMP: i64 = 16384 |
| 22 | const MD_HISTMAX: i64 = 65536 |
| 23 | const MD_Q_PER_MM: i64 = 100 |
| 24 | const MD_UM_PER_Q: i64 = 10 |
| 25 | const MD_M8388607: i64 = 8388607 |
| 26 | const MD_M8388608: i64 = 8388608 |
| 27 | const MD_FARQ: i64 = 60000 |
| 28 | const MD_BIG: i64 = 4611686018427387903 |
functions
| 30 | func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 31 | func 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 } |
| 32 | func 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) } |
| 34 | func md_f32q(w: i64) -> i64 |
| 48 | func md_isqrt(x: i64) -> i64 |
| 55 | func md_refuse(reason: *u8) -> i64 { hw("MESHDIST REFUSED: " as *u8); hw(reason); hw("\n" as *u8); return 0 } |
| 58 | func md_load(path: *u8, vx: *i64) -> i64 |
| 89 | func md_pt(px: i64, py: i64, pz: i64, v: *i64, o: i64) -> i64 called by 1: md_near |
| 185 | func md_cell(v: i64, g0: i64) -> i64 |
| 192 | func md_grid(v: *i64, nt: i64, start: *i64, refs: *i64, maxrefs: i64) -> i64 |
| 316 | func md_near(px: i64, py: i64, pz: i64, v: *i64, start: *i64, refs: *i64) -> i64 |
| 366 | func md_dir(label: *u8, src: *i64, ns: i64, dst: *i64, ndst: i64, start: *i64, refs: *i64, want: i64) -> i64 |
| 418 | func md_run(candp: *u8, oracp: *u8, want: i64) -> i64 |
| 495 | func md_enc(v: i64, scale: i64) -> i64 called by 1: md_paint |
| 510 | func md_w32(b: *u8, o: i64, v: i64) -> i64 called by 1: md_paint |
| 518 | func md_paint(candp: *u8, oracp: *u8, outp: *u8, band_um: i64) -> i64 |
| 653 | func md_parts(candp: *u8, oracp: *u8, want: i64) -> i64 |
| 800 | func md_fix(path: *u8, zoff_f32: i64) -> i64 |
| 830 | func md_selftest() -> i64 |
| 844 | func main(argc: i64, argv: *i64) -> i64 |