Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:53

0001 /**
0002 CSGTargetGlobalTest
0003 =====================
0004 
0005 MOI=solidXJfixture:64 CSGTargetGlobalTest
0006 
0007 **/
0008 #include <csignal>
0009 
0010 #include "NP.hh"
0011 #include "SPath.hh"
0012 #include "SSys.hh"
0013 #include "SSim.hh"
0014 #include "SStr.hh"
0015 #include "OPTICKS_LOG.hh"
0016 
0017 #include "scuda.h"
0018 #include "sqat4.h"
0019 #include "CSGFoundry.h"
0020 
0021 
0022 int main(int argc, char** argv)
0023 {
0024     OPTICKS_LOG(argc, argv); 
0025 
0026     SSim::Create(); 
0027     CSGFoundry* fd = CSGFoundry::Load(); 
0028     LOG(info) << "foundry " << fd->desc() ; 
0029     //fd->summary(); 
0030 
0031 
0032     qat4 q0 ; 
0033     q0.zero(); 
0034 
0035     qat4 q1 ; 
0036     q1.zero(); 
0037 
0038     float4 ce = make_float4( 0.f, 0.f, 0.f, 1000.f ); 
0039 
0040     const char* moi = SSys::getenvvar("MOI", "solidXJfixture:64"); 
0041 
0042     int midx, max_mord, iidx ; 
0043     fd->parseMOI(midx, max_mord, iidx,  moi );  
0044 
0045     // TODO: provide discovery interface that returns max mordinal for a midx 
0046     //       and also provides the midx range too  
0047 
0048 
0049     const char* name = midx > -1 ? fd->getName(midx) : nullptr ; 
0050 
0051     NP* ces = NP::Make<float>(max_mord, 4 ); 
0052     float* ces_data = ces->values<float>() ;   
0053 
0054     std::cout 
0055         << " moi " << std::setw(15) << moi
0056         << " midx " << std::setw(5) << midx 
0057         << " max_mord " << std::setw(5) << max_mord 
0058         << " iidx " << std::setw(6) << iidx
0059         << " name " << std::setw(10) << ( name ? name : "-" ) 
0060         << std::endl 
0061         ;
0062 
0063     assert( iidx == 0 ); 
0064 
0065     for(int mord=0 ; mord < max_mord ; mord++ )
0066     {
0067         fd->getCenterExtent(ce, midx, mord, iidx, &q0 );  
0068         fd->getTransform(q1, midx, mord, iidx ); 
0069         bool q_match = qat4::compare(q0, q1, 0.f) == 0 ; 
0070 
0071         ces_data[mord*4 + 0] = ce.x ; 
0072         ces_data[mord*4 + 1] = ce.y ; 
0073         ces_data[mord*4 + 2] = ce.z ; 
0074         ces_data[mord*4 + 3] = ce.w ;   
0075 
0076         std::cout 
0077             << " mord " << std::setw(6) << mord
0078             << " ce " <<  ce 
0079             << std::endl 
0080             ;
0081 
0082         assert( q_match ); 
0083         if(!q_match) std::raise(SIGINT); 
0084     }
0085 
0086     const char* base = "$TMP/CSGTargetGlobalTest" ; 
0087     int create_dirs = 1 ; // 1:filepath 
0088     const char* path = SPath::Resolve(base, moi, "ce.npy", create_dirs ); 
0089     LOG(info) << "writing " << path ; 
0090     ces->save(path); 
0091 
0092     return 0 ; 
0093 }
0094 
0095 
0096