nx_stl_test.nx
buildroot/runtime/nx_stl_test.nx
about
nx_stl_test.nx -- hand-build a binary STL tetrahedron in-memory,
parse it back, verify everything round-trips correctly.
Tetrahedron at unit-millimetre scale (becomes Q14 = 16384 after parse):
v0 = (0, 0, 0)
v1 = (1, 0, 0)
v2 = (0, 1, 0)
v3 = (0, 0, 1)
Triangles (CCW outward winding matching nx_mesh_make_tetrahedron):
T0: v1, v2, v3 (far face)
T1: v0, v3, v2 (x=0 face)
T2: v0, v1, v3 (y=0 face)
T3: v0, v2, v1 (z=0 face)
Each triangle = 50 bytes:
12 bytes normal (we write zeros; parser ignores them)
36 bytes 9 floats for 3 verts
2 bytes attribute (zero)
Total file size = 80-byte header + 4-byte n_tris + 4*50 = 284 bytes.
Closed-form invariants:
(a) parse returns OK verdict
(b) n_tris_header == 4
(c) n_verts_unique == 4 (perfect dedup -- tetrahedron really
does have exactly 4 unique vertices)
(d) mesh.n_tris == 4
(e) parsed coordinates match expected Q14 values
(f) nx_mesh_is_manifold returns OK on the parsed mesh
(g) Truncated buffer detected
(h) ASCII STL detected and refused
expect_exit: 0
license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_mesh.nxnx_mesh_print_check.nxnx_stl.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
| 78 | const F32_ZERO: i64 = 0x00000000 |
| 79 | const F32_ONE: i64 = 0x3F800000 |
| 80 | const Q14_ONE: i64 = 16384 |
functions
| 43 | func smoke_put_f32_bits(buf: *u8, off: i64, bits32: i64) -> i64 called by 1: smoke_put_tri |
| 54 | func smoke_put_tri(buf: *u8, off: i64, |
| 82 | func main() -> i64 |