Skip to content

Commit

Permalink
Add commented out logic for SPSR repository
Browse files Browse the repository at this point in the history
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
  • Loading branch information
starseeker committed Aug 6, 2024
1 parent 1c367b9 commit f607741
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
40 changes: 40 additions & 0 deletions CMake/FindPOISSONRECON.cmake
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 3 additions & 0 deletions dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
53 changes: 53 additions & 0 deletions poissonrecon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions poissonrecon/poissonrecon.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PATCH

23 changes: 23 additions & 0 deletions poissonrecon/poissonrecon.patch
Original file line number Diff line number Diff line change
@@ -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
+

0 comments on commit f607741

Please sign in to comment.