nx_csg_scene.nx
buildroot/runtime/nx_csg_scene.nx
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
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
| 42 | struct NxCsgScene |
consts
| 29 | const NX_MAGIC_1024: i64 = 1024 |
| 30 | const NX_MAGIC_65536: i64 = 65536 |
| 33 | const NX_ROT_NONE: i64 = 0 |
| 34 | const NX_ROT_X: i64 = 1 |
| 35 | const NX_ROT_Y: i64 = 2 |
| 36 | const NX_ROT_Z: i64 = 3 |
functions
| 55 | func nx_csg_scene_new(cap: i64) -> *NxCsgScene |
| 71 | func nx_csg_scene_add(s: *NxCsgScene, p: *NxSdfPrim, op: i64, k: i64) -> i64 |
| 87 | func nx_csg_scene_add_rot(s: *NxCsgScene, p: *NxSdfPrim, op: i64, k: i64, |
| 101 | func nx_csg_scene_eval_i(s: *NxCsgScene, i: i64, x: i64, y: i64, z: i64) -> i64 |
| 130 | func nx_csg_scene_field(s: *NxCsgScene, x: i64, y: i64, z: i64) -> i64 called by 3: nx_csg_scene_count_insidenx_csg_extract_scenemain calls 2: nx_csg_scene_eval_inx_csg_combine_k |
| 143 | func nx_csg_scene_count_inside(s: *NxCsgScene, |
| 166 | func nx_csg_extract_scene(s: *NxCsgScene, |