Skip to content

Commit

Permalink
Merge pull request #20 from naturerobots/h5-conversion-tool-fixes
Browse files Browse the repository at this point in the history
H5 conversion tool fixes
  • Loading branch information
amock committed May 16, 2024
2 parents 1da6abb + c7cf9f9 commit c3569a2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,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)
Expand All @@ -627,7 +628,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)
Expand Down
26 changes: 18 additions & 8 deletions src/tools/lvr2_hdf5_mesh_builder/HDF5MeshTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ int main( int argc, char ** argv )
DenseVertexMap<color> colors;
boost::optional<DenseVertexMap<color>> colorsOpt;
ChannelOptional<uint8_t> channel_opt;
bool colorsFoundInSource = false;
if (readFromHdf5)
{
colorsOpt = hdf5In.getDenseAttributeMap<DenseVertexMap<color>>("vertex_colors");
Expand All @@ -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<uint8_t>("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());
Expand All @@ -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<DenseVertexMap<color>>(
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<DenseVertexMap<color>>(
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
Expand Down

0 comments on commit c3569a2

Please sign in to comment.