本文整理汇总了C++中NBNetBuilder::applyOptions方法的典型用法代码示例。如果您正苦于以下问题:C++ NBNetBuilder::applyOptions方法的具体用法?C++ NBNetBuilder::applyOptions怎么用?C++ NBNetBuilder::applyOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NBNetBuilder
的用法示例。
在下文中一共展示了NBNetBuilder::applyOptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessError
/* -------------------------------------------------------------------------
* main
* ----------------------------------------------------------------------- */
int
main(int argc, char** argv) {
OptionsCont& oc = OptionsCont::getOptions();
// give some application descriptions
oc.setApplicationDescription("Road network importer / builder for the road traffic simulation SUMO.");
oc.setApplicationName("netconvert", "SUMO netconvert Version " + (std::string)VERSION_STRING);
int ret = 0;
try {
XMLSubSys::init(false);
fillOptions();
OptionsIO::getOptions(true, argc, argv);
if (oc.processMetaOptions(argc < 2)) {
SystemFrame::close();
return 0;
}
MsgHandler::initOutputOptions();
if (!checkOptions()) {
throw ProcessError();
}
RandHelper::initRandGlobal();
NBNetBuilder nb;
nb.applyOptions(oc);
// load data
NILoader nl(nb);
nl.load(oc);
if (oc.getBool("ignore-errors")) {
MsgHandler::getErrorInstance()->clear();
}
// check whether any errors occured
if (MsgHandler::getErrorInstance()->wasInformed()) {
throw ProcessError();
}
nb.compute(oc);
if(oc.getAnyVerbosity())
std::cout<<"Writing output file..."<<std::endl;
NWFrame::writeNetwork(oc, nb);
if(oc.getAnyVerbosity())
std::cout<<"Output file writed"<<std::endl;
} catch (ProcessError& e) {
if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
WRITE_ERROR(e.what());
}
MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
ret = 1;
#ifndef _DEBUG
} catch (...) {
MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
ret = 1;
#endif
}
NBDistribution::clear();
OutputDevice::closeAll();
SystemFrame::close();
// report about ending
if (ret == 0) {
std::cout << "Success." << std::endl;
}
return ret;
}
示例2: ProcessError
int
main(int argc, char** argv) {
OptionsCont& oc = OptionsCont::getOptions();
// give some application descriptions
oc.setApplicationDescription("Road network generator for the microscopic road traffic simulation SUMO.");
oc.setApplicationName("netgen", "SUMO netgen Version " + (std::string)VERSION_STRING);
int ret = 0;
try {
// initialise the application system (messaging, xml, options)
XMLSubSys::init(false);
fillOptions();
OptionsIO::getOptions(true, argc, argv);
if (oc.processMetaOptions(argc < 2)) {
SystemFrame::close();
return 0;
}
MsgHandler::initOutputOptions();
if (!checkOptions()) {
throw ProcessError();
}
RandHelper::initRandGlobal();
NBNetBuilder nb;
nb.applyOptions(oc);
// build the netgen-network description
NGNet* net = buildNetwork(nb);
// ... and we have to do this...
oc.resetWritable();
// transfer to the netbuilding structures
net->toNB();
delete net;
// report generated structures
WRITE_MESSAGE(" Generation done;");
WRITE_MESSAGE(" " + toString<int>(nb.getNodeCont().size()) + " nodes generated.");
WRITE_MESSAGE(" " + toString<int>(nb.getEdgeCont().size()) + " edges generated.");
nb.compute(oc);
NWFrame::writeNetwork(oc, nb);
} catch (ProcessError& e) {
if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
WRITE_ERROR(e.what());
}
MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
ret = 1;
#ifndef _DEBUG
} catch (...) {
MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
ret = 1;
#endif
}
OutputDevice::closeAll();
SystemFrame::close();
if (ret == 0) {
std::cout << "Success." << std::endl;
}
return ret;
}
示例3: ProcessError
/* -------------------------------------------------------------------------
* main
* ----------------------------------------------------------------------- */
int
main(int argc, char** argv) {
OptionsCont& oc = OptionsCont::getOptions();
// give some application descriptions
oc.setApplicationDescription("Network importer / builder for the microscopic, multi-modal traffic simulation SUMO.");
oc.setApplicationName("netconvert", "Eclipse SUMO netconvert Version " VERSION_STRING);
int ret = 0;
try {
XMLSubSys::init();
fillOptions();
OptionsIO::setArgs(argc, argv);
OptionsIO::getOptions();
if (oc.processMetaOptions(argc < 2)) {
SystemFrame::close();
return 0;
}
XMLSubSys::setValidation(oc.getString("xml-validation"), oc.getString("xml-validation.net"));
MsgHandler::initOutputOptions();
if (!checkOptions()) {
throw ProcessError();
}
RandHelper::initRandGlobal();
// build the projection
if (!GeoConvHelper::init(oc)) {
throw ProcessError("Could not build projection!");
}
NBNetBuilder nb;
nb.applyOptions(oc);
// load data
NILoader nl(nb);
nl.load(oc);
if (oc.getBool("ignore-errors")) {
MsgHandler::getErrorInstance()->clear();
}
// check whether any errors occurred
if (MsgHandler::getErrorInstance()->wasInformed()) {
throw ProcessError();
}
nb.compute(oc);
// check whether any errors occurred
if (MsgHandler::getErrorInstance()->wasInformed()) {
throw ProcessError();
}
NWFrame::writeNetwork(oc, nb);
} catch (const ProcessError& e) {
if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
WRITE_ERROR(e.what());
}
MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
ret = 1;
#ifndef _DEBUG
} catch (const std::exception& e) {
if (std::string(e.what()) != std::string("")) {
WRITE_ERROR(e.what());
}
MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
ret = 1;
} catch (...) {
MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
ret = 1;
#endif
}
DistributionCont::clear();
SystemFrame::close();
// report about ending
if (ret == 0) {
std::cout << "Success." << std::endl;
}
return ret;
}
示例4: nl
FXint
GNELoadThread::run() {
// register message callbacks
MsgHandler::getMessageInstance()->addRetriever(myMessageRetriever);
MsgHandler::getErrorInstance()->addRetriever(myErrorRetriever);
MsgHandler::getWarningInstance()->addRetriever(myWarningRetriever);
GNENet* net = 0;
// try to load the given configuration
OptionsCont& oc = OptionsCont::getOptions();
oc.clear();
if (!initOptions()) {
submitEndAndCleanup(net);
return 0;
}
MsgHandler::initOutputOptions();
if (!(NIFrame::checkOptions() &&
NBFrame::checkOptions() &&
NWFrame::checkOptions())) {
// options are not valid
WRITE_ERROR("Invalid Options. Nothing loaded");
submitEndAndCleanup(net);
return 0;
}
MsgHandler::getErrorInstance()->clear();
MsgHandler::getWarningInstance()->clear();
MsgHandler::getMessageInstance()->clear();
RandHelper::initRandGlobal();
if (!GeoConvHelper::init(oc)) {
WRITE_ERROR("Could not build projection!");
submitEndAndCleanup(net);
return 0;
}
XMLSubSys::setValidation(oc.getString("xml-validation"), oc.getString("xml-validation.net"));
// this netbuilder instance becomes the responsibility of the GNENet
NBNetBuilder* netBuilder = new NBNetBuilder();
netBuilder->applyOptions(oc);
if (myNewNet) {
// create new network
net = new GNENet(netBuilder);
} else {
NILoader nl(*netBuilder);
try {
nl.load(oc);
if (!myLoadNet) {
WRITE_MESSAGE("Performing initial computation ...\n");
// perform one-time processing (i.e. edge removal)
netBuilder->compute(oc);
// @todo remove one-time processing options!
} else {
// make coordinate conversion usable before first netBuilder->compute()
GeoConvHelper::computeFinal();
}
if (oc.getBool("ignore-errors")) {
MsgHandler::getErrorInstance()->clear();
}
// check whether any errors occured
if (MsgHandler::getErrorInstance()->wasInformed()) {
throw ProcessError();
} else {
net = new GNENet(netBuilder);
}
} catch (ProcessError& e) {
if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
WRITE_ERROR(e.what());
}
WRITE_ERROR("Failed to build network.");
delete net;
delete netBuilder;
net = 0;
} catch (std::exception& e) {
WRITE_ERROR(e.what());
#ifdef _DEBUG
throw;
#endif
delete net;
delete netBuilder;
net = 0;
}
}
// only a single setting file is supported
submitEndAndCleanup(net, oc.getString("gui-settings-file"), oc.getBool("registry-viewport"));
return 0;
}