Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002 stree_load_test.cc
0003 ===================
0004 
0005 ::
0006 
0007     ~/o/sysrap/tests/stree_load_test.sh
0008 
0009     TEST=get_inst IIDX=100                      ~/o/sysrap/tests/stree_load_test.sh
0010     TEST=pick_lvid_ordinal_node                 ~/o/sysrap/tests/stree_load_test.sh
0011     TEST=find_inst_gas                          ~/o/sysrap/tests/stree_load_test.sh
0012 
0013     TEST=pick_lvid_ordinal_repeat_ordinal_inst_ ~/o/sysrap/tests/stree_load_test.sh
0014     TEST=pick_lvid_ordinal_repeat_ordinal_inst  ~/o/sysrap/tests/stree_load_test.sh
0015     TEST=get_frame                              ~/o/sysrap/tests/stree_load_test.sh
0016     TEST=get_prim_aabb                          ~/o/sysrap/tests/stree_load_test.sh
0017 
0018     TEST=desc_factor_nodes FIDX=0               ~/o/sysrap/tests/stree_load_test.sh
0019     TEST=desc_repeat_node RIDX=0 RORD=0         ~/o/sysrap/tests/stree_load_test.sh
0020 
0021 **/
0022 
0023 #include "ssys.h"
0024 #include "stree.h"
0025 #include "stra.h"
0026 #include "strid.h"
0027 #include "sn.h"
0028 #include "SBitSet.h"
0029 
0030 
0031 struct stree_load_test
0032 {
0033     const char* TEST ;
0034     const stree* st ;
0035 
0036     stree_load_test();
0037     void init();
0038 
0039     int get_combined_transform(int LVID, int NDID  );
0040     int get_inst(int idx) const ;
0041     int get_frame_f4(int idx) const ;
0042     int pick_lvid_ordinal_node() const ;
0043     int find_inst_gas() const ;
0044     int pick_lvid_ordinal_repeat_ordinal_inst_() const ;
0045     int pick_lvid_ordinal_repeat_ordinal_inst() const ;
0046     int get_frame() const ;
0047     int get_frame_scan_(const char* solid, int i0, int i1, int j0, int j1) const ;
0048     int get_frame_scan() const ;
0049     int get_frame_MOI() const ;
0050     int get_prim_aabb() const ;
0051     int desc_repeat_index() const ;
0052 
0053     int get_global_aabb() const ;
0054     int get_global_aabb_check() const ;
0055 
0056     int get_global_aabb_sibling_overlaps() const ;
0057 
0058 
0059     int desc_factor_nodes(int fidx) const ;
0060     int desc_repeat_node(int ridx, int rord) const ;
0061     int desc_repeat_nodes() const ;
0062 
0063     int desc_nds() const ;
0064     int desc_rem() const ;
0065     int desc_tri() const ;
0066     int desc_NRT() const ;
0067 
0068     int desc_node_ELVID() const ;
0069     int desc_node_ECOPYNO() const ;
0070     int desc_node_EBOUNDARY() const ;
0071 
0072     int desc_node_solids() const ;
0073     int desc_solids() const ;
0074     int desc_solid(int lvid) const ;
0075     int desc() const ;
0076     int save_desc(const char* fold) const ;
0077     int make_tree_digest() const ;
0078 
0079     int desc_nodes_with_center_within_ce() const ;
0080     int desc_prim() const ;
0081 
0082 
0083     int main();
0084 };
0085 
0086 inline stree_load_test::stree_load_test()
0087     :
0088     TEST(ssys::getenvvar("TEST", nullptr)),
0089     st(nullptr)
0090 {
0091     init();
0092 }
0093 
0094 inline void stree_load_test::init()
0095 {
0096     bool noload = strcmp(TEST,"get_global_aabb_check") == 0 ;
0097     if(!noload)
0098     {
0099         st = stree::Load();
0100         if( st == nullptr ) std::cout << "stree_load_test::init FAILED TO LOAD TREE \n" ;
0101     }
0102 
0103     std::cout << "[stree_load_test::init\n" ;
0104     std::cout << ( st ? st->desc_id() : "-" ) << "\n" ;
0105     std::cout << "]stree_load_test::init\n" ;
0106 }
0107 
0108 
0109 inline int stree_load_test::get_combined_transform( int LVID, int NDID )
0110 {
0111     std::cout
0112         << "stree_load_test::get_combined_transform"
0113         << " LVID " << LVID
0114         << " NDID " << NDID
0115         << std::endl
0116         ;
0117 
0118     std::vector<snode> nodes ;  // structural volume nodes with the LVID, could be thousands
0119     st->find_lvid_nodes_(nodes, LVID, 'N') ;
0120 
0121     int num_nodes = nodes.size();
0122     std::cout << " VOL " << st->desc_nodes_(nodes) ;
0123 
0124 
0125     std::vector<sn*> nds ;    // CSG constituent nodes of the LV
0126     sn::GetLVNodes(nds, LVID );
0127     int num_nds = nds.size();
0128     std::cout << " sn::Desc(nds) " << std::endl << sn::Desc(nds) ;
0129 
0130     assert( num_nodes > 0 && num_nds > 1 );
0131 
0132     std::vector<glm::tmat4x4<double>> tvs ;
0133     tvs.reserve(num_nodes*2);
0134 
0135     for(int i=0 ; i < num_nodes ; i++)
0136     {
0137         bool dump_NDID = i == NDID ;
0138 
0139         const snode& node = nodes[i] ;
0140         const sn*  nd = nds[0] ;
0141 
0142         glm::tmat4x4<double> t(1.) ;
0143         glm::tmat4x4<double> v(1.) ;
0144 
0145         std::stringstream* out = dump_NDID ? new std::stringstream : nullptr ;
0146         stree::VTR* t_stack = nullptr ;
0147 
0148         st->get_combined_transform(t, v, node, nd, out, t_stack );
0149 
0150         tvs.push_back(t);
0151         tvs.push_back(v);
0152 
0153         if(out)
0154         {
0155             std::string str = out->str();
0156             std::cout
0157                 << " dump_NDID " << ( dump_NDID ? "YES" : "NO" )
0158                 << " i " << std::setw(3) << i
0159                 << std::endl
0160                 << stra<double>::Desc(t, v, "t", "v")
0161                 << std::endl
0162                 << str
0163                 << std::endl
0164                 ;
0165         }
0166     }
0167 
0168     NP* a = NP::Make<double>( num_nodes, 2, 4, 4);
0169     a->read2<double>( (double*)tvs.data() );
0170 
0171     //NP* a = NPX::ArrayFromVector<double>( tvs, 2, 4, 4) ;
0172 
0173     const char* path = "/tmp/test_get_combined_transform.npy" ;
0174     std::cout << " save " << path << std::endl ;
0175     a->save(path);
0176     return 0 ;
0177 }
0178 
0179 inline int stree_load_test::get_inst(int idx) const
0180 {
0181     const glm::tmat4x4<double>* inst = st->get_inst(idx) ;
0182     const glm::tmat4x4<double>* iinst = st->get_iinst(idx) ;
0183     const glm::tmat4x4<float>* inst_f4 = st->get_inst_f4(idx) ;
0184     const glm::tmat4x4<float>* iinst_f4 = st->get_iinst_f4(idx) ;
0185 
0186     std::cout
0187         << "stree_load_test::get_inst"
0188         << " idx " << idx
0189         << " inst " << ( inst ? "YES" : "NO " )
0190         << " iinst " << ( iinst ? "YES" : "NO " )
0191         << " inst_f4 " << ( inst_f4 ? "YES" : "NO " )
0192         << " iinst_f4 " << ( iinst_f4 ? "YES" : "NO " )
0193         << std::endl
0194         ;
0195 
0196     if(inst)  std::cout << "inst"  << std::endl << stra<double>::Desc(*inst) << std::endl ;
0197     if(iinst) std::cout << "iinst" << std::endl << stra<double>::Desc(*iinst) << std::endl ;
0198     if(inst_f4)  std::cout << "inst_f4"  << std::endl << stra<float>::Desc(*inst_f4) << std::endl ;
0199     if(iinst_f4) std::cout << "iinst_f4" << std::endl << stra<float>::Desc(*iinst_f4) << std::endl ;
0200 
0201     if(inst)  std::cout << "inst"  << std::endl << strid::Desc<double,int64_t>(*inst) << std::endl ;
0202     if(iinst) std::cout << "iinst" << std::endl << strid::Desc<double,int64_t>(*iinst) << std::endl ;
0203     if(inst_f4)  std::cout << "inst_f4"  << std::endl << strid::Desc<float,int32_t>(*inst_f4) << std::endl ;
0204     if(iinst_f4) std::cout << "iinst_f4" << std::endl << strid::Desc<float,int32_t>(*iinst_f4) << std::endl ;
0205     return 0 ;
0206 }
0207 
0208 inline int stree_load_test::get_frame_f4(int idx) const
0209 {
0210     sframe fr = {} ;
0211     st->get_frame_f4( fr, idx );
0212 
0213     std::cout
0214        << "stree_load_test::get_frame_f4"
0215        << " idx " << idx
0216        << std::endl
0217        << fr.desc()
0218        << std::endl
0219        ;
0220 
0221     return 0 ;
0222 }
0223 
0224 inline int stree_load_test::pick_lvid_ordinal_node() const
0225 {
0226     std::cout
0227         << "stree_load_test::pick_lvid_ordinal_node"
0228         << "\n"
0229         << " (lvid, lvid_ordinal, n.desc ) "
0230         << "\n"
0231         ;
0232 
0233     for(int i=0 ; i < 150 ; i++)
0234     {
0235         for( int j=0 ; j < 2 ; j++)
0236         {
0237             int lvid = i ;
0238             int lvid_ordinal = j ;
0239             const snode* n = st->pick_lvid_ordinal_node( lvid, lvid_ordinal, 'N' );
0240             std::cout
0241                << "("
0242                << std::setw(4) << lvid
0243                << " "
0244                << std::setw(4) << lvid_ordinal
0245                << ") "
0246                << ( n ? n->desc() : "-" )
0247                << "\n"
0248                ;
0249         }
0250     }
0251     return 0 ;
0252 }
0253 
0254 inline int stree_load_test::find_inst_gas() const
0255 {
0256     std::cout
0257         << "stree_load_test::find_inst_gas"
0258         << "\n"
0259         << " (gas_idx, gas_ordinal, inst_idx, inst_idx_slow ) "
0260         << "\n"
0261         ;
0262 
0263     for(int i=0 ; i < 10 ; i++)
0264     {
0265         int q_gas_idx = i ;
0266 
0267         for(int j=0 ; j < 3 ;  j++)
0268         {
0269             int q_gas_ordinal = j ;
0270             int inst_idx = st->find_inst_gas(q_gas_idx, q_gas_ordinal );
0271             int inst_idx_slow = st->find_inst_gas_slowly(q_gas_idx, q_gas_ordinal );
0272 
0273             std::cout
0274                 << "("
0275                 << std::setw(4) << q_gas_idx
0276                 << " "
0277                 << std::setw(4) << q_gas_ordinal
0278                 << " "
0279                 << std::setw(7) << inst_idx
0280                 << " "
0281                 << std::setw(7) << inst_idx_slow
0282                 << ") "
0283                 << "\n"
0284                 ;
0285         }
0286     }
0287     return 0 ;
0288 }
0289 
0290 
0291 inline int stree_load_test::pick_lvid_ordinal_repeat_ordinal_inst_() const
0292 {
0293     std::cout
0294         << "stree_load_test::pick_lvid_ordinal_repeat_ordinal_inst_"
0295         << " ( lvid, lvid_ordinal, repeat_ordinal, inst_idx ) "
0296         << "\n"
0297         ;
0298 
0299     for(int i=0 ; i < 150 ; i++)
0300     for(int j=0 ; j < 2 ; j++)
0301     for(int k=0 ; k < 2 ; k++)
0302     {
0303         int lvid = i ;
0304         int lvid_ordinal = j ;
0305         int repeat_ordinal = k ;
0306         int inst_idx = st->pick_lvid_ordinal_repeat_ordinal_inst_( lvid, lvid_ordinal, repeat_ordinal );
0307 
0308         std::cout
0309             << "("
0310             << std::setw(4) << lvid
0311             << " "
0312             << std::setw(4) << lvid_ordinal
0313             << " "
0314             << std::setw(6) << repeat_ordinal
0315             << " "
0316             << std::setw(7) << inst_idx
0317             << ") "
0318             << "\n"
0319             ;
0320     }
0321     return 0 ;
0322 }
0323 
0324 inline int stree_load_test::pick_lvid_ordinal_repeat_ordinal_inst() const
0325 {
0326     std::cout
0327         << "stree_load_test::pick_lvid_ordinal_repeat_ordinal_inst"
0328         << " ( i, spec, inst_idx ) "
0329         << "\n"
0330         ;
0331 
0332     std::vector<std::string> v_spec = {{ "Hama:0:0", "Hama:0:1000", "NNVT", "NNVT:0", "NNVT:0:0", "NNVT:0:1000" }} ;
0333     int num = v_spec.size();
0334     for(int i=0 ; i < num ; i++)
0335     {
0336         const std::string& spec = v_spec[i] ;
0337         int inst_idx = st->pick_lvid_ordinal_repeat_ordinal_inst( spec.c_str() );
0338 
0339         std::cout
0340             << "("
0341             << std::setw(4) << i
0342             << " "
0343             << std::setw(50) << spec
0344             << " "
0345             << std::setw(7) << inst_idx
0346             << ") "
0347             << "\n"
0348             ;
0349     }
0350     return 0 ;
0351 }
0352 
0353 inline int stree_load_test::get_frame() const
0354 {
0355     std::vector<std::string> v_spec =
0356        {{
0357           "HamamatsuR12860sMask:0:0",
0358           "Hama:0:0",
0359           "Hama:0:1000",
0360           "NNVT",
0361           "NNVT:0",
0362           "NNVT:0:0",
0363           "NNVT:0:1000",
0364           "sDeadWater:0:-1",
0365           "GZ1.A06_07_FlangeI_Web_FlangeII:0:-1",
0366           "GZ1.B06_07_FlangeI_Web_FlangeII:0:-1",
0367           "GZ1.A06_07_FlangeI_Web_FlangeII:15:-1",
0368           "GZ1.B06_07_FlangeI_Web_FlangeII:15:-1"
0369        }} ;
0370     int num = v_spec.size();
0371     for(int i=0 ; i < num ; i++)
0372     {
0373         const std::string& spec = v_spec[i] ;
0374         sfr fr = st->get_frame(spec.c_str());
0375         std::cout << fr ;
0376     }
0377     return 0 ;
0378 }
0379 
0380 inline int stree_load_test::get_frame_MOI() const
0381 {
0382     const char* MOI = ssys::getenvvar("MOI", nullptr);
0383     if(!MOI) return 1 ;
0384 
0385     sfr mfr = st->get_frame(MOI);
0386     std::cout << "stree_load_test::get_frame_MOI\n" <<  MOI << "\n" << mfr << "\n"  ;
0387     return 0 ;
0388 }
0389 
0390 
0391 inline int stree_load_test::get_frame_scan_(const char* solid, int i0, int i1, int j0, int j1) const
0392 {
0393     const char* fmt = "%s:%d:%d" ;
0394     std::cout
0395         << "stree_load_test::get_frame_scan_"
0396         << " fmt [" << fmt << "] "
0397         << " solid [" << ( solid ? solid : "-" ) << "] "
0398         << " i0 " << i0 << " i1 " << i1
0399         << " j0 " << j0 << " j1 " << j1
0400         << "\n"
0401         ;
0402 
0403     for(int i=i0 ; i < i1 ; i++)
0404     for(int j=j0 ; j <= j1 ; j++)
0405     {
0406         std::string _moi = sstr::Format_(fmt, solid, i, j);
0407         const char* moi = _moi.c_str();
0408         bool has_frame = st->has_frame(moi);
0409         std::cout << "\n\n" << moi << " has_frame " <<  ( has_frame ? "YES" : "NO" ) << "\n" ;
0410 
0411         if(has_frame)
0412         {
0413             sfr mfr = st->get_frame(moi);
0414             //std::cout <<  mfr << "\n" ;
0415             std::cout <<  mfr.desc_ce() << "\n" ;
0416         }
0417     }
0418     return 0 ;
0419 }
0420 inline int stree_load_test::get_frame_scan() const
0421 {
0422     const char* solid = "solidXJfixture" ;
0423     get_frame_scan_(solid, 0, 60, -1, -1 );
0424     return 0 ;
0425 }
0426 
0427 
0428 inline int stree_load_test::get_prim_aabb() const
0429 {
0430     std::cout << "stree_load_test::get_prim_aabb \n" ;
0431     std::array<double,6> pbb ;
0432 
0433     for(int i=0 ; i < 3 ; i++)
0434     {
0435         int num_nd = 0 ;
0436         const char* label = nullptr ;
0437         switch(i)
0438         {
0439             case 0: num_nd = st->nds.size()       ; label = "st->nds"       ; break ;
0440             case 1: num_nd = st->rem.size()       ; label = "st->rem"       ; break ;
0441             case 2: num_nd = st->inst_nidx.size() ; label = "st->inst_nidx" ; break ;
0442         }
0443 
0444         std::cout << label << " " << num_nd << std::endl ;
0445 
0446         for(int j=0 ; j < 3 ; j++)
0447         {
0448             int k0 = 0 ;
0449             int k1 = 0 ;
0450             if( j == 0 )
0451             {
0452                 k0 = 0 ;
0453                 k1 = k0 + 20 ;
0454             }
0455             else if( j == 1 )
0456             {
0457                 k0 = num_nd/2  ;
0458                 k1 = k0 + 20 ;
0459             }
0460             else if( j == 2 )
0461             {
0462                 k0 = num_nd - 20   ;
0463                 k1 = num_nd ;
0464             }
0465 
0466             for(int k=k0 ; k < k1 ; k++)
0467             {
0468                 const snode* node = nullptr ;
0469                 if(      i == 0 ) node = &st->nds[k] ;
0470                 else if( i == 1 ) node = &st->rem[k] ;
0471                 else if( i == 2 ) node = &st->nds[st->inst_nidx[k]] ;
0472 
0473                 std::ostream* out = nullptr ;
0474                 stree::VTR* t_stack = nullptr ;
0475                 st->get_prim_aabb( pbb.data(), *node, out, t_stack );
0476                 std::cout
0477                     << " [" << std::setw(5) << k << "]"
0478                     << " : "
0479                     << s_bb::Desc<double>( pbb.data() )
0480                     << std::endl
0481                     ;
0482             }
0483         }
0484     }
0485     return 0 ;
0486 }
0487 
0488 
0489 /**
0490 stree_load_test::desc_repeat_index
0491 -------------------------------------
0492 
0493 
0494 ::
0495 
0496     stree_load_test::desc_repeat_index
0497     [stree::desc_repeat_index
0498     [stree::desc_repeat_index N[nds.npy]
0499        0 :       3431
0500        1 :     128000
0501        2 :     113913
0502        3 :      59268
0503        4 :       9596
0504        5 :       2400
0505        6 :        590
0506        7 :        590
0507        8 :       1770           ## 590*3 = 1770
0508        9 :      64480           ## 496*130 =
0509       10 :        370
0510       11 :       2118           ## 353*6 = 2118
0511     TOT: :     386526
0512     ]stree::desc_repeat_index N[nds.npy]
0513     [stree::desc_repeat_index R[rem.npy]
0514        0 :       3087
0515     TOT: :       3087
0516     ]stree::desc_repeat_index R[rem.npy]
0517     [stree::desc_repeat_index T[tri.npy]
0518        0 :        344
0519     TOT: :        344
0520     ]stree::desc_repeat_index T[tri.npy]
0521      N_tot     386526 N0       3431 (R_tot + T_tot)       3431 N0_expect YES
0522      R_tot       3087 R0       3087 R0_expect YES
0523      T_tot        344 T0        344 T0_expect YES
0524     ]stree::desc_repeat_index
0525 
0526 
0527 
0528     (ok) A[blyth@localhost CSGFoundry]$ cat.py mmlabel.txt
0529     0    3087:sWorld
0530     1    5:PMT_3inch_pmt_solid
0531     2    9:NNVTMCPPMTsMask_virtual
0532     3    12:HamamatsuR12860sMask_virtual
0533     4    4:mask_PMT_20inch_vetosMask_virtual
0534     5    4:PMT_8inch_pmt_solid
0535     6    1:sStrutBallhead
0536     7    1:base_steel
0537     8    3:uni_acrylic1
0538     9    130:sPanel
0539     10   1:sStrut_0
0540     11   6:PMT_20inch_pmt_solid_head
0541     12   344:ConnectingCutTube_0
0542 
0543     THE SOLID WITH INDEX 12 IS AN EXTRA FOR THE TRIANGULATED NODES
0544     THAT ALL HAVE repeat_index zero
0545 
0546 **/
0547 
0548 
0549 inline int stree_load_test::desc_repeat_index() const
0550 {
0551     std::cout << "[stree_load_test::desc_repeat_index\n" ;
0552     std::cout << st->desc_repeat_index() << "\n" ;
0553     std::cout << "]stree_load_test::desc_repeat_index\n" ;
0554     return 0 ;
0555 }
0556 
0557 
0558 inline int stree_load_test::get_global_aabb() const
0559 {
0560     std::cout << "[stree_load_test::get_global_aabb \n" ;
0561 
0562     NPFold* f = st->get_global_aabb();
0563     f->save("$TMPFOLD/get_global_aabb");
0564 
0565     std::cout << "]stree_load_test::get_global_aabb \n" ;
0566     return 0 ;
0567 }
0568 
0569 
0570 /**
0571 stree_load_test::get_global_aabb_check
0572 ----------------------------------------
0573 
0574 This approach yields too many overlaps to wade thru
0575 
0576 **/
0577 
0578 inline int stree_load_test::get_global_aabb_check() const
0579 {
0580     NPFold* f = NPFold::Load("$TMPFOLD/get_global_aabb");
0581     const NP* bb = f->get("bb");
0582     const NP* ii = f->get("ii");
0583 
0584     const double* bbv = bb->cvalues<double>();
0585     const size_t* iiv = ii->cvalues<size_t>();
0586 
0587     std::cout << "[stree_load_test::get_global_aabb_check \n" ;
0588     std::cout << " bb " << ( bb ? bb->sstr() : "-" ) << "\n";
0589     std::cout << " ii " << ( ii ? ii->sstr() : "-" ) << "\n";
0590 
0591     enum { bb_nj = 6 };
0592 
0593     assert( bb->shape[0] == ii->shape[0] );
0594     assert( bb->shape[1] == bb_nj );
0595     assert( ii->shape[1] == snode::NV );
0596 
0597     struct Overlap
0598     {
0599         size_t i, j ;
0600     };
0601 
0602     std::vector<Overlap> overlap ;
0603 
0604     size_t num_bb = bb->shape[0] ;
0605     for( size_t i = 0 ; i < num_bb ; i++ )
0606     for( size_t j = 0 ; j < num_bb ; j++ )
0607     {
0608         if( j >= i ) continue ;
0609         const double* a = &bbv[bb_nj*i+0] ;
0610         const double* b = &bbv[bb_nj*j+0] ;
0611         bool has_overlap = s_bb::HasOverlap<double>( a, b );
0612         if(has_overlap) overlap.push_back( {i, j} );
0613     }
0614     std::cout
0615        << " overlap " << overlap.size()
0616        << "\n"
0617        ;
0618 
0619     std::cout << "]stree_load_test::get_global_aabb_check \n" ;
0620     return 0 ;
0621 }
0622 
0623 
0624 
0625 
0626 inline int stree_load_test::get_global_aabb_sibling_overlaps() const
0627 {
0628     std::cout << "[stree_load_test::get_global_aabb_sibling_overlaps \n" ;
0629 
0630     NPFold* f = st->get_global_aabb_sibling_overlaps();
0631     f->save("$TMPFOLD/get_global_aabb_sibling_overlaps");
0632 
0633     std::cout << "]stree_load_test::get_global_aabb_sibling_overlaps \n" ;
0634     return 0 ;
0635 }
0636 
0637 
0638 
0639 
0640 
0641 
0642 
0643 inline int stree_load_test::desc_factor_nodes(int fidx) const
0644 {
0645     std::cout << st->desc_factor_nodes(fidx) << "\n" ;
0646     return 0 ;
0647 }
0648 
0649 
0650 inline int stree_load_test::desc_repeat_node(int ridx, int rord) const
0651 {
0652     std::cout << st->desc_repeat_node(ridx, rord) << "\n" ;
0653     return 0 ;
0654 }
0655 inline int stree_load_test::desc_repeat_nodes() const
0656 {
0657     std::cout << st->desc_repeat_nodes() << "\n" ;
0658     return 0 ;
0659 }
0660 
0661 
0662 inline int stree_load_test::desc_nds() const
0663 {
0664     std::cout << st->desc_nds() << "\n" ;
0665     return 0 ;
0666 }
0667 inline int stree_load_test::desc_rem() const
0668 {
0669     std::cout << st->desc_rem() << "\n" ;
0670     return 0 ;
0671 }
0672 inline int stree_load_test::desc_tri() const
0673 {
0674     std::cout << st->desc_tri() << "\n" ;
0675     return 0 ;
0676 }
0677 inline int stree_load_test::desc_NRT() const
0678 {
0679     std::cout << st->desc_NRT() << "\n" ;
0680     return 0 ;
0681 }
0682 
0683 inline int stree_load_test::desc_node_ELVID() const
0684 {
0685     std::cout << st->desc_node_ELVID() << "\n" ;
0686     return 0 ;
0687 }
0688 
0689 inline int stree_load_test::desc_node_ECOPYNO() const
0690 {
0691     std::cout << st->desc_node_ECOPYNO() << "\n" ;
0692     return 0 ;
0693 }
0694 inline int stree_load_test::desc_node_EBOUNDARY() const
0695 {
0696     std::cout << st->desc_node_EBOUNDARY() << "\n" ;
0697     return 0 ;
0698 }
0699 
0700 
0701 
0702 
0703 inline int stree_load_test::desc_node_solids() const
0704 {
0705     std::cout << st->desc_node_solids() ;
0706     return 0 ;
0707 }
0708 
0709 /**
0710 stree_load_test::desc_solids
0711 -----------------------------
0712 
0713 solids vector not persisted
0714 **/
0715 
0716 inline int stree_load_test::desc_solids() const
0717 {
0718     std::cout << st->desc_solids() ;
0719     return 0 ;
0720 }
0721 inline int stree_load_test::desc_solid(int lvid) const
0722 {
0723     std::cout << st->desc_solid(lvid) ;
0724 
0725     std::vector<int> nodes ;
0726     char src = 'N' ;
0727     st->find_lvid_nodes(nodes, lvid, src );
0728 
0729     std::cout
0730         << "st.find_lvid_nodes (structural nodes) "
0731         << " lvid " << lvid
0732         << " src " << src
0733         << " nodes.size " << nodes.size()
0734         << "\n"
0735         ;
0736 
0737     for(size_t i=0 ; i < nodes.size() ; i++ )
0738     {
0739         int nidx = nodes[i];
0740         std::cout << " nidx " << nidx << "\n" ;
0741 
0742         const glm::tmat4x4<double>& m2w = st->m2w[nidx] ;
0743         std::cout << "m2w\n" << stra<double>::Desc(m2w) << "\n" ;
0744 
0745         const glm::tmat4x4<double>& gtd = st->gtd[nidx] ;
0746         std::cout << "gtd\n" << stra<double>::Desc(m2w) << "\n" ;
0747     }
0748 
0749 
0750 
0751 
0752     std::vector<sn*> nds ;    // CSG constituent nodes of the LV
0753     sn::GetLVNodes(nds, lvid );
0754     int num_nds = nds.size();
0755     std::cout
0756         << " sn::Desc(nds) (csg nodes) lvid " << lvid << " num_nds " << num_nds
0757         << "\n"
0758         << sn::Desc(nds)
0759         << "\n"
0760         << " sn::DescXform(nds) (csg nodes) lvid " << lvid << " num_nds " << num_nds
0761         << sn::DescXform(nds)
0762         << "\n"
0763         << " sn::DescXformFull(nds) (csg nodes) lvid " << lvid << " num_nds " << num_nds
0764         << sn::DescXformFull(nds)
0765         << "\n"
0766         ;
0767 
0768     return 0 ;
0769 }
0770 inline int stree_load_test::desc() const
0771 {
0772     std::cout << st->desc() << "\n" ;
0773     return 0 ;
0774 }
0775 inline int stree_load_test::save_desc(const char* fold) const
0776 {
0777     std::cout
0778         << "stree_load_test::save_desc"
0779         << " fold " << ( fold ? fold : "-" )
0780         << "\n"
0781         ;
0782     if(fold==nullptr) return 0;
0783 
0784     st->save_desc(fold);
0785     return 0 ;
0786 }
0787 inline int stree_load_test::make_tree_digest() const
0788 {
0789     const char* tree_digest = st->get_tree_digest();
0790 
0791     std::vector<unsigned char> extra ;
0792     std::string dynamic_0 = st->make_tree_digest(extra);
0793 
0794     uint32_t value = 0xdeadbeef ;
0795     SBitSet* bs0 = SBitSet::Create<uint32_t>( value );
0796     bs0->serialize(extra);
0797 
0798     std::string dynamic_1 = st->make_tree_digest(extra);
0799 
0800     std::cout
0801         << "stree_load_test::make_tree_digest"
0802         << "\n"
0803         << " tree_digest " << ( tree_digest ? tree_digest : "-" )
0804         << "\n"
0805         << " dynamic_0   " << dynamic_0
0806         << "\n"
0807         << " dynamic_1   " << dynamic_1
0808         << "\n"
0809         ;
0810 
0811     return 0 ;
0812 }
0813 
0814 inline int stree_load_test::desc_nodes_with_center_within_ce() const
0815 {
0816      std::vector<double>* ce = ssys::getenv_vec<double>("CE", "-6000,0,20000,1000");
0817      assert(ce);
0818      std::cout << st->desc_nodes_with_center_within_ce( ce->data() );
0819      return 0 ;
0820 }
0821 
0822 
0823 inline int stree_load_test::desc_prim() const
0824 {
0825      std::cout << st->desc_prim();
0826      return 0 ;
0827 }
0828 
0829 
0830 
0831 
0832 inline int stree_load_test::main()
0833 {
0834     const char* TMPFOLD = ssys::getenvvar("TMPFOLD", nullptr);
0835 
0836     int LVID = ssys::getenvint("LVID",  0);
0837     int NDID = ssys::getenvint("NDID",  0);
0838     int IIDX = ssys::getenvint("IIDX",  0);
0839     int FIDX = ssys::getenvint("FIDX",  0);
0840     int RIDX = ssys::getenvint("RIDX",  0);
0841     int RORD = ssys::getenvint("RORD",  0);
0842 
0843     int rc = 0 ;
0844     bool ALL = strcmp(TEST, "ALL") == 0 ;
0845 
0846     if(ALL||strcmp(TEST, "get_combined_transform")==0)   rc += get_combined_transform(LVID, NDID );
0847     if(ALL||strcmp(TEST, "get_inst") == 0)               rc += get_inst(IIDX) ;
0848     if(ALL||strcmp(TEST, "get_frame_f4") == 0)           rc += get_frame_f4(IIDX);
0849     if(ALL||strcmp(TEST, "pick_lvid_ordinal_node") == 0) rc += pick_lvid_ordinal_node();
0850     if(ALL||strcmp(TEST, "find_inst_gas") == 0)          rc += find_inst_gas();
0851     if(ALL||strcmp(TEST, "pick_lvid_ordinal_repeat_ordinal_inst_") == 0) rc += pick_lvid_ordinal_repeat_ordinal_inst_();
0852     if(ALL||strcmp(TEST, "pick_lvid_ordinal_repeat_ordinal_inst") == 0)  rc += pick_lvid_ordinal_repeat_ordinal_inst();
0853     if(ALL||strcmp(TEST, "get_frame") == 0)                              rc += get_frame();
0854     if(ALL||strcmp(TEST, "get_frame_MOI") == 0)                          rc += get_frame_MOI();
0855     if(ALL||strcmp(TEST, "get_frame_scan") == 0)                         rc += get_frame_scan();
0856     if(ALL||strcmp(TEST, "get_prim_aabb") == 0)                          rc += get_prim_aabb();
0857 
0858     if(ALL||strcmp(TEST, "get_global_aabb") == 0)                        rc += get_global_aabb();
0859     if(ALL||strcmp(TEST, "get_global_aabb_check") == 0)                  rc += get_global_aabb_check();
0860     if(ALL||strcmp(TEST, "get_global_aabb_sibling_overlaps") == 0)       rc += get_global_aabb_sibling_overlaps();
0861 
0862     if(ALL||strcmp(TEST, "desc_repeat_index") == 0)                      rc += desc_repeat_index();
0863     if(ALL||strcmp(TEST, "desc_factor_nodes") == 0)                      rc += desc_factor_nodes(FIDX);
0864     if(ALL||strcmp(TEST, "desc_repeat_node") == 0)                       rc += desc_repeat_node(RIDX, RORD);
0865     if(ALL||strcmp(TEST, "desc_repeat_nodes") == 0)                      rc += desc_repeat_nodes();
0866     if(ALL||strcmp(TEST, "desc_nds") == 0)                               rc += desc_nds();
0867     if(ALL||strcmp(TEST, "desc_rem") == 0)                               rc += desc_rem();
0868     if(ALL||strcmp(TEST, "desc_tri") == 0)                               rc += desc_tri();
0869     if(ALL||strcmp(TEST, "desc_NRT") == 0)                               rc += desc_NRT();
0870     if(ALL||strcmp(TEST, "desc_node_ELVID") == 0)                        rc += desc_node_ELVID();
0871     if(ALL||strcmp(TEST, "desc_node_ECOPYNO") == 0)                      rc += desc_node_ECOPYNO();
0872     if(ALL||strcmp(TEST, "desc_node_EBOUNDARY") == 0)                    rc += desc_node_EBOUNDARY();
0873     if(ALL||strcmp(TEST, "desc_node_solids") == 0)                       rc += desc_node_solids() ;
0874     if(ALL||strcmp(TEST, "desc_solids") == 0)                            rc += desc_solids() ;
0875     if(ALL||strcmp(TEST, "desc_solid") == 0)                             rc += desc_solid(LVID) ;
0876     if(ALL||strcmp(TEST, "desc") == 0)                                   rc += desc();
0877     if(ALL||strcmp(TEST, "save_desc") == 0)                              rc += save_desc(TMPFOLD);
0878     if(ALL||strcmp(TEST, "make_tree_digest") == 0)                       rc += make_tree_digest();
0879     if(ALL||strcmp(TEST, "desc_nodes_with_center_within_ce") == 0)       rc += desc_nodes_with_center_within_ce();
0880     if(ALL||strcmp(TEST, "desc_prim") == 0)                              rc += desc_prim();
0881 
0882     return rc ;
0883 }
0884 
0885 
0886 int main(int argc, char** argv)
0887 {
0888     stree_load_test t;
0889     return t.main();
0890 }
0891 
0892 /**
0893     TEST=desc_solid LVID=43 ~/o/sysrap/tests/stree_load_test.sh  run
0894     TEST=desc_solid LVID=124 ~/o/sysrap/tests/stree_load_test.sh  run
0895     TEST=desc_solid LVID=32 ~/o/sysrap/tests/stree_load_test.sh
0896 
0897 
0898     TEST=desc_node_ELVID ELVID=43,44,45,46 ~/o/sysrap/tests/stree_load_test.sh
0899     TEST=desc_node_ECOPYNO ECOPYNO=52400   ~/o/sysrap/tests/stree_load_test.sh
0900     TEST=desc_node_EBOUNDARY EBOUNDARY=303   ~/o/sysrap/tests/stree_load_test.sh
0901 **/
0902