nx_infill_test.nx
buildroot/runtime/nx_infill_test.nx
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
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
structs
| none |
consts
| 39 | const Q14: i64 = 16384 |
| 40 | const LINE_WIDTH: i64 = 6554 |
functions
| 42 | func smoke_seg_x1(s: *NxSliceSoup, i: i64) -> i64 |
| 46 | func smoke_seg_y1(s: *NxSliceSoup, i: i64) -> i64 |
| 50 | func smoke_seg_x2(s: *NxSliceSoup, i: i64) -> i64 |
| 54 | func smoke_seg_y2(s: *NxSliceSoup, i: i64) -> i64 |
| 59 | func main() -> i64 |