code wiki / (root) / nx_vessel_gcode.nx

nx_vessel_gcode.nx source

↩ module page · 49 lines · 2274 B

1// nx_vessel_gcode.nx -- C2 of the VESSEL-DESIGN ladder: SLICE the printable 2// vessel solid to real G-code -- the manufacturing handoff, one step from a 3// physical print. Composes the existing sovereign slicer: the C1 CSG solid 4// -> nx_csg_extract_scene (mesh) -> nx_slice_pipe_run_v2 (skirt + auto 5// supports + perimeters + infill) -> G-code text in the emitter buffer, 6// targeting a real machine + material profile. 7// 8// THE EXCEED: a geometry that was certified thermally + safety-wise (C0/H*) 9// becomes a print-ready toolpath in the SAME sovereign pipeline -- design 10// to G-code with no third-party CAD/CAM, nothing left but to press print. 11// 12// genealogy_id: nishi_slice_pipeline + nishi_vessel_csg_c1 13 14import "nx_syscalls.nx" 15import "nx_sdf.nx" 16import "nx_csg.nx" 17import "nx_csg_scene.nx" 18import "nx_mesh.nx" 19import "nx_machine_graph.nx" 20import "nx_material_profile.nx" 21import "nx_gcode_emit.nx" 22import "nx_slice_pipeline.nx" 23import "nx_vessel_csg.nx" 24 25const NX_VGC_Q14: i64 = 16384 26 27// Build the vessel, mesh it at the given grid res, and slice it to G-code 28// for a QIDI X-Max3 + generic PLA. Returns the emitter (G-code in e.buf, 29// length e.len), or null on allocation failure. 30func nx_vessel_to_gcode(outer_r_mm: i64, wall_mm: i64, height_mm: i64, base_mm: i64, 31 res: i64, lh_q14: i64, lw_q14: i64, 32 infill_pct: i64, buf_cap: i64) -> *NxGcodeEmitter { 33 let s: *NxCsgScene = nx_vessel_csg_build(outer_r_mm, wall_mm, height_mm, base_mm) 34 let half: i64 = height_mm / 2 35 let margin: i64 = 6 36 let lo: i64 = (0 - outer_r_mm - margin) * NX_VGC_Q14 37 let hi: i64 = (outer_r_mm + margin) * NX_VGC_Q14 38 let loz: i64 = (0 - half - margin) * NX_VGC_Q14 39 let hiz: i64 = (half + margin) * NX_VGC_Q14 40 let mesh: *NxMesh = nx_csg_extract_scene(s, lo, lo, loz, hi, hi, hiz, res) 41 if (mesh as i64) == 0 { return (0) as *NxGcodeEmitter } 42 let qidi: *NxMachineGraph = nx_machine_graph_qidi_xmax3() 43 let pla: *NxMaterialProfile = nx_material_profile_generic_pla() 44 let e: *NxGcodeEmitter = nx_gemit_new(qidi, pla, lh_q14, lw_q14, buf_cap) 45 if (e as i64) == 0 { return (0) as *NxGcodeEmitter } 46 nx_gemit_preamble(e) 47 nx_slice_pipe_run_v2(e, mesh, infill_pct, lh_q14) 48 return e 49}