Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:23

0001 #!/usr/bin/env python
0002 """
0003 stree_load_test.py
0004 ====================
0005 
0006 ::
0007 
0008     In [14]: np.unique( st.rem.num_child, return_index=True, return_counts=True  )
0009     Out[14]:
0010     (array([    0,     1,     2,     3,     4,    54,    63,  4521, 46276], dtype=int32),
0011      array([   4,    2,    0,    6,   14, 2328,   12,  204, 2326]),
0012      array([2884,    7,   65,    3,  126,    1,    1,    1,    1]))
0013 
0014 
0015     In [18]: np.unique( st.rem.lvid, return_counts=True  )
0016     Out[18]:
0017     (array([  0,   1,   2,   3,   4,   5,   6,   7,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,
0018              42,  43,  44,  45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,  70,  71,  72,  73,  74,  75,  76,  77,  78,  79,
0019              80,  81,  82,  83,  84,  85,  86,  87,  88,  89,  90,  91,  92,  93,  94,  95,  96,  97, 102, 103, 123, 124, 125, 126, 127, 128, 135, 136, 137, 138], dtype=int32),
0020      array([  1,   1,   1,   1,   1,   1,   1,   1, 126,  63,   1,   1,   1,   1,  10,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  10,  30,  30,
0021              30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,  30,
0022              30,  30,  30,  30,  30,  30,  30,  30,  30,  30,   2,  36,   8,   8,   1,   1, 370, 220,  56,  56,   1,   1,   1,   1,   1,   1,   1,   1,   1,   1]))
0023 
0024 
0025 
0026     In [8]: np.unique(f.nds[:,11], return_counts=True )  # repeat_index:11
0027     Out[8]:
0028     (array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32),
0029      array([  3089, 128000,  88305,  34979,  14400,    590,    590,    590,    590,  65520]))
0030 
0031     In [13]: np.unique( st.nds.repeat_index, return_counts=True )
0032     Out[13]:
0033     (array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype=int32),
0034      array([  3089, 128000, 138765,  69958,  14400,    590,    590,    590,    590,  65520]))
0035 
0036 
0037     In [17]: np.unique( st.nds.lvid[st.nds.repeat_index == 1], return_index=True, return_counts=True )
0038     Out[17]:
0039     (array([129, 130, 131, 132, 133], dtype=int32),
0040      array([2, 3, 1, 4, 0]),                        ## index starts from zero, because have selected only the one ridx
0041      array([25600, 25600, 25600, 25600, 25600]))
0042 
0043     In [22]: st.nds.lvid[st.nds.repeat_index == 1].reshape(-1,5)
0044     Out[22]:
0045     array([[133, 131, 129, 130, 132],
0046            [133, 131, 129, 130, 132],
0047            [133, 131, 129, 130, 132],
0048            [133, 131, 129, 130, 132],
0049            [133, 131, 129, 130, 132],
0050            [133, 131, 129, 130, 132],
0051            [133, 131, 129, 130, 132],
0052 
0053 
0054     In [8]: np.unique( st.csg.typecode, return_counts=True )
0055     Out[8]:
0056     (array([  1,   2,   3,  11, 101, 103, 105, 108, 110], dtype=int32),
0057      array([199,   1,  30,  20,   7,  27,  97,  10, 246]))
0058 
0059 
0060 
0061 
0062 
0063 
0064     CSGFoundry.dumpSolid ridx  1 label               r1 numPrim      5 primOffset   3089
0065      so_primIdx 3089 numNode    3 nodeOffset 23207 meshIdx 133 repeatIdx   1 primIdx2   0 : PMT_3inch_pmt_solid
0066      so_primIdx 3090 numNode    1 nodeOffset 23210 meshIdx 131 repeatIdx   1 primIdx2   1 : PMT_3inch_body_solid_ell_ell_helper
0067      so_primIdx 3091 numNode    1 nodeOffset 23211 meshIdx 129 repeatIdx   1 primIdx2   2 : PMT_3inch_inner1_solid_ell_helper
0068      so_primIdx 3092 numNode    1 nodeOffset 23212 meshIdx 130 repeatIdx   1 primIdx2   3 : PMT_3inch_inner2_solid_ell_helper
0069      so_primIdx 3093 numNode    1 nodeOffset 23213 meshIdx 132 repeatIdx   1 primIdx2   4 : PMT_3inch_cntr_solid
0070 
0071 
0072 
0073     In [18]: np.unique( st.nds.lvid[st.nds.repeat_index == 2], return_index=True, return_counts=True )
0074     Out[18]:
0075     (array([118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128], dtype=int32),
0076      array([ 1,  2,  5,  7,  8,  9, 10,  6,  4,  3,  0]),
0077      array([12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615]))
0078 
0079 
0080     In [26]: st.f.factor[:,:4]
0081     Out[26]:
0082     array([[    0, 25600, 25600,     5],
0083            [    1, 12615, 12615,    11],
0084            [    2,  4997,  4997,    14],
0085            [    3,  2400,  2400,     6],
0086            [    4,   590,     0,     1],
0087            [    5,   590,     0,     1],
0088            [    6,   590,     0,     1],
0089            [    7,   590,     0,     1],
0090            [    8,   504,   504,   130]], dtype=int32)
0091 
0092 
0093 
0094 
0095 
0096     In [16]: np.unique( st.nds.lvid[st.nds.repeat_index == 2], return_counts=True )
0097     Out[16]:
0098     (array([118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128], dtype=int32),
0099      array([12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615, 12615]))
0100 
0101 
0102 
0103 
0104 
0105     In [9]: snode.Label(6,11), f.nds[f.nds[:,ri] == 1 ]
0106     Out[9]:
0107     ('           ix      dp      sx      pt      nc      fc      sx      lv      cp      se      sx      ri      bd',
0108      array([[194249,      6,  20675,  67846,      2, 194250, 194254,    122, 300000,     -1,     -1,      1,     26],
0109             [194250,      7,      0, 194249,      2, 194251, 194253,    120,      0,     -1,     -1,      1,     29],
0110             [194251,      8,      0, 194250,      0,     -1, 194252,    118,      0,     -1,     -1,      1,     36],
0111             [194252,      8,      1, 194250,      0,     -1,     -1,    119,      0,     -1,     -1,      1,     37],
0112             [194253,      7,      1, 194249,      0,     -1,     -1,    121,      0,     -1,     -1,      1,     24],
0113             [194254,      6,  20676,  67846,      2, 194255, 194259,    122, 300001,     -1,     -1,      1,     26],
0114             [194255,      7,      0, 194254,      2, 194256, 194258,    120,      0,     -1,     -1,      1,     29],
0115             [194256,      8,      0, 194255,      0,     -1, 194257,    118,      0,     -1,     -1,      1,     36],
0116             [194257,      8,      1, 194255,      0,     -1,     -1,    119,      0,     -1,     -1,      1,     37],
0117             [194258,      7,      1, 194254,      0,     -1,     -1,    121,      0,     -1,     -1,      1,     24],
0118 
0119 
0120 
0121     n = st.f._csg.node
0122 
0123     In [8]: snd.Label(3,8), n[n[:,snd.lv] == 105]
0124     Out[8]:
0125     ('        ix   dp   sx   pt   nc   fc   sx   lv   tc   pm   bb   xf',
0126      array([[483,   4,   0, 484,   0,  -1,  -1, 105, 105, 294, 294,  -1],
0127             [484,   3,   0, 486,   1, 483, 485, 105,  11,  -1,  -1,  -1],
0128             [485,   3,   1, 486,   0,  -1,  -1, 105, 103, 295, 295, 183],
0129             [486,   2,   0, 488,   2, 484, 487, 105,   1,  -1,  -1,  -1],
0130             [487,   2,   1, 488,   0,  -1,  -1, 105, 105, 296, 296, 184],
0131             [488,   1,   0, 495,   2, 486, 494, 105,   1,  -1,  -1,  -1],
0132             [489,   4,   0, 490,   0,  -1,  -1, 105, 105, 297, 297,  -1],
0133             [490,   3,   0, 492,   1, 489, 491, 105,  11,  -1,  -1,  -1],
0134             [491,   3,   1, 492,   0,  -1,  -1, 105, 103, 298, 298, 186],
0135             [492,   2,   0, 494,   2, 490, 493, 105,   1,  -1,  -1,  -1],
0136             [493,   2,   1, 494,   0,  -1,  -1, 105, 105, 299, 299, 187],
0137             [494,   1,   1, 495,   2, 492,  -1, 105,   1,  -1,  -1, 188],
0138             [495,   0,  -1,  -1,   2, 488,  -1, 105,   3,  -1,  -1,  -1]], dtype=int32))
0139 
0140 
0141     In [9]: print(st.desc_csg(18))
0142     desc_csg lvid:18 st.f.soname[18]:GLw1.up10_up11_FlangeI_Web_FlangeII0x59f4850
0143             ix   dp   sx   pt   nc   fc   sx   lv   tc   pm   bb   xf
0144     array([[ 32,   2,   0,  34,   0,  -1,  33,  18, 110,  25,  25,  -1],
0145            [ 33,   2,   1,  34,   0,  -1,  -1,  18, 110,  26,  26,   5],
0146            [ 34,   1,   0,  36,   2,  32,  35,  18,   1,  -1,  -1,  -1],
0147            [ 35,   1,   1,  36,   0,  -1,  -1,  18, 110,  27,  27,   6],
0148            [ 36,   0,  -1,  -1,   2,  34,  -1,  18,   1,  -1,  -1,  -1]], dtype=int32)
0149 
0150 
0151 
0152 """
0153 
0154 import numpy as np
0155 from opticks.ana.fold import Fold
0156 from opticks.sysrap.stree import stree, snode, sn   # formerly used snd
0157 
0158 np.set_printoptions(edgeitems=16)
0159 
0160 def test_bd(st):
0161     print("u_bd, n_bd = np.unique( st.nds.boundary, return_counts=True ) ")
0162     u_bd, n_bd = np.unique( st.nds.boundary, return_counts=True )
0163     for i in range(len(u_bd)):
0164         u = u_bd[i]
0165         n = n_bd[i]
0166         print(" %3d : %4d : %6d : %s " % (i, u, n, st.f.bd_names[u] ))
0167     pass
0168     print(st.desc_boundary())
0169 
0170 def test_rem(st):
0171     print("u_lv, n_lv = np.unique( st.rem.lvid, return_counts=True  )")
0172     u_lv, n_lv = np.unique( st.rem.lvid, return_counts=True  )
0173     for i in range(len(u_lv)):
0174         u = u_lv[i]
0175         n = n_lv[i]
0176         print(" %3d : %4d : %6d : %s " % (i, u, n, st.f.soname_names[u] ))
0177     pass
0178 
0179     print(st.desc_remainder())
0180 
0181 
0182 def test_csg(st):
0183     print("[---test_csg" )
0184     print(" count total csg nodes for each lv : ie number of nodes in every subtree ")
0185     print("u_cl, n_cl = np.unique( st.f._csg.sn[:,sn.lv], return_counts=True)")
0186     u_cl, n_cl = np.unique( st.f._csg.sn[:,sn.lv], return_counts=True)
0187     for i in range(len(u_cl)):
0188         u = u_cl[i]
0189         n = n_cl[i]
0190         print(" %3d : %4d : %6d : %s " % (i, u, n, st.f.soname_names[u] ))
0191     pass
0192     print("]---test_csg" )
0193 
0194 
0195 if __name__ == '__main__':
0196 
0197     snode.Type()
0198     sn.Type()     # formerly snd
0199 
0200 
0201     print("[--f = Fold.Load")
0202     f = Fold.Load(symbol="f")
0203     print("]--f = Fold.Load")
0204 
0205     print("[--repr(f)")
0206     print(repr(f))
0207     print("]--repr(f)")
0208 
0209     print("[--st = stree(f)")
0210     st = stree(f)
0211     print("]--st = stree(f)")
0212 
0213     print("[--repr(st)")
0214     print(repr(st))
0215     print("]--repr(st)")
0216 
0217     #test_bd(st)
0218     #test_rem(st)
0219 
0220     test_csg(st)
0221 
0222     print("[--st.descSolids")
0223     print(st.descSolids(True))
0224     print(st.descSolids(False))
0225     print("]--st.descSolids")
0226 
0227 
0228