code wiki / (root) / nx_infill.nx

nx_infill.nx

buildroot/runtime/nx_infill.nx

8590 B224 linesdepth 8pulls 13 transitivereach 33 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_infill.nx -- scan-line infill pattern generator for closed NxPolygon contours. Produces line segments that the G-code emitter prints as rectilinear infill inside the perimeter. Algorithm: classical scan-line fill (Foley/van Dam 1990). 1. compute polygon bbox 2. for each horizontal scan line at y = bbox.min_y + k*spacing: a. find x-coord where each polygon edge crosses y (skip horizontal edges; integer cross-multiply form) b. sort x-coords ascending c. pair consecutive crossings; emit segment per pair Spacing derived from line_width + density_pct: spacing_mm = (line_width_mm * 100) / density_pct Density 100% = touching lines, 50% = 50% air, 25% = 75% air. Grid pattern (perpendicular alternation per layer for better mechanical isotropy): when called with vertical=1, the algorithm runs on a transposed (x<->y) coordinate system, producing vertical scan lines. Caller toggles `vertical` per layer index. Reuses NxSliceSoup as output (same flat-segment shape as nx_slice_plane; downstream G-code emitter consumes either). Composes nx_polygon (closed contour input) + nx_qsort_i64 (crossing-coord sort) + nx_slice_plane (segment soup output type). Per cardinal NISHI_3D_PRINT_ROADMAP ยง2.x infill: lines pattern v1 is the substrate floor. Honeycomb / gyroid / cubic are future patterns queued for after this primitive validates on real prints. Per cardinal feedback-bits-up-exceed-never-match: substrate ships the universal scan-line core; richer patterns layer on top, NOT instead of, this primitive. Pure i64 arithmetic throughout (integer cross-multiply avoids division during the straddle test; one division per crossing for the x-coord computation). license_tier: ORIGINAL

dependencies 4 imports · 2 importers

nx_syscalls.nx nx_polygon.nx nx_slice_plane.nx nx_qsort.nx nx_infill.nx nx_infill_test.nx nx_slice_pipeline.nx

imports: nx_syscalls.nxnx_polygon.nxnx_slice_plane.nxnx_qsort.nx

imported by: nx_infill_test.nxnx_slice_pipeline.nx

structs

none

consts

48const NX_INFILL_PATTERN_LINES: i64 = 0
49const NX_INFILL_PATTERN_GRID: i64 = 1 // alternating dir/layer
50const NX_INFILL_PATTERN_HONEYCOMB: i64 = 2 // queued
51const NX_INFILL_PATTERN_GYROID: i64 = 3 // queued
55const NX_INFILL_OK: i64 = 0
56const NX_INFILL_ERR_BAD_POLYGON: i64 = 1
57const NX_INFILL_ERR_BAD_DENSITY: i64 = 2
58const NX_INFILL_ERR_BAD_PATTERN: i64 = 3
59const NX_INFILL_ERR_CAPACITY: i64 = 4

functions

61func nx_infill_verdict_name(v: i64) -> *u8
81func nx_infill_scanline_xs(poly: *NxPolygon, y: i64,
119func nx_infill_scanline_ys(poly: *NxPolygon, x: i64,
161func nx_infill_lines(poly: *NxPolygon, density_pct: i64,