File indexing completed on 2026-04-09 07:49:41
0001 #include "SArgs.hh"
0002 #include "s_time.h"
0003
0004 #include "SStr.hh"
0005 #include "sproc.h"
0006 #include "SOpticks.hh"
0007 #include "SEventConfig.hh"
0008
0009 #include "SLOG.hh"
0010
0011 const plog::Severity SOpticks::LEVEL = SLOG::EnvLevel("SOpticks", "DEBUG");
0012
0013
0014 SOpticks::SOpticks(int argc, char** argv, const char* argforced)
0015 :
0016 m_sargs(new SArgs(argc, argv, argforced, nullptr))
0017 {
0018 }
0019
0020 bool SOpticks::hasArg(const char* arg) const
0021 {
0022 return m_sargs->hasArg(arg);
0023 }
0024
0025 bool SOpticks::isEnabledMergedMesh(unsigned ridx)
0026 {
0027 return true ;
0028 }
0029
0030 std::vector<unsigned>& SOpticks::getSolidSelection()
0031 {
0032 return m_solid_selection ;
0033 }
0034
0035 const std::vector<unsigned>& SOpticks::getSolidSelection() const
0036 {
0037 return m_solid_selection ;
0038 }
0039
0040 int SOpticks::getRaygenMode() const
0041 {
0042 return 0 ;
0043 }
0044
0045
0046
0047 Composition* SOpticks::getComposition() const
0048 {
0049 return nullptr ;
0050 }
0051 const char* SOpticks::getOutDir() const
0052 {
0053 return nullptr ;
0054 }
0055
0056
0057 const char* SOpticks::CFBaseScriptPath()
0058 {
0059 std::stringstream ss ;
0060 ss << "/tmp/CFBASE.sh" ;
0061 std::string s = ss.str();
0062 return strdup(s.c_str());
0063 }
0064
0065 std::string SOpticks::CFBaseScriptString(const char* cfbase, const char* msg )
0066 {
0067 std::stringstream ss ;
0068 ss
0069 << "# " << msg
0070 << std::endl
0071 << "# " << s_time::Stamp()
0072 << std::endl
0073 << "export CFBASE=" << cfbase
0074 << std::endl
0075 << "cfcd(){ cd " << cfbase << "/CSGFoundry ; pwd ; } "
0076 << std::endl
0077 << "# "
0078 << std::endl
0079 ;
0080
0081 std::string s = ss.str();
0082 return s ;
0083 }
0084
0085
0086 void SOpticks::WriteCFBaseScript(const char* cfbase, const char* msg)
0087 {
0088 const char* sh_path = CFBaseScriptPath() ;
0089 std::string sh = CFBaseScriptString(cfbase, msg);
0090
0091 LOG(info)
0092 << "writing sh_path " << sh_path << std::endl
0093 << "sh [" << std::endl
0094 << sh
0095 << "]"
0096 ;
0097
0098 SStr::Save(sh_path, sh.c_str()) ;
0099 }
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115 void SOpticks::WriteOutputDirScript()
0116 {
0117 const char* outfold = SEventConfig::OutFold();
0118 WriteOutputDirScript(outfold);
0119 }
0120
0121 void SOpticks::WriteOutputDirScript(const char* outdir)
0122 {
0123 const char* exename = sproc::ExecutableName() ;
0124 const char* envvar = SStr::Concat(exename, "_OUTPUT_DIR" );
0125 const char* sh_path = SStr::Concat(exename, "_OUTPUT_DIR" , ".sh") ;
0126
0127 std::stringstream ss ;
0128 ss
0129 << "# SOpticks::WriteOutputDirScript " << std::endl
0130 << "# " << s_time::Stamp() << std::endl
0131 << std::endl
0132 << "export " << envvar << "=" << outdir
0133 << std::endl
0134 ;
0135
0136 std::string sh = ss.str();
0137
0138 LOG(LEVEL)
0139 << " outdir " << outdir
0140 << "writing sh_path " << sh_path << std::endl
0141 << "sh [" << std::endl
0142 << sh
0143 << "]"
0144 ;
0145
0146 SStr::Save(sh_path, sh.c_str()) ;
0147 }
0148
0149
0150
0151
0152