From f607741abf2068e066394d2588f9edc7a328a586 Mon Sep 17 00:00:00 2001 From: Clifford Yapp <238416+starseeker@users.noreply.github.com> Date: Tue, 6 Aug 2024 15:14:40 -0400 Subject: [PATCH] Add commented out logic for SPSR repository Not adding the submodule yet - need to be sure this can actually work - but looking to use the "header only" mode of SPSR added to upstream code to replace the bundled copy in BRL-CAD. Once it is demonstrated to be working, add the submodule and uncomment in dependencies.cmake --- CMake/FindPOISSONRECON.cmake | 40 +++++++++++++++++++++++++ dependencies.cmake | 3 ++ poissonrecon/CMakeLists.txt | 53 +++++++++++++++++++++++++++++++++ poissonrecon/poissonrecon.deps | 2 ++ poissonrecon/poissonrecon.patch | 23 ++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 CMake/FindPOISSONRECON.cmake create mode 100644 poissonrecon/CMakeLists.txt create mode 100644 poissonrecon/poissonrecon.deps create mode 100644 poissonrecon/poissonrecon.patch diff --git a/CMake/FindPOISSONRECON.cmake b/CMake/FindPOISSONRECON.cmake new file mode 100644 index 00000000..a4b2ef83 --- /dev/null +++ b/CMake/FindPOISSONRECON.cmake @@ -0,0 +1,40 @@ +# Find Adaptive Multigrid Solver headers for Poisson Surface Reconstruction +# +# Once done this will define +# +# POISSONRECON_FOUND - system has Adaptive Multigrid Solver headers +# POISSONRECON_INCLUDE_DIR - the Adaptive Multigrid Solver include directory +# +# and the following imported target: +# +# POISSONRECON::POISSONRECON- Provides include dir for headers + +set(_POISSONRECON_SEARCHES) + +# Search POISSONRECON_ROOT first if it is set. +if(POISSONRECON_ROOT) + set(_POISSONRECON_SEARCH_ROOT PATHS ${POISSONRECON_ROOT} NO_DEFAULT_PATH) + list(APPEND _POISSONRECON_SEARCHES _POISSONRECON_SEARCH_ROOT) +endif() + +# Try each search configuration. +foreach(search ${_POISSONRECON_SEARCHES}) + find_path(POISSONRECON_INCLUDE_DIR NAMES SPSR/Reconstructors.h ${${search}} PATH_SUFFIXES include) +endforeach() + +mark_as_advanced(POISSONRECON_INCLUDE_DIR) + +# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(POISSONRECON REQUIRED_VARS POISSONRECON_INCLUDE_DIR) + +if(POISSONRECON_FOUND) + set(POISSONRECON_INCLUDE_DIRS ${POISSONRECON_INCLUDE_DIR}) + + if(NOT TARGET POISSONRECON::POISSONRECON) + add_library(POISSONRECON::POISSONRECON UNKNOWN IMPORTED) + set_target_properties(POISSONRECON::POISSONRECON PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${POISSONRECON_INCLUDE_DIRS}") + endif() +endif() diff --git a/dependencies.cmake b/dependencies.cmake index 45f9ee37..aed765e9 100644 --- a/dependencies.cmake +++ b/dependencies.cmake @@ -231,6 +231,9 @@ add_project(opencv GROUPS "BRLCAD_EXTRA") # https://github.com/davideberly/GeometricTools add_project(gte GROUPS "BRLCAD") +# Adaptive Multigrid Solvers - Poisson Surface Reconstruction code. +# https://github.com/mkazhdan/PoissonRecon +#add_project(poissonrecon GROUPS "BRLCAD") # OpenMesh Library - library for representing and manipulating polygonal meshes # https://www.graphics.rwth-aachen.de/software/openmesh/ diff --git a/poissonrecon/CMakeLists.txt b/poissonrecon/CMakeLists.txt new file mode 100644 index 00000000..e3ee2fe7 --- /dev/null +++ b/poissonrecon/CMakeLists.txt @@ -0,0 +1,53 @@ +# Decide if we're using GeometricTools +cad_enable(POISSONRECON "libbg") + +unset(POISSONRECON_BUNDLED CACHE) + +if (NOT ENABLE_POISSONRECON AND NOT DISABLE_POISSONRECON) + + # https://github.com/mkazhdan/PoissonRecon/ + find_package(POISSONRECON) + + if (NOT TARGET POISSONRECON::POISSONRECON) + set(ENABLE_POISSONRECON "ON" CACHE BOOL "Enable SPSR build") + endif (NOT TARGET POISSONRECON::POISSONRECON) + +endif (NOT ENABLE_POISSONRECON AND NOT DISABLE_POISSONRECON) + +set(ENABLE_POISSONRECON "${ENABLE_POISSONRECON}" CACHE BOOL "Enable SPSR build") + +# Decision made + +if (ENABLE_POISSONRECON) + + git_submodule_init(PoissonRecon POISSONRECON/CMakeLists.txt) + + TargetDeps(POISSONRECON) + + ExternalProject_Add(POISSONRECON_BLD + URL "${CMAKE_CURRENT_SOURCE_DIR}/PoissonRecon" + BUILD_ALWAYS ${EXT_BUILD_ALWAYS} ${LOG_OPTS} + PATCH_COMMAND ${PATCH_EXECUTABLE};-E;-p1;${PATCH_OPTIONS};-i;${CMAKE_CURRENT_SOURCE_DIR}/poissonrecon.patch + CMAKE_ARGS + ${BUILD_TYPE_SPECIFIER} + -DCMAKE_INSTALL_PREFIX=${CMAKE_NOBUNDLE_INSTALL_PREFIX} + LOG_CONFIGURE ${EXT_BUILD_QUIET} + LOG_BUILD ${EXT_BUILD_QUIET} + LOG_INSTALL ${EXT_BUILD_QUIET} + LOG_OUTPUT_ON_FAILURE ${EXT_BUILD_QUIET} + STEP_TARGETS install + ) + + TargetInstallDeps(POISSONRECON POISSONRECON_DEPENDS) + + set(POISSONRECON_BUNDLED TRUE CACHE BOOL "SPSR bundle flag") + +endif (ENABLE_POISSONRECON) + +# Local Variables: +# tab-width: 8 +# mode: cmake +# indent-tabs-mode: t +# End: +# ex: shiftwidth=2 tabstop=8 + diff --git a/poissonrecon/poissonrecon.deps b/poissonrecon/poissonrecon.deps new file mode 100644 index 00000000..ecdeab5f --- /dev/null +++ b/poissonrecon/poissonrecon.deps @@ -0,0 +1,2 @@ +PATCH + diff --git a/poissonrecon/poissonrecon.patch b/poissonrecon/poissonrecon.patch new file mode 100644 index 00000000..c06be944 --- /dev/null +++ b/poissonrecon/poissonrecon.patch @@ -0,0 +1,23 @@ +diff -Naur PoissonRecon/CMakeLists.txt POISSONRECON_BLD/CMakeLists.txt +--- PoissonRecon/CMakeLists.txt 1969-12-31 19:00:00.000000000 -0500 ++++ POISSONRECON_BLD/CMakeLists.txt 2024-07-31 16:48:17.163077007 -0400 +@@ -0,0 +1,19 @@ ++cmake_minimum_required(VERSION 3.8) ++ ++project(SPSR) ++ ++file(GLOB SPSR_FILES "${CMAKE_SOURCE_DIR}/Src/*") ++ ++if(NOT DEFINED INCLUDE_DIR) ++ set(INCLUDE_DIR include) ++endif(NOT DEFINED INCLUDE_DIR) ++ ++install(FILES ${SPSR_FILES} DESTINATION ${INCLUDE_DIR}/SPSR) ++ ++# Local Variables: ++# tab-width: 8 ++# mode: cmake ++# indent-tabs-mode: t ++# End: ++# ex: shiftwidth=2 tabstop=8 ++