49 po::options_description desc(
"Available options");
51 (
"help,h",
"Produce this help message.")
52 (
"modules-list,l",
"Print the list of available modules.")
53 (
"modules-opt,p", po::value<string>(),
54 "Print options for a module.")
55 (
"module,m", po::value<vector<string> >(),
56 "Specify modules which are to be used.")
57 (
"verbose,v",
"Enable verbose mode.");
59 po::options_description hidden(
"Hidden options");
61 (
"input-file", po::value<vector<string> >(),
"Input filename");
63 po::options_description cmdline_options;
64 cmdline_options.add(hidden).add(desc);
66 po::options_description visible(
"Allowed options");
69 po::positional_options_description
p;
70 p.add(
"input-file", -1);
76 po::store(po::command_line_parser(argc, argv).
77 options(cmdline_options).positional(p).
run(), vm);
80 catch (
const std::exception& e)
82 cerr << e.what() << endl;
88 if (vm.count(
"modules-list"))
94 if (vm.count(
"modules-opt"))
97 boost::split(tmp1, vm[
"modules-opt"].as<string>(), boost::is_any_of(
":"));
101 cerr <<
"ERROR: To specify a module, use one of in, out or proc "
102 <<
"together with the filename; for example in:vtk." << endl;
106 if (tmp1[0] !=
"in" && tmp1[0] !=
"out" && tmp1[0] !=
"proc")
108 cerr <<
"ERROR: Invalid module type " << tmp1[0] << endl;
118 else if (tmp1[0] ==
"out")
122 else if (tmp1[0] ==
"proc")
130 cerr <<
"Options for module " << tmp1[1] <<
":" << endl;
135 if (vm.count(
"help") || vm.count(
"input-file") != 1) {
136 cerr <<
"Usage: NekMesh [options] inputfile.ext1 outputfile.ext2"
142 vector<string> inout = vm[
"input-file"].as<vector<string> >();
144 if (inout.size() < 2)
146 cerr <<
"ERROR: You must specify an input and output file." << endl;
161 vector<ModuleSharedPtr> modules;
162 vector<string> modcmds;
164 if (vm.count(
"verbose"))
166 mesh->m_verbose =
true;
169 if (vm.count(
"module"))
171 modcmds = vm[
"module"].as<vector<string> >();
175 modcmds.insert (modcmds.begin(), inout[0]);
176 modcmds.push_back(inout[1]);
178 for (
int i = 0; i < modcmds.size(); ++i)
185 boost::split(tmp1, modcmds[i], boost::is_any_of(
":"));
187 if (i == 0 || i == modcmds.size() - 1)
198 if (tmp1.size() == 1)
200 int dot = tmp1[0].find_last_of(
'.') + 1;
201 string ext = tmp1[0].substr(dot, tmp1[0].length() - dot);
205 string tmp = tmp1[0].substr(0, tmp1[0].length() - 3);
206 dot = tmp.find_last_of(
'.') + 1;
207 ext = tmp.substr(dot, tmp.length() - dot);
211 tmp1.push_back(
string(i == 0 ?
"infile=" :
"outfile=")+tmp1[0]);
215 module.second = tmp1[1];
216 tmp1.push_back(
string(i == 0 ?
"infile=" :
"outfile=")+tmp1[0]);
223 module.second = tmp1[0];
228 modules.push_back(mod);
231 for (
int j = offset; j < tmp1.size(); ++j)
234 boost::split(tmp2, tmp1[j], boost::is_any_of(
"="));
236 if (tmp2.size() == 1)
238 mod->RegisterConfig(tmp2[0],
"1");
240 else if (tmp2.size() == 2)
242 mod->RegisterConfig(tmp2[0], tmp2[1]);
246 cerr <<
"ERROR: Invalid module configuration: format is "
247 <<
"either :arg or :arg=val" << endl;
257 for (
int i = 0; i < modules.size(); ++i)
259 modules[i]->Process();
void PrintAvailableClasses(std::ostream &pOut=std::cout)
Prints the available classes to stdout.
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
pair< ModuleType, string > ModuleKey
boost::shared_ptr< Module > ModuleSharedPtr
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()