nx_body_rest_registration_gate_t345.nx source
↩ module page · 56 lines · 3427 B
1import "nx_body_rest_registration_candidate_t345.nx"
2import "nx_gate_verdict.nx"
3func brg_len(s:*u8)->i64{var n:i64=0;while s[n]!=0 as u8{n=n+1};return n}
4func brg_refuse(out:*NxBufOwned,s:*u8,limit:i64,cap:i64)->i64{
5 let ptr:i64=out.buf as i64;let n:i64=out.len;let c:i64=out.cap;let first:i64=(out.buf as *i64)[0]
6 let rc:i64=br_parse(s,brg_len(s),cap,limit,out)
7 return (rc<0&&(out.buf as i64)==ptr&&out.len==n&&out.cap==c&&(out.buf as *i64)[0]==first) as i64
8}
9func main()->i64{
10 let ctr:*i64=gv_ctr();gv_head("BODY-REST-REGISTRATION")
11 let out:*NxBufOwned=sys_mmap(NX_BO_BYTES) as *NxBufOwned
12 var n:i64=0;let raw:*u8=sys_read_file("/volume1/homes/elderwesto/nishihost/buildroot/knowledge/gates/rest-reference-t345.dat",&n)
13 let limit:i64=10000;let cap:i64=n*BR_ROW_BYTES
14 let rc:i64=br_parse(raw,n,cap,limit,out)
15 gv_check("actual qualified skelgen21 joints preserve allXYZ parent side",rc==0&&out.len==21*BR_ROW_BYTES,ctr)
16 let rows:*i64=out.buf as *i64;let foot:i64=br_joint_index(rows,21,12);let other:i64=br_joint_index(rows,21,20)
17 gv_check("actual bilateral toe coordinates and parent identity",foot>=0&&other>=0&&rows[foot*6+3]==84&&rows[other*6+3]==-84&&rows[foot*6+5]==266&&rows[other*6+1]==19,ctr)
18 let offset:*i64=sys_mmap(24) as *i64;br_local_offset(rows,21,foot,offset)
19 gv_check("actual ankle-to-toe localXYZ recovered",offset[0]==0&&offset[1]==-68&&offset[2]==266,ctr)
20 let second:*NxBufOwned=sys_mmap(NX_BO_BYTES) as *NxBufOwned;br_parse(raw,n,cap,limit,second)
21 var same:i64=1;var i:i64=0;while i<out.len{if out.buf[i]!=second.buf[i]{same=0};i=i+1}
22 gv_check("same actualinput deterministically reproduces every jointbyte",same==1&&out.len==second.len,ctr)
23 gv_check("duplicateid refuses with prior completeoutput unchanged",brg_refuse(out,"J 0 -1 0 0 0 0
24J 0 -1 0 0 0 0
25",limit,cap)==1,ctr)
26 gv_check("missingparent refuses unchanged",brg_refuse(out,"J 0 -1 0 0 0 0
27J 1 9 1 1 2 3
28",limit,cap)==1,ctr)
29 gv_check("cycle refuses unchanged",brg_refuse(out,"J 0 -1 0 0 0 0
30J 1 2 1 1 2 3
31J 2 1 1 4 5 6
32",limit,cap)==1,ctr)
33 gv_check("INT64MIN coordinate refuses before subtraction",brg_refuse(out,"J 0 -1 0 -9223372036854775808 0 0
34",limit,cap)==1,ctr)
35 gv_check("INT64MAX coordinate refuses before subtraction",brg_refuse(out,"J 0 -1 0 9223372036854775807 0 0
36",limit,cap)==1,ctr)
37 gv_check("integer overflow token refuses unchanged",brg_refuse(out,"J 0 -1 0 9223372036854775808 0 0
38",limit,cap)==1,ctr)
39 gv_check("trailingtoken refuses unchanged",brg_refuse(out,"J 0 -1 0 1 2 3 trailing
40",limit,cap)==1,ctr)
41 gv_check("budget refusal preserves previousoutput",brg_refuse(out,"J 0 -1 0 0 0 0
42J 1 0 1 1 2 3
43",limit,BR_ROW_BYTES)==1,ctr)
44 let perm:*u8="J 1 0 1 7 8 9
45J 0 -1 0 1 2 3
46";let pr:i64=br_parse(perm,brg_len(perm),cap,limit,second)
47 br_local_offset(second.buf as *i64,2,0,offset)
48 gv_check("permuted parent order preserves fullXYZ localoffset",pr==0&&offset[0]==6&&offset[1]==6&&offset[2]==6,ctr)
49 let roots:*u8="J 10 -1 0 1 2 3
50J 20 -1 0 4 5 6
51";let rr:i64=br_parse(roots,brg_len(roots),cap,limit,second)
52 gv_check("declared multi-root rest graph accepted",rr==0&&second.len==2*BR_ROW_BYTES,ctr)
53 nx_bo_release(out);nx_bo_release(second)
54 gv_check("ownedrelease idempotent and descriptors cleared",nx_bo_release(out)==0&&out.len==0&&out.cap==0&&(out.buf as i64)==0,ctr)
55 return gv_verdict("BODY-REST-REGISTRATION",ctr,"full rest parser only; mesh registration and visible baseline still pending")
56}