nx_solid_grid_gate_t365.nx source
↩ module page · 56 lines · 3728 B
1import "nx_solid_grid_candidate_t365.nx"
2import "nx_gate_verdict.nx"
3func scg_box(t:*i64,lo:i64,hi:i64)->i64{
4t[0]=lo;t[1]=-10;t[2]=-10;
5t[3]=lo;t[4]=10;t[5]=10;
6t[6]=lo;t[7]=10;t[8]=-10;
7t[9]=lo;t[10]=-10;t[11]=-10;
8t[12]=lo;t[13]=-10;t[14]=10;
9t[15]=lo;t[16]=10;t[17]=10;
10t[18]=hi;t[19]=-10;t[20]=-10;
11t[21]=hi;t[22]=10;t[23]=-10;
12t[24]=hi;t[25]=10;t[26]=10;
13t[27]=hi;t[28]=-10;t[29]=-10;
14t[30]=hi;t[31]=10;t[32]=10;
15t[33]=hi;t[34]=-10;t[35]=10;
16t[36]=lo;t[37]=-10;t[38]=-10;
17t[39]=lo;t[40]=10;t[41]=-10;
18t[42]=hi;t[43]=10;t[44]=-10;
19t[45]=lo;t[46]=-10;t[47]=-10;
20t[48]=hi;t[49]=10;t[50]=-10;
21t[51]=hi;t[52]=-10;t[53]=-10;
22t[54]=lo;t[55]=-10;t[56]=10;
23t[57]=hi;t[58]=-10;t[59]=10;
24t[60]=hi;t[61]=10;t[62]=10;
25t[63]=lo;t[64]=-10;t[65]=10;
26t[66]=hi;t[67]=10;t[68]=10;
27t[69]=lo;t[70]=10;t[71]=10;
28t[72]=lo;t[73]=-10;t[74]=-10;
29t[75]=hi;t[76]=-10;t[77]=-10;
30t[78]=hi;t[79]=-10;t[80]=10;
31t[81]=lo;t[82]=-10;t[83]=-10;
32t[84]=hi;t[85]=-10;t[86]=10;
33t[87]=lo;t[88]=-10;t[89]=10;
34t[90]=lo;t[91]=10;t[92]=-10;
35t[93]=lo;t[94]=10;t[95]=10;
36t[96]=hi;t[97]=10;t[98]=10;
37t[99]=lo;t[100]=10;t[101]=-10;
38t[102]=hi;t[103]=10;t[104]=10;
39t[105]=hi;t[106]=10;t[107]=-10;
40return 0}
41func main(argc:i64,argv:*i64)->i64{
42 let g:*i64=gv_ctr();gv_head("Bucketed solid union grid" as *u8)
43 let t:*i64=sys_mmap(24*72) as *i64;scg_box(t,0,10);scg_box((t as *u8+12*72) as *i64,5,15)
44 let counts:*i64=sys_mmap(16) as *i64;counts[0]=12;counts[1]=12
45 let r:*SfgRecipe=sys_mmap(__size_of(SfgRecipe)) as *SfgRecipe;r.ox=-7;r.oy=-13;r.oz=-13;r.step=4;r.nx=9;r.ny=7;r.nz=7;r.units=1;r.max_bytes=2097152;r.max_tests=100000
46 let s:*SfgStats=sys_mmap(__size_of(SfgStats)) as *SfgStats;let e:*SfuFailure=sys_mmap(__size_of(SfuFailure)) as *SfuFailure;let o:*NxBufOwned=sys_mmap(__size_of(NxBufOwned)) as *NxBufOwned
47 var rc:i64=sfg_grid_v1(t,24,counts,2,r,o,s,e);gv_check("actual closed solid grid generation succeeds" as *u8,(rc==0) as i64,g)
48 var same:i64=1;if rc==0{let f:*i64=o.buf as *i64;var x:i64=0;while x<r.nx{var y:i64=0;while y<r.ny{var z:i64=0;while z<r.nz{let px:i64=r.ox+x*r.step;let py:i64=r.oy+y*r.step;let pz:i64=r.oz+z*r.step;var want:i64=2*SFC_COORD;if py>-10&&py<10&&pz>-10&&pz<10{if px<0{want=0-px}else{if px>15{want=px-15}else{want=px;if 15-px<want{want=15-px};want=0-want}}};if f[(x*r.ny+y)*r.nz+z]!=want{same=0};z=z+1};y=y+1};x=x+1}}else{same=0};gv_check("all441 nodes match independent analytic cube-union oracle" as *u8,same,g)
49 gv_check("counted bucket fill exactly equals actual triangle tests" as *u8,(rc==0&&s.tests==s.insertions&&s.tests<49*24) as i64,g)
50 gv_check("complete caller coordinates and source unit metadata remain external contract" as *u8,(s.field_words==441&&s.columns==49&&r.ox==-7&&r.units==1) as i64,g)
51 var provenance:i64=0;if rc==0{let h:*i64=(o.buf+s.event_offset) as *i64;var i:i64=0;var a:i64=0;var b:i64=0;while i<s.event_count{if h[i*2]==0{a=a+1};if h[i*2]==1{b=b+1};i=i+1};if a>0&&b>0&&a+b==s.event_count{provenance=1}};gv_check("unmerged original part crossings retained beside union" as *u8,provenance,g)
52 let peak:i64=s.peak_bytes;nx_bo_release(o);r.max_bytes=peak-1;rc=sfg_grid_v1(t,24,counts,2,r,o,s,e);gv_check("one byte below derived peak refuses without output" as *u8,(rc==SFU_RESOURCE&&o.cap==0) as i64,g)
53 r.max_bytes=2097152;r.max_tests=1;rc=sfg_grid_v1(t,24,counts,2,r,o,s,e);gv_check("triangle test admission refuses before allocation" as *u8,(rc==SFU_RESOURCE&&o.cap==0) as i64,g)
54 r.max_tests=100000;r.nx=9223372036854775807;rc=sfg_grid_v1(t,24,counts,2,r,o,s,e);gv_check("grid domain checks precede extent multiplication" as *u8,(rc==SFC_DOMAIN&&o.cap==0) as i64,g)
55 return gv_verdict("solid_grid" as *u8,g,"analytic closed-solid grid only; no wholecharacter or anatomical acceptance" as *u8)
56}