code wiki / (root) / nx_csg_scene.nx

nx_csg_scene.nx

buildroot/runtime/nx_csg_scene.nx

10583 B264 linesdepth 6pulls 9 transitivereach 18 importersview sourcekind librarytopic csg
docsdependenciesstructsconstsfunctions

about

nx_csg_scene.nx -- N-PRIMITIVE CSG. nx_csg_extract is hardwired to TWO primitives (a op b); real parts need many features folded into ONE watertight solid -- a toilet- cleaner head is plate MINUS pocket MINUS slots UNION neck UNION socket MINUS bore. This GROWS the capability by COMPOSING what already exists, adding no new geometry math: * the boolean algebra is the EXISTING nx_csg_combine_k (min/max + smooth-min fillet) * the surface mesher is the EXISTING marching-tetrahedra core (mt_tet, imported) * per-primitive ROTATION (about an arbitrary pivot) is the EXISTING nx_trig (cos/sin), applied by inverse-rotating the query point -- nx_sdf stays untouched * the only new thing is a LEFT-FOLD of the field over a list of (prim, op, fillet-k): field = combine_k(op[1], eval(p0), eval(p1), k[1]) ... combine_k(op[n-1], ., eval(p_{n-1}), k[n-1]) prim[0] is the seed (its op/k ignored). Robust by construction: SDF booleans can never fail/self-intersect the way B-rep does, and the marching grid is shared so the result is watertight by the same canonical-edge argument as nx_csg_extract. Output is a pipeline-native Q14-mm NxMesh -> nx_stl_write_mesh -> slicer -> G-code, exactly like every other sovereign solid. NOTE (tech-debt, logged not hidden): the grid+marching loop below is copied from nx_csg_extract with only the 2-prim field swapped for the scene field. The clean refactor is a field-eval callback in nx_csg_extract; deferred until NishiLang fn-ptr support is confirmed. license_tier: ORIGINAL

dependencies 5 imports · 15 importers

nx_syscalls.nx nx_mesh.nx nx_sdf.nx nx_csg.nx nx_trig.nx nx_csg_scene.nx nx_csg_rot_gate.nx nx_csg_rotxz_gate.nx nx_csg_scene_gate.nx nx_mesh_decimate_gate.nx nx_underridge_cleaner.nx nx_underridge_cleaner_gate.nx nx_underridge_gel_gate.nx nx_underridge_hook_gate.nx nx_underridge_hook_gcode_gate.nx nx_underridge_hook_petg_gate.nx

diagram shows first 10 each side; +0 more imports, +5 more importers in the complete lists below.

imports: nx_syscalls.nxnx_mesh.nxnx_sdf.nxnx_csg.nxnx_trig.nx

imported by: nx_csg_rot_gate.nxnx_csg_rotxz_gate.nxnx_csg_scene_gate.nxnx_mesh_decimate_gate.nxnx_underridge_cleaner.nxnx_underridge_cleaner_gate.nxnx_underridge_gel_gate.nxnx_underridge_hook_gate.nxnx_underridge_hook_gcode_gate.nxnx_underridge_hook_petg_gate.nxnx_underridge_master_gate.nxnx_vessel_csg.nxnx_vessel_csg_test.nxnx_vessel_emit.nxnx_vessel_gcode.nx

structs

42struct NxCsgScene

consts

29const NX_MAGIC_1024: i64 = 1024
30const NX_MAGIC_65536: i64 = 65536
33const NX_ROT_NONE: i64 = 0
34const NX_ROT_X: i64 = 1
35const NX_ROT_Y: i64 = 2
36const NX_ROT_Z: i64 = 3

functions

55func nx_csg_scene_new(cap: i64) -> *NxCsgScene
71func nx_csg_scene_add(s: *NxCsgScene, p: *NxSdfPrim, op: i64, k: i64) -> i64
87func nx_csg_scene_add_rot(s: *NxCsgScene, p: *NxSdfPrim, op: i64, k: i64,
101func nx_csg_scene_eval_i(s: *NxCsgScene, i: i64, x: i64, y: i64, z: i64) -> i64
130func nx_csg_scene_field(s: *NxCsgScene, x: i64, y: i64, z: i64) -> i64
143func nx_csg_scene_count_inside(s: *NxCsgScene,
166func nx_csg_extract_scene(s: *NxCsgScene,