Skip to content

Commit

Permalink
Merge branch 'master' into dev/itk540
Browse files Browse the repository at this point in the history
  • Loading branch information
jilei-hao committed Sep 24, 2024
2 parents d5ddb24 + 75a4212 commit eea609a
Show file tree
Hide file tree
Showing 50 changed files with 8,133 additions and 3,988 deletions.
151 changes: 151 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
## This config file is only relevant for clang-format version 8.0.0
##
## Examples of each format style can be found on the in the clang-format documentation
## See: https://clang.llvm.org/docs/ClangFormatStyleOptions.html for details of each option
##
## The clang-format binaries can be downloaded as part of the clang binary distributions
## from http://releases.llvm.org/download.html
##
## Use the script Utilities/Maintenance/clang-format.bash to faciliate
## maintaining a consistent code style.
##
## EXAMPLE apply code style enforcement before commit:
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --modified
## EXAMPLE apply code style enforcement after commit:
# Utilities/Maintenance/clang-format.bash --clang ${PATH_TO_CLANG_FORMAT_8.0.0} --last
---
# This configuration requires clang-format version 8.0.0 exactly.
BasedOnStyle: Mozilla
Language: Cpp
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
# clang 9.0 AllowAllArgumentsOnNextLine: true
# clang 9.0 AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
# clang 9.0 AllowShortLambdasOnASingleLine: All
# clang 9.0 features AllowShortIfStatementsOnASingleLine: Never
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: All
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
# clang 9.0 feature AfterCaseLabel: false
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
## This is the big change from historical ITK formatting!
# Historically ITK used a style similar to https://en.wikipedia.org/wiki/Indentation_style#Whitesmiths_style
# with indented braces, and not indented code. This style is very difficult to automatically
# maintain with code beautification tools. Not indenting braces is more common among
# formatting tools.
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
#clang 6.0 BreakBeforeInheritanceComma: true
BreakInheritanceList: BeforeComma
BreakBeforeTernaryOperators: true
#clang 6.0 BreakConstructorInitializersBeforeComma: true
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
## The following line allows larger lines in non-documentation code
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
IndentPPDirectives: AfterHash
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 2
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: false
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
## The following line allows larger lines in non-documentation code
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
ReflowComments: true
# We may want to sort the includes as a separate pass
SortIncludes: false
# We may want to revisit this later
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
# SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 2
UseTab: Never
...
106 changes: 101 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
PROJECT(GREEDY)

# Required CMake version
CMAKE_MINIMUM_REQUIRED(VERSION 3.10.2)
if(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0003 NEW)
CMAKE_POLICY(SET CMP0077 NEW)
Expand Down Expand Up @@ -55,6 +55,9 @@ OPTION(GREEDY_BUILD_STACK_REG "Build experimental slice stack registration code"
# Do we want to enable PDE-based methods that require sparse solvers
OPTION(GREEDY_USE_SPARSE_SOLVERS "Build registration tools that use sparse solvers" OFF)

# Do we want to build the landmark geodesic shooting registration code?
OPTION(GREEDY_BUILD_LMSHOOT "Build landmark geodesic shooting library and tools" OFF)

#--------------------------------------------------------------------------------
# Dependent packages
#--------------------------------------------------------------------------------
Expand Down Expand Up @@ -89,6 +92,14 @@ INCLUDE_DIRECTORIES(
${GREEDY_SOURCE_DIR}/src/ITKFilters/include
)

# LMShoot needs eigen
IF(GREEDY_BUILD_LMSHOOT)
FIND_PACKAGE (Eigen3 3.3 REQUIRED)
IF(EIGEN3_FOUND)
ADD_DEFINITIONS(-DHAVE_EIGEN)
ENDIF()
ENDIF()

#--------------------------------------------------------------------------------
# Hard-coded documentation
#--------------------------------------------------------------------------------
Expand Down Expand Up @@ -175,8 +186,10 @@ SET(HEADERS

# Define greedy library files
SET(GREEDY_LIB_SRC
${CMAKE_CURRENT_BINARY_DIR}/GreedyVersion.cxx
src/lddmm_data.cxx
src/lddmm_sparse.cxx
src/CommandLineHelper.cxx
src/GreedyAPI.cxx
src/GreedyMeshIO.cxx
src/GreedyParameters.cxx
Expand All @@ -188,24 +201,27 @@ SET(GREEDY_LIB_SRC

SET(LDDMM_SRC src/lddmm_main.cxx)
SET(GREEDY_SRC
${CMAKE_CURRENT_BINARY_DIR}/GreedyVersion.cxx
src/greedy_main.cxx)

SET(MACF_SRC src/macf_optimization.cxx)

SET(STACK_GREEDY_SRC
${CMAKE_CURRENT_BINARY_DIR}/GreedyVersion.cxx
src/dijkstra/ShortestPath.cxx
src/greedy_stack_reg.cxx)

SET(CHUNK_GREEDY_SRC
${CMAKE_CURRENT_BINARY_DIR}/GreedyVersion.cxx
testing/src/greedy_multi_chunk.cxx)

SET(TEMPLATE_AVG_SRC
${CMAKE_CURRENT_BINARY_DIR}/GreedyVersion.cxx
src/template_make_average.cxx)

SET(LMSHOOT_LIB_SRC
src/lmshoot/PointSetHamiltonianSystem.cxx
src/lmshoot/PointSetGeodesicShooting.cxx
src/GreedyMeshIO.cxx
src/lmshoot/PointSetGeodesicToWarp.cxx)


ADD_LIBRARY(greedyapi ${GREEDY_LIB_SRC} ${HEADERS})
TARGET_INCLUDE_DIRECTORIES(greedyapi PUBLIC ${GREEDY_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES(greedyapi ${VTK_LIBRARIES} ${ITK_LIBRARIES})
Expand Down Expand Up @@ -249,6 +265,26 @@ IF(BUILD_CLI)
ADD_DEPENDENCIES(stack_greedy docs_to_hex)
ENDIF()

IF(GREEDY_BUILD_LMSHOOT)
# Add lmshoot library
ADD_LIBRARY(lmshootapi ${LMSHOOT_LIB_SRC})
TARGET_LINK_LIBRARIES(lmshootapi ${GREEDY_API_LIBS})
TARGET_INCLUDE_DIRECTORIES(lmshootapi PRIVATE ${EIGEN3_INCLUDE_DIR})

# Add the individual programs
ADD_EXECUTABLE(lmshoot src/lmshoot/lmshoot_main.cxx)
TARGET_LINK_LIBRARIES(lmshoot lmshootapi ${GREEDY_API_LIBS})

ADD_EXECUTABLE(lmtowarp src/lmshoot/lmtowarp_main.cxx)
TARGET_LINK_LIBRARIES(lmtowarp lmshootapi ${GREEDY_API_LIBS})

ADD_EXECUTABLE(lmshoot_test src/lmshoot/TestGeodesicShooting.cxx)
TARGET_LINK_LIBRARIES(lmshoot_test lmshootapi ${GREEDY_API_LIBS})

SET(GREEDY_INSTALL_TARGETS ${GREEDY_INSTALL_TARGETS} lmshootapi lmshoot lmtowarp)

ENDIF()

ADD_EXECUTABLE(greedy ${GREEDY_SRC})
TARGET_LINK_LIBRARIES(greedy ${GREEDY_API_LIBS} ${FFTWF_LIB} ${FFTWF_THREADS_LIB} ${SPARSE_LIBRARY})

Expand All @@ -274,6 +310,61 @@ IF(INSTALL_CLI)
ENDIF()

INSTALL(TARGETS ${GREEDY_INSTALL_TARGETS} DESTINATION ${CLI_INSTALL_PATH} COMPONENT Runtime)
INSTALL(TARGETS greedyapi DESTINATION lib EXPORT GreedyTargets)
FILE(GLOB_RECURSE GREEDY_HEADER_FILES "${GREEDY_SOURCE_DIR}/src/*.h" "${GREEDY_SOURCE_DIR}/src/*.txx")
INSTALL(FILES ${GREEDY_HEADER_FILES} DESTINATION include)

IF(GREEDY_BUILD_LMSHOOT)
INSTALL(TARGETS lmshootapi DESTINATION lib EXPORT GreedyTargets)
INSTALL(FILES ${LMSHOOT_HEADER_FILES} DESTINATION include)
ENDIF()

EXPORT(EXPORT GreedyTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/GreedyTargets.cmake"
NAMESPACE Greedy::)

INSTALL(EXPORT GreedyTargets
FILE GreedyTargets.cmake
NAMESPACE Greedy::
DESTINATION ${GREEDY_BINARY_DIR})

include(CMakePackageConfigHelpers)

install(EXPORT GreedyTargets
FILE GreedyTargets.cmake
DESTINATION lib/cmake/Greedy)

set ( Greedy_INCLUDE_DIRS "include" )

# generate the config file that is includes the exports
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/GreedyConfig.cmake"
INSTALL_DESTINATION "lib/cmake/example"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
PATH_VARS Greedy_INCLUDE_DIRS)

# Also generate a config file for the build tree
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ConfigBuildTree.cmake.in
# "${CMAKE_CURRENT_BINARY_DIR}/Convert3DConfig.cmake"
# @ONLY)

#configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
# ${CMAKE_CURRENT_BINARY_DIR}/Convert3DConfig.cmake
# INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Convert3D
# PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)


# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/GreedyConfigVersion.cmake"
VERSION "${GREEDY_VERSION_FULL}"
COMPATIBILITY AnyNewerVersion)

# install the configuration file
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/GreedyConfig.cmake
DESTINATION lib/cmake/Greedy)

ENDIF(INSTALL_CLI)

Expand Down Expand Up @@ -323,4 +414,9 @@ IF(NOT GREEDY_BUILD_AS_SUBPROJECT)
ADD_TEST(NAME "Phantom_NCC_Sim_NoMask" COMMAND test_greedy phantom 1 3 NCC 7 0 WORKING_DIRECTORY ${TESTING_DATADIR})
ADD_TEST(NAME "Phantom_WNCC_Sim_NoMask" COMMAND test_greedy phantom 1 3 WNCC 7 0 WORKING_DIRECTORY ${TESTING_DATADIR})

# Add tests for lmshoot
IF(GREEDY_BUILD_LMSHOOT)
ADD_TEST(NAME "lmshoot_regression" COMMAND lmshoot_test shoot_regression.mat WORKING_DIRECTORY ${TESTING_DATADIR}/lmshoot)
ENDIF()

ENDIF(NOT GREEDY_BUILD_AS_SUBPROJECT)
5 changes: 5 additions & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@
include ( "${CMAKE_CURRENT_LIST_DIR}/GreedyTargets.cmake" )

set ( Greedy_INCLUDE_DIRS "@PACKAGE_Greedy_INCLUDE_DIRS@")
set ( Greedy_LIBRARIES greedyapi )
Loading

0 comments on commit eea609a

Please sign in to comment.