From 5221e14504fb7823e4774ce1f46595ad6e45ac14 Mon Sep 17 00:00:00 2001 From: Matthias Holoch Date: Tue, 7 May 2024 11:45:18 +0200 Subject: [PATCH 1/2] enable build of conversion tool --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3b2ccb2..846f62ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -603,6 +603,7 @@ add_subdirectory(src/liblvr2) if(BUILD_TOOLS) add_subdirectory(src/tools/lvr2_reconstruct) add_subdirectory(src/tools/lvr2_mesh_reducer) + add_subdirectory(src/tools/lvr2_hdf5_mesh_builder) endif(BUILD_TOOLS) if(BUILD_TOOLS_EXPERIMENTAL) @@ -617,7 +618,6 @@ if(BUILD_TOOLS_EXPERIMENTAL) add_subdirectory(src/tools/lvr2_plymerger) # add_subdirectory(src/tools/lvr2_hdf5_builder) add_subdirectory(src/tools/lvr2_hdf5_builder_2) - add_subdirectory(src/tools/lvr2_hdf5_mesh_builder) add_subdirectory(src/tools/lvr2_slam2hdf5) add_subdirectory(src/tools/lvr2_hdf5togeotiff) add_subdirectory(src/tools/lvr2_slam6d_merger) From ce927b059cccefe91b0617e6958691ff73efcc65 Mon Sep 17 00:00:00 2001 From: Matthias Holoch Date: Tue, 7 May 2024 11:45:29 +0200 Subject: [PATCH 2/2] fix crash when no color information exists in mesh source --- .../lvr2_hdf5_mesh_builder/HDF5MeshTool.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/tools/lvr2_hdf5_mesh_builder/HDF5MeshTool.cpp b/src/tools/lvr2_hdf5_mesh_builder/HDF5MeshTool.cpp index df8be5b3..7151084b 100644 --- a/src/tools/lvr2_hdf5_mesh_builder/HDF5MeshTool.cpp +++ b/src/tools/lvr2_hdf5_mesh_builder/HDF5MeshTool.cpp @@ -257,6 +257,7 @@ int main( int argc, char ** argv ) DenseVertexMap colors; boost::optional> colorsOpt; ChannelOptional channel_opt; + bool colorsFoundInSource = false; if (readFromHdf5) { colorsOpt = hdf5In.getDenseAttributeMap>("vertex_colors"); @@ -265,10 +266,12 @@ int main( int argc, char ** argv ) { std::cout << timestamp << "Using existing vertex colors..." << std::endl; colors = *colorsOpt; + colorsFoundInSource = true; } else if (meshBuffer != nullptr && (channel_opt = meshBuffer->getChannel("vertex_colors")) && channel_opt && channel_opt.get().width() == 3 && channel_opt.get().numElements() == hem.numVertices()) { std::cout << timestamp << "Using existing colors from mesh buffer..." << std::endl; + colorsFoundInSource = true; auto &channel = channel_opt.get(); colors.reserve(channel.numElements()); @@ -279,16 +282,23 @@ int main( int argc, char ** argv ) } if (!colorsOpt || !writeToHdf5Input) { - std::cout << timestamp << "Adding vertex colors..." << std::endl; - bool addedVertexColors = hdf5.addDenseAttributeMap>( - hem, colors, "vertex_colors"); - if (addedVertexColors) + if (colorsFoundInSource) { - std::cout << timestamp << "successfully added vertex colors" << std::endl; - } - else + std::cout << timestamp << "Adding vertex colors found in source..." << std::endl; + bool addedVertexColors = hdf5.addDenseAttributeMap>( + hem, colors, "vertex_colors"); + if (addedVertexColors) + { + std::cout << timestamp << "successfully added vertex colors" << std::endl; + } + else + { + std::cout << timestamp << "could not add vertex colors!" << std::endl; + } + } + else { - std::cout << timestamp << "could not add vertex colors!" << std::endl; + std::cout << timestamp << "Skipping vertex colors: No colors found in input file." << std::endl; } } else