File indexing completed on 2026-04-09 07:49:00
0001 #pragma once
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <vector>
0011 #include <string>
0012 #include <glm/fwd.hpp>
0013
0014 #include <optix.h>
0015
0016 #include "plog/Severity.h"
0017 #include "sfr.h"
0018
0019 #include "CSGOPTIX_API_EXPORT.hh"
0020
0021 struct SMeta ;
0022 struct NP ;
0023 struct quad4 ;
0024 struct quad6 ;
0025 struct qat4 ;
0026 struct float4 ;
0027 struct uchar4 ;
0028
0029 struct scontext ;
0030 struct SGLM ;
0031 struct SSim ;
0032
0033 struct CSGFoundry ;
0034 struct CSGView ;
0035
0036 template <typename T> struct Tran ;
0037 struct QSim ;
0038 struct QEvt ;
0039
0040 struct Params ;
0041 class Opticks ;
0042 class Composition ;
0043
0044 #if OPTIX_VERSION < 70000
0045 struct Six ;
0046 struct Dummy ;
0047 #else
0048 struct Ctx ;
0049 struct PIP ;
0050 struct SBT ;
0051 #endif
0052 struct Frame ;
0053
0054
0055
0056
0057 #include "SSimulator.h"
0058
0059 struct CSGOPTIX_API CSGOptiX : public SSimulator
0060 {
0061 friend struct QSim ;
0062
0063 static constexpr const char* RELDIR = "CSGOptiX" ;
0064 static const plog::Severity LEVEL ;
0065 static CSGOptiX* INSTANCE ;
0066 static CSGOptiX* Get();
0067 static int Version();
0068
0069 static int RenderMain();
0070 static int SimtraceMain();
0071 static int SimulateMain();
0072
0073
0074 static const char* Desc();
0075
0076 SGLM* sglm ;
0077
0078 const char* flight ;
0079 const CSGFoundry* foundry ;
0080 const char* outdir ;
0081 const char* _optixpath ;
0082 const char* optixpath ;
0083 float tmin_model ;
0084 plog::Severity level = plog::debug ;
0085
0086 std::vector<unsigned> solid_selection ;
0087 std::vector<double> kernel_times ;
0088 std::vector<int64_t> kernel_times_ ;
0089 int kernel_count ;
0090
0091 int raygenmode ;
0092 Params* params ;
0093
0094
0095 #if OPTIX_VERSION < 70000
0096 Six* six ;
0097 Dummy* dummy0 ;
0098 Dummy* dummy1 ;
0099 #else
0100 Ctx* ctx ;
0101 PIP* pip ;
0102 SBT* sbt ;
0103 #endif
0104
0105 Frame* framebuf ;
0106 SMeta* meta ;
0107 double kernel_dt ;
0108
0109 scontext* sctx ;
0110 QSim* sim ;
0111 QEvt* qev ;
0112
0113 const char* desc() const ;
0114
0115 private:
0116 static Params* InitParams( int raygenmode, const SGLM* sglm ) ;
0117 static void InitEvt( CSGFoundry* fd );
0118 static void InitMeta();
0119 static void InitSim( SSim* ssim );
0120 static void InitGeo( CSGFoundry* fd );
0121
0122 public:
0123 static CSGOptiX* Create(CSGFoundry* foundry );
0124
0125
0126 virtual ~CSGOptiX();
0127 CSGOptiX(const CSGFoundry* foundry );
0128
0129 private:
0130 void init();
0131 void initMeta();
0132 void initCtx();
0133 void initPIP();
0134 void initSBT();
0135 void initCheckSim();
0136 void initStack();
0137 void initParams();
0138 void initGeometry();
0139 void initSimulate();
0140 #ifdef WITH_OLD_FRAME
0141 void initFrame();
0142 #endif
0143 void initRender();
0144 void initPIDXYZ();
0145 public:
0146 void setExternalDevicePixels(uchar4* _d_pixel );
0147 void destroy();
0148 public:
0149
0150 void setFrame();
0151 void setFrame(const char* moi);
0152 void setFrame(const float4& ce);
0153 void setFrame(const sfr& fr_);
0154
0155
0156 static constexpr const char* _prepareParamRender_DEBUG = "CSGOptiX__prepareParamRender_DEBUG" ;
0157 void prepareParamRender();
0158 void prepareParamSimulate();
0159 void prepareParam();
0160
0161 private:
0162 double launch();
0163 private:
0164 const char* getRenderStemDefault() const ;
0165 public:
0166
0167 bool handle_snap(int wanted_snap);
0168
0169 double render(const char* stem_=nullptr);
0170 void render_save(const char* stem_=nullptr);
0171 void render_save_inverted(const char* stem_=nullptr);
0172 void render_save_(const char* stem_=nullptr, bool inverted=false);
0173
0174 double simtrace(int eventID);
0175 double simulate(int eventID, bool reset);
0176 void reset(int eventID);
0177
0178 NP* simulate(const NP* gs, int eventID);
0179
0180
0181
0182
0183
0184 public:
0185 double render_launch();
0186 private:
0187 double simtrace_launch();
0188 double simulate_launch();
0189
0190 public:
0191 const CSGFoundry* getFoundry() const ;
0192 static std::string AnnotationTime( double dt, const char* extra=nullptr );
0193 static std::string Annotation( double dt, const char* bot_line, const char* extra=nullptr );
0194 const char* getDefaultSnapPath() const ;
0195
0196 void snap(const char* path, const char* bottom_line, const char* top_line, unsigned line_height, bool inverted );
0197
0198
0199 #ifdef WITH_FRAME_PHOTON
0200 void writeFramePhoton(const char* dir, const char* name);
0201 #endif
0202 int render_flightpath();
0203
0204 void saveMeta(const char* jpg_path) const ;
0205
0206 static constexpr const char* CTX_LOGNAME = "CSGOptiX__Ctx.log" ;
0207 void write_Ctx_log(const char* dir=nullptr) const ;
0208
0209 static int _OPTIX_VERSION() ;
0210 };
0211