code wiki / (root) / nx_stl_test.nx

nx_stl_test.nx

buildroot/runtime/nx_stl_test.nx

5752 B160 linesdepth 6pulls 11 transitivereach 0 importersview sourcekind gate/prooftopic stl
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_mesh.nx nx_mesh_print_check.nx nx_stl.nx nx_stl_test.nx

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

main sys_mmap smoke_put_tri smoke_put_f32_bits nx_stl_load_binary sys_mmap ↻ nx_stl_is_ascii nx_le_read_u32 nx_mesh_alloc sys_mmap ↻ nx_stl_next_pow2 nx_hash_new nx_fp32_bytes_to_q14 nx_fp32_bits_to_q14 nx_stl_intern_vertex nx_stl_pack_xyz nx_le_write_u64 nx_le_write_u32 nx_hash_fnv1a_bytes nx_hash_has nx_hash_probe nx_hash_fnv1a_i64 nx_hash_get nx_hash_probe ↻ nx_mesh_get_vertex_x nx_mesh_get_vertex_y nx_mesh_get_vertex_z nx_mesh_set_vertex nx_hash_put nx_hash_probe ↻ nx_mesh_set_triangle nx_mesh_get_vertex_x ↻ nx_mesh_get_vertex_y ↻ nx_mesh_get_vertex_z ↻ nx_mesh_is_manifold nx_mesh_print_tri_v nx_mesh_print_dir_edge_cou nx_mesh_print_tri_v ↻

structs

none

consts

78const F32_ZERO: i64 = 0x00000000
79const F32_ONE: i64 = 0x3F800000
80const Q14_ONE: i64 = 16384

functions

43func smoke_put_f32_bits(buf: *u8, off: i64, bits32: i64) -> i64
called by 1: smoke_put_tri
54func smoke_put_tri(buf: *u8, off: i64,
called by 1: main calls 1: smoke_put_f32_bits
82func main() -> i64