Back to home page

EIC code displayed by LXR

 
 

    


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

0001 
0002 #include "NP.hh"
0003 #include "SPath.hh"
0004 #include "OPTICKS_LOG.hh"
0005 
0006 #include "QTex.hh"
0007 #include "QTexMaker.hh"
0008 #include "QTexLookup.hh"
0009 
0010 const char* FOLD = "$TMP/QTexLookupTest" ; 
0011 
0012 NP* make_array(unsigned ni, unsigned nj, unsigned nk)
0013 {
0014     std::vector<float> src ; 
0015     for(unsigned i=0 ; i < ni ; i++)
0016     for(unsigned j=0 ; j < nj ; j++)
0017     for(unsigned k=0 ; k < nk ; k++)
0018     {
0019         float val = float(i*100 + j*10 + k) ;  
0020         src.push_back(val); 
0021     }
0022 
0023     NP* a = NP::Make<float>( ni, nj, nk ); 
0024     a->read(src.data()) ; 
0025     a->set_meta<unsigned>("hd_factor", 10); 
0026 
0027     return a ; 
0028 }
0029 
0030 int main(int argc, char** argv)
0031 {
0032     OPTICKS_LOG(argc, argv); 
0033 
0034     const NP* origin = make_array( 5, 10, 4 ); 
0035     char filterMode = 'P' ; 
0036     unsigned hd_factor = origin->get_meta<unsigned>("hd_factor"); 
0037     assert( hd_factor > 0 ); 
0038     bool normalizedCoords = false ; 
0039 
0040     QTex<float4>* tex = QTexMaker::Make2d_f4(origin, filterMode, normalizedCoords ); 
0041     assert(tex); 
0042 
0043     tex->setHDFactor(hd_factor); 
0044     tex->uploadMeta(); 
0045 
0046     QTexLookup<float4> look(tex); 
0047     NP* out = look.lookup(); 
0048 
0049     int create_dirs = 2 ; // 2:dirpath
0050     const char* fold = SPath::Resolve(FOLD, create_dirs); 
0051 
0052     out->save(fold, "lookup.npy"); 
0053     origin->save(fold, "origin.npy"); 
0054 
0055     return 0 ; 
0056 }
0057 
0058 
0059