code wiki / (root) / nx_infill_test.nx

nx_infill_test.nx

buildroot/runtime/nx_infill_test.nx

4681 B131 linesdepth 9pulls 14 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

about

nx_infill_test.nx -- scan-line infill on a unit-mm CCW square at multiple densities, hand-computed expected counts and endpoints. Unit square (0,0) - (1mm, 1mm) in Q14: (0,0) - (16384, 16384). Line width = 0.4mm = 6554 Q14. Density 100% -> spacing = 6554 Q14. Scan lines at y = 0, 6554, 13108 (next 19662 > 16384 = out of bbox). 3 segments. Density 50% -> spacing = 13108 Q14. Scan lines at y = 0, 13108. 2 segments. Density 25% -> spacing = 26216 Q14. Scan line at y = 0 only. 1 segment. At each scan line, the square produces ONE crossing pair from x = 0 to x = 16384 (left and right vertical edges of the square). Horizontal edges of the square (top and bottom) are skipped by the straddle test, which is the right behaviour. Closed-form invariants: (a) 100% density horizontal scan -> exactly 3 segments. (b) 50% density horizontal scan -> exactly 2 segments. (c) 25% density horizontal scan -> exactly 1 segment. (d) Every emitted segment is horizontal (y1 == y2). (e) Every emitted segment spans full width (x1=0, x2=16384). (f) Vertical scan (vertical=1) at 50% density -> 2 vertical segments (x1==x2, span full height). (g) density_pct = 0 returns BAD_DENSITY verdict. (h) density_pct = 101 returns BAD_DENSITY verdict. (i) 3-vert polygon (triangle) at 100% density yields > 0 segments. expect_exit: 0 license_tier: ORIGINAL

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_polygon.nx nx_slice_plane.nx nx_infill.nx nx_infill_test.nx

imports: nx_syscalls.nxnx_polygon.nxnx_slice_plane.nxnx_infill.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_polygon_make_square nx_polygon_alloc sys_mmap nx_polygon_add_vert nx_polygon_set_vert nx_polygon_vert_ptr nx_slice_soup_new sys_mmap ↻ nx_infill_lines sys_mmap ↻ nx_polygon_bbox nx_polygon_get_x nx_polygon_vert_ptr ↻ nx_polygon_get_y nx_polygon_vert_ptr ↻ nx_infill_scanline_xs nx_polygon_get_x ↻ nx_polygon_get_y ↻ nx_infill_scanline_ys nx_polygon_get_x ↻ nx_polygon_get_y ↻ nx_qsort_i64 nx_qsort_i64_range nx_qsort_insertion_i64 nx_qsort_partition_i64 nx_qsort_swap_i64 nx_qsort_i64_range ↻ nx_slice_soup_emit nx_slice_soup_seg_ptr smoke_seg_y1 nx_slice_soup_seg_ptr ↻ smoke_seg_y2 nx_slice_soup_seg_ptr ↻ smoke_seg_x1 nx_slice_soup_seg_ptr ↻ smoke_seg_x2 nx_slice_soup_seg_ptr ↻ nx_polygon_alloc ↻ nx_polygon_add_vert ↻

structs

none

consts

39const Q14: i64 = 16384
40const LINE_WIDTH: i64 = 6554

functions

42func smoke_seg_x1(s: *NxSliceSoup, i: i64) -> i64
called by 1: main calls 1: nx_slice_soup_seg_ptr
46func smoke_seg_y1(s: *NxSliceSoup, i: i64) -> i64
called by 1: main calls 1: nx_slice_soup_seg_ptr
50func smoke_seg_x2(s: *NxSliceSoup, i: i64) -> i64
called by 1: main calls 1: nx_slice_soup_seg_ptr
54func smoke_seg_y2(s: *NxSliceSoup, i: i64) -> i64
called by 1: main calls 1: nx_slice_soup_seg_ptr
59func main() -> i64