Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /**
0002 CSGMakerTest.cc
0003 =================
0004 
0005 HMM: this was stomping on standard GEOM folder  
0006 USING MakeGeom/LoadGeom needs to effectively change GEOM to the name argument
0007 and standard corresponding folder 
0008 
0009 NOPE : THIS IS DOING SOMETHING NON-STANDARD
0010 SO SHOULD DO THINGS IN NON-STANDARD MANUAL WAY 
0011 
0012 **/
0013 
0014 #include <csignal>
0015 #include "ssys.h"
0016 #include "spath.h"
0017 #include "SSim.hh"
0018 #include "CSGFoundry.h"
0019 #include "CSGMaker.h"
0020 #include "OPTICKS_LOG.hh"
0021 
0022 /**
0023 GetNames
0024 ---------
0025 
0026 Populate the names vector with all CSGMaker names or just the 
0027 one provided when envvar CSGMakerTest_GEOM is defined. 
0028 For listnames:true dump the names to stdout. 
0029 
0030 **/
0031 
0032 void GetNames( std::vector<std::string>& names, bool listnames )
0033 {
0034      const char* geom = ssys::getenvvar("CSGMakerTest_GEOM", nullptr ); 
0035      // NB ExecutableName_GEOM is treated as GEOM override 
0036 
0037      if( geom == nullptr ) 
0038      {
0039          CSGMaker::GetNames(names); 
0040      }
0041      else
0042      { 
0043          names.push_back(geom); 
0044      }
0045      LOG(info) << " names.size " << names.size() ; 
0046      if(listnames) for(unsigned i=0 ; i < names.size() ; i++) std::cout << names[i] << std::endl ; 
0047 }
0048 
0049 int main(int argc, char** argv)
0050 {
0051      const char* arg =  argc > 1 ? argv[1] : nullptr ; 
0052      bool listnames = arg && ( strcmp(arg,"N") == 0 || strcmp(arg,"n") == 0 ) ; 
0053      OPTICKS_LOG(argc, argv); 
0054 
0055      SSim* sim = SSim::Create(); 
0056      assert(sim); 
0057      if(!sim) std::raise(SIGINT); 
0058 
0059      std::vector<std::string> names ; 
0060      GetNames(names, listnames); 
0061      if(listnames) return 0 ; 
0062 
0063      for(unsigned i=0 ; i < names.size() ; i++)
0064      {
0065          const char* name = names[i].c_str() ; 
0066          LOG(info) << name ; 
0067 
0068          CSGFoundry* fd = CSGMaker::MakeGeom( name ); 
0069          LOG(info) << fd->desc();    
0070 
0071          const char* base = spath::Join("$TMP/CSGMakerTest",name) ; 
0072 
0073          fd->save(base);  
0074 
0075          CSGFoundry* lfd = CSGFoundry::Load(base); 
0076 
0077 
0078          LOG(info) << " lfd.loaddir " << lfd->loaddir ; 
0079 
0080          int rc = CSGFoundry::Compare(fd, lfd );  
0081          assert( 0 == rc );
0082          if(0!=rc) std::raise(SIGINT); 
0083      }
0084 
0085      return 0 ; 
0086 }