Commit 8dde221c authored by Mike Kremer's avatar Mike Kremer

Provide option to specify output filename

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@159 66977474-1d4b-4f09-8fe9-267525286df2
parent c4cd6d50
......@@ -10,10 +10,10 @@
int main(int _argc, char* _argv[]) {
if(_argc != 3 ||
if(_argc < 3 || _argc > 4 ||
(_argc > 1 && (std::strcmp(_argv[1], "--help") == 0 || std::strcmp(_argv[1], "-h") == 0))) {
std::cerr << "You need to specify a source file to convert!" << std::endl << std::endl;
std::clog << "Usage: file_converter <format> <filename>" << std::endl << std::endl;
std::clog << "Usage: file_converter <format> <filename> [output_filename]" << std::endl << std::endl;
std::clog << "Available file formats:" << std::endl;
std::clog << " -t\tTetmesh" << std::endl;
std::clog << std::endl;
......@@ -58,14 +58,20 @@ int main(int _argc, char* _argv[]) {
OpenVolumeMesh::IO::FileManager fileManager;
std::string filename(_argv[2]);
std::string::size_type idx = filename.rfind('.');
std::string filename;
std::string out_filename = filename.substr(0, idx);
out_filename.append(".ovm");
if(_argc == 3) {
filename = _argv[2];
std::string::size_type idx = filename.rfind('.');
filename = filename.substr(0, idx);
filename.append(".ovm");
} else {
filename = _argv[3];
}
// Write mesh to file
fileManager.writeFile(out_filename.c_str(), mesh);
fileManager.writeFile(filename.c_str(), mesh);
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment