code wiki / (root) / nx_solid_actual_loft_gate_t365.nx

nx_solid_actual_loft_gate_t365.nx source

↩ module page · 43 lines · 4648 B

1import "nx_solid_mesh_column_candidate_t365.nx" 2import "nx_gate_verdict.nx" 3func bag_u32(b:*u8,o:i64)->i64{return (b[o] as i64)|((b[o+1] as i64)<<8)|((b[o+2] as i64)<<16)|((b[o+3] as i64)<<24)} 4func bag_equal(a:*u8,b:*u8,n:i64)->i64{var i:i64=0;while i<n{if a[i]!=b[i]{return 0};i=i+1};return 1} 5func bag_at(b:*u8,o:i64)->*u8{return ((b as i64)+o) as *u8} 6func bag_header(b:*u8,n:i64)->i64{ 7 if (b as i64)<=0||n<88{return 0};if bag_equal(b,"NXMSH2" as *u8,6)!=1||bag_u32(b,8)!=3{return 0} 8 let nt:i64=bag_u32(b,12);if n!=88+nt*88{return 0} 9 var i:i64=0;var end:i64=0;while i<3{if bag_u32(b,32+i*24)!=end{return 0};end=end+bag_u32(b,36+i*24);if end>nt{return 0};i=i+1};if end!=nt{return 0};return 1 10} 11// Actual generator positions are integer-mm Float32 values. Refuse a nonintegral or nonfinite position. 12func bag_integer(bits:i64,out:*i64)->i64{ 13 let e:i64=(bits>>23)&255;let m:i64=bits&8388607;if e==0&&m==0{out[0]=0;return 0};if e<127||e>157{return SFC_DOMAIN} 14 var v:i64=m+8388608;let shift:i64=e-150;if shift>=0{v=v<<shift}else{let mask:i64=(1<<(0-shift))-1;if (v&mask)!=0{return SFC_DOMAIN};v=v>>(0-shift)} 15 if ((bits>>31)&1)==1{v=0-v};if v<0-SFC_COORD||v>SFC_COORD{return SFC_DOMAIN};out[0]=v;return 0 16} 17func bag_vertex_equal(a:*u8,ai:i64,b:*u8,bi:i64)->i64{return bag_equal(bag_at(a,ai*12),bag_at(b,bi*12),12)} 18func main(argc:i64,argv:*i64)->i64{ 19 let g:*i64=gv_ctr();gv_head("Actual canonical loft part union columns" as *u8);if argc!=2{return 2} 20 let len:*i64=sys_mmap(8) as *i64;let src:*u8=sys_read_file(argv[1] as *u8,len) 21 let ok:i64=bag_header(src,len[0]);gv_check("complete actual canonical NXMSH2 extent" as *u8,ok,g);if ok==0{return 3} 22 gv_check("expected complete source and skin counts" as *u8,(bag_u32(src,12)==103824&&bag_u32(src,36)==34608) as i64,g) 23 let t:*i64=sys_mmap((2296+2072)*72) as *i64;let c:*i64=sys_mmap(16) as *i64;c[0]=2296;c[1]=2072 24 let scratch:*i64=sys_mmap(8) as *i64;var ti:i64=0;var good:i64=1;while ti<4368{var original:i64=ti;if ti>=2296{original=19768+ti-2296};var j:i64=0;while j<9{let rc:i64=bag_integer(bag_u32(src,88+original*84+j*4),scratch);if rc!=0{good=0}else{if scratch[0]<0-SFC_COORD/256||scratch[0]>SFC_COORD/256{good=0}else{t[ti*9+j]=scratch[0]*256}};j=j+1};ti=ti+1} 25 gv_check("all selected source vertices decode exactly into declared Q256 frame" as *u8,good,g);if good==0{return 4} 26 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 27 var rc:i64=0 28rc=sfc_mesh_column_v1(t,4368,c,2,396864,64,0,o,e);gv_check("actual loft column 0 returns explicit part union" as *u8,(rc==0&&o.len==16) as i64,g) 29if rc==0&&o.len==16{let a:*i64=o.buf as *i64;gv_check("column 0 matches independent floating triangle oracle quantized endpoints" as *u8,(a[0]==-19178&&a[1]==19109) as i64,g);sfu_column_value(a,2,0,100000,v);gv_check("column 0 source overlap center remains inside" as *u8,(v[0]<0) as i64,g)} 30nx_bo_release(o) 31rc=sfc_mesh_column_v1(t,4368,c,2,382016,64,0,o,e);gv_check("actual loft column 1 returns explicit part union" as *u8,(rc==0&&o.len==16) as i64,g) 32if rc==0&&o.len==16{let a:*i64=o.buf as *i64;gv_check("column 1 matches independent floating triangle oracle quantized endpoints" as *u8,(a[0]==-17604&&a[1]==17591) as i64,g);sfu_column_value(a,2,0,100000,v);gv_check("column 1 source overlap center remains inside" as *u8,(v[0]<0) as i64,g)} 33nx_bo_release(o) 34rc=sfc_mesh_column_v1(t,4368,c,2,409664,64,0,o,e);gv_check("actual loft column 2 returns explicit part union" as *u8,(rc==0&&o.len==16) as i64,g) 35if rc==0&&o.len==16{let a:*i64=o.buf as *i64;gv_check("column 2 matches independent floating triangle oracle quantized endpoints" as *u8,(a[0]==-22036&&a[1]==22043) as i64,g);sfu_column_value(a,2,0,100000,v);gv_check("column 2 source overlap center remains inside" as *u8,(v[0]<0) as i64,g)} 36nx_bo_release(o) 37rc=sfc_mesh_column_v1(t,4368,c,2,435264,64,0,o,e);gv_check("actual loft column 3 returns explicit part union" as *u8,(rc==0&&o.len==16) as i64,g) 38if rc==0&&o.len==16{let a:*i64=o.buf as *i64;gv_check("column 3 matches independent floating triangle oracle quantized endpoints" as *u8,(a[0]==-19174&&a[1]==19144) as i64,g);sfu_column_value(a,2,0,100000,v);gv_check("column 3 source overlap center remains inside" as *u8,(v[0]<0) as i64,g)} 39nx_bo_release(o) 40rc=sfc_mesh_column_v1(t,4368,c,2,396864,38464,0,o,e);gv_check("actual loft column 4 returns explicit part union" as *u8,(rc==0&&o.len==0) as i64,g) 41nx_bo_release(o) 42return gv_verdict("actual_loft_union" as *u8,g,"two actual source parts and five columns only; no full-grid topology or anatomy claim" as *u8) 43}