File indexing completed on 2026-04-09 07:49:01
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #include "ssys.h"
0026 #include "SEvt.hh"
0027 #include "CSGFoundry.h"
0028 #include "CSGOptiX.h"
0029 #include "NP.hh"
0030
0031 struct CSGOptiXService
0032 {
0033 static CSGOptiXService* INSTANCE ;
0034 static CSGOptiXService* Get();
0035 static NP* Simulate(NP* gs, int eventID );
0036
0037 int level ;
0038 SEvt* evt ;
0039 CSGFoundry* fd ;
0040 CSGOptiX* cx ;
0041
0042 CSGOptiXService();
0043 NP* simulate(NP* gs, int eventID );
0044 std::string desc() const ;
0045 };
0046
0047
0048 CSGOptiXService* CSGOptiXService::INSTANCE = nullptr ;
0049
0050 CSGOptiXService* CSGOptiXService::Get()
0051 {
0052 if(!INSTANCE) new CSGOptiXService ;
0053 assert(INSTANCE);
0054 return INSTANCE ;
0055 }
0056
0057 NP* CSGOptiXService::Simulate( NP* gs, int eventID )
0058 {
0059 CSGOptiXService* svc = Get();
0060 return svc->simulate(gs, eventID );
0061 }
0062
0063
0064 inline CSGOptiXService::CSGOptiXService()
0065 :
0066 level(ssys::getenvint("CSGOptiXService_level",0)),
0067 evt(SEvt::Create(SEvt::EGPU)),
0068 fd(CSGFoundry::Load()),
0069 cx(CSGOptiX::Create(fd))
0070 {
0071 INSTANCE = this ;
0072 std::cout << desc() ;
0073 }
0074
0075
0076 inline NP* CSGOptiXService::simulate( NP* gs, int eventID )
0077 {
0078 if(level > 0) std::cout << "[CSGOptiXService::simulate gs " << ( gs ? gs->sstr() : "-" ) << "\n" ;
0079
0080 NP* ht = cx->simulate(gs, eventID );
0081
0082 if(level > 0) std::cout << "]CSGOptiXService::simulate ht " << ( ht ? ht->sstr() : "-" ) << "\n" ;
0083 return ht ;
0084 }
0085
0086 inline std::string CSGOptiXService::desc() const
0087 {
0088 std::stringstream ss ;
0089 ss << "-CSGOptiXService::desc"
0090 << " evt " << ( evt ? "YES" : "NO " )
0091 << " fd " << ( fd ? "YES" : "NO " )
0092 << " cx " << ( cx ? "YES" : "NO " )
0093 << "\n"
0094 ;
0095
0096 std::string str = ss.str() ;
0097 return str ;
0098 }
0099
0100