nx_solid_mesh_column_gate_t365.nx source
↩ module page · 62 lines · 4774 B
1import "nx_solid_mesh_column_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 scg_tetra(t:*i64,q:i64)->i64{t[0]=0*q;t[1]=-10*q;t[2]=-10*q;t[3]=0*q;t[4]=0*q;t[5]=10*q;t[6]=0*q;t[7]=10*q;t[8]=-10*q;t[9]=0*q;t[10]=-10*q;t[11]=-10*q;t[12]=0*q;t[13]=10*q;t[14]=-10*q;t[15]=1*q;t[16]=0*q;t[17]=0*q;t[18]=0*q;t[19]=10*q;t[20]=-10*q;t[21]=0*q;t[22]=0*q;t[23]=10*q;t[24]=1*q;t[25]=0*q;t[26]=0*q;t[27]=0*q;t[28]=0*q;t[29]=10*q;t[30]=0*q;t[31]=-10*q;t[32]=-10*q;t[33]=1*q;t[34]=0*q;t[35]=0*q;return 0}
42func main(argc:i64,argv:*i64)->i64{
43 let g:*i64=gv_ctr();gv_head("Actual closed triangle solids union" as *u8)
44 let t:*i64=sys_mmap(24*72) as *i64;let b:*i64=(t as *u8+12*72) as *i64
45 let c:*i64=sys_mmap(16) as *i64;c[0]=12;c[1]=12
46 let o:*NxBufOwned=sys_mmap(__size_of(NxBufOwned)) as *NxBufOwned;let e:*SfuFailure=sys_mmap(__size_of(SfuFailure)) as *SfuFailure;let v:*i64=sys_mmap(8) as *i64
47 scg_box(t,0,10);scg_box(b,5,15)
48 var rc:i64=sfc_mesh_column_v1(t,24,c,2,0,0,408,o,e);gv_check("overlapping closed cubes crossing diagonal edges" as *u8,(rc==0&&o.len==16) as i64,g)
49 if rc==0{sfu_column_value(o.buf as *i64,o.len/8,7,100,v)};gv_check("actual overlapping cube interiors union" as *u8,(rc==0&&v[0]==-7) as i64,g);nx_bo_release(o)
50 scg_box(b,20,30);rc=sfc_mesh_column_v1(t,24,c,2,1,2,408,o,e);gv_check("actual separated cubes preserve two intervals" as *u8,(rc==0&&o.len==32) as i64,g);if rc==0{sfu_column_value(o.buf as *i64,4,15,100,v)};gv_check("actual separated cube gap outside" as *u8,(rc==0&&v[0]==5) as i64,g);nx_bo_release(o)
51 scg_box(b,10,20);rc=sfc_mesh_column_v1(t,24,c,2,0,0,408,o,e);if rc==0{sfu_column_value(o.buf as *i64,o.len/8,10,100,v)};gv_check("actual face-touching solids remove internal face" as *u8,(rc==0&&o.len==16&&v[0]==-10) as i64,g);nx_bo_release(o)
52 scg_box(b,0,10);rc=sfc_mesh_column_v1(t,24,c,2,0,0,408,o,e);gv_check("actual coincident cube parts do not cancel" as *u8,(rc==0&&o.len==16) as i64,g);nx_bo_release(o)
53 rc=sfc_mesh_column_v1(t,24,c,2,20,0,408,o,e);gv_check("column outside both parts is empty" as *u8,(rc==0&&o.len==0) as i64,g);nx_bo_release(o)
54 rc=sfc_mesh_column_v1(t,24,c,2,0,0,407,o,e);gv_check("complete live allocation peak admitted by caller" as *u8,(rc==SFU_RESOURCE&&o.cap==0) as i64,g)
55 // Remove one complete X face from the first solid while retaining the rest in a contiguous span.
56 c[0]=10;c[1]=12;rc=sfc_mesh_column_v1((t as *u8+2*72) as *i64,22,c,2,0,0,0,o,e);gv_check("open part refuses odd crossings with part identity" as *u8,(rc==SFU_ODD&&e.part==0&&o.cap==0) as i64,g)
57 c[0]=12;c[1]=12;scg_box(t,-10,0);scg_box(b,5,15);rc=sfc_mesh_column_v1(t,24,c,2,1,2,408,o,e);if rc==0{sfu_column_value(o.buf as *i64,o.len/8,-5,100,v)};gv_check("caller frame retained without recenter or axis swap" as *u8,(rc==0&&v[0]==-5) as i64,g);nx_bo_release(o)
58 t[0]=SFC_COORD+1;rc=sfc_mesh_column_v1(t,24,c,2,0,0,408,o,e);gv_check("coordinate arithmetic domain refuses before products" as *u8,(rc==SFC_DOMAIN&&e.part==0&&e.crossing==0&&o.cap==0) as i64,g)
59 scg_tetra(t,1);c[0]=4;rc=sfc_mesh_column_v1(t,4,c,1,0,5,0,o,e);gv_check("valid thin sloped tetrahedron reports insufficient quantized precision" as *u8,(rc==SFC_PRECISION&&e.part==0&&o.cap==0) as i64,g)
60 scg_tetra(t,256);rc=sfc_mesh_column_v1(t,4,c,1,0,1280,0,o,e);if rc==0&&o.len==16{let a:*i64=o.buf as *i64;gv_check("same sloped solid at explicit Q256 retains half-unit thickness" as *u8,(a[0]==0&&a[1]==128) as i64,g)}else{gv_check("same sloped solid at explicit Q256 retains half-unit thickness" as *u8,0,g)};nx_bo_release(o)
61 return gv_verdict("solid_mesh_column" as *u8,g,"closed cube triangle witnesses only; no wholebody, metric SDF or anatomical acceptance" as *u8)
62}