diff --git a/main.cpp b/main.cpp index a322c4707a69457e38df7e1e981ee3a657c4f327..6fad76334489496de6d70a449f362f98c50f1b06 100644 --- a/main.cpp +++ b/main.cpp @@ -10,7 +10,7 @@ void txt2pcd( std::filesystem::path input, std::filesystem::path output ) { - std::ifstream inputFile{input.c_str()}; + std::ifstream inputFile{ input.c_str() }; if ( inputFile ) { @@ -20,7 +20,7 @@ void txt2pcd( std::filesystem::path input, std::filesystem::path output ) std::string line; auto len = inputFile.tellg(); - char buf{'\0'}; + char buf{ '\0' }; do { @@ -104,7 +104,7 @@ void txt2pcd( std::filesystem::path input, std::filesystem::path output ) void printHelp() { - std::cout << "Usage: txt2pcd inputCloud.txt outputCloud.pcd\n"; + std::cout << "Usage: txt2pcd inputCloud.txt [outputCloud.pcd]\n"; } int main( int argc, char** argv ) @@ -120,6 +120,14 @@ int main( int argc, char** argv ) std::cerr << e.what() << "\n"; } } + else if ( argc == 2 ) + { + auto basefilename = std::filesystem::path{ argv[ 1 ] }; + auto outfilename = basefilename; + outfilename.replace_extension( std::filesystem::path{ "pcd" } ); + + txt2pcd( basefilename, outfilename ); + } else { printHelp();