int main(int ac, char **av) { bool debug = false; std::string conf = "config.xml"; apimeal::Error err; Logger *log; for (int i = 1;i < ac;i++) { std::string tmp(av[i]); if (tmp == "-d" || tmp == "--debug") debug = true; else if (tmp == "-h" || tmp == "--help") { std::cout << "Usage: ./zia [configuration_file] [OPTS]" << std::endl; std::cout << " -d/--debug : debug mode, print all the log message" << std::endl; return (0); } else conf.assign(av[i]); } SSL_load_error_strings(); SSL_library_init(); OpenSSL_add_all_algorithms(); ConfParser *parser = ConfParser::getInstance(); parser->setFile(conf); parser->initialize(err); log = Logger::getInstance(parser->getLoggerFormat(), debug, parser->getLoggerFile()); check_error(err, log); Server server(log, parser); check_error(err, log); server.listenServer(); log->kill(); return (0); }
int main( int argc, char** argv ) { if ( argc < 2 ) { cerr << "Usage: " << argv[0] << " <config_file> [<config_file> ...]" << endl; return -1; } ConfParser p; for ( int i = 1; i < argc; ++i ) { try { ConfBlock& b = p.parse( argv[i] ); b.writeConfigFile( string( argv[i] ) + ".out" ); } catch ( std::exception& e ) { cerr << e.what() << endl; } } return 0; }
void CoronaRenderer::render() { std::string oslShaderPath = (getRendererHome() + "shaders").asChar(); logger.debug(MString("setting osl shader search path to: ") + oslShaderPath.c_str()); this->oslRenderer.setShaderSearchPath(oslShaderPath); this->oslRenderer.setup(); //doit(); //return; logger.debug(MString("Starting corona rendering...")); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// INIT SHADING CORE + SCEME ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Context context; context.core = ICore::createInstance(); context.scene = context.core->createScene(); context.logger = new mtco_Logger(context.core); logger.debug(MString("core/scene/logger...")); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// SETTINGS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// context.settings = new MySettings(); // populate the settings with parameters from a configuration file. If the file does not exist, a new one // is created with default values. ConfParser parser; Corona::String resPath = (getRendererHome() + "ressources/").asChar(); logger.debug(MString("parser: ") + (resPath + CORONA_DEFAULT_CONF_FILENAME).cStr()); parser.parseFile(resPath + CORONA_DEFAULT_CONF_FILENAME, context.settings, ConfParser::CREATE_IF_NONEXISTENT); logger.debug(MString("defineSettings...")); this->clearMaterialLists(); this->defineSettings(); logger.debug(MString("definePasses...")); this->definePasses(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// INTERNAL FRAME BUFFER ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // create a new framebuffer, and init it before the rendering logger.debug(MString("createFb...")); context.fb = context.core->createFb(); //colorMappingData = context.settings->getColorMapping(); //this->context.fb->setColorMapping(colorMappingData); // the settings and render passes need to contain final parameters of the rendering at the time of the call logger.debug(MString("initFb...")); context.fb->initFb(context.settings, context.renderPasses); //Corona::ColorMappingData cmData; //cmData.gamma = 1.0f; //context.fb->setColorMapping(cmData); logger.debug(MString("createScene...")); createScene(); logger.debug(MString("createScene done...")); // test that the now ready scene and settings do not have any errors logger.debug(MString("sanityCheck scene...")); context.core->sanityCheck(context.scene); logger.debug(MString("sanityCheck settings...")); //this->sanityCheck(context.settings); context.core->sanityCheck(context.settings); Corona::String basePath = (this->mtco_renderGlobals->basePath + "/corona/").asChar(); logger.debug(MString("beginSession...")); ICore::AdditionalInfo info; info.defaultFilePath = basePath; context.core->beginSession(context.scene, context.settings, context.fb, context.logger, info); // run the rendering. This function blocks until it is done logger.debug(MString("renderFrame...")); context.core->renderFrame(); context.isCancelled = true; context.core->endSession(); this->saveImage(); // delete what we have created and call deallocation functions for objects the core has created delete context.logger; delete context.settings; for(auto it = context.renderPasses.begin(); it != context.renderPasses.end(); ++it) { context.core->destroyRenderPass(*it); } context.core->destroyScene(context.scene); context.core->destroyFb(context.fb); ICore::destroyInstance(context.core); context.core = NULL; context.fb = NULL; context.renderPasses.clear(); context.isCancelled = false; context.scene = NULL; // for sequence rendering, at the moment clean up pointers // will be removed if I restructure the geo updates for( size_t objId = 0; objId < this->mtco_scene->objectList.size(); objId++) { mtco_MayaObject *obj = (mtco_MayaObject *)this->mtco_scene->objectList[objId]; obj->geom = NULL; obj->instance = NULL; } }
void CoronaRenderer::render() { OSL::OSLShadingNetworkRenderer *r = (OSL::OSLShadingNetworkRenderer *)getObjPtr("oslRenderer"); if (r == NULL) { std::cerr << "error CoronaRenderer::render: OSL renderer == NULL\n"; return; } this->oslRenderer = r; r->setup(); // delete existing shadingsys and reinit all //doit(); //return; logger.debug(MString("Starting corona rendering...")); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// INIT SHADING CORE + SCEME ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Context context; context.core = ICore::createInstance(); context.scene = context.core->createScene(); context.logger = new mtco_Logger(context.core); logger.debug(MString("core/scene/logger...")); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// SETTINGS ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// context.settings = new Settings(); context.colorMappingData = new Corona::ColorMappingData; // populate the settings with parameters from a configuration file. If the file does not exist, a new one // is created with default values. ConfParser parser; Corona::String resPath = (getRendererHome() + "ressources/").asChar(); logger.debug(MString("parser: ") + (resPath + CORONA_DEFAULT_CONF_FILENAME).cStr()); parser.parseFile(resPath + CORONA_DEFAULT_CONF_FILENAME, context.settings, ConfParser::CREATE_IF_NONEXISTENT); logger.debug(MString("defineSettings...")); this->clearMaterialLists(); this->defineSettings(); logger.debug(MString("definePasses...")); this->definePasses(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// //// INTERNAL FRAME BUFFER ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // create a new framebuffer, and init it before the rendering logger.debug(MString("createFb...")); context.fb = context.core->createFb(); context.fb->initFb(context.settings, context.renderPasses); this->mtco_renderGlobals->getImageName(); Corona::String dumpFilename = (this->mtco_renderGlobals->imageOutputFile + ".dmp").asChar(); if (this->mtco_renderGlobals->dumpAndResume) { context.settings->set(Corona::PARAM_RANDOM_SEED, 0); if (!context.fb->accumulateFromExr(dumpFilename)) { logger.debug(MString("Accumulating from a dumpfile failed: ") + dumpFilename.cStr()); } else{ // random seed has to be 0 for resuming a render context.settings->set(Corona::PARAM_RESUME_RENDERING, true); context.settings->set(Corona::PARAM_RANDOM_SEED, 0); } } createScene(); context.core->sanityCheck(context.scene); context.core->sanityCheck(context.settings); Corona::String basePath = (this->mtco_renderGlobals->basePath + "/corona/").asChar(); logger.debug(MString("beginSession...")); ICore::AdditionalInfo info; info.defaultFilePath = basePath; context.core->beginSession(context.scene, context.settings, context.fb, context.logger, info); // run the rendering. This function blocks until it is done logger.debug(MString("renderFrame...")); context.core->renderFrame(); context.isCancelled = true; context.core->endSession(); this->saveImage(); // delete what we have created and call deallocation functions for objects the core has created delete context.logger; delete context.settings; for(auto it = context.renderPasses.begin(); it != context.renderPasses.end(); ++it) { context.core->destroyRenderPass(*it); } context.core->destroyScene(context.scene); context.core->destroyFb(context.fb); ICore::destroyInstance(context.core); context.core = NULL; context.fb = NULL; context.renderPasses.clear(); context.isCancelled = false; context.scene = NULL; // for sequence rendering, at the moment clean up pointers // will be removed if I restructure the geo updates for( size_t objId = 0; objId < this->mtco_scene->objectList.size(); objId++) { mtco_MayaObject *obj = (mtco_MayaObject *)this->mtco_scene->objectList[objId]; obj->geom = NULL; obj->instance = NULL; } }
// Returns: // True - configuration file was read // False - configuration file was not read, either because an error occurred, or because the config file was previously // read and has not changed since then. bool ReplicaConfig::readConfigFile() { SNode s; if( LocalFS::stat(pathToConfigFile, s) < 0 || s.m_llTimeStamp == configFileTimestamp ) return false; configFileTimestamp = s.m_llTimeStamp; ConfParser parser; Param param; if (0 != parser.init(pathToConfigFile)) return false; while (parser.getNextParam(param) >= 0) { if ("REPLICATION_NUMBER" == param.m_strName) { for (vector<string>::iterator i = param.m_vstrValue.begin(); i != param.m_vstrValue.end(); ++ i) { string path; int num1, num2; if (parseItem(*i, path, num1, num2) >= 0) { string rp = Metadata::revisePath(path); if (rp.length() > 0) { configData.m_mReplicaNum[rp] = pair<int,int>(num1,num2); } } } } else if ("REPLICATION_DISTANCE" == param.m_strName) { for (vector<string>::iterator i = param.m_vstrValue.begin(); i != param.m_vstrValue.end(); ++ i) { string path; int dist; if (parseItem(*i, path, dist) >= 0) { string rp = Metadata::revisePath(path); if (rp.length() > 0) configData.m_mReplicaDist[rp] = dist; } } } else if ("REPLICATION_LOCATION" == param.m_strName) { for (vector<string>::iterator i = param.m_vstrValue.begin(); i != param.m_vstrValue.end(); ++ i) { string path; string loc; parseItem(*i, path, loc); string rp = Metadata::revisePath(path); vector<int> topo; Topology::parseTopo(loc.c_str(), topo); if ((rp.length() > 0) && !topo.empty()) configData.m_mRestrictedLoc[rp] = topo; } } else if ("REPLICATION_MAX_TRANS" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_iReplicationMaxTrans = atoi(param.m_vstrValue[0].c_str()); else cerr << "no value specified for REPLICATION_MAX_TRANS" << endl; } else if ("CHECK_REPLICA_ON_SAME_IP" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_bCheckReplicaOnSameIp = (param.m_vstrValue[0] == "TRUE" ); else cerr << "no value specified for CHECK_REPLICA_ON_SAME_IP" << endl; } else if ("PCT_SLAVES_TO_CONSIDER" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_iPctSlavesToConsider = atoi(param.m_vstrValue[0].c_str()); else cerr << "no value specified for PCT_SLAVES_TO_CONSIDER" << endl; } else if ("REPLICATION_START_DELAY" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_iReplicationStartDelay = atoi(param.m_vstrValue[0].c_str()); else cerr << "no value specified for REPLICATION_START_DELAY" << endl; } else if ("REPLICATION_FULL_SCAN_DELAY" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_iReplicationFullScanDelay = atoi(param.m_vstrValue[0].c_str()); else cerr << "no value specified for REPLICATION_FULL_SCAN_DELAY" << endl; if (configData.m_iReplicationFullScanDelay < 60) configData.m_iReplicationFullScanDelay = 60; } else if ("DISK_BALANCE_AGGRESSIVENESS" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_iDiskBalanceAggressiveness = atoi(param.m_vstrValue[0].c_str()); else cerr << "no value specified for DISK_BALANCE_AGGRESSIVENESS" << endl; configData.m_iDiskBalanceAggressiveness = std::max( 0, configData.m_iDiskBalanceAggressiveness ); configData.m_iDiskBalanceAggressiveness = std::min( 100, configData.m_iDiskBalanceAggressiveness ); } else if ("REPLICATE_ON_TRANSACTION_CLOSE" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_bReplicateOnTransactionClose = (param.m_vstrValue[0] == "TRUE"); else cerr << "no value specified for REPLICATE_ON_TRANSACTION_CLOSE" << endl; } else if ("CHECK_REPLICA_CLUSTER" == param.m_strName) { if( !param.m_vstrValue.empty() ) configData.m_bCheckReplicaCluster = (param.m_vstrValue[0] == "TRUE"); else cerr << "no value specified for CHECK_REPLCIA_CLUSTER" << endl; } else { cerr << "unrecognized replica.conf parameter: " << param.m_strName << endl; } } parser.close(); return true; }
int MasterConf::init(const string& path) { ConfParser parser; Param param; if (0 != parser.init(path)) return -1; while (parser.getNextParam(param) >= 0) { if (param.m_vstrValue.empty()) continue; if ("SECTOR_PORT" == param.m_strName) m_iServerPort = atoi(param.m_vstrValue[0].c_str()); else if ("SECURITY_SERVER" == param.m_strName) { char buf[128]; strncpy(buf, param.m_vstrValue[0].c_str(), 128); unsigned int i = 0; for (unsigned int n = strlen(buf); i < n; ++ i) { if (buf[i] == ':') break; } buf[i] = '\0'; m_strSecServIP = buf; m_iSecServPort = atoi(buf + i + 1); } else if ("MAX_ACTIVE_USER" == param.m_strName) m_iMaxActiveUser = atoi(param.m_vstrValue[0].c_str()); else if ("DATA_DIRECTORY" == param.m_strName) { m_strHomeDir = param.m_vstrValue[0]; if (m_strHomeDir.c_str()[m_strHomeDir.length() - 1] != '/') m_strHomeDir += "/"; } else if ("REPLICA_NUM" == param.m_strName) m_iReplicaNum = atoi(param.m_vstrValue[0].c_str()); else if ("REPLICA_DIST" == param.m_strName) m_iReplicaDist = atoi(param.m_vstrValue[0].c_str()); else if ("META_LOC" == param.m_strName) { if ("MEMORY" == param.m_vstrValue[0]) m_MetaType = MEMORY; else if ("DISK" == param.m_vstrValue[0]) m_MetaType = DISK; } else if ("SLAVE_TIMEOUT" == param.m_strName) { m_iSlaveTimeOut = atoi(param.m_vstrValue[0].c_str()); // slave reports every 30 - 60 seconds if (m_iSlaveTimeOut < 120) m_iSlaveTimeOut = 120; } else if ("LOST_SLAVE_RETRY_TIME" == param.m_strName) { m_iSlaveRetryTime = atoi(param.m_vstrValue[0].c_str()); if (m_iSlaveRetryTime < 0) m_iSlaveRetryTime = 0; } else if ("SLAVE_MIN_DISK_SPACE" == param.m_strName) { m_llSlaveMinDiskSpace = atoll(param.m_vstrValue[0].c_str()) * 1000000; } else if ("CLIENT_TIMEOUT" == param.m_strName) { m_iClientTimeOut = atoi(param.m_vstrValue[0].c_str()); // client only sends heartbeat every 60 - 120 seconds, so this value cannot be too small if (m_iClientTimeOut < 300) m_iClientTimeOut = 300; } else if ("LOG_LEVEL" == param.m_strName) { m_iLogLevel = atoi(param.m_vstrValue[0].c_str()); } else if ("PROCESS_THREADS" == param.m_strName) { m_iProcessThreads = atoi(param.m_vstrValue[0].c_str()); } else if ("WRITE_ONCE_PROTECTION" == param.m_strName) { for (vector<string>::iterator i = param.m_vstrValue.begin(); i != param.m_vstrValue.end(); ++ i) { string rp = Metadata::revisePath(*i); m_vWriteOncePath.push_back(rp); } } else { cerr << "unrecongnized system parameter: " << param.m_strName << endl; } } parser.close(); return 0; }
int ClientConf::init(const string& path) { ConfParser parser; Param param; if (0 != parser.init(path)) return -1; while (parser.getNextParam(param) >= 0) { if (param.m_vstrValue.empty()) continue; if ("MASTER_ADDRESS" == param.m_strName) { char buf[128]; strncpy(buf, param.m_vstrValue[0].c_str(), 128); unsigned int i = 0; for (unsigned int n = strlen(buf); i < n; ++ i) { if (buf[i] == ':') break; } buf[i] = '\0'; m_strMasterIP = buf; m_iMasterPort = atoi(buf + i + 1); } else if ("USERNAME" == param.m_strName) { m_strUserName = param.m_vstrValue[0]; } else if ("PASSWORD" == param.m_strName) { m_strPassword = param.m_vstrValue[0]; } else if ("CERTIFICATE" == param.m_strName) { m_strCertificate = param.m_vstrValue[0]; } else if ("MAX_CACHE_SIZE" == param.m_strName) { #ifndef WIN32 m_llMaxCacheSize = atoll(param.m_vstrValue[0].c_str()) * 1000000; #else m_llMaxCacheSize = _atoi64(param.m_vstrValue[0].c_str()) * 1000000; #endif } else if ("FUSE_READ_AHEAD_BLOCK" == param.m_strName) { m_iFuseReadAheadBlock = atoi(param.m_vstrValue[0].c_str()) * 1000000; } else if ("MAX_READ_CACHE_SIZE" == param.m_strName) { #ifndef WIN32 m_llMaxWriteCacheSize = atoll(param.m_vstrValue[0].c_str()) * 1000000; #else m_llMaxWriteCacheSize = _atoi64(param.m_vstrValue[0].c_str()) * 1000000; #endif } else cerr << "unrecongnized client.conf parameter: " << param.m_strName << endl; } parser.close(); return 0; }
int SlaveConf::init(const string& path) { // initialize these values; a slave must call init() // cannot initialize the following values in constructor because they are reserved for global conf m_iMasterPort = 6000; m_strHomeDir = "./"; m_llMaxDataSize = -1; m_iMaxServiceNum = 64; m_MetaType = MEMORY; m_iLogLevel = 1; ConfParser parser; Param param; if (0 != parser.init(path)) return -1; while (parser.getNextParam(param) >= 0) { if (param.m_vstrValue.empty()) continue; if ("MASTER_ADDRESS" == param.m_strName) { char buf[128]; strncpy(buf, param.m_vstrValue[0].c_str(), 128); unsigned int i = 0; for (unsigned int n = strlen(buf); i < n; ++ i) { if (buf[i] == ':') break; } buf[i] = '\0'; m_strMasterHost = buf; m_iMasterPort = atoi(buf + i + 1); } else if ("DATA_DIRECTORY" == param.m_strName) { m_strHomeDir = param.m_vstrValue[0]; if (m_strHomeDir.c_str()[m_strHomeDir.length() - 1] != '/') m_strHomeDir += "/"; } else if ("MAX_DATA_SIZE" == param.m_strName) { m_llMaxDataSize = atoll(param.m_vstrValue[0].c_str()) * 1024 * 1024; } else if ("MAX_SERVICE_INSTANCE" == param.m_strName) m_iMaxServiceNum = atoi(param.m_vstrValue[0].c_str()); else if ("LOCAL_ADDRESS" == param.m_strName) m_strLocalIP = param.m_vstrValue[0]; else if ("PUBLIC_ADDRESS" == param.m_strName) m_strPublicIP = param.m_vstrValue[0]; else if ("META_LOC" == param.m_strName) { if ("MEMORY" == param.m_vstrValue[0]) m_MetaType = MEMORY; else if ("DISK" == param.m_vstrValue[0]) m_MetaType = DISK; } else if ("LOG_LEVEL" == param.m_strName) { m_iLogLevel = atoi(param.m_vstrValue[0].c_str()); } else { cerr << "unrecongnized system parameter: " << param.m_strName << endl; } } parser.close(); return 0; }
int SlaveConf::init(const string& path) { ConfParser parser; Param param; if (0 != parser.init(path)) return -1; while (parser.getNextParam(param) >= 0) { if (param.m_vstrValue.empty()) continue; if ("MASTER_ADDRESS" == param.m_strName) { char buf[128]; strncpy(buf, param.m_vstrValue[0].c_str(), 128); unsigned int i = 0; for (unsigned int n = strlen(buf); i < n; ++ i) { if (buf[i] == ':') break; } buf[i] = '\0'; m_strMasterHost = buf; m_iMasterPort = atoi(buf + i + 1); } else if ("DATA_DIRECTORY" == param.m_strName) { m_strHomeDir = param.m_vstrValue[0]; #ifdef WIN32 win_to_unix_path (m_strHomeDir); struct stat t; if (stat(m_strHomeDir.c_str(), &t) != 0) { char szPath[MAX_PATH]=""; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_DEFAULT, szPath))) { m_strHomeDir.assign (szPath); char first = param.m_vstrValue[0][0]; if (first != '/' && first != '\\') m_strHomeDir += "\\"; m_strHomeDir.append(param.m_vstrValue[0]); win_to_unix_path (m_strHomeDir); } } #ifdef _DEBUG printf ("DATA_DIRECTORY: %s\n", m_strHomeDir.c_str()); #endif #endif if (m_strHomeDir.c_str()[m_strHomeDir.length() - 1] != '/') m_strHomeDir += "/"; } else if ("MAX_DATA_SIZE" == param.m_strName) { #ifndef WIN32 m_llMaxDataSize = atoll(param.m_vstrValue[0].c_str()) * 1024 * 1024; #else m_llMaxDataSize = _atoi64(param.m_vstrValue[0].c_str()) * 1024 * 1024; #endif } else if ("MAX_SERVICE_INSTANCE" == param.m_strName) m_iMaxServiceNum = atoi(param.m_vstrValue[0].c_str()); else if ("LOCAL_ADDRESS" == param.m_strName) m_strLocalIP = param.m_vstrValue[0]; else if ("PUBLIC_ADDRESS" == param.m_strName) m_strPublicIP = param.m_vstrValue[0]; else if ("META_LOC" == param.m_strName) { if ("MEMORY" == param.m_vstrValue[0]) m_MetaType = MEMORY; else if ("DISK" == param.m_vstrValue[0]) m_MetaType = DISK; } else cerr << "unrecongnized system parameter: " << param.m_strName << endl; } parser.close(); return 0; }
int MasterConf::init(const string& path) { ConfParser parser; Param param; if (0 != parser.init(path)) return -1; while (parser.getNextParam(param) >= 0) { if (param.m_vstrValue.empty()) continue; if ("SECTOR_PORT" == param.m_strName) m_iServerPort = atoi(param.m_vstrValue[0].c_str()); else if ("SECURITY_SERVER" == param.m_strName) { char buf[128]; strncpy(buf, param.m_vstrValue[0].c_str(), 128); unsigned int i = 0; for (unsigned int n = strlen(buf); i < n; ++ i) { if (buf[i] == ':') break; } buf[i] = '\0'; m_strSecServIP = buf; m_iSecServPort = atoi(buf + i + 1); } else if ("MAX_ACTIVE_USER" == param.m_strName) m_iMaxActiveUser = atoi(param.m_vstrValue[0].c_str()); else if ("DATA_DIRECTORY" == param.m_strName) { m_strHomeDir = param.m_vstrValue[0]; #ifdef WIN32 win_to_unix_path (m_strHomeDir); struct stat t; if (stat(m_strHomeDir.c_str(), &t) != 0) { char szPath[MAX_PATH]=""; if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, SHGFP_TYPE_DEFAULT, szPath))) { m_strHomeDir.assign (szPath); char first = param.m_vstrValue[0][0]; if (first != '/' && first != '\\') m_strHomeDir += "\\"; m_strHomeDir.append(param.m_vstrValue[0]); win_to_unix_path (m_strHomeDir); } } #ifdef _DEBUG printf ("DATA_DIRECTORY: %s\n", m_strHomeDir.c_str()); #endif #endif char last = m_strHomeDir.c_str()[m_strHomeDir.length() - 1]; if (last != '/' && last != '\\') m_strHomeDir += "/"; } else if ("REPLICA_NUM" == param.m_strName) m_iReplicaNum = atoi(param.m_vstrValue[0].c_str()); else if ("META_LOC" == param.m_strName) { if ("MEMORY" == param.m_vstrValue[0]) m_MetaType = MEMORY; else if ("DISK" == param.m_vstrValue[0]) m_MetaType = DISK; } else if ("SLAVE_TIMEOUT" == param.m_strName) { m_iSlaveTimeOut = atoi(param.m_vstrValue[0].c_str()); if (m_iSlaveTimeOut < 120) m_iSlaveTimeOut = 120; } else if ("SLAVE_MIN_DISK_SPACE" == param.m_strName) { #ifndef WIN32 m_llSlaveMinDiskSpace = atoll(param.m_vstrValue[0].c_str()) * 1000000; #else m_llSlaveMinDiskSpace = _atoi64(param.m_vstrValue[0].c_str()) * 1000000; #endif } else if ("CLIENT_TIMEOUT" == param.m_strName) { m_iClientTimeOut = atoi(param.m_vstrValue[0].c_str()); } else if ("LOG_LEVEL" == param.m_strName) { m_iLogLevel = atoi(param.m_vstrValue[0].c_str()); } else { cerr << "unrecongnized system parameter: " << param.m_strName << endl; } } parser.close(); return 0; }
// init all data which will be used during a rendering. // These data will be reused in rendering until the rendering is done. void CoronaRenderer::initializeRenderer() { Logging::debug("CoronaRenderer::initializeRenderer()"); MFnDependencyNode gFn(getRenderGlobalsNode()); clearDataList(); // clear nativeMtlData if (MGlobal::mayaState() != MGlobal::kBatch) MayaTo::getWorldPtr()->setRenderType(MayaTo::MayaToWorld::WorldRenderType::UIRENDER); else MayaTo::getWorldPtr()->setRenderType(MayaTo::MayaToWorld::WorldRenderType::BATCHRENDER); // first we delete any still existing elements. // after a render, the framebuffers, core and passes still exist until a new scene is loaded // or a new rendering is started. if (context.logger != nullptr) { delete context.logger; context.logger = nullptr; } if (context.settings != nullptr) { delete context.settings; context.settings = nullptr; } context.renderPasses.clear(); if (context.fb != nullptr) { context.core->destroyFb(context.fb); context.fb = nullptr; } if (context.scene != nullptr) { context.core->destroyScene(context.scene); context.scene = nullptr; } if (context.core != nullptr) { ICore::destroyInstance(context.core); context.core = nullptr; } if (context.colorMappingData != nullptr) { delete context.colorMappingData; context.colorMappingData = nullptr; } context.settings = new Settings(); context.core = ICore::createInstance(); context.logger = new mtco_Logger(context.core); context.colorMappingData = new Corona::ColorMappingData; if (gFn.findPlug("useCoronaVFB").asBool()) if (MGlobal::mayaState() != MGlobal::kBatch) vfbCallbacks.core = context.core; ConfParser parser; Corona::String resPath = (getRendererHome() + "resources/").asChar(); Logging::debug(MString("parser: ") + (resPath + CORONA_DEFAULT_CONF_FILENAME).cStr()); parser.parseFile(resPath + CORONA_DEFAULT_CONF_FILENAME, context.settings, ConfParser::CREATE_IF_NONEXISTENT); this->defineSettings(); this->defineColorMapping(); this->definePasses(); context.fb = context.core->createFb(); context.fb->initFb(context.settings, context.renderPasses); context.core->sanityCheck(context.settings); if (gFn.findPlug("useCoronaVFB").asBool()) if (MGlobal::mayaState() != MGlobal::kBatch) context.core->getWxVfb().renderStarted(context.fb, &vfbCallbacks, IWxVfb::EnviroConfig()); // this can be extracted and placed in a button function in the render globals std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr; MFnDependencyNode renderGlobalsNode(getRenderGlobalsNode()); Corona::String dumpFilename = (renderGlobals->getImageOutputFile() + ".dmp").asChar(); if (getBoolAttr("dumpAndResume", renderGlobalsNode, false)) { context.settings->set(Corona::PARAM_RANDOM_SEED, 0); if (!context.fb->accumulateFromExr(dumpFilename)) { Logging::debug(MString("Accumulating from a dumpfile failed: ") + dumpFilename.cStr()); } else{ // random seed has to be 0 for resuming a render context.settings->set(Corona::PARAM_RESUME_RENDERING, true); context.settings->set(Corona::PARAM_RANDOM_SEED, 0); } } OSL::OSLShadingNetworkRenderer *r = (OSL::OSLShadingNetworkRenderer *)MayaTo::getWorldPtr()->getObjPtr("oslRenderer"); if (r == nullptr) { Logging::debug("error CoronaRenderer::render: OSL renderer == nullptr"); return; } this->oslRenderer = r; r->setup(); // delete existing shadingsys and reinit all }