Skip to content

Commit

Permalink
viewer and experimental tools are compiling again
Browse files Browse the repository at this point in the history
  • Loading branch information
amock committed Dec 9, 2024
1 parent 3942c1a commit 2a78b79
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 85 deletions.
134 changes: 79 additions & 55 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.16)
project(lvr2 VERSION 3.0.0)

# OPTIONS
Expand Down Expand Up @@ -187,14 +187,15 @@ endif(WITH_CV_NONFREE)
# Searching for FLANN
#------------------------------------------------------------------------------
find_package(FLANN REQUIRED)
if(FLANN_FOUND)
message(STATUS "Found FLANN library: ${FLANN_INCLUDE_DIR}")
include_directories(${FLANN_INCLUDRE_DIR})
endif(FLANN_FOUND)
message(STATUS "Found FLANN library: ${FLANN_INCLUDE_DIR}")
include_directories(${FLANN_INCLUDRE_DIR})

#------------------------------------------------------------------------------
# Searching for LZ4
#------------------------------------------------------------------------------
find_package(Lz4 REQUIRED)
include_directories( ${LZ4_INCLUDE_DIR} )
message(STATUS "Found LZ4 library: ${LZ4_LIBRARY}")
include_directories(${LZ4_INCLUDE_DIR})
message(STATUS "Found LZ4 library: ${LZ4_INCLUDE_DIR}")

#------------------------------------------------------------------------------
# Searching for GSL
Expand Down Expand Up @@ -223,6 +224,56 @@ if(OPENCL_FOUND)
endif(OpenCL_NEW_API)
endif(OPENCL_FOUND)

if(BUILD_VIEWER)
#------------------------------------------------------------------------------
# Searching for VTK
#------------------------------------------------------------------------------
set(VTK_QT_VERSION 5)
find_package(VTK REQUIRED)

if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_EQUAL "8")
# patched QVTKOpenGL header because of name clash with signals.
add_subdirectory(ext/QVTKOpenGLWidget)
include_directories(BEFORE ${QVTK_PATCHED_INCLUDE_DIR} )
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${QVTK_PATCHED_INCLUDE_DIR})
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK8)
elseif(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_EQUAL "9")
add_subdirectory(ext/QVTKOpenGLWidget)
include_directories(BEFORE ${QVTK_PATCHED_INCLUDE_DIR} )
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${QVTK_PATCHED_INCLUDE_DIR})
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK9)
endif()
if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_LESS "6")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK5)
endif()

if(VTK_MAJOR_VERSION VERSION_EQUAL "7")
if(VTK_MINOR_VERSION VERSION_GREATER "0")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()
endif()

if(VTK_MAJOR_VERSION VERSION_GREATER "7")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()

if(VTK_VERSION VERSION_GREATER "7")

list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
set(VTK_COMPONENTS "${VTK_AVAILABLE_COMPONENTS}")
set(VTK_HAS_QT OFF)
foreach(VTK_COMPONENT ${VTK_COMPONENTS})
if("${VTK_COMPONENT}" STREQUAL "GUISupportQt")
set(VTK_HAS_QT ON)
endif()
endforeach()

message(STATUS "Found VTK (Version > 7)")
if(VTK_HAS_QT)
message(STATUS "Found VTK compoment QVTK")
endif()
endif()
endif(BUILD_VIEWER)

#------------------------------------------------------------------------------
# Searching for NABO
Expand Down Expand Up @@ -726,8 +777,9 @@ if(BUILD_TOOLS_EXPERIMENTAL)

endif(BUILD_TOOLS_EXPERIMENTAL)



###############################################################################
# LVR2 EXAMPLES
###############################################################################
if(BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
Expand All @@ -736,53 +788,9 @@ endif()
# LVR2 VIEWER + LVR2 ASCII VIEWER
###############################################################################
if(BUILD_VIEWER)
#------------------------------------------------------------------------------
# Searching for VTK
#------------------------------------------------------------------------------
set(VTK_QT_VERSION 5)
find_package(VTK REQUIRED)

if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_EQUAL "8")
# patched QVTKOpenGL header because of name clash with signals.
add_subdirectory(ext/QVTKOpenGLWidget)
include_directories(BEFORE ${QVTK_PATCHED_INCLUDE_DIR} )
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${QVTK_PATCHED_INCLUDE_DIR})
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK8)
elseif(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_EQUAL "9")
add_subdirectory(ext/QVTKOpenGLWidget)
include_directories(BEFORE ${QVTK_PATCHED_INCLUDE_DIR} )
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${QVTK_PATCHED_INCLUDE_DIR})
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK9)
endif()
if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_LESS "6")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK5)
endif()

if(VTK_MAJOR_VERSION VERSION_EQUAL "7")
if(VTK_MINOR_VERSION VERSION_GREATER "0")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()
endif()

if(VTK_MAJOR_VERSION VERSION_GREATER "7")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()

if(VTK_VERSION VERSION_GREATER "7")

list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
set(VTK_COMPONENTS "${VTK_AVAILABLE_COMPONENTS}")
set(VTK_HAS_QT OFF)
foreach(VTK_COMPONENT ${VTK_COMPONENTS})
if("${VTK_COMPONENT}" STREQUAL "GUISupportQt")
set(VTK_HAS_QT ON)
endif()
endforeach()

message(STATUS "Found VTK (Version > 7)")
if(VTK_HAS_QT)
message(STATUS "Found VTK compoment QVTK")
endif()
if(DEFINED VTK_USE_FILE)
include(${VTK_USE_FILE})
endif()

find_package(Qt5 COMPONENTS Core Widgets Xml OpenGL)
Expand Down Expand Up @@ -856,6 +864,22 @@ install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ext/HighFive/include/
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ext/spdlog/include/
DESTINATION "include")


###############################################################################
# Uninstall
###############################################################################
# https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/lvr2-uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/lvr2-uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/lvr2-uninstall.cmake
COMMENT "Uninstall lvr2 libraries and all header files")
endif()

###############################################################################
# DOCUMENTATION
###############################################################################
Expand Down
60 changes: 57 additions & 3 deletions CMakeModules/FindLz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,60 @@
# LZ4_LIBRARY, path to liblz4.so
# LZ4_FOUND, whether lz4 has been found

find_package(PkgConfig REQUIRED)
pkg_check_modules(lz4 REQUIRED IMPORTED_TARGET liblz4)
set(LZ4_LIBRARY PkgConfig::lz4)
set(LZ4_FOUND FALSE)

message(STATUS "Try to find LZ4: find_path + find_library")
find_path(LZ4_INCLUDE_DIR
NAMES lz4.h
DOC "lz4 include directory")

find_library(LZ4_LIBRARY
NAMES lz4 liblz4
DOC "lz4 library")

if(NOT LZ4_FOUND)
message(STATUS "Try to find LZ4: FindPackageHandleStandardArgs")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LZ4
REQUIRED_VARS LZ4_LIBRARY LZ4_INCLUDE_DIR
VERSION_VAR LZ4_VERSION)
endif(NOT LZ4_FOUND)

if (LZ4_INCLUDE_DIR)
file(STRINGS "${LZ4_INCLUDE_DIR}/lz4.h" _lz4_version_lines
REGEX "#define[ \t]+LZ4_VERSION_(MAJOR|MINOR|RELEASE)")
string(REGEX REPLACE ".*LZ4_VERSION_MAJOR *\([0-9]*\).*" "\\1" _lz4_version_major "${_lz4_version_lines}")
string(REGEX REPLACE ".*LZ4_VERSION_MINOR *\([0-9]*\).*" "\\1" _lz4_version_minor "${_lz4_version_lines}")
string(REGEX REPLACE ".*LZ4_VERSION_RELEASE *\([0-9]*\).*" "\\1" _lz4_version_release "${_lz4_version_lines}")
set(LZ4_VERSION "${_lz4_version_major}.${_lz4_version_minor}.${_lz4_version_release}")
unset(_lz4_version_major)
unset(_lz4_version_minor)
unset(_lz4_version_release)
unset(_lz4_version_lines)
endif()

if(NOT LZ4_FOUND)
find_package(PkgConfig)
pkg_search_module(LZ4 lz4 liblz4)
if(TARGET PkgConfig::LZ4)
set(LZ4_INCLUDE_DIR ${LZ4_INCLUDEDIR})
set(LZ4_LIBRARY PkgConfig::LZ4)
set(LZ4_FOUND TRUE)
endif(TARGET PkgConfig::LZ4)
endif(NOT LZ4_FOUND)

if (LZ4_FOUND)
set(LZ4_INCLUDE_DIRS "${LZ4_INCLUDE_DIR}")
set(LZ4_LIBRARIES "${LZ4_LIBRARY}")

if (NOT TARGET LZ4::LZ4)
add_library(LZ4::LZ4 UNKNOWN IMPORTED)
set_target_properties(LZ4::LZ4 PROPERTIES
IMPORTED_LOCATION "${LZ4_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}")
endif ()
endif ()

mark_as_advanced(LZ4_FOUND)
mark_as_advanced(LZ4_INCLUDE_DIR)
mark_as_advanced(LZ4_LIBRARY)
17 changes: 17 additions & 0 deletions CMakeModules/lvr2-uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif()
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif()
endforeach()
1 change: 1 addition & 0 deletions LVR2Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ list(APPEND LVR2_LIBRARIES ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES})
## OPTIONAL DEPS ##
#####################

# VTK
if(@VTK_FOUND@)
find_package(VTK REQUIRED)
list(APPEND LVR2_INCLUDE_DIRS ${VTK_INCLUDE_DIRS})
Expand Down
2 changes: 1 addition & 1 deletion ext/laslib/src/bytestreamin_istream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ inline BOOL ByteStreamInIstream::seek(const I64 position)

inline BOOL ByteStreamInIstream::seekEnd(const I64 distance)
{
stream.seekg(static_cast<streamoff>(-distance), ios::end);
stream.seekg(static_cast<streamoff>(-distance), std::ios::end);
return stream.good();
}

Expand Down
2 changes: 1 addition & 1 deletion ext/laslib/src/bytestreamout_ostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ inline BOOL ByteStreamOutOstream::seek(I64 position)

inline BOOL ByteStreamOutOstream::seekEnd()
{
stream.seekp(0, ios::end);
stream.seekp(0, std::ios::end);
return stream.good();
}

Expand Down
4 changes: 2 additions & 2 deletions include/lvr2/reconstruction/LargeScaleReconstruction.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,10 @@ namespace lvr2
largeScale << "/tmp/lvr2_lsr_mpi_" << rank << "_" << chunk;

std::ifstream fl(largeScale.str());
fl.seekg(0, ios::end);
fl.seekg(0, std::ios::end);
int len = fl.tellg();
char* result = new char[len];
fl.seekg(0, ios::beg);
fl.seekg(0, std::ios::beg);
fl.read(result, len);
fl.close();

Expand Down
2 changes: 1 addition & 1 deletion src/liblvr2/registration/GraphSLAM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ void GraphSLAM::fillEquation(const vector<SLAMScanPtr>& scans, const Graph& grap
int x, y;
for (auto& e : result)
{
tie(x, y) = e.first;
std::tie(x, y) = e.first;
Matrix6d& m = e.second;
for (int dx = 0; dx < 6; dx++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/tools/lvr2_ground_level_extractor/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ int main(int argc, char* argv[])
{
// Right now, LVR2 doesn't support Large Coordinates and we can't use the Translation fully
// In Functions where we use the Matrix we need to exclude the Translation
tie(affineMatrix,affineTranslation) = computeAffineGeoRefMatrix(srcPoints,dstPoints,numberOfPoints);
std::tie(affineMatrix,affineTranslation) = computeAffineGeoRefMatrix(srcPoints,dstPoints,numberOfPoints);
fullAffineMatrix = affineTranslation * affineMatrix;

// Check, if Rotation is supported
Expand Down
Loading

0 comments on commit 2a78b79

Please sign in to comment.