import curation_paths as paths import json,struct,os,hashlib,numpy as np,sys,xml.etree.ElementTree as ET from multiprocessing import Pool A=paths.A CT={5126:np.float32} def qmat(q): x,y,z,w=q; return np.array([[1-2*(y*y+z*z),2*(x*y-z*w),2*(x*z+y*w)],[2*(x*y+z*w),1-2*(x*x+z*z),2*(y*z-x*w)],[2*(x*z-y*w),2*(y*z+x*w),1-2*(x*x+y*y)]]) def nodemat(n): if "matrix" in n: return np.array(n["matrix"],dtype=float).reshape(4,4).T M=np.eye(4) t=n.get("translation",[0,0,0]); r=n.get("rotation",[0,0,0,1]); s=n.get("scale",[1,1,1]) M[:3,:3]=qmat(r)@np.diag(s); M[:3,3]=t; return M def read(path): b=open(path,"rb").read() if b[:4]!=b"glTF": raise ValueError("not_glb") off=12; js=None; binc=None while off6000: P=P[rng.choice(len(P),6000,replace=False)] np.savez(f,key=a["key"],pts=P.astype(np.float32),err=err); return 0 if __name__=="__main__": os.makedirs(A+"/pc2",exist_ok=True) spec=json.load(open(A+"/pc_spec.json")) # attach urdf mesh scales for a in spec: if a["key"].startswith("U:"): a["scales"]=None with Pool(24) as p: r=p.map(work,spec,chunksize=8) import glob,collections as C c=C.Counter() for f in glob.glob(A+"/pc2/*.npz"): z=np.load(f,allow_pickle=True); c["pts" if "pts" in z.files else "fail:"+str(z["err"])]+=1 print(dict(c))