File indexing completed on 2026-04-10 07:49:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include <algorithm>
0031 #include <iterator>
0032 #include <cstdlib>
0033 #include <csignal>
0034
0035 #include "ssys.h"
0036
0037 #include "SSim.hh"
0038 #include "SOpticks.hh"
0039 #include "SEventConfig.hh"
0040 #include "SBitSet.h"
0041 #include "SGeoConfig.hh"
0042
0043 #include "OPTICKS_LOG.hh"
0044 #include "scuda.h"
0045 #include "sqat4.h"
0046
0047 #include "SGLM.h"
0048 #include "CSGFoundry.h"
0049 #include "CSGCopy.h"
0050 #include "CSGOptiX.h"
0051
0052
0053 const plog::Severity LEVEL = debug ;
0054
0055
0056 struct CSGOptiXRenderTest
0057 {
0058 CSGOptiXRenderTest() ;
0059
0060 const char* solid_selection ;
0061
0062 CSGFoundry* fd ;
0063 CSGOptiX* cx ;
0064
0065 const char* flight ;
0066 float4 ce ;
0067
0068 const char* default_arg ;
0069 std::vector<std::string> args ;
0070
0071 void initSolidSelection();
0072 void initArgs();
0073
0074 void setFrame_solid_selection();
0075
0076 };
0077
0078
0079 CSGOptiXRenderTest::CSGOptiXRenderTest()
0080 :
0081 solid_selection(SGeoConfig::SolidSelection()),
0082 fd(CSGFoundry::Load()),
0083 cx(CSGOptiX::Create(fd)),
0084 flight(SGeoConfig::FlightConfig()),
0085 ce(make_float4(0.f, 0.f, 0.f, 1000.f )),
0086 default_arg(ssys::getenvvar("MOI", "sWorld:0:0"))
0087 {
0088 initSolidSelection();
0089 initArgs();
0090 }
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 void CSGOptiXRenderTest::initSolidSelection()
0102 {
0103 if( solid_selection == nullptr ) return ;
0104
0105 fd->findSolidIdx(cx->solid_selection, solid_selection);
0106 std::string solsel = fd->descSolidIdx(cx->solid_selection);
0107 LOG(error)
0108 << " solid_selection " << solid_selection
0109 << " cx.solid_selection.size " << cx->solid_selection.size()
0110 << " solsel " << solsel
0111 ;
0112
0113 }
0114
0115 void CSGOptiXRenderTest::initArgs()
0116 {
0117 unsigned num_select = cx->solid_selection.size();
0118 if( solid_selection )
0119 {
0120 bool num_select_expect = num_select > 0 ;
0121 assert( num_select_expect );
0122 if(!num_select_expect) std::raise(SIGINT);
0123 }
0124
0125 std::vector<std::string>* arglist = SGeoConfig::Arglist() ;
0126
0127 if( arglist && arglist->size() > 0 )
0128 {
0129 std::copy(arglist->begin(), arglist->end(), std::back_inserter(args));
0130 LOG(LEVEL) << " using arglist from SGeoConfig::Arglist " ;
0131 }
0132 else
0133 {
0134 args.push_back(default_arg);
0135
0136 }
0137 }
0138
0139 void CSGOptiXRenderTest::setFrame_solid_selection()
0140 {
0141 assert( solid_selection );
0142 fd->gasCE(ce, cx->solid_selection );
0143
0144 LOG(LEVEL)
0145 << " solid_selection " << solid_selection
0146 << " cx.solid_selection.size " << cx->solid_selection.size()
0147 << " ce (" << ce.x << " " << ce.y << " " << ce.z << " " << ce.w << ") "
0148 ;
0149
0150 cx->setFrame(ce);
0151 }
0152
0153
0154
0155 int main(int argc, char** argv)
0156 {
0157 OPTICKS_LOG(argc, argv);
0158
0159 SEventConfig::SetRGModeRender();
0160
0161 SSim::Create();
0162
0163 CSGOptiXRenderTest t;
0164
0165 if( t.solid_selection )
0166 {
0167 const char* arg = ssys::getenvvar("NAMESTEM", "") ;
0168 LOG(LEVEL) << " t.solid_selection " << t.solid_selection << " arg " << arg ;
0169 t.setFrame_solid_selection();
0170 t.cx->render();
0171 }
0172 else if( t.flight )
0173 {
0174 const char* arg = t.args[0].c_str();
0175 LOG(LEVEL) << " t.flight arg " << arg ;
0176 t.cx->setFrame(arg);
0177 t.cx->render_flightpath();
0178 }
0179 else
0180 {
0181
0182 for(unsigned i=0 ; i < t.args.size() ; i++)
0183 {
0184 const char* arg = t.args[i].c_str();
0185
0186 t.cx->setFrame(arg);
0187 t.cx->render();
0188 }
0189 }
0190 return 0 ;
0191 }
0192