From 9df10f452d9044fbacbc492bd2f05fb4ace90670 Mon Sep 17 00:00:00 2001 From: m-schuetz Date: Mon, 24 Aug 2020 17:24:39 +0200 Subject: [PATCH] fix argument parsing; allow drag&drop of las files into binary; copy json license to build --- CMakeLists.txt | 6 + Converter/Converter.sln | 25 ---- Converter/Converter.vcxproj | 183 ------------------------- Converter/Converter.vcxproj.filters | 117 ---------------- Converter/libs/arguments/Arguments.hpp | 7 +- Converter/src/main.cpp | 48 ++++++- 6 files changed, 55 insertions(+), 331 deletions(-) delete mode 100644 Converter/Converter.sln delete mode 100644 Converter/Converter.vcxproj delete mode 100644 Converter/Converter.vcxproj.filters diff --git a/CMakeLists.txt b/CMakeLists.txt index d6516d29..19c0d481 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,6 +67,12 @@ add_custom_command( ${LASZIP_DIR}/COPYING $/licenses/license_laszip.txt) +add_custom_command( + TARGET PotreeConverter POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_SOURCE_DIR}/Converter/libs/json/LICENSE + $/licenses/license_json.txt) + add_custom_command( TARGET PotreeConverter POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy diff --git a/Converter/Converter.sln b/Converter/Converter.sln deleted file mode 100644 index 776a29c8..00000000 --- a/Converter/Converter.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29728.190 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcxproj", "{EC1A1F30-3466-4FCC-AB78-0D6B27DD66DF}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {EC1A1F30-3466-4FCC-AB78-0D6B27DD66DF}.Debug|x64.ActiveCfg = Debug|x64 - {EC1A1F30-3466-4FCC-AB78-0D6B27DD66DF}.Debug|x64.Build.0 = Debug|x64 - {EC1A1F30-3466-4FCC-AB78-0D6B27DD66DF}.Release|x64.ActiveCfg = Release|x64 - {EC1A1F30-3466-4FCC-AB78-0D6B27DD66DF}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {BA7F1F15-AA32-4C5B-A8A6-0CFB69CB5FBD} - EndGlobalSection -EndGlobal diff --git a/Converter/Converter.vcxproj b/Converter/Converter.vcxproj deleted file mode 100644 index 0eab7200..00000000 --- a/Converter/Converter.vcxproj +++ /dev/null @@ -1,183 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - {EC1A1F30-3466-4FCC-AB78-0D6B27DD66DF} - Converter - 10.0 - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - true - $(SolutionDir)obj\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - - - false - - - false - $(SolutionDir)obj\$(Platform)_$(Configuration)\ - $(SolutionDir)bin\$(Platform)_$(Configuration)\ - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - $(SolutionDir)include;$(SolutionDir)modules;$(SolutionDir)libs;%(AdditionalIncludeDirectories) - stdcpplatest - - - Console - true - $(SolutionDir)libs\laszip\laszip3d.lib;%(AdditionalDependencies) - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - true - stdcpplatest - $(SolutionDir)include;$(SolutionDir)modules;$(SolutionDir)libs;%(AdditionalIncludeDirectories) - - - Console - true - true - true - $(SolutionDir)libs\laszip\laszip3.lib;%(AdditionalDependencies) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Converter/Converter.vcxproj.filters b/Converter/Converter.vcxproj.filters deleted file mode 100644 index 85693920..00000000 --- a/Converter/Converter.vcxproj.filters +++ /dev/null @@ -1,117 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {e25098e1-194d-473d-b473-6591e4ca437a} - - - {ef980e61-7f19-48c3-8cb0-cb609cb8f49f} - - - {e34b9969-2068-4d55-8100-b37e5759ad45} - - - {415b75a6-67a9-4ec8-9e3c-d1ca02998a6d} - - - {041691af-d9e4-4db8-8005-e7c45d2ff2cb} - - - {b8bd940f-2505-404b-9247-16916a8e6e55} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - modules\deprecated - - - modules\deprecated - - - - - modules\LasLoader - - - modules\unsuc - - - modules\unsuc - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - modules\arguments - - - Header Files - - - modules\tools - - - modules\tools - - - Header Files - - - Header Files - - - Header Files - - - modules\deprecated - - - modules\deprecated - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/Converter/libs/arguments/Arguments.hpp b/Converter/libs/arguments/Arguments.hpp index 3ecaafb5..4c234ce2 100644 --- a/Converter/libs/arguments/Arguments.hpp +++ b/Converter/libs/arguments/Arguments.hpp @@ -284,13 +284,16 @@ class Arguments { AValue get(string name) { Argument *arg = getArgument(name); + vector values; + for (auto entry : map) { if (arg->is(entry.first)) { - return AValue(entry.second); + values.insert(values.end(), entry.second.begin(), entry.second.end()); + //return AValue(entry.second); } } - return AValue({}); + return AValue(values); } diff --git a/Converter/src/main.cpp b/Converter/src/main.cpp index e3d11249..f4a0bdac 100644 --- a/Converter/src/main.cpp +++ b/Converter/src/main.cpp @@ -33,10 +33,6 @@ Options parseArguments(int argc, char** argv) { } vector source = args.get("source").as>(); - string outdir = args.get("outdir").as(); - - string method = args.get("method").as("poisson"); - string chunkMethod = args.get("chunkMethod").as("LASZIP"); if (source.size() == 0) { cout << "/Converter -o " << endl; @@ -44,6 +40,48 @@ Options parseArguments(int argc, char** argv) { exit(1); } + string method = args.get("method").as("poisson"); + string chunkMethod = args.get("chunkMethod").as("LASZIP"); + + string outdir = ""; + if (args.has("outdir")) { + outdir = args.get("outdir").as(); + } else { + + string sourcepath = source[0]; + fs::path path(sourcepath); + + //cout << fs::canonical(source[0]) << endl; + //exit(123); + + if (!fs::exists(path)) { + GENERATE_ERROR_MESSAGE << "file does not exist: " << source[0] << endl; + + exit(123); + } + + path = fs::canonical(path); + + string suggestedBaseName = path.filename().string() + "_converted"; + outdir = sourcepath + "/../" + suggestedBaseName; + + int i = 1; + while(fs::exists(outdir)) { + outdir = sourcepath + "/../" + suggestedBaseName + "_" + std::to_string(i); + + if (i > 100) { + GENERATE_ERROR_MESSAGE << "unsuccessfully tried to find empty output directory. stopped at 100 iterations: " << outdir << endl; + + exit(123); + } + + i++; + } + + } + + outdir = fs::weakly_canonical(fs::path(outdir)).string(); + vector flags = args.get("flags").as>(); vector attributes = args.get("attributes").as>(); @@ -376,7 +414,9 @@ int main(int argc, char** argv) { exit(0); } + string targetDir = options.outdir; + cout << "target directory: '" << targetDir << "'" << endl; State state; state.pointsTotal = stats.totalPoints;