Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-10 07:50:29

0001 #!/usr/bin/env python
0002 """
0003 U4TreeCreateTest.py
0004 =====================
0005 """
0006 
0007 import numpy as np, textwrap
0008 from opticks.ana.fold import Fold
0009 from opticks.sysrap.stree import stree, snode
0010 from opticks.sysrap.sn_check import sn_check
0011 
0012 np.set_printoptions(edgeitems=16)
0013 
0014 if __name__ == '__main__':
0015     f = Fold.Load("$FOLD/stree", symbol="f")
0016     print(repr(f))
0017     snode.Fields(bi=True)  # bi:True exports field indices into builtins scope
0018     print(snode.Label(6,11),"\n", f.nds[f.nds[:,ri] == 1 ])
0019 
0020     prim_nidx = f.prim_nidx[:,0] ## nidx values of every prim [globalPrimIdx(0-based, contiguous)]
0021     assert( np.all( prim_nidx > -1 ) )
0022     prim_nidx_tab = np.c_[np.unique(prim_nidx, return_counts=True)]
0023     assert( np.all( prim_nidx_tab[:,1] == 1 ) )
0024 
0025     nidx_prim = f.nidx_prim[:,0] ## prim values of every nidx [lots of repeats from instancing]
0026     assert( np.all( nidx_prim > -1 ) )
0027     nidx_prim_tab = np.c_[np.unique(nidx_prim, return_counts=True)]
0028     assert( len(nidx_prim_tab) == len(prim_nidx) )
0029 
0030 
0031     c = sn_check(f, symbol="c")
0032     print(repr(c))
0033 
0034     sn = f._csg.sn
0035     s_tv = f._csg.s_tv
0036     s_pa = f._csg.s_pa
0037     s_bb = f._csg.s_bb
0038 
0039     if hasattr(f, 'csg'):
0040         snd = f.csg.node
0041         xform = f.csg.xform
0042         param = f.csg.param
0043         aabb = f.csg.aabb
0044 
0045         EXPR = r"""
0046         np.all( snd == sn )
0047         np.all( xform == s_tv )
0048         np.all( param == s_pa )
0049         np.all( aabb == s_bb )
0050         """
0051     else:
0052         snd = None
0053         xform = None
0054         param = None
0055         aabb = None
0056 
0057         EXPR = r"""
0058         sn
0059         s_tv
0060         s_pa
0061         s_bb
0062         """
0063     pass
0064 
0065     for expr in list(filter(None,textwrap.dedent(EXPR).split("\n"))):
0066         print(expr)
0067         if expr[0] == "#": continue
0068         print(eval(expr))
0069     pass
0070 
0071 
0072 
0073 
0074