diff --git a/CMake/PackageDepends/MITK_MatchPoint_Config.cmake b/CMake/PackageDepends/MITK_MatchPoint_Config.cmake
new file mode 100644
index 0000000000..7f81ac7e80
--- /dev/null
+++ b/CMake/PackageDepends/MITK_MatchPoint_Config.cmake
@@ -0,0 +1,2 @@
+list(APPEND ALL_INCLUDE_DIRECTORIES ${MatchPoint_INCLUDE_DIRS})
+list(APPEND ALL_LIBRARIES MAPCore MAPIO MAPDeployment MAPAlgorithms MAPAlgorithmsITK MAPAlgorithmsPlastimatch)
diff --git a/CMake/mitkFunctionCreateMatchPointDeployedAlgorithm.cmake b/CMake/mitkFunctionCreateMatchPointDeployedAlgorithm.cmake
new file mode 100644
index 0000000000..d44b85510b
--- /dev/null
+++ b/CMake/mitkFunctionCreateMatchPointDeployedAlgorithm.cmake
@@ -0,0 +1,102 @@
+#!
+#! Create a Command Line App.
+#!
+#! \brief This function will create a command line executable and the scripts required to run it
+#!
+#! \param NAME (required) Name of the algorithm / cmake target
+#! \param DEPENDS (optional) Required MITK modules beyond MitkCommandLine
+#! \param PACKAGE_DEPENDS (optional) list of "packages" this command line app depends on (e.g. ITK, VTK, etc.)
+#! \param CPP_FILES (optional) list of cpp files, if it is not given NAME.cpp is assumed
+#! \param INCLUDE_DIRS (optional): All directories that should be added as include dirs to the project
+#! \param PROFILE (optional): The profile file that should be used for the algorithm. If not set it is "./.profile".
+#! \param ADDITIONAL_LIBS (optional) List of additional private libraries linked to this module.
+#! The folder containing the library will be added to the global list of library search paths.
+#! \param H_FILES (optional) List of public header files for this module.
+#! Assuming that there exists a file called MyApp.cpp
, an example call looks like:
+#! \code
+#! mitkFunctionCreateCommandLineApp(
+#! NAME MyApp
+#! DEPENDS MitkCore MitkPlanarFigure
+#! PACKAGE_DEPENDS ITK VTK
+#! )
+#! \endcode
+#!
+
+function(mitkFunctionCreateMatchPointDeployedAlgorithm)
+
+ set(_function_params
+ NAME # Name of the algorithm/target
+ )
+
+ set(_function_multiparams
+ DEPENDS # list of modules this command line app depends on
+ PACKAGE_DEPENDS # list of "packages" this command line app depends on (e.g. ITK, VTK, etc.)
+ CPP_FILES # (optional) list of cpp files, if it is not given NAME.cpp is assumed
+ INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE]
+ ADDITIONAL_LIBS # list of addidtional private libraries linked to this module.
+ H_FILES # list of header files: [PUBLIC|PRIVATE]
+ )
+
+ set(_function_options
+
+ )
+
+ cmake_parse_arguments(ALG "${_function_options}" "${_function_params}" "${_function_multiparams}" ${ARGN})
+
+ if( NOT (DEFINED MITK_USE_MatchPoint) OR NOT (${MITK_USE_MatchPoint}))
+ message(FATAL_ERROR "Need package Matchpoint to deploy MatchPoint Algorithms.")
+ endif()
+
+ if(NOT ALG_NAME)
+ message(FATAL_ERROR "NAME argument cannot be empty.")
+ endif()
+
+ SET(ALG_TARGET "MDRA_${ALG_NAME}")
+
+ if(NOT ALG_CPP_FILES)
+ set(ALG_CPP_FILES "${ALG_NAME}.cpp")
+ endif()
+
+ IF(NOT ALG_PROFILE)
+ set(ALG_PROFILE "${ALG_NAME}.profile")
+ ENDIF(NOT ALG_PROFILE)
+
+ MESSAGE(STATUS "... generate MDRA profile (from ${ALG_PROFILE})...")
+
+ include(${MatchPoint_SOURCE_DIR}/CMake/mapFunctionCreateAlgorithmProfile.cmake)
+ CREATE_ALGORITHM_PROFILE(${ALG_NAME} ${ALG_PROFILE})
+
+ MESSAGE(STATUS "... algorithm UID: ${ALGORITHM_PROFILE_UID}")
+
+ ADD_LIBRARY(${ALG_TARGET} SHARED ${ALG_CPP_FILES} ${ALGORITHM_PROFILE_FILE})
+
+ SET_TARGET_PROPERTIES(${ALG_TARGET} PROPERTIES
+ OUTPUT_NAME "mdra-${MatchPoint_VERSION_MAJOR}-${MatchPoint_VERSION_MINOR}_${ALG_NAME}"
+ OUTPUT_NAME_DEBUG "mdra-D-${MatchPoint_VERSION_MAJOR}-${MatchPoint_VERSION_MINOR}_${ALG_NAME}"
+ PREFIX "" )
+
+ mitk_use_modules(TARGET ${ALG_TARGET}
+ MODULES ${ALG_DEPENDS}
+ PACKAGES PRIVATE ITK MatchPoint ${ALG_PACKAGE_DEPENDS}
+ )
+
+ target_include_directories(${ALG_TARGET} PRIVATE ${ALG_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
+
+ if(ALG_ADDITIONAL_LIBS)
+ target_link_libraries(${ALG_TARGET} PRIVATE ${ALG_ADDITIONAL_LIBS})
+ get_property(_mitk_additional_library_search_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
+ foreach(_lib_filepath ${ALG_ADDITIONAL_LIBS})
+ get_filename_component(_search_path "${_lib_filepath}" PATH)
+ if(_search_path)
+ list(APPEND _mitk_additional_library_search_paths "${_search_path}")
+ endif()
+ endforeach()
+ if(_mitk_additional_library_search_paths)
+ list(REMOVE_DUPLICATES _mitk_additional_library_search_paths)
+ set_property(GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS ${_mitk_additional_library_search_paths})
+ endif()
+ endif()
+
+ install(TARGETS ${ALG_TARGET} RUNTIME DESTINATION bin LIBRARY DESTINATION bin)
+
+endfunction()
diff --git a/CMake/mitkFunctionCreateModule.cmake b/CMake/mitkFunctionCreateModule.cmake
index 7dc9b255bd..df79827d47 100644
--- a/CMake/mitkFunctionCreateModule.cmake
+++ b/CMake/mitkFunctionCreateModule.cmake
@@ -1,655 +1,655 @@
##################################################################
#
# mitk_create_module
#
#! Creates a module for the automatic module dependency system within MITK.
#!
#! Example:
#!
#! \code
#! mitk_create_module(
#! DEPENDS PUBLIC MitkCore
#! PACKAGE_DEPENDS
#! PRIVATE Qt5|Xml+Networking
#! PUBLIC ITK|Watershed
#! WARNINGS_AS_ERRORS
#! \endcode
#!
#! The parameter specifies the name of the module which is used
#! to create a logical target name. The parameter is optional in case the
#! MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME variable evaluates to TRUE. The
#! module name will then be derived from the directory name in which this
#! function is called.
#!
#! If set, the following variables will be used to validate the module name:
#!
#! MITK_MODULE_NAME_REGEX_MATCH The module name must match this regular expression.
#! MITK_MODULE_NAME_REGEX_NOT_MATCH The module name must not match this regular expression.
#!
#! If the MITK_MODULE_NAME_PREFIX variable is set, the module name will be prefixed
#! with its contents.
#!
#! A modules source files are specified in a separate CMake file usually
#! called files.cmake, located in the module root directory. The
#! mitk_create_module() macro evaluates the following CMake variables
#! from the files.cmake file:
#!
#! - CPP_FILES A list of .cpp files
#! - H_FILES A list of .h files without a corresponding .cpp file
#! - TXX_FILES A list of .txx files
#! - RESOURCE_FILES A list of files (resources) which are embedded into the module
#! - MOC_H_FILES A list of Qt header files which should be processed by the MOC
#! - UI_FILES A list of .ui Qt UI files
#! - QRC_FILES A list of .qrc Qt resource files
#! - DOX_FILES A list of .dox Doxygen files
#!
#! List of variables available after the function is called:
#! - MODULE_NAME
#! - MODULE_TARGET
#! - MODULE_IS_ENABLED
#! - MODULE_SUBPROJECTS
#!
#! \sa mitk_create_executable
#!
#! Parameters (all optional):
#!
#! \param The module name (also used as target name)
#! \param FILES_CMAKE File name of a CMake file setting source list variables
#! (defaults to files.cmake)
#! \param VERSION Module version number, e.g. "1.2.0"
#! \param AUTOLOAD_WITH A module target name identifying the module which will
#! trigger the automatic loading of this module
#! \param DEPRECATED_SINCE Marks this modules as deprecated since
#! \param DESCRIPTION A description for this module
#!
#! Multi-value Parameters (all optional):
#!
#! \param SUBPROJECTS List of CDash labels
#! \param INCLUDE_DIRS Include directories for this module:
#! \verbatim
#! [[PUBLIC|PRIVATE|INTERFACE] ...]...
#! \endverbatim
#! The default scope for include directories is PUBLIC.
#! \param DEPENDS List of module dependencies:
#! \verbatim
#! [[PUBLIC|PRIVATE|INTERFACE] ...]...
#! \endverbatim
#! The default scope for module dependencies is PUBLIC.
#! \param PACKAGE_DEPENDS List of public packages dependencies (e.g. Qt, VTK, etc.).
#! Package dependencies have the following syntax:
#! \verbatim
#! [PUBLIC|PRIVATE|INTERFACE] PACKAGE[|COMPONENT1[+COMPONENT2]...]
#! \endverbatim
#! The default scope for package dependencies is PRIVATE.
-#! \param ADDITIONAL_LIBS List of addidtional private libraries linked to this module.
+#! \param ADDITIONAL_LIBS List of additional private libraries linked to this module.
#! The folder containing the library will be added to the global list of library search paths.
#! \param CPP_FILES List of source files for this module. If the list is non-empty,
#! the module does not need to provide a files.cmake file or FILES_CMAKE argument.
#! \param H_FILES List of public header files for this module. It is recommended to use
#! a files.cmake file instead.
#!
#! Options (optional)
#!
#! \param FORCE_STATIC Force building this module as a static library
#! \param GCC_DEFAULT_VISIBILITY Do not use gcc visibility flags - all
#! symbols will be exported
#! \param NO_INIT Do not create CppMicroServices initialization code
#! \param NO_FEATURE_INFO Do not create a feature info by calling add_feature_info()
#! \param WARNINGS_AS_ERRORS Treat compiler warnings as errors
#
##################################################################
function(mitk_create_module)
set(_macro_params
VERSION # module version number, e.g. "1.2.0"
EXPORT_DEFINE # export macro name for public symbols of this module (DEPRECATED)
AUTOLOAD_WITH # a module target name identifying the module which will trigger the
# automatic loading of this module
FILES_CMAKE # file name of a CMake file setting source list variables
# (defaults to files.cmake)
DEPRECATED_SINCE # marks this modules as deprecated
DESCRIPTION # a description for this module
)
set(_macro_multiparams
SUBPROJECTS # list of CDash labels
INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE]
INTERNAL_INCLUDE_DIRS # include dirs internal to this module (DEPRECATED)
DEPENDS # list of modules this module depends on: [PUBLIC|PRIVATE|INTERFACE]
DEPENDS_INTERNAL # list of modules this module internally depends on (DEPRECATED)
PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.): [PUBLIC|PRIVATE|INTERFACE]
TARGET_DEPENDS # list of CMake targets this module should depend on
ADDITIONAL_LIBS # list of addidtional private libraries linked to this module.
CPP_FILES # list of cpp files
H_FILES # list of header files: [PUBLIC|PRIVATE]
)
set(_macro_options
FORCE_STATIC # force building this module as a static library
HEADERS_ONLY # this module is a headers-only library
GCC_DEFAULT_VISIBILITY # do not use gcc visibility flags - all symbols will be exported
NO_DEFAULT_INCLUDE_DIRS # do not add default include directories like "include" or "."
NO_INIT # do not create CppMicroServices initialization code
NO_FEATURE_INFO # do not create a feature info by calling add_feature_info()
WARNINGS_AS_ERRORS # treat all compiler warnings as errors
EXECUTABLE # create an executable; do not use directly, use mitk_create_executable() instead
C_MODULE # compile all source files as C sources
CXX_MODULE # compile all source files as C++ sources
)
cmake_parse_arguments(MODULE "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN})
set(MODULE_NAME ${MODULE_UNPARSED_ARGUMENTS})
# -----------------------------------------------------------------
# Sanity checks
if(NOT MODULE_NAME)
if(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME)
get_filename_component(MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
else()
message(SEND_ERROR "The module name must not be empty")
endif()
endif()
set(_deprecated_args INTERNAL_INCLUDE_DIRS DEPENDS_INTERNAL EXPORT_DEFINE TARGET_DEPENDS HEADERS_ONLY)
foreach(_deprecated_arg ${_deprecated_args})
if(MODULE_${_deprecated_arg})
message(WARNING "The ${_deprecated_arg} argument is deprecated")
endif()
endforeach()
set(_module_type module)
set(_Module_type Module)
if(MODULE_EXECUTABLE)
set(_module_type executable)
set(_Module_type Executable)
endif()
if(MITK_MODULE_NAME_REGEX_MATCH)
if(NOT ${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_MATCH})
message(SEND_ERROR "The ${_module_type} name \"${MODULE_NAME}\" does not match the regular expression \"${MITK_MODULE_NAME_REGEX_MATCH}\".")
endif()
endif()
if(MITK_MODULE_NAME_REGEX_NOT_MATCH)
if(${MODULE_NAME} MATCHES ${MITK_MODULE_NAME_REGEX_NOT_MATCH})
message(SEND_ERROR "The ${_module_type} name \"${MODULE_NAME}\" must not match the regular expression \"${MITK_MODULE_NAME_REGEX_NOT_MATCH}\".")
endif()
endif()
if(MITK_MODULE_NAME_PREFIX AND NOT MODULE_NAME MATCHES "^${MITK_MODULE_NAME_PREFIX}.*$")
set(MODULE_NAME "${MITK_MODULE_NAME_PREFIX}${MODULE_NAME}")
endif()
if(NOT MODULE_FILES_CMAKE)
set(MODULE_FILES_CMAKE files.cmake)
endif()
if(NOT IS_ABSOLUTE ${MODULE_FILES_CMAKE})
set(MODULE_FILES_CMAKE ${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE})
endif()
if(NOT MODULE_SUBPROJECTS)
if(MITK_DEFAULT_SUBPROJECTS)
set(MODULE_SUBPROJECTS ${MITK_DEFAULT_SUBPROJECTS})
endif()
endif()
# check if the subprojects exist as targets
if(MODULE_SUBPROJECTS)
foreach(subproject ${MODULE_SUBPROJECTS})
if(NOT TARGET ${subproject})
message(SEND_ERROR "The subproject ${subproject} does not have a corresponding target")
endif()
endforeach()
endif()
# -----------------------------------------------------------------
# Check if module should be build
set(MODULE_TARGET ${MODULE_NAME})
# assume worst case
set(MODULE_IS_ENABLED 0)
# first we check if we have an explicit module build list
if(MITK_MODULES_TO_BUILD)
list(FIND MITK_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX)
if(_MOD_INDEX EQUAL -1)
set(MODULE_IS_EXCLUDED 1)
endif()
endif()
if(NOT MODULE_IS_EXCLUDED)
# first of all we check for the dependencies
_mitk_parse_package_args(${MODULE_PACKAGE_DEPENDS})
mitk_check_module_dependencies(MODULES ${MODULE_DEPENDS}
PACKAGES ${PACKAGE_NAMES}
MISSING_DEPENDENCIES_VAR _MISSING_DEP
PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES)
if(_MISSING_DEP)
if(MODULE_NO_FEATURE_INFO)
message("${_Module_type} ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}")
endif()
set(MODULE_IS_ENABLED 0)
else()
set(MODULE_IS_ENABLED 1)
# now check for every package if it is enabled. This overlaps a bit with
# MITK_CHECK_MODULE ...
foreach(_package ${PACKAGE_NAMES})
if((DEFINED MITK_USE_${_package}) AND NOT (MITK_USE_${_package}))
message("${_Module_type} ${MODULE_NAME} won't be built. Turn on MITK_USE_${_package} if you want to use it.")
set(MODULE_IS_ENABLED 0)
break()
endif()
endforeach()
endif()
endif()
# -----------------------------------------------------------------
# Start creating the module
if(MODULE_IS_ENABLED)
# clear variables defined in files.cmake
set(RESOURCE_FILES )
set(CPP_FILES )
set(H_FILES )
set(TXX_FILES )
set(DOX_FILES )
set(UI_FILES )
set(MOC_H_FILES )
set(QRC_FILES )
# clear other variables
set(Q${KITNAME}_GENERATED_CPP )
set(Q${KITNAME}_GENERATED_MOC_CPP )
set(Q${KITNAME}_GENERATED_QRC_CPP )
set(Q${KITNAME}_GENERATED_UI_CPP )
# check and set-up auto-loading
if(MODULE_AUTOLOAD_WITH)
if(NOT TARGET "${MODULE_AUTOLOAD_WITH}")
message(SEND_ERROR "The module target \"${MODULE_AUTOLOAD_WITH}\" specified as the auto-loading module for \"${MODULE_NAME}\" does not exist")
endif()
endif()
set(_module_autoload_meta_target "${CMAKE_PROJECT_NAME}-autoload")
# create a meta-target if it does not already exist
if(NOT TARGET ${_module_autoload_meta_target})
add_custom_target(${_module_autoload_meta_target})
endif()
if(NOT MODULE_EXPORT_DEFINE)
set(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT)
endif()
if(MITK_GENERATE_MODULE_DOT)
message("MODULEDOTNAME ${MODULE_NAME}")
foreach(dep ${MODULE_DEPENDS})
message("MODULEDOT \"${MODULE_NAME}\" -> \"${dep}\" ; ")
endforeach(dep)
endif(MITK_GENERATE_MODULE_DOT)
if (EXISTS ${MODULE_FILES_CMAKE})
include(${MODULE_FILES_CMAKE})
endif()
if(MODULE_CPP_FILES)
list(APPEND CPP_FILES ${MODULE_CPP_FILES})
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src")
# Preprend the "src" directory to the cpp file list
set(_cpp_files ${CPP_FILES})
set(CPP_FILES )
foreach(_cpp_file ${_cpp_files})
list(APPEND CPP_FILES "src/${_cpp_file}")
endforeach()
endif()
if(CPP_FILES OR RESOURCE_FILES OR UI_FILES OR MOC_H_FILES OR QRC_FILES)
set(MODULE_HEADERS_ONLY 0)
if(MODULE_C_MODULE)
set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE C)
elseif(MODULE_CXX_MODULE)
set_source_files_properties(${CPP_FILES} PROPERTIES LANGUAGE CXX)
endif()
else()
set(MODULE_HEADERS_ONLY 1)
if(MODULE_AUTOLOAD_WITH)
message(SEND_ERROR "A headers only module cannot be auto-loaded")
endif()
endif()
set(module_c_flags )
set(module_c_flags_debug )
set(module_c_flags_release )
set(module_cxx_flags )
set(module_cxx_flags_debug )
set(module_cxx_flags_release )
if(MODULE_GCC_DEFAULT_VISIBILITY OR NOT CMAKE_COMPILER_IS_GNUCXX)
# We only support hidden visibility for gcc for now. Clang still has troubles with
# correctly marking template declarations and explicit template instantiations as exported.
# See http://comments.gmane.org/gmane.comp.compilers.clang.scm/50028
# and http://llvm.org/bugs/show_bug.cgi?id=10113
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
else()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
endif()
if(MODULE_WARNINGS_AS_ERRORS)
if(MSVC_VERSION)
mitkFunctionCheckCAndCXXCompilerFlags("/WX" module_c_flags module_cxx_flags)
else()
mitkFunctionCheckCAndCXXCompilerFlags(-Werror module_c_flags module_cxx_flags)
# The flag "c++0x-static-nonintegral-init" has been renamed in newer Clang
# versions to "static-member-init", see
# http://clang-developers.42468.n3.nabble.com/Wc-0x-static-nonintegral-init-gone-td3999651.html
#
# Also, older Clang and seemingly all gcc versions do not warn if unknown
# "-no-*" flags are used, so CMake will happily append any -Wno-* flag to the
# command line. This may get confusing if unrelated compiler errors happen and
# the error output then additionally contains errors about unknown flags (which
# is not the case if there were no compile errors).
#
# So instead of using -Wno-* we use -Wno-error=*, which will be properly rejected by
# the compiler and if applicable, prints the specific warning as a real warning and
# not as an error (although -Werror was given).
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=c++0x-static-nonintegral-init" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=static-member-init" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=unknown-warning" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=gnu" module_c_flags module_cxx_flags)
mitkFunctionCheckCAndCXXCompilerFlags("-Wno-error=inconsistent-missing-override" module_c_flags module_cxx_flags)
endif()
endif(MODULE_WARNINGS_AS_ERRORS)
if(MODULE_FORCE_STATIC)
set(_STATIC STATIC)
else()
set(_STATIC )
endif(MODULE_FORCE_STATIC)
if(NOT MODULE_HEADERS_ONLY)
if(NOT MODULE_NO_INIT OR RESOURCE_FILES)
find_package(CppMicroServices QUIET NO_MODULE REQUIRED)
endif()
if(NOT MODULE_NO_INIT)
usFunctionGenerateModuleInit(CPP_FILES)
endif()
set(binary_res_files )
set(source_res_files )
if(RESOURCE_FILES)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/resource")
set(res_dir resource)
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Resources")
set(res_dir Resources)
else()
message(SEND_ERROR "Resources specified but ${CMAKE_CURRENT_SOURCE_DIR}/resource directory not found.")
endif()
foreach(res_file ${RESOURCE_FILES})
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}/${res_file})
list(APPEND binary_res_files "${res_file}")
else()
list(APPEND source_res_files "${res_file}")
endif()
endforeach()
# Add a source level dependencies on resource files
usFunctionGetResourceSource(TARGET ${MODULE_TARGET} OUT CPP_FILES)
endif()
endif()
if(MITK_USE_QT)
if(UI_FILES)
qt5_wrap_ui(Q${KITNAME}_GENERATED_UI_CPP ${UI_FILES})
endif()
if(MOC_H_FILES)
qt5_wrap_cpp(Q${KITNAME}_GENERATED_MOC_CPP ${MOC_H_FILES} OPTIONS -DBOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
endif()
if(QRC_FILES)
qt5_add_resources(Q${KITNAME}_GENERATED_QRC_CPP ${QRC_FILES})
endif()
endif()
set(Q${KITNAME}_GENERATED_CPP ${Q${KITNAME}_GENERATED_CPP} ${Q${KITNAME}_GENERATED_UI_CPP} ${Q${KITNAME}_GENERATED_MOC_CPP} ${Q${KITNAME}_GENERATED_QRC_CPP})
mitkFunctionOrganizeSources(
SOURCE ${CPP_FILES}
HEADER ${H_FILES}
TXX ${TXX_FILES}
DOC ${DOX_FILES}
UI ${UI_FILES}
QRC ${QRC_FILES}
MOC ${Q${KITNAME}_GENERATED_MOC_CPP}
GEN_QRC ${Q${KITNAME}_GENERATED_QRC_CPP}
GEN_UI ${Q${KITNAME}_GENERATED_UI_CPP}
)
set(coverage_sources
${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES}
${TOOL_CPPS} ${TOOL_GUI_CPPS})
if(MODULE_SUBPROJECTS)
set_property(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK)
endif()
# ---------------------------------------------------------------
# Create the actual module target
if(MODULE_HEADERS_ONLY)
add_library(${MODULE_TARGET} INTERFACE)
else()
if(MODULE_EXECUTABLE)
add_executable(${MODULE_TARGET}
${MODULE_CPP_FILES} ${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP}
${DOX_FILES} ${UI_FILES} ${QRC_FILES})
set(_us_module_name main)
else()
add_library(${MODULE_TARGET} ${_STATIC}
${coverage_sources} ${CPP_FILES_GENERATED} ${Q${KITNAME}_GENERATED_CPP}
${DOX_FILES} ${UI_FILES} ${QRC_FILES})
set(_us_module_name ${MODULE_TARGET})
endif()
# Apply properties to the module target.
target_compile_definitions(${MODULE_TARGET} PRIVATE US_MODULE_NAME=${_us_module_name})
if(MODULE_C_MODULE)
if(module_c_flags)
string(REPLACE " " ";" module_c_flags "${module_c_flags}")
target_compile_options(${MODULE_TARGET} PRIVATE ${module_c_flags})
endif()
if(module_c_flags_debug)
string(REPLACE " " ";" module_c_flags_debug "${module_c_flags_debug}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_c_flags_debug}>)
endif()
if(module_c_flags_release)
string(REPLACE " " ";" module_c_flags_release "${module_c_flags_release}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_c_flags_release}>)
endif()
else()
if(module_cxx_flags)
string(REPLACE " " ";" module_cxx_flags "${module_cxx_flags}")
target_compile_options(${MODULE_TARGET} PRIVATE ${module_cxx_flags})
endif()
if(module_cxx_flags_debug)
string(REPLACE " " ";" module_cxx_flags_debug "${module_cxx_flags_debug}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_cxx_flags_debug}>)
endif()
if(module_cxx_flags_release)
string(REPLACE " " ";" module_cxx_flags_release "${module_cxx_flags_release}")
target_compile_options(${MODULE_TARGET} PRIVATE $<$:${module_cxx_flags_release}>)
endif()
endif()
set_property(TARGET ${MODULE_TARGET} PROPERTY US_MODULE_NAME ${_us_module_name})
if(MINGW)
target_link_libraries(${MODULE_TARGET} ssp) # add stack smash protection lib
endif()
# Add additional library search directories to a global property which
# can be evaluated by other CMake macros, e.g. our install scripts.
if(MODULE_ADDITIONAL_LIBS)
target_link_libraries(${MODULE_TARGET} PRIVATE ${MODULE_ADDITIONAL_LIBS})
get_property(_mitk_additional_library_search_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
foreach(_lib_filepath ${MODULE_ADDITIONAL_LIBS})
get_filename_component(_search_path "${_lib_filepath}" PATH)
if(_search_path)
list(APPEND _mitk_additional_library_search_paths "${_search_path}")
endif()
endforeach()
if(_mitk_additional_library_search_paths)
list(REMOVE_DUPLICATES _mitk_additional_library_search_paths)
set_property(GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS ${_mitk_additional_library_search_paths})
endif()
endif()
# add the target name to a global property which is used in the top-level
# CMakeLists.txt file to export the target
set_property(GLOBAL APPEND PROPERTY MITK_MODULE_TARGETS ${MODULE_TARGET})
if(MODULE_AUTOLOAD_WITH)
# for auto-loaded modules, adapt the output directory
add_dependencies(${_module_autoload_meta_target} ${MODULE_TARGET})
if(WIN32)
set(_module_output_prop RUNTIME_OUTPUT_DIRECTORY)
else()
set(_module_output_prop LIBRARY_OUTPUT_DIRECTORY)
endif()
set(_module_output_dir ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH})
get_target_property(_module_is_imported ${MODULE_AUTOLOAD_WITH} IMPORTED)
if(NOT _module_is_imported)
# if the auto-loading module is not imported, get its location
# and put the auto-load module relative to it.
get_target_property(_module_output_dir ${MODULE_AUTOLOAD_WITH} ${_module_output_prop})
set_target_properties(${MODULE_TARGET} PROPERTIES
${_module_output_prop} ${_module_output_dir}/${MODULE_AUTOLOAD_WITH})
else()
set_target_properties(${MODULE_TARGET} PROPERTIES
${_module_output_prop} ${CMAKE_${_module_output_prop}}/${MODULE_AUTOLOAD_WITH})
endif()
set_target_properties(${MODULE_TARGET} PROPERTIES
MITK_AUTOLOAD_DIRECTORY ${MODULE_AUTOLOAD_WITH})
# add the auto-load module name as a property
set_property(TARGET ${MODULE_AUTOLOAD_WITH} APPEND PROPERTY MITK_AUTOLOAD_TARGETS ${MODULE_TARGET})
endif()
if(binary_res_files)
usFunctionAddResources(TARGET ${MODULE_TARGET}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${res_dir}
FILES ${binary_res_files})
endif()
if(source_res_files)
usFunctionAddResources(TARGET ${MODULE_TARGET}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${res_dir}
FILES ${source_res_files})
endif()
if(binary_res_files OR source_res_files)
usFunctionEmbedResources(TARGET ${MODULE_TARGET})
endif()
if(MODULE_DEPRECATED_SINCE)
set_property(TARGET ${MODULE_TARGET} PROPERTY MITK_MODULE_DEPRECATED_SINCE ${MODULE_DEPRECATED_SINCE})
endif()
# create export macros
if (NOT MODULE_EXECUTABLE)
set(_export_macro_name )
if(MITK_LEGACY_EXPORT_MACRO_NAME)
set(_export_macro_names
EXPORT_MACRO_NAME ${MODULE_EXPORT_DEFINE}
NO_EXPORT_MACRO_NAME ${MODULE_NAME}_NO_EXPORT
DEPRECATED_MACRO_NAME ${MODULE_NAME}_DEPRECATED
NO_DEPRECATED_MACRO_NAME ${MODULE_NAME}_NO_DEPRECATED
)
endif()
generate_export_header(${MODULE_NAME}
${_export_macro_names}
EXPORT_FILE_NAME ${MODULE_NAME}Exports.h
)
endif()
target_include_directories(${MODULE_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
endif()
# ---------------------------------------------------------------
# Properties for both header-only and compiled modules
if(MODULE_HEADERS_ONLY)
set(_module_property_type INTERFACE)
else()
set(_module_property_type PUBLIC)
endif()
if(MODULE_TARGET_DEPENDS)
add_dependencies(${MODULE_TARGET} ${MODULE_TARGET_DEPENDS})
endif()
if(MODULE_SUBPROJECTS AND NOT MODULE_HEADERS_ONLY)
set_property(TARGET ${MODULE_TARGET} PROPERTY LABELS ${MODULE_SUBPROJECTS} MITK)
foreach(subproject ${MODULE_SUBPROJECTS})
add_dependencies(${subproject} ${MODULE_TARGET})
endforeach()
endif()
set(DEPENDS "${MODULE_DEPENDS}")
if(NOT MODULE_NO_INIT AND NOT MODULE_HEADERS_ONLY)
# Add a CppMicroServices dependency implicitly, since it is
# needed for the generated "module initialization" code.
set(DEPENDS "CppMicroServices;${DEPENDS}")
endif()
if(DEPENDS OR MODULE_PACKAGE_DEPENDS)
mitk_use_modules(TARGET ${MODULE_TARGET}
MODULES ${DEPENDS}
PACKAGES ${MODULE_PACKAGE_DEPENDS}
)
endif()
if(NOT MODULE_C_MODULE)
target_compile_features(${MODULE_TARGET} ${_module_property_type} ${MITK_CXX_FEATURES})
endif()
# add include directories
if(MODULE_INTERNAL_INCLUDE_DIRS)
target_include_directories(${MODULE_TARGET} PRIVATE ${MODULE_INTERNAL_INCLUDE_DIRS})
endif()
if(NOT MODULE_NO_DEFAULT_INCLUDE_DIRS)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(${MODULE_TARGET} ${_module_property_type} include)
else()
target_include_directories(${MODULE_TARGET} ${_module_property_type} .)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_include_directories(${MODULE_TARGET} PRIVATE src)
endif()
endif()
target_include_directories(${MODULE_TARGET} ${_module_property_type} ${MODULE_INCLUDE_DIRS})
endif()
# -----------------------------------------------------------------
# Record missing dependency information
if(_MISSING_DEP)
if(MODULE_DESCRIPTION)
set(MODULE_DESCRIPTION "${MODULE_DESCRIPTION} (missing dependencies: ${_MISSING_DEP})")
else()
set(MODULE_DESCRIPTION "(missing dependencies: ${_MISSING_DEP})")
endif()
endif()
if(NOT MODULE_NO_FEATURE_INFO)
add_feature_info(${MODULE_NAME} MODULE_IS_ENABLED "${MODULE_DESCRIPTION}")
endif()
set(MODULE_NAME ${MODULE_NAME} PARENT_SCOPE)
set(MODULE_TARGET ${MODULE_TARGET} PARENT_SCOPE)
set(MODULE_IS_ENABLED ${MODULE_IS_ENABLED} PARENT_SCOPE)
set(MODULE_SUBPROJECTS ${MODULE_SUBPROJECTS} PARENT_SCOPE)
endfunction()
diff --git a/CMake/mitkFunctionGetLibrarySearchPaths.cmake b/CMake/mitkFunctionGetLibrarySearchPaths.cmake
index 309a182e73..b0599e3edd 100644
--- a/CMake/mitkFunctionGetLibrarySearchPaths.cmake
+++ b/CMake/mitkFunctionGetLibrarySearchPaths.cmake
@@ -1,167 +1,175 @@
macro(_find_package package_name)
find_package(${package_name} REQUIRED PATHS ${${package_name}_DIR} PATH_SUFFIXES ${package_name} NO_DEFAULT_PATH NO_MODULE QUIET)
if(NOT ${package_name}_FOUND)
find_package(${package_name} REQUIRED)
endif()
endmacro()
function(mitkFunctionGetLibrarySearchPaths search_path intermediate_dir)
set(_dir_candidates
"${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
"${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins"
"${MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
"${MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugins"
)
if(MITK_EXTERNAL_PROJECT_PREFIX)
list(APPEND _dir_candidates
"${MITK_EXTERNAL_PROJECT_PREFIX}/bin"
"${MITK_EXTERNAL_PROJECT_PREFIX}/lib"
)
endif()
# Determine the Qt5 library installation prefix
set(_qmake_location )
if(MITK_USE_QT AND TARGET ${Qt5Core_QMAKE_EXECUTABLE})
get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE}
PROPERTY IMPORT_LOCATION)
endif()
if(_qmake_location)
if(NOT _qt_install_libs)
if(WIN32)
execute_process(COMMAND ${_qmake_location} -query QT_INSTALL_BINS
OUTPUT_VARIABLE _qt_install_libs
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
execute_process(COMMAND ${_qmake_location} -query QT_INSTALL_LIBS
OUTPUT_VARIABLE _qt_install_libs
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
file(TO_CMAKE_PATH "${_qt_install_libs}" _qt_install_libs)
set(_qt_install_libs ${_qt_install_libs} CACHE INTERNAL "Qt library installation prefix" FORCE)
endif()
if(_qt_install_libs)
list(APPEND _dir_candidates ${_qt_install_libs})
endif()
elseif(MITK_USE_QT)
message(WARNING "The qmake executable could not be found.")
endif()
get_property(_additional_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
if(MITK_USE_HDF5)
_find_package(HDF5)
get_target_property(_location hdf5 LOCATION)
get_filename_component(_location ${_location} PATH)
list(APPEND _additional_paths ${_location})
# This is a work-around. The hdf5-config.cmake file is not robust enough
# to be included several times via find_pakcage calls.
set(HDF5_LIBRARIES ${HDF5_LIBRARIES} PARENT_SCOPE)
endif()
if(MITK_USE_Vigra)
# we cannot use _find_package(Vigra) here because the vigra-config.cmake file
# always includes the target-exports files without using an include guard. This
# would lead to errors when another find_package(Vigra) call is processed. The
# (bad) assumption here is that for the time being, only the Classification module
# is using Vigra.
if(UNIX)
list(APPEND _additional_paths ${Vigra_DIR}/lib)
else()
list(APPEND _additional_paths ${Vigra_DIR}/bin)
endif()
endif()
if(_additional_paths)
list(APPEND _dir_candidates ${_additional_paths})
endif()
# The code below is sub-optimal. It makes assumptions about
# the structure of the build directories, pointed to by
# the *_DIR variables. Instead, we should rely on package
# specific "LIBRARY_DIRS" variables, if they exist.
if(WIN32)
if(SOFA_DIR)
list(APPEND _dir_candidates "${SOFA_DIR}/bin")
endif()
list(APPEND _dir_candidates "${ITK_DIR}/bin")
else()
if(SOFA_DIR)
list(APPEND _dir_candidates "${SOFA_DIR}/lib")
endif()
endif()
+ if(MITK_USE_MatchPoint)
+ if(WIN32)
+ list(APPEND _dir_candidates "${MatchPoint_DIR}/bin")
+ else()
+ list(APPEND _dir_candidates "${MatchPoint_DIR}/lib")
+ endif()
+ endif()
+
if(OpenCV_DIR)
set(_opencv_link_directories
"${OpenCV_LIB_DIR_DBG}"
"${OpenCV_LIB_DIR_OPT}"
"${OpenCV_3RDPARTY_LIB_DIR_DBG}"
"${OpenCV_3RDPARTY_LIB_DIR_OPT}")
list(REMOVE_DUPLICATES _opencv_link_directories)
if(WIN32)
foreach(_opencv_link_directory ${_opencv_link_directories})
list(APPEND _dir_candidates "${_opencv_link_directory}/../bin")
endforeach()
else()
list(APPEND _dir_candidates ${_opencv_link_directories})
endif()
endif()
if(MITK_USE_Python)
list(APPEND _dir_candidates "${CTK_DIR}/CMakeExternals/Install/bin")
list(APPEND _dir_candidates "${MITK_EXTERNAL_PROJECT_PREFIX}/lib/python2.7/bin")
endif()
if(MITK_USE_TOF_PMDO3 OR MITK_USE_TOF_PMDCAMCUBE OR MITK_USE_TOF_PMDCAMBOARD)
list(APPEND _dir_candidates "${MITK_PMD_SDK_DIR}/plugins" "${MITK_PMD_SDK_DIR}/bin")
endif()
if(MITK_USE_CTK)
list(APPEND _dir_candidates "${CTK_LIBRARY_DIRS}")
foreach(_ctk_library ${CTK_LIBRARIES})
if(${_ctk_library}_LIBRARY_DIRS)
list(APPEND _dir_candidates "${${_ctk_library}_LIBRARY_DIRS}")
endif()
endforeach()
endif()
if(MITK_USE_BLUEBERRY)
if(DEFINED CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY)
if(IS_ABSOLUTE "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}")
list(APPEND _dir_candidates "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}")
else()
list(APPEND _dir_candidates "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}")
endif()
endif()
endif()
if(MITK_LIBRARY_DIRS)
list(APPEND _dir_candidates ${MITK_LIBRARY_DIRS})
endif()
list(REMOVE_DUPLICATES _dir_candidates)
set(_search_dirs )
foreach(_dir ${_dir_candidates})
if(EXISTS "${_dir}/${intermediate_dir}")
list(APPEND _search_dirs "${_dir}/${intermediate_dir}")
else()
list(APPEND _search_dirs "${_dir}")
endif()
endforeach()
# Special handling for "internal" search dirs. The intermediate directory
# might not have been created yet, so we can't check for its existence.
# Hence we just add it for Windows without checking.
set(_internal_search_dirs "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins")
if(WIN32)
foreach(_dir ${_internal_search_dirs})
set(_search_dirs "${_dir}/${intermediate_dir}" ${_search_dirs})
endforeach()
else()
set(_search_dirs ${_internal_search_dirs} ${_search_dirs})
endif()
list(REMOVE_DUPLICATES _search_dirs)
set(${search_path} ${_search_dirs} PARENT_SCOPE)
endfunction()
diff --git a/CMake/mitkInstallRules.cmake b/CMake/mitkInstallRules.cmake
index f41b0e21f9..a185d391e6 100644
--- a/CMake/mitkInstallRules.cmake
+++ b/CMake/mitkInstallRules.cmake
@@ -1,142 +1,152 @@
MITK_INSTALL(FILES "${MITK_SOURCE_DIR}/mitk.ico")
MITK_INSTALL(FILES "${MITK_SOURCE_DIR}/mitk.bmp")
# Install CTK Qt (designer) plugins
if(MITK_USE_CTK)
if(EXISTS ${CTK_QTDESIGNERPLUGINS_DIR})
set(_qtplugin_install_destinations)
if(MACOSX_BUNDLE_NAMES)
foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
list(APPEND _qtplugin_install_destinations
${bundle_name}.app/Contents/MacOS/${_install_DESTINATION}/plugins/designer)
endforeach()
else()
list(APPEND _qtplugin_install_destinations bin/plugins/designer)
endif()
set(_ctk_qt_plugin_folder_release)
set(_ctk_qt_plugin_folder_debug)
if(NOT CMAKE_CFG_INTDIR STREQUAL ".")
set(_ctk_qt_plugin_folder_release "Release/")
set(_ctk_qt_plugin_folder_debug "Debug/")
endif()
foreach(_qtplugin_install_dir ${_qtplugin_install_destinations})
install(DIRECTORY "${CTK_QTDESIGNERPLUGINS_DIR}/designer/${_ctk_qt_plugin_folder_release}"
DESTINATION ${_qtplugin_install_dir}
CONFIGURATIONS Release
)
install(DIRECTORY "${CTK_QTDESIGNERPLUGINS_DIR}/designer/${_ctk_qt_plugin_folder_debug}"
DESTINATION ${_qtplugin_install_dir}
CONFIGURATIONS Debug
)
endforeach()
endif()
endif()
# related to MITK:T19679
if(MACOSX_BUNDLE_NAMES)
foreach(bundle_name ${MACOSX_BUNDLE_NAMES})
get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE}
PROPERTY IMPORT_LOCATION)
get_filename_component(_qmake_path "${_qmake_location}" DIRECTORY)
install(FILES "${_qmake_path}/../plugins/platforms/libqcocoa.dylib"
DESTINATION "${bundle_name}.app/Contents/MacOS/platforms"
CONFIGURATIONS Release)
install(FILES "${_qmake_path}/../plugins/sqldrivers/libqsqlite.dylib"
DESTINATION "${bundle_name}.app/Contents/MacOS/sqldrivers"
CONFIGURATIONS Release)
install(FILES "${_qmake_path}/../plugins/iconengines/libqsvgicon.dylib"
DESTINATION "${bundle_name}.app/Contents/MacOS/iconengines"
CONFIGURATIONS Release)
# related to MITK:T19679-InstallQtWebEnginProcess
if(MITK_USE_QT_WEBENGINE)
get_filename_component(ABS_DIR_HELPERS "${_qmake_path}/../lib/QtWebEngineCore.framework/Helpers" REALPATH)
install(DIRECTORY ${ABS_DIR_HELPERS}
DESTINATION "${bundle_name}.app/Contents/Frameworks/QtWebEngineCore.framework/"
CONFIGURATIONS Release)
endif()
endforeach()
endif()
if(WIN32)
if(MITK_USE_QT)
get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE}
PROPERTY IMPORT_LOCATION)
get_filename_component(_qmake_path "${_qmake_location}" DIRECTORY)
install(FILES "${_qmake_path}/../plugins/platforms/qwindows.dll"
DESTINATION "bin/plugins/platforms"
CONFIGURATIONS Release)
install(FILES "${_qmake_path}/../plugins/sqldrivers/qsqlite.dll"
DESTINATION "bin/plugins/sqldrivers"
CONFIGURATIONS Release)
install(FILES "${_qmake_path}/../plugins/imageformats/qsvg.dll"
DESTINATION "bin/plugins/imageformats"
CONFIGURATIONS Release)
if(MITK_USE_QT_WEBENGINE)
MITK_INSTALL( FILES "${_qmake_path}/QtWebEngineProcess.exe")
endif()
install(DIRECTORY "${_qmake_path}/../resources/"
DESTINATION "bin/resources/"
CONFIGURATIONS Release)
install(FILES "${_qmake_path}/../plugins/platforms/qwindowsd.dll"
DESTINATION "bin/plugins/platforms"
CONFIGURATIONS Debug)
install(FILES "${_qmake_path}/../plugins/sqldrivers/qsqlited.dll"
DESTINATION "bin/plugins/sqldrivers"
CONFIGURATIONS Debug)
install(FILES "${_qmake_path}/../plugins/imageformats/qsvgd.dll"
DESTINATION "bin/plugins/imageformats"
CONFIGURATIONS Debug)
install(DIRECTORY "${_qmake_path}/../resources/"
DESTINATION "bin/resources/"
CONFIGURATIONS Debug)
endif()
#DCMTK Dlls install target (shared libs on gcc only)
if(MINGW AND DCMTK_ofstd_LIBRARY)
set(_dcmtk_libs
${DCMTK_dcmdata_LIBRARY}
${DCMTK_dcmimgle_LIBRARY}
${DCMTK_dcmnet_LIBRARY}
${DCMTK_ofstd_LIBRARY}
)
foreach(_dcmtk_lib ${_dcmtk_libs})
MITK_INSTALL(FILES ${_dcmtk_lib} )
endforeach()
endif()
#MinGW dll
if(MINGW)
find_library(MINGW_RUNTIME_DLL "mingwm10.dll" HINTS ${CMAKE_FIND_ROOT_PATH}/sys-root/mingw/bin)
if(MINGW_RUNTIME_DLL)
MITK_INSTALL(FILES ${MINGW_RUNTIME_DLL} )
else()
message(SEND_ERROR "Could not find mingwm10.dll which is needed for a proper install")
endif()
find_library(MINGW_GCC_RUNTIME_DLL "libgcc_s_dw2-1.dll" HINTS ${CMAKE_FIND_ROOT_PATH}/sys-root/mingw/bin)
if(MINGW_GCC_RUNTIME_DLL)
MITK_INSTALL(FILES ${MINGW_GCC_RUNTIME_DLL} )
else()
message(SEND_ERROR "Could not find libgcc_s_dw2-1.dll which is needed for a proper install")
endif()
endif()
else()
#DCMTK Dlls install target (shared libs on gcc only)
if(DCMTK_ofstd_LIBRARY)
set(_dcmtk_libs
${DCMTK_dcmdata_LIBRARY}
${DCMTK_dcmimgle_LIBRARY}
${DCMTK_dcmnet_LIBRARY}
${DCMTK_ofstd_LIBRARY}
)
foreach(_dcmtk_lib ${_dcmtk_libs})
#MITK_INSTALL(FILES ${_dcmtk_lib} DESTINATION lib)
endforeach()
endif()
endif()
+
+#install Matchpoint libs that are currently not auto detected
+if(MITK_USE_MatchPoint)
+ install(DIRECTORY "${MITK_EXTERNAL_PROJECT_PREFIX}/bin/"
+ DESTINATION "bin"
+ FILES_MATCHING PATTERN "MAPUtilities*")
+ install(DIRECTORY "${MITK_EXTERNAL_PROJECT_PREFIX}/bin/"
+ DESTINATION "bin"
+ FILES_MATCHING PATTERN "MAPAlgorithms*")
+endif()
diff --git a/CMakeExternals/ITK-4.9.0.patch b/CMakeExternals/ITK-4.9.0.patch
index d210df02f0..a41e56f5fa 100644
--- a/CMakeExternals/ITK-4.9.0.patch
+++ b/CMakeExternals/ITK-4.9.0.patch
@@ -1,21 +1,31 @@
diff --git a/Modules/ThirdParty/GDCM/CMakeLists.txt b/Modules/ThirdParty/GDCM/CMakeLists.txt
--- a/Modules/ThirdParty/GDCM/CMakeLists.txt
+++ b/Modules/ThirdParty/GDCM/CMakeLists.txt
@@ -4,7 +4,7 @@ if(ITK_USE_SYSTEM_GDCM)
if(ITK_USE_SYSTEM_GDCM)
set(ITKGDCM_SYSTEM_INCLUDE_DIRS ${GDCM_INCLUDE_DIRS})
set(ITKGDCM_SYSTEM_LIBRARY_DIRS ${GDCM_LIBRARY_DIRS})
- set(ITKGDCM_LIBRARIES gdcmDICT gdcmMSFF)
+ set(ITKGDCM_LIBRARIES gdcmDICT gdcmMSFF gdcmDSED)
set(ITKGDCM_NO_SRC 1)
# When this module is loaded by an app, load GDCM too.
@@ -42,7 +42,7 @@ else()
endif()
endif()
endif()
- set(ITKGDCM_LIBRARIES gdcmDICT gdcmMSFF )
+ set(ITKGDCM_LIBRARIES gdcmDICT gdcmMSFF gdcmDSED)
endif()
itk_module_impl()
+diff --git a/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt b/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt
+--- a/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt
++++ b/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt
+@@ -38,5 +38,6 @@ INSTALL(TARGETS ITKEXPAT
+ INSTALL(FILES
+ ${ITK3P_EXPAT_BINARY_DIR}/expatDllConfig.h
+ ${ITK3P_EXPAT_SOURCE_DIR}/expat.h
++ ${ITK3P_EXPAT_SOURCE_DIR}/itk_expat_mangle.h
+ DESTINATION ${ITK3P_INSTALL_INCLUDE_DIR} # TODO: itk_expat.h #include "itkexpat/expat.h"
+ COMPONENT Development)
diff --git a/CMakeExternals/MatchPoint.cmake b/CMakeExternals/MatchPoint.cmake
new file mode 100644
index 0000000000..2fd129a6ae
--- /dev/null
+++ b/CMakeExternals/MatchPoint.cmake
@@ -0,0 +1,61 @@
+#-----------------------------------------------------------------------------
+# MatchPoint
+#-----------------------------------------------------------------------------
+
+set(MatchPoint_SOURCE_DIR "" CACHE PATH "Location of the MatchPoint source directory")
+mark_as_advanced(MatchPoint_SOURCE_DIR)
+
+# Sanity checks
+if(DEFINED MatchPoint_DIR AND NOT EXISTS ${MatchPoint_DIR})
+ message(FATAL_ERROR "MatchPoint_DIR variable is defined but corresponds to non-existing directory")
+endif()
+
+if(NOT MatchPoint_DIR AND MatchPoint_SOURCE_DIR AND NOT EXISTS ${MatchPoint_SOURCE_DIR})
+ message(FATAL_ERROR "MatchPoint_SOURCE_DIR variable is defined but corresponds to non-existing directory")
+endif()
+
+set(proj MatchPoint)
+set(proj_DEPENDENCIES ITK)
+
+set(MatchPoint_DEPENDS ${proj})
+
+if(NOT MatchPoint_DIR)
+
+ if(MatchPoint_SOURCE_DIR)
+ set(download_step SOURCE_DIR ${MatchPoint_SOURCE_DIR})
+ else()
+ set(download_step
+ URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MatchPoint_rev1481.tar.gz
+ URL_MD5 82b9b1bb3f909f2e00397e285ce8c981
+ )
+ endif()
+
+ ExternalProject_Add(${proj}
+ ${download_step}
+ # INSTALL_COMMAND "${CMAKE_COMMAND} -P cmake_install.cmake"
+ CMAKE_GENERATOR ${gen}
+ CMAKE_ARGS
+ ${ep_common_args}
+ ${additional_cmake_args}
+ -DBUILD_TESTING:BOOL=OFF
+ -DITK_DIR:PATH=${ITK_DIR} #/src/ITK-build
+ -DMAP_USE_SYSTEM_GDCM:BOOL=ON
+ -DMAP_DISABLE_ITK_IO_FACTORY_AUTO_REGISTER:BOOL=ON
+ -DMAP_WRAP_Plastimatch:BOOL=ON
+ -DGDCM_DIR:PATH=${GDCM_DIR}
+ CMAKE_CACHE_ARGS
+ ${ep_common_cache_args}
+ CMAKE_CACHE_DEFAULT_ARGS
+ ${ep_common_cache_default_args}
+ DEPENDS ${proj_DEPENDENCIES}
+ )
+
+ ExternalProject_Get_Property(${proj} binary_dir)
+ set(${proj}_DIR ${binary_dir})
+ mitkFunctionInstallExternalCMakeProject(${proj})
+
+else()
+
+ mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}")
+
+endif()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3ad206a15..5e6fe2540f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,1412 +1,1416 @@
set(MITK_CMAKE_MINIMUM_REQUIRED_VERSION 3.2)
cmake_minimum_required(VERSION ${MITK_CMAKE_MINIMUM_REQUIRED_VERSION})
#-----------------------------------------------------------------------------
# See http://www.cmake.org/cmake/help/v3.2/manual/cmake-policies.7.html for details
#-----------------------------------------------------------------------------
set(project_policies )
foreach(policy ${project_policies})
if(POLICY ${policy})
cmake_policy(SET ${policy} NEW)
endif()
endforeach()
#-----------------------------------------------------------------------------
# Superbuild Option - Enabled by default
#-----------------------------------------------------------------------------
option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON)
if(MITK_USE_SUPERBUILD)
project(MITK-superbuild)
set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR})
else()
project(MITK VERSION 2016.03.99)
endif()
#-----------------------------------------------------------------------------
# Update CMake module path
#------------------------------------------------------------------------------
set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake)
set(CMAKE_MODULE_PATH
${MITK_CMAKE_DIR}
${CMAKE_MODULE_PATH}
)
#-----------------------------------------------------------------------------
# CMake function(s) and macro(s)
#-----------------------------------------------------------------------------
# Standard CMake macros
include(FeatureSummary)
include(CTestUseLaunchers)
include(CMakeParseArguments)
include(FindPackageHandleStandardArgs)
# MITK macros
include(mitkFunctionGetGccVersion)
include(mitkFunctionCheckCompilerFlags)
include(mitkFunctionSuppressWarnings) # includes several functions
include(mitkMacroEmptyExternalProject)
include(mitkFunctionGenerateProjectXml)
include(mitkFunctionEnableBuildConfiguration)
include(mitkFunctionWhitelists)
include(mitkFunctionAddExternalProject)
SUPPRESS_VC_DEPRECATED_WARNINGS()
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
#-----------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
#-----------------------------------------------------------------------------
# Check miminum Mac OS X version
#-----------------------------------------------------------------------------
# The minimum supported Mac OS X version is 10.9. If you use a version less than 10.9, there is no guarantee that the build still works.
if(APPLE)
exec_program(sw_vers ARGS -productVersion OUTPUT_VARIABLE osx_version)
if (osx_version VERSION_LESS "10.9")
message(WARNING "Detected OS X version \"${osx_version}\" is not supported anymore. Minimum required OS X version is 10.9 or greater.")
endif()
if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.9)
message(WARNING "Detected OS X deployment target \"${CMAKE_OSX_DEPLOYMENT_TARGET}\" is not supported anymore. Minimum required OS X version is 10.9 or greater.")
endif()
endif()
#-----------------------------------------------------------------------------
# Check miminum compiler versions
#-----------------------------------------------------------------------------
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 4.7.3 as provided by ppa:ubuntu-toolchain-r/test for Ubuntu 12.04
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7.3)
message(FATAL_ERROR "GCC version must be at least 4.7.3
If you are using Ubuntu 12.04, you can easily install gcc and g++ 4.7.3 (or any later version available) in addition to your version ${CMAKE_CXX_COMPILER_VERSION}:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.7 g++-4.7
Make sure to explicitly specify these compilers when configuring MITK:
CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-4.7
CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-4.7
For more information on the proposed PPA see the Toolchain Updates section of https://wiki.ubuntu.com/ToolChain.")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# require at least clang 3.4 as provided by Ubuntu 12.04
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
message(FATAL_ERROR "Clang version must be at least 3.4")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# require at least clang 5.0
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
message(FATAL_ERROR "Apple Clang version must be at least 5.0")
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# require at least Visual Studio 2012
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17.0.61030.0)
message(FATAL_ERROR "Microsoft Visual Studio 2012 Update 4 or newer required (MSVC 17.0.61030.0)")
endif()
else()
message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang (Linux or Apple), GCC and MSVC.")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
else()
set(GCC_VERSION 0)
endif()
set(MITK_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS 0)
set(CMAKE_CXX_STANDARD ${MITK_CXX_STANDARD})
set(CMAKE_CXX_STANDARD_REQUIRED 1)
# This is necessary to avoid problems with compile feature checks.
# CMAKE_CXX_STANDARD seems to only set the -std=c++11 flag for targets.
# However, compile flag checks also need to be done with -std=c++11.
# The MITK_CXX11_FLAG variable is also used for external projects
# build during the MITK super-build.
mitkFunctionCheckCompilerFlags("-std=c++11" MITK_CXX11_FLAG)
if(NOT MITK_CXX11_FLAG)
# Older gcc compilers use -std=c++0x
mitkFunctionCheckCompilerFlags("-std=c++0x" MITK_CXX11_FLAG)
endif()
#-----------------------------------------------------------------------------
# Warn if source or build path is too long
#-----------------------------------------------------------------------------
if(WIN32)
set(_src_dir_length_max 50)
set(_bin_dir_length_max 50)
if(MITK_USE_SUPERBUILD)
set(_src_dir_length_max 34) # _src_dir_length_max - strlen(ep/src/ITK-build)
set(_bin_dir_length_max 40) # _bin_dir_length_max - strlen(MITK-build)
endif()
string(LENGTH "${MITK_SOURCE_DIR}" _src_n)
string(LENGTH "${MITK_BINARY_DIR}" _bin_n)
# The warnings should be converted to errors
if(_src_n GREATER _src_dir_length_max)
message(WARNING "MITK source code directory path length is too long (${_src_n} > ${_src_dir_length_max})."
"Please move the MITK source code directory to a directory with a shorter path." )
endif()
if(_bin_n GREATER _bin_dir_length_max)
message(WARNING "MITK build directory path length is too long (${_bin_n} > ${_bin_dir_length_max})."
"Please move the MITK build directory to a directory with a shorter path." )
endif()
endif()
#-----------------------------------------------------------------------------
# Additional MITK Options (also shown during superbuild)
#-----------------------------------------------------------------------------
macro(env_option name doc value)
set(_value $ENV{${name}})
if("${_value}" STREQUAL "")
set(_value ${value})
endif()
option(${name} "${doc}" ${_value})
endmacro()
# -----------------------------------------
# General build options
option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON)
option(WITH_COVERAGE "Enable/Disable coverage" OFF)
option(BUILD_TESTING "Test the project" ON)
env_option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF)
env_option(MITK_BUILD_EXAMPLES "Build the MITK Examples" OFF)
option(MITK_ENABLE_PIC_READER "Enable support for reading the DKFZ pic file format." ON)
mark_as_advanced(MITK_BUILD_ALL_APPS
MITK_ENABLE_PIC_READER
)
# -----------------------------------------
# Qt version related variables
env_option(MITK_USE_QT "Use Qt library" ON)
env_option(MITK_USE_QT_WEBENGINE "Use Qt WebEngine library" ON)
if(MITK_USE_QT)
set(MITK_QT5_MINIMUM_VERSION 5.6.0)
set(MITK_QT5_COMPONENTS Concurrent OpenGL PrintSupport Script Sql Svg Widgets Xml XmlPatterns UiTools Help LinguistTools)
if(MITK_USE_QT_WEBENGINE)
set(MITK_QT5_COMPONENTS ${MITK_QT5_COMPONENTS} WebEngineWidgets)
endif()
if(APPLE)
set(MITK_QT5_COMPONENTS ${MITK_QT5_COMPONENTS} DBus)
endif()
find_package(Qt5 ${MITK_QT5_MINIMUM_VERSION} COMPONENTS ${MITK_QT5_COMPONENTS} REQUIRED)
if(Qt5_DIR)
get_filename_component(_Qt5_DIR "${Qt5_DIR}/../../../" ABSOLUTE)
list(FIND CMAKE_PREFIX_PATH "${_Qt5_DIR}" _result)
if(_result LESS 0)
set(CMAKE_PREFIX_PATH "${_Qt5_DIR};${CMAKE_PREFIX_PATH}" CACHE PATH "" FORCE)
endif()
endif()
elseif(MITK_USE_QT_WEBENGINE)
set(MITK_USE_QT_WEBENGINE OFF)
endif()
# ------------------------------------------------------------------------
# Register external projects which can be build with the MITK superbuild
# system. Each mitkFunctionAddExternalProject() call registers an external
# project for which a CMakeExternals/.cmake file must exist. The
# call also creates a MITK_USE_ variable (appearing in the CMake
# UI if the NO_CACHE option is *not* given).
# -----------------------------------------
# Optional external projects with no
# inter-dependencies
set_property(GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS "")
mitkFunctionAddExternalProject(NAME Poco ON COMPONENTS Foundation Net Util XML Zip)
mitkFunctionAddExternalProject(NAME DCMTK ON DOC "EXPERIMENTAL, superbuild only: Use DCMTK in MITK")
mitkFunctionAddExternalProject(NAME OpenIGTLink OFF)
mitkFunctionAddExternalProject(NAME tinyxml ON ADVANCED)
mitkFunctionAddExternalProject(NAME GDCM ON ADVANCED)
mitkFunctionAddExternalProject(NAME GLUT OFF ADVANCED)
mitkFunctionAddExternalProject(NAME Raptor2 OFF ADVANCED)
mitkFunctionAddExternalProject(NAME Eigen ON ADVANCED DOC "Use the Eigen library")
mitkFunctionAddExternalProject(NAME GLEW ON ADVANCED DOC "Use the GLEW library")
mitkFunctionAddExternalProject(NAME ANN ON ADVANCED DOC "Use Approximate Nearest Neighbor Library")
mitkFunctionAddExternalProject(NAME CppUnit ON ADVANCED DOC "Use CppUnit for unit tests")
mitkFunctionAddExternalProject(NAME PCRE OFF ADVANCED NO_PACKAGE)
mitkFunctionAddExternalProject(NAME ZLIB OFF ADVANCED NO_PACKAGE NO_CACHE)
mitkFunctionAddExternalProject(NAME HDF5 OFF ADVANCED)
# -----------------------------------------
# The following external projects must be
# ordered according to their
# inter-dependencies
mitkFunctionAddExternalProject(NAME SWIG OFF ADVANCED NO_PACKAGE DEPENDS PCRE)
mitkFunctionAddExternalProject(NAME Python OFF NO_PACKAGE DEPENDS SWIG DOC "Use Python wrapping in MITK")
mitkFunctionAddExternalProject(NAME Numpy OFF ADVANCED NO_PACKAGE)
mitkFunctionAddExternalProject(NAME OpenCV OFF)
mitkFunctionAddExternalProject(NAME Vigra OFF DEPENDS HDF5)
# These are "hard" dependencies and always set to ON
mitkFunctionAddExternalProject(NAME ITK ON NO_CACHE)
mitkFunctionAddExternalProject(NAME VTK ON NO_CACHE)
mitkFunctionAddExternalProject(NAME Boost ON NO_CACHE)
mitkFunctionAddExternalProject(NAME SimpleITK OFF DEPENDS ITK GDCM SWIG)
mitkFunctionAddExternalProject(NAME ACVD OFF DOC "Use Approximated Centroidal Voronoi Diagrams")
mitkFunctionAddExternalProject(NAME CTK ON DEPENDS QT DCMTK DOC "Use CTK in MITK")
mitkFunctionAddExternalProject(NAME Rasqal OFF DEPENDS Raptor2 PCRE ADVANCED)
mitkFunctionAddExternalProject(NAME Redland OFF DEPENDS Rasqal DOC "Use the Redland RDF library")
mitkFunctionAddExternalProject(NAME SOFA OFF DEPENDS GLUT Boost DOC "Use Simulation Open Framework Architecture")
mitkFunctionAddExternalProject(NAME VMTK OFF DEPENDS ITK VTK)
+mitkFunctionAddExternalProject(NAME MatchPoint OFF ADVANCED DEPENDS ITK DOC "Use the MatchPoint translation image registration library")
if(MITK_USE_QT)
mitkFunctionAddExternalProject(NAME Qwt ON ADVANCED DEPENDS QT)
endif()
# -----------------------------------------
# Other MITK_USE_* options not related to
# external projects build via the
# MITK superbuild
env_option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON)
env_option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF)
#-----------------------------------------------------------------------------
# Build configurations
#-----------------------------------------------------------------------------
set(_buildConfigs "Custom")
file(GLOB _buildConfigFiles CMake/BuildConfigurations/*.cmake)
foreach(_buildConfigFile ${_buildConfigFiles})
get_filename_component(_buildConfigFile ${_buildConfigFile} NAME_WE)
list(APPEND _buildConfigs ${_buildConfigFile})
endforeach()
set(MITK_BUILD_CONFIGURATION "Custom" CACHE STRING "Use pre-defined MITK configurations")
set_property(CACHE MITK_BUILD_CONFIGURATION PROPERTY STRINGS ${_buildConfigs})
mitkFunctionEnableBuildConfiguration()
mitkFunctionCreateWhitelistPaths(MITK)
mitkFunctionFindWhitelists(MITK)
# -----------------------------------------
# Custom dependency logic
option(MITK_USE_SYSTEM_Boost "Use the system Boost" OFF)
set(MITK_USE_Boost_LIBRARIES "" CACHE STRING "A semi-colon separated list of required Boost libraries")
if(MITK_USE_SOFA)
# SOFA requires boost system library
list(FIND MITK_USE_Boost_LIBRARIES system _result)
if(_result LESS 0)
message("> Adding 'system' to MITK_USE_Boost_LIBRARIES.")
list(APPEND MITK_USE_Boost_LIBRARIES system)
endif()
# SOFA requires boost thread library
list(FIND MITK_USE_Boost_LIBRARIES thread _result)
if(_result LESS 0)
message("> Adding 'thread' to MITK_USE_Boost_LIBRARIES.")
list(APPEND MITK_USE_Boost_LIBRARIES thread)
endif()
# Simulation plugin requires boost chrono library
list(FIND MITK_USE_Boost_LIBRARIES chrono _result)
if(_result LESS 0)
message("> Adding 'chrono' to MITK_USE_Boost_LIBRARIES.")
list(APPEND MITK_USE_Boost_LIBRARIES chrono)
endif()
set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "" FORCE)
# Allow setting external SOFA plugins directory and SOFA plugins
set(MITK_USE_SOFA_PLUGINS_DIR ${MITK_USE_SOFA_PLUGINS_DIR} CACHE PATH "External SOFA plugins directory" FORCE)
set(MITK_USE_SOFA_PLUGINS ${MITK_USE_SOFA_PLUGINS} CACHE PATH "List of semicolon-separated plugin names" FORCE)
endif()
# sanity check for supported Qt version. Only >= 5.3 is supported by CTK/PythonQt
if(MITK_USE_QT AND MITK_USE_Python)
set(minimum_required_python_qt5_version "5.3.0")
find_package(Qt5 COMPONENTS Core REQUIRED)
if(${Qt5Core_VERSION_STRING} VERSION_LESS ${minimum_required_python_qt5_version})
message(WARNING "Can't build MITK Python with Qt version < ${minimum_required_python_qt5_version}. Disabling Python support")
set(MITK_USE_Python OFF CACHE BOOL "Use python wrapping in MITK" FORCE)
endif()
endif()
# only windows can't build python in debug mode
if(MITK_USE_Python AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND WIN32)
message(WARNING "Disabling Python support. Building MITK Python in debug mode on Windowsis not supported!")
set(MITK_USE_Python OFF CACHE BOOL "Use python wrapping in MITK" FORCE)
set(MITK_USE_Numpy OFF CACHE BOOL "Use Numpy" FORCE)
set(MITK_USE_SimpleITK OFF CACHE BOOL "Use SimpleITK" FORCE)
elseif(MITK_USE_Python)
set(MITK_USE_ZLIB ON)
if(NOT MITK_USE_Numpy)
message("> Forcing MITK_USE_Numpy to ON because of MITK_USE_Python")
set(MITK_USE_Numpy ON CACHE BOOL "Use Numpy" FORCE)
endif()
if(NOT MITK_USE_SimpleITK)
message("> Forcing MITK_USE_SimpleITK to ON because of MITK_USE_Python")
set(MITK_USE_SimpleITK ON CACHE BOOL "Use SimpleITK" FORCE)
endif()
option(MITK_USE_SYSTEM_PYTHON "Use the system python runtime" OFF)
if(MITK_USE_SYSTEM_PYTHON)
find_package(PythonLibs REQUIRED)
find_package(PythonInterp REQUIRED)
endif()
elseif(MITK_USE_Python AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND WIN32)
message(WARNING "Disabling Python support. Building MITK Python in debug mode on Windowsis not supported!")
set(MITK_USE_Python OFF CACHE BOOL "Use python wrapping in MITK" FORCE)
endif()
if(BUILD_TESTING AND NOT MITK_USE_CppUnit)
message("> Forcing MITK_USE_CppUnit to ON because BUILD_TESTING=ON")
set(MITK_USE_CppUnit ON CACHE BOOL "Use CppUnit for unit tests" FORCE)
endif()
if(MITK_USE_BLUEBERRY)
option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF)
mark_as_advanced(MITK_BUILD_ALL_PLUGINS)
if(NOT MITK_USE_CTK)
message("> Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY")
set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE)
endif()
endif()
#-----------------------------------------------------------------------------
# Pixel type multiplexing
#-----------------------------------------------------------------------------
# Customize the default pixel types for multiplex macros
set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES
"int, unsigned int, short, unsigned short, char, unsigned char"
CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros")
set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES
"double, float"
CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros")
set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES
"itk::RGBPixel, itk::RGBAPixel"
CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros")
set(MITK_ACCESSBYITK_DIMENSIONS
"2,3"
CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros")
mark_as_advanced(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES
MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES
MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES
MITK_ACCESSBYITK_DIMENSIONS
)
# consistency checks
if(NOT MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES)
set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES
"int, unsigned int, short, unsigned short, char, unsigned char"
CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES)
set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES
"double, float"
CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES)
set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES
"itk::RGBPixel, itk::RGBAPixel"
CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES)
string(REPLACE "," ";" _integral_types ${MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES})
string(REPLACE "," ";" _floating_types ${MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES})
foreach(_scalar_type ${_integral_types} ${_floating_types})
set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES
"${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}itk::VariableLengthVector<${_scalar_type}>,")
endforeach()
string(LENGTH "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" _length)
math(EXPR _length "${_length} - 1")
string(SUBSTRING "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" 0 ${_length} MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES)
set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES ${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}
CACHE STRING "List of vector pixel types used in AccessByItk and InstantiateAccessFunction macros for itk::VectorImage types" FORCE)
endif()
if(NOT MITK_ACCESSBYITK_DIMENSIONS)
set(MITK_ACCESSBYITK_DIMENSIONS
"2,3"
CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros")
endif()
#-----------------------------------------------------------------------------
# Project.xml
#-----------------------------------------------------------------------------
# A list of topologically ordered targets
set(CTEST_PROJECT_SUBPROJECTS)
list(APPEND CTEST_PROJECT_SUBPROJECTS
MITK-Core
MITK-CoreUI
MITK-IGT
MITK-ToF
MITK-DTI
MITK-Registration
MITK-Modules # all modules not contained in a specific subproject
MITK-Plugins # all plugins not contained in a specific subproject
MITK-Examples
Unlabeled # special "subproject" catching all unlabeled targets and tests
)
# Configure CTestConfigSubProject.cmake that could be used by CTest scripts
configure_file(${MITK_SOURCE_DIR}/CTestConfigSubProject.cmake.in
${MITK_BINARY_DIR}/CTestConfigSubProject.cmake)
if(CTEST_PROJECT_ADDITIONAL_TARGETS)
# those targets will be executed at the end of the ctest driver script
# and they also get their own subproject label
set(subproject_list "${CTEST_PROJECT_SUBPROJECTS};${CTEST_PROJECT_ADDITIONAL_TARGETS}")
else()
set(subproject_list "${CTEST_PROJECT_SUBPROJECTS}")
endif()
# Generate Project.xml file expected by the CTest driver script
mitkFunctionGenerateProjectXml(${MITK_BINARY_DIR} MITK "${subproject_list}" ${MITK_USE_SUPERBUILD})
#-----------------------------------------------------------------------------
# Superbuild script
#-----------------------------------------------------------------------------
if(MITK_USE_SUPERBUILD)
include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake")
# Print configuration summary
message("\n\n")
feature_summary(
DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------"
WHAT ALL)
return()
endif()
#*****************************************************************************
#**************************** END OF SUPERBUILD ****************************
#*****************************************************************************
#-----------------------------------------------------------------------------
# CMake function(s) and macro(s)
#-----------------------------------------------------------------------------
include(WriteBasicConfigVersionFile)
include(CheckCXXSourceCompiles)
include(GenerateExportHeader)
include(mitkFunctionAddCustomModuleTest)
include(mitkFunctionCheckModuleDependencies)
include(mitkFunctionCompileSnippets)
include(mitkFunctionConfigureVisualStudioUserProjectFile)
include(mitkFunctionConvertXPSchema)
include(mitkFunctionCreateBlueBerryApplication)
include(mitkFunctionCreateCommandLineApp)
include(mitkFunctionCreateModule)
include(mitkFunctionCreatePlugin)
include(mitkFunctionCreateProvisioningFile)
include(mitkFunctionCreateWindowsBatchScript)
include(mitkFunctionGetLibrarySearchPaths)
include(mitkFunctionGetVersion)
include(mitkFunctionGetVersionDescription)
include(mitkFunctionInstallAutoLoadModules)
include(mitkFunctionInstallCTKPlugin)
include(mitkFunctionInstallProvisioningFiles)
include(mitkFunctionInstallThirdPartyCTKPlugins)
include(mitkFunctionOrganizeSources)
include(mitkFunctionTestPlugin)
include(mitkFunctionUseModules)
+if( ${MITK_USE_MatchPoint} )
+ include(mitkFunctionCreateMatchPointDeployedAlgorithm)
+endif()
include(mitkMacroConfigureItkPixelTypes)
include(mitkMacroCreateExecutable)
include(mitkMacroCreateModuleTests)
include(mitkMacroGenerateToolsLibrary)
include(mitkMacroGetLinuxDistribution)
include(mitkMacroGetPMDPlatformString)
include(mitkMacroInstall)
include(mitkMacroInstallHelperApp)
include(mitkMacroInstallTargets)
include(mitkMacroMultiplexPicType)
# Deprecated
include(mitkMacroCreateCTKPlugin)
#-----------------------------------------------------------------------------
# Global CMake variables
#-----------------------------------------------------------------------------
# Required and enabled C++11 features for all MITK code.
# These are added as PUBLIC compile features to all MITK modules.
set(MITK_CXX_FEATURES
cxx_auto_type
cxx_decltype
cxx_enum_forward_declarations
cxx_extended_friend_declarations
cxx_extern_templates
cxx_final
cxx_lambdas
cxx_local_type_template_args
cxx_long_long_type
cxx_nullptr
cxx_override
cxx_range_for
cxx_right_angle_brackets
cxx_rvalue_references
cxx_static_assert
cxx_strong_enums
cxx_template_template_parameters
cxx_trailing_return_types
cxx_variadic_macros
)
if(NOT DEFINED CMAKE_DEBUG_POSTFIX)
# We can't do this yet because the CTK Plugin Framework
# cannot cope with a postfix yet.
#set(CMAKE_DEBUG_POSTFIX d)
endif()
#-----------------------------------------------------------------------------
# Output directories.
#-----------------------------------------------------------------------------
set(_default_LIBRARY_output_dir lib)
set(_default_RUNTIME_output_dir bin)
set(_default_ARCHIVE_output_dir lib)
foreach(type LIBRARY RUNTIME ARCHIVE)
# Make sure the directory exists
if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY
AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY})
message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}")
file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}")
endif()
if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY)
set(CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY})
else()
set(CMAKE_${type}_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${_default_${type}_output_dir})
set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY})
endif()
set(CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY} CACHE INTERNAL "Output directory for ${type} files.")
mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY)
endforeach()
#-----------------------------------------------------------------------------
# Set MITK specific options and variables (NOT available during superbuild)
#-----------------------------------------------------------------------------
# Look for optional Doxygen package
find_package(Doxygen)
option(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF)
mark_as_advanced(BLUEBERRY_DEBUG_SMARTPOINTER)
# ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and mitkWorkbench
option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON)
mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW)
# TODO: check if necessary
option(USE_ITKZLIB "Use the ITK zlib for pic compression." ON)
mark_as_advanced(USE_ITKZLIB)
if(NOT MITK_FAST_TESTING)
if(DEFINED MITK_CTEST_SCRIPT_MODE
AND (MITK_CTEST_SCRIPT_MODE STREQUAL "continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "experimental") )
set(MITK_FAST_TESTING 1)
endif()
endif()
if(NOT UNIX AND NOT MINGW)
set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms")
endif()
if(MITK_BUILD_ALL_PLUGINS)
set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL")
endif()
# Configure pixel types used for ITK image access multiplexing
mitkMacroConfigureItkPixelTypes()
# Configure module naming conventions
set(MITK_MODULE_NAME_REGEX_MATCH "^[A-Z].*$")
set(MITK_MODULE_NAME_REGEX_NOT_MATCH "^[Mm][Ii][Tt][Kk].*$")
set(MITK_MODULE_NAME_PREFIX "Mitk")
set(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME 1)
#-----------------------------------------------------------------------------
# Get MITK version info
#-----------------------------------------------------------------------------
mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK)
mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK)
# MITK_VERSION
set(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}")
if(MITK_VERSION_PATCH STREQUAL "99")
set(MITK_VERSION_STRING "${MITK_VERSION_STRING}-${MITK_REVISION_SHORTID}")
endif()
#-----------------------------------------------------------------------------
# Installation preparation
#
# These should be set before any MITK install macros are used
#-----------------------------------------------------------------------------
# on Mac OSX all BlueBerry plugins get copied into every
# application bundle (.app directory) specified here
if(MITK_USE_BLUEBERRY AND APPLE)
include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake")
foreach(mitk_app ${MITK_APPS})
# extract option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 1 option_name)
list(GET target_info_list 0 app_name)
# check if the application is enabled
if(${option_name} OR MITK_BUILD_ALL_APPS)
set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} Mitk${app_name})
endif()
endforeach()
endif()
#-----------------------------------------------------------------------------
# Set coverage Flags
#-----------------------------------------------------------------------------
if(WITH_COVERAGE)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG")
set(COVERAGE_CXX_FLAGS ${coverage_flags})
set(COVERAGE_C_FLAGS ${coverage_flags})
endif()
endif()
#-----------------------------------------------------------------------------
# MITK C/CXX Flags
#-----------------------------------------------------------------------------
set(MITK_C_FLAGS "${COVERAGE_C_FLAGS}")
set(MITK_C_FLAGS_DEBUG )
set(MITK_C_FLAGS_RELEASE )
set(MITK_CXX_FLAGS "${COVERAGE_CXX_FLAGS} ${MITK_CXX11_FLAG}")
set(MITK_CXX_FLAGS_DEBUG )
set(MITK_CXX_FLAGS_RELEASE )
set(MITK_EXE_LINKER_FLAGS )
set(MITK_SHARED_LINKER_FLAGS )
find_package(OpenMP)
if (OPENMP_FOUND)
set(MITK_C_FLAGS "${MITK_C_FLAGS} ${OpenMP_C_FLAGS}")
set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()
if(WIN32)
set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -D_WIN32_WINNT=0x0501 -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN -DNOMINMAX")
mitkFunctionCheckCompilerFlags("/wd4005" MITK_CXX_FLAGS) # warning C4005: macro redefinition
mitkFunctionCheckCompilerFlags("/wd4231" MITK_CXX_FLAGS) # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation
# the following line should be removed after fixing bug 17637
mitkFunctionCheckCompilerFlags("/wd4316" MITK_CXX_FLAGS) # warning C4316: object alignment on heap
mitkFunctionCheckCompilerFlags("/wd4180" MITK_CXX_FLAGS) # warning C4180: qualifier applied to function type has no meaning
endif()
if(NOT MSVC_VERSION)
foreach(_flag
-Wall
-Wextra
-Wpointer-arith
-Winvalid-pch
-Wcast-align
-Wwrite-strings
-Wno-error=gnu
-Wno-error=unknown-pragmas
# The strict-overflow warning is generated by ITK template code
-Wno-error=strict-overflow
-Woverloaded-virtual
-Wstrict-null-sentinel
#-Wold-style-cast
#-Wsign-promo
-Wno-array-bounds
-fdiagnostics-show-option
)
mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS)
endforeach()
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS)
mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS)
if(MINGW)
# suppress warnings about auto imported symbols
set(MITK_SHARED_LINKER_FLAGS "-Wl,--enable-auto-import ${MITK_SHARED_LINKER_FLAGS}")
endif()
set(MITK_CXX_FLAGS_RELEASE "-U_FORTIFY_SOURCES -D_FORTIFY_SOURCE=2 ${MITK_CXX_FLAGS_RELEASE}")
endif()
set(MITK_MODULE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS})
set(MITK_EXE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS})
#-----------------------------------------------------------------------------
# MITK Packages
#-----------------------------------------------------------------------------
set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends)
set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR})
if(NOT MITK_USE_SYSTEM_Boost)
set(Boost_NO_SYSTEM_PATHS 1)
endif()
set(Boost_USE_MULTITHREADED 1)
set(Boost_USE_STATIC_LIBS 0)
set(Boost_USE_STATIC_RUNTIME 0)
set(Boost_ADDITIONAL_VERSIONS "1.60" "1.60.0")
# We need this later for a DCMTK workaround
set(_dcmtk_dir_orig ${DCMTK_DIR})
# This property is populated at the top half of this file
get_property(MITK_EXTERNAL_PROJECTS GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS)
foreach(ep ${MITK_EXTERNAL_PROJECTS})
get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE)
get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS)
if(MITK_USE_${ep} AND _package)
if(_components)
find_package(${_package} COMPONENTS ${_components} REQUIRED CONFIG)
else()
# Prefer config mode first because it finds external
# Config.cmake files pointed at by _DIR variables.
# Otherwise, existing Find.cmake files could fail.
# (e.g. in the case of GLEW and the FindGLEW.cmake file shipped
# with CMake).
find_package(${_package} QUIET CONFIG)
string(TOUPPER "${_package}" _package_uc)
if(NOT (${_package}_FOUND OR ${_package_uc}_FOUND))
find_package(${_package} REQUIRED)
endif()
endif()
endif()
endforeach()
# Ensure that the MITK CMake module path comes first
set(CMAKE_MODULE_PATH
${MITK_CMAKE_DIR}
${CMAKE_MODULE_PATH}
)
if(MITK_USE_DCMTK)
# Due to the preferred CONFIG mode in find_package calls above,
# the DCMTKConfig.cmake file is read, which does not provide useful
# package information. We explictly need MODULE mode to find DCMTK.
if(${_dcmtk_dir_orig} MATCHES "${MITK_EXTERNAL_PROJECT_PREFIX}.*")
# Help our FindDCMTK.cmake script find our super-build DCMTK
set(DCMTK_DIR ${MITK_EXTERNAL_PROJECT_PREFIX})
else()
# Use the original value
set(DCMTK_DIR ${_dcmtk_dir_orig})
endif()
find_package(DCMTK REQUIRED MODULE)
endif()
if(MITK_USE_Python)
find_package(PythonLibs REQUIRED)
find_package(PythonInterp REQUIRED)
if(MITK_USE_Numpy)
find_package(Numpy REQUIRED)
endif()
endif()
if(MITK_USE_SOFA)
# The SOFAConfig.cmake file does not provide exported targets or
# libraries with absolute paths, hence we need to make the link
# directories globally available until the SOFAConfig.cmake file
# supports a proper mechanism for handling targets.
# The same code is needed in MITKConfig.cmake.
link_directories(${SOFA_LIBRARY_DIRS})
endif()
# Same as SOFA above
link_directories(${Boost_LIBRARY_DIRS})
if(MITK_USE_OpenIGTLink)
# Same as SOFA above
link_directories(${OpenIGTLink_LIBRARY_DIRS})
endif()
if(MITK_USE_SimpleITK)
link_directories(${SimpleITK_LIBRARY_DIRS})
endif()
if(MITK_USE_OpenCL)
find_package(OpenCL REQUIRED)
endif()
# Qt support
if(MITK_USE_QT)
find_package(Qt5Core ${MITK_QT5_MINIMUM_VERSION} REQUIRED) # at least Core required
get_target_property(_qmake_exec Qt5::qmake LOCATION)
execute_process(COMMAND ${_qmake_exec} -query QT_INSTALL_BINS
RESULT_VARIABLE _result
OUTPUT_VARIABLE QT_BINARY_DIR
ERROR_VARIABLE _error
)
string(STRIP "${QT_BINARY_DIR}" QT_BINARY_DIR)
if(_result OR NOT EXISTS "${QT_BINARY_DIR}")
message(FATAL_ERROR "Could not determine Qt binary directory: ${_result} ${QT_BINARY_DIR} ${_error}")
endif()
find_program(QT_HELPGENERATOR_EXECUTABLE
NAMES qhelpgenerator qhelpgenerator-qt5 qhelpgenerator5
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_COLLECTIONGENERATOR_EXECUTABLE
NAMES qcollectiongenerator qcollectiongenerator-qt5 qcollectiongenerator5
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_ASSISTANT_EXECUTABLE
NAMES assistant assistant-qt5 assistant5
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_XMLPATTERNS_EXECUTABLE
NAMES xmlpatterns
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
mark_as_advanced(QT_HELPGENERATOR_EXECUTABLE
QT_COLLECTIONGENERATOR_EXECUTABLE
QT_ASSISTANT_EXECUTABLE
QT_XMLPATTERNS_EXECUTABLE
)
if(MITK_USE_BLUEBERRY)
option(BLUEBERRY_USE_QT_HELP "Enable support for integrating plugin documentation into Qt Help" ${DOXYGEN_FOUND})
mark_as_advanced(BLUEBERRY_USE_QT_HELP)
# Sanity checks for in-application BlueBerry plug-in help generation
if(BLUEBERRY_USE_QT_HELP)
set(_force_blueberry_use_qt_help_to_off 0)
if(NOT DOXYGEN_FOUND)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen was not found.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_LESS 1.8.7)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen version 1.8.7 or newer not found.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(NOT QT_HELPGENERATOR_EXECUTABLE)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because QT_HELPGENERATOR_EXECUTABLE is empty.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(NOT MITK_USE_QT_WEBENGINE)
message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because MITK_USE_QT_WEBENGINE is OFF.")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(NOT QT_XMLPATTERNS_EXECUTABLE)
message("You have enabled Qt Help support, but QT_XMLPATTERNS_EXECUTABLE is empty")
set(_force_blueberry_use_qt_help_to_off 1)
endif()
if(_force_blueberry_use_qt_help_to_off)
set(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating plugin documentation into Qt Help" FORCE)
endif()
endif()
if(BLUEBERRY_QT_HELP_REQUIRED AND NOT BLUEBERRY_USE_QT_HELP)
message(FATAL_ERROR "BLUEBERRY_USE_QT_HELP is required to be set to ON")
endif()
endif()
endif()
#-----------------------------------------------------------------------------
# Testing
#-----------------------------------------------------------------------------
if(BUILD_TESTING)
enable_testing()
include(CTest)
mark_as_advanced(TCL_TCLSH DART_ROOT)
option(MITK_ENABLE_RENDERING_TESTING OFF "Enable the MITK rendering tests. Requires x-server in Linux.")
#Rendering testing does not work for Linux nightlies, thus it is disabled per default
#and activated for Mac and Windows.
if(WIN32 OR APPLE)
set(MITK_ENABLE_RENDERING_TESTING ON)
endif()
mark_as_advanced( MITK_ENABLE_RENDERING_TESTING )
# Setup file for setting custom ctest vars
configure_file(
CMake/CTestCustom.cmake.in
${MITK_BINARY_DIR}/CTestCustom.cmake
@ONLY
)
# Initial cache for ProjectTemplate and PluginGenerator tests
configure_file(
CMake/mitkTestInitialCache.txt.in
${MITK_BINARY_DIR}/mitkTestInitialCache.txt
@ONLY
)
# Configuration for the CMake-generated test driver
set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ")
set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN "
try
{")
set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " }
catch( std::exception & excp )
{
fprintf(stderr,\"%s\\n\",excp.what());
return EXIT_FAILURE;
}
catch( ... )
{
printf(\"Exception caught in the test driver\\n\");
return EXIT_FAILURE;
}
")
set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output")
if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR})
file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR})
endif()
# Test the external project template
if(MITK_USE_BLUEBERRY)
include(mitkTestProjectTemplate)
endif()
# Test the package target
include(mitkPackageTest)
endif()
configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h)
#-----------------------------------------------------------------------------
# MITK_SUPERBUILD_BINARY_DIR
#-----------------------------------------------------------------------------
# If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild.
# In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR
if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR)
set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR})
endif()
#-----------------------------------------------------------------------------
# Set C/CXX and linker flags for MITK code
#-----------------------------------------------------------------------------
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MITK_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MITK_CXX_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MITK_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MITK_C_FLAGS_RELEASE}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MITK_EXE_LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MITK_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${MITK_MODULE_LINKER_FLAGS}")
#-----------------------------------------------------------------------------
# Add custom targets representing CDash subprojects
#-----------------------------------------------------------------------------
foreach(subproject ${CTEST_PROJECT_SUBPROJECTS})
if(NOT TARGET ${subproject} AND NOT subproject MATCHES "Unlabeled")
add_custom_target(${subproject})
endif()
endforeach()
#-----------------------------------------------------------------------------
# Add subdirectories
#-----------------------------------------------------------------------------
add_subdirectory(Utilities)
add_subdirectory(Modules)
if(MITK_USE_BLUEBERRY)
set(BLUEBERRY_XPDOC_OUTPUT_DIR ${MITK_DOXYGEN_OUTPUT_DIR}/html/extension-points/html/)
set(MITK_DEFAULT_SUBPROJECTS MITK-Plugins)
# Plug-in testing (needs some work to be enabled again)
if(BUILD_TESTING)
set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp")
if(TARGET CoreApp)
get_target_property(_is_macosx_bundle CoreApp MACOSX_BUNDLE)
if(APPLE AND _is_macosx_bundle)
set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.app/Contents/MacOS/CoreApp")
endif()
endif()
set(BLUEBERRY_TEST_APP_ID "org.mitk.qt.coreapplication")
endif()
include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake")
mitkFunctionWhitelistPlugins(MITK MITK_PLUGINS)
set(mitk_plugins_fullpath "")
foreach(mitk_plugin ${MITK_PLUGINS})
list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin})
endforeach()
if(EXISTS ${MITK_PRIVATE_MODULES}/PluginList.cmake)
include(${MITK_PRIVATE_MODULES}/PluginList.cmake)
foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS})
list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_plugin})
endforeach()
endif()
if(MITK_BUILD_EXAMPLES)
include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake")
set(mitk_example_plugins_fullpath )
foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS})
list(APPEND mitk_example_plugins_fullpath Examples/Plugins/${mitk_example_plugin})
list(APPEND mitk_plugins_fullpath Examples/Plugins/${mitk_example_plugin})
endforeach()
endif()
# Specify which plug-ins belong to this project
macro(GetMyTargetLibraries all_target_libraries varname)
set(re_ctkplugin_mitk "^org_mitk_[a-zA-Z0-9_]+$")
set(re_ctkplugin_bb "^org_blueberry_[a-zA-Z0-9_]+$")
set(_tmp_list)
list(APPEND _tmp_list ${all_target_libraries})
ctkMacroListFilter(_tmp_list re_ctkplugin_mitk re_ctkplugin_bb OUTPUT_VARIABLE ${varname})
endmacro()
# Get infos about application directories and build options
include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake")
set(mitk_apps_fullpath )
foreach(mitk_app ${MITK_APPS})
# extract option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 0 directory_name)
list(GET target_info_list 1 option_name)
if(${option_name})
list(APPEND mitk_apps_fullpath "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${directory_name}^^${option_name}")
endif()
endforeach()
if (mitk_plugins_fullpath)
ctkMacroSetupPlugins(${mitk_plugins_fullpath}
BUILD_OPTION_PREFIX MITK_BUILD_
APPS ${mitk_apps_fullpath}
BUILD_ALL ${MITK_BUILD_ALL_PLUGINS}
COMPACT_OPTIONS)
endif()
set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake")
if(${PROJECT_NAME}_PLUGIN_LIBRARIES)
ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE})
else()
file(REMOVE ${MITK_PLUGIN_USE_FILE})
set(MITK_PLUGIN_USE_FILE )
endif()
endif()
#-----------------------------------------------------------------------------
# Documentation
#-----------------------------------------------------------------------------
if(DOXYGEN_FOUND)
add_subdirectory(Documentation)
endif()
#-----------------------------------------------------------------------------
# Installation
#-----------------------------------------------------------------------------
# set MITK cpack variables
# These are the default variables, which can be overwritten ( see below )
include(mitkSetupCPack)
set(use_default_config ON)
# MITK_APPS is set in Applications/AppList.cmake (included somewhere above
# if MITK_USE_BLUEBERRY is set to ON).
if(MITK_APPS)
set(activated_apps_no 0)
list(LENGTH MITK_APPS app_count)
# Check how many apps have been enabled
# If more than one app has been activated, the we use the
# default CPack configuration. Otherwise that apps configuration
# will be used, if present.
foreach(mitk_app ${MITK_APPS})
# extract option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 1 option_name)
# check if the application is enabled
if(${option_name} OR MITK_BUILD_ALL_APPS)
MATH(EXPR activated_apps_no "${activated_apps_no} + 1")
endif()
endforeach()
if(app_count EQUAL 1 AND (activated_apps_no EQUAL 1 OR MITK_BUILD_ALL_APPS))
# Corner case if there is only one app in total
set(use_project_cpack ON)
elseif(activated_apps_no EQUAL 1 AND NOT MITK_BUILD_ALL_APPS)
# Only one app is enabled (no "build all" flag set)
set(use_project_cpack ON)
else()
# Less or more then one app is enabled
set(use_project_cpack OFF)
endif()
foreach(mitk_app ${MITK_APPS})
# extract target_dir and option_name
string(REPLACE "^^" "\\;" target_info ${mitk_app})
set(target_info_list ${target_info})
list(GET target_info_list 0 target_dir)
list(GET target_info_list 1 option_name)
list(GET target_info_list 2 executable_name)
# check if the application is enabled
if(${option_name} OR MITK_BUILD_ALL_APPS)
# check whether application specific configuration files will be used
if(use_project_cpack)
# use files if they exist
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake")
endif()
if(EXISTS "${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in")
set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/Applications/${target_dir}/CPackConfig.cmake")
configure_file(${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in
${CPACK_PROJECT_CONFIG_FILE} @ONLY)
set(use_default_config OFF)
endif()
endif()
# add link to the list
list(APPEND CPACK_CREATE_DESKTOP_LINKS "${executable_name}")
endif()
endforeach()
endif()
# if no application specific configuration file was used, use default
if(use_default_config)
configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in
${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY)
set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake")
endif()
# include CPack model once all variables are set
include(CPack)
# Additional installation rules
include(mitkInstallRules)
#-----------------------------------------------------------------------------
# Last configuration steps
#-----------------------------------------------------------------------------
# ---------------- Export targets -----------------
set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake")
file(REMOVE ${MITK_EXPORTS_FILE})
set(targets_to_export)
get_property(module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS)
if(module_targets)
list(APPEND targets_to_export ${module_targets})
endif()
if(MITK_USE_BLUEBERRY)
if(MITK_PLUGIN_LIBRARIES)
list(APPEND targets_to_export ${MITK_PLUGIN_LIBRARIES})
endif()
endif()
export(TARGETS ${targets_to_export} APPEND
FILE ${MITK_EXPORTS_FILE})
set(MITK_EXPORTED_TARGET_PROPERTIES )
foreach(target_to_export ${targets_to_export})
get_target_property(autoload_targets ${target_to_export} MITK_AUTOLOAD_TARGETS)
if(autoload_targets)
set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES}
set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_TARGETS \"${autoload_targets}\")")
endif()
get_target_property(autoload_dir ${target_to_export} MITK_AUTOLOAD_DIRECTORY)
if(autoload_dir)
set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES}
set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_DIRECTORY \"${autoload_dir}\")")
endif()
get_target_property(deprecated_module ${target_to_export} MITK_MODULE_DEPRECATED_SINCE)
if(deprecated_module)
set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES}
set_target_properties(${target_to_export} PROPERTIES MITK_MODULE_DEPRECATED_SINCE \"${deprecated_module}\")")
endif()
endforeach()
# ---------------- External projects -----------------
get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS)
set(MITK_CONFIG_EXTERNAL_PROJECTS )
#string(REPLACE "^^" ";" _mitk_external_projects ${MITK_EXTERNAL_PROJECTS})
foreach(ep ${MITK_EXTERNAL_PROJECTS})
get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS)
set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS}
set(MITK_USE_${ep} ${MITK_USE_${ep}})
set(MITK_${ep}_DIR \"${${ep}_DIR}\")
set(MITK_${ep}_COMPONENTS ${_components})
")
endforeach()
foreach(ep ${MITK_EXTERNAL_PROJECTS})
get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE)
get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS)
if(_components)
set(_components_arg COMPONENTS \${_components})
else()
set(_components_arg)
endif()
if(_package)
set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS}
if(MITK_USE_${ep})
set(${ep}_DIR \${MITK_${ep}_DIR})
if(MITK_${ep}_COMPONENTS)
mitkMacroFindDependency(${_package} COMPONENTS \${MITK_${ep}_COMPONENTS})
else()
mitkMacroFindDependency(${_package})
endif()
endif()")
endif()
endforeach()
# ---------------- Tools -----------------
configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in
${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY)
configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in
${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY)
configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in
${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY)
# ---------------- Configure files -----------------
configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h)
configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h)
set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc)
set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities)
configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h)
configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY)
write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${MITK_VERSION_STRING} COMPATIBILITY AnyNewerVersion)
# If we are under Windows, create two batch files which correctly
# set up the environment for the application and for Visual Studio
if(WIN32)
include(mitkFunctionCreateWindowsBatchScript)
set(VS_SOLUTION_FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.sln")
if(MITK_USE_HDF5)
list(APPEND MITK_LIBRARY_DIRS ${HDF5_DIR}/install/bin)
message(STATUS "MITK-Runtime " ${MITK_RUNTIME_PATH})
endif(MITK_USE_HDF5)
foreach(VS_BUILD_TYPE debug release)
mitkFunctionCreateWindowsBatchScript("${MITK_SOURCE_DIR}/CMake/StartVS.bat.in"
${PROJECT_BINARY_DIR}/StartVS_${VS_BUILD_TYPE}.bat
${VS_BUILD_TYPE})
endforeach()
endif(WIN32)
#-----------------------------------------------------------------------------
# MITK Applications
#-----------------------------------------------------------------------------
# This must come after MITKConfig.h was generated, since applications
# might do a find_package(MITK REQUIRED).
add_subdirectory(Applications)
#-----------------------------------------------------------------------------
# MITK Examples
#-----------------------------------------------------------------------------
if(MITK_BUILD_EXAMPLES)
# This must come after MITKConfig.h was generated, since applications
# might do a find_package(MITK REQUIRED).
add_subdirectory(Examples)
endif()
#-----------------------------------------------------------------------------
# Print configuration summary
#-----------------------------------------------------------------------------
message("\n\n")
feature_summary(
DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------"
WHAT ALL
)
diff --git a/Modules/MatchPointRegistration/CMakeLists.txt b/Modules/MatchPointRegistration/CMakeLists.txt
new file mode 100644
index 0000000000..f9e690d6e0
--- /dev/null
+++ b/Modules/MatchPointRegistration/CMakeLists.txt
@@ -0,0 +1,15 @@
+MITK_CREATE_MODULE(
+ INCLUDE_DIRS PUBLIC Rendering Helper
+ DEPENDS MitkCore MitkSceneSerializationBase
+ PACKAGE_DEPENDS
+ PRIVATE ITK VTK
+ PUBLIC MatchPoint
+)
+
+if( ${MITK_USE_MatchPoint} )
+ ADD_SUBDIRECTORY(autoload/IO)
+ ADD_SUBDIRECTORY(algorithms)
+ if(BUILD_TESTING)
+ ADD_SUBDIRECTORY(Testing)
+ endif(BUILD_TESTING)
+endif()
diff --git a/Modules/MatchPointRegistration/Helper/QmitkAlgorithmListModel.cpp b/Modules/MatchPointRegistration/Helper/QmitkAlgorithmListModel.cpp
new file mode 100644
index 0000000000..3f24fdfad6
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/QmitkAlgorithmListModel.cpp
@@ -0,0 +1,150 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#include "QmitkAlgorithmListModel.h"
+
+#include "mapAlgorithmProfileHelper.h"
+
+
+
+QmitkAlgorithmListModel::
+ QmitkAlgorithmListModel(QObject *parent) :
+QAbstractTableModel(parent)
+{
+
+}
+
+void
+ QmitkAlgorithmListModel::
+ SetAlgorithms(::map::deployment::DLLDirectoryBrowser::DLLInfoListType algList)
+{
+ emit beginResetModel();
+
+ m_AlgList = algList;
+
+ emit endResetModel();
+};
+
+int
+ QmitkAlgorithmListModel::
+ rowCount(const QModelIndex &parent) const
+{
+ if(parent.isValid())
+ {
+ return 0;
+ }
+
+ return m_AlgList.size();
+}
+
+int
+ QmitkAlgorithmListModel::
+ columnCount(const QModelIndex &parent) const
+{
+ if(parent.isValid())
+ return 0;
+
+ return 4;
+}
+
+QVariant
+ QmitkAlgorithmListModel::
+ data(const QModelIndex &index, int role) const
+{
+ if(!index.isValid())
+ return QVariant();
+
+ QVariant result;
+
+ if(index.row()getAlgorithmUID().getName().c_str());
+ break;
+ case 1:
+ result = QVariant(info->getAlgorithmUID().getNamespace().c_str());
+ break;
+ case 2:
+ result = QVariant(info->getAlgorithmUID().getVersion().c_str());
+ break;
+ case 3:
+ std::stringstream descriptionString;
+ ::map::algorithm::profile::ValueListType keys = ::map::algorithm::profile::getKeywords(info->getAlgorithmProfileStr());
+ for (::map::algorithm::profile::ValueListType::const_iterator keyPos = keys.begin(); keyPos!=keys.end();++keyPos)
+ {
+ if (keyPos != keys.begin())
+ {
+ descriptionString << "; ";
+ }
+ descriptionString << *keyPos;
+ }
+ descriptionString << "
";
+ result = QVariant(descriptionString.str().c_str());
+ break;
+ }
+ }
+ else if (Qt::UserRole == role)
+ {
+ result = QVariant(index.row());
+ }
+
+ }
+
+ return result;
+}
+
+Qt::ItemFlags
+ QmitkAlgorithmListModel::
+ flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags flags = QAbstractItemModel::flags(index);
+
+ return flags;
+}
+
+QVariant
+ QmitkAlgorithmListModel::
+ headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if( (Qt::DisplayRole == role) &&
+ (Qt::Horizontal == orientation))
+ {
+ if (section==0)
+ {
+ return QVariant("Name");
+ }
+ else if (section==1)
+ {
+ return QVariant("Namespace");
+ }
+ else if (section==2)
+ {
+ return QVariant("Version");
+ }
+ else if (section==3)
+ {
+ return QVariant("Keywords");
+ }
+ }
+ return QVariant();
+}
diff --git a/Modules/MatchPointRegistration/Helper/QmitkAlgorithmListModel.h b/Modules/MatchPointRegistration/Helper/QmitkAlgorithmListModel.h
new file mode 100644
index 0000000000..1ce8e6e76e
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/QmitkAlgorithmListModel.h
@@ -0,0 +1,56 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef QmitkAlgorithmListModel_h
+#define QmitkAlgorithmListModel_h
+
+#include
+#include
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+
+// MatchPoint
+#include
+
+/*!
+ \class QmitkAlgorithmListModel
+ Model that takes a list of MatchPoint algorithm dll handles and represents it as model in context of the QT view-model-concept.
+ \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+*/
+class MITKMATCHPOINTREGISTRATION_EXPORT QmitkAlgorithmListModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+ public:
+ QmitkAlgorithmListModel(QObject *parent = NULL);
+ virtual ~QmitkAlgorithmListModel() {};
+
+ void SetAlgorithms(::map::deployment::DLLDirectoryBrowser::DLLInfoListType algList);
+
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+ virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+private:
+
+ ::map::deployment::DLLDirectoryBrowser::DLLInfoListType m_AlgList;
+};
+
+#endif // mitkQmitkAlgorithmListModel_h
+
diff --git a/Modules/MatchPointRegistration/Helper/QmitkMapPropertyDelegate.cpp b/Modules/MatchPointRegistration/Helper/QmitkMapPropertyDelegate.cpp
new file mode 100644
index 0000000000..36e72b2cf6
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/QmitkMapPropertyDelegate.cpp
@@ -0,0 +1,286 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+
+#include "QmitkMapPropertyDelegate.h"
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+QmitkMapPropertyDelegate::QmitkMapPropertyDelegate(QObject * /*parent*/)
+{
+}
+
+void QmitkMapPropertyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option
+ , const QModelIndex &index) const
+{
+
+ QVariant data = index.data(Qt::DisplayRole);
+
+ QString name = data.value();
+
+ QStyledItemDelegate::paint(painter, option, index);
+
+}
+
+QWidget* QmitkMapPropertyDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option
+ , const QModelIndex &index) const
+{
+ QVariant data = index.data(Qt::EditRole);
+ QVariant displayData = index.data(Qt::DisplayRole);
+ QString name = index.model()->data(index.model()->index(index.row(), index.column() - 1)).value();
+
+ if (data.isValid())
+ {
+
+ QWidget* editorWidget = NULL;
+
+ if (data.type() == QVariant::Int)
+ {
+ QSpinBox* spinBox = new QSpinBox(parent);
+ spinBox->setSingleStep(1);
+ spinBox->setMinimum(std::numeric_limits::min());
+ spinBox->setMaximum(std::numeric_limits::max());
+ editorWidget = spinBox;
+ }
+ // see qt documentation. cast is correct, it would be obsolete if we
+ // store doubles
+ else if (static_cast(data.type()) == QMetaType::Float)
+ {
+ QDoubleSpinBox* spinBox = new QDoubleSpinBox(parent);
+ spinBox->setDecimals(5);
+ spinBox->setSingleStep(0.1);
+ spinBox->setMinimum(std::numeric_limits::min());
+ spinBox->setMaximum(std::numeric_limits::max());
+
+ editorWidget = spinBox;
+ }
+ else if (data.type() == QVariant::StringList)
+ {
+ QStringList entries = data.value();
+ QComboBox* comboBox = new QComboBox(parent);
+ comboBox->setEditable(false);
+ comboBox->addItems(entries);
+
+ editorWidget = comboBox;
+ }
+ else
+ {
+ editorWidget = QStyledItemDelegate::createEditor(parent, option, index);
+ }
+
+ if (editorWidget)
+ {
+ // install event filter
+ editorWidget->installEventFilter(const_cast(this));
+ }
+
+ return editorWidget;
+
+ }
+ else
+ return new QLabel(displayData.toString(), parent);
+
+}
+
+void QmitkMapPropertyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
+{
+
+ QVariant data = index.data(Qt::EditRole);
+ QVariant displayData = index.data(Qt::DisplayRole);
+
+ std::cout << "Set EDITOR DATA : " << data.toDouble() << std::endl;
+
+ if (data.isValid())
+ {
+
+
+ if (data.type() == QVariant::Int)
+ {
+ QSpinBox* spinBox = qobject_cast(editor);
+ spinBox->setValue(data.toInt());
+ }
+ // see qt documentation. cast is correct, it would be obsolete if we
+ // store doubles
+ else if (static_cast(data.type()) == QMetaType::Float)
+ {
+ QDoubleSpinBox* spinBox = qobject_cast(editor);
+ spinBox->setValue(data.toDouble());
+
+ std::cout << "Set EDITOR DATA : " << spinBox->value() << std::endl;
+ }
+
+ else if (data.type() == QVariant::StringList)
+ {
+ QComboBox* comboBox = qobject_cast(editor);
+ QString displayString = displayData.value();
+ comboBox->setCurrentIndex(comboBox->findData(displayString));
+ }
+
+ else
+ return QStyledItemDelegate::setEditorData(editor, index);
+ }
+}
+
+void QmitkMapPropertyDelegate::setModelData(QWidget *editor, QAbstractItemModel* model
+ , const QModelIndex &index) const
+{
+ QVariant data = index.data(Qt::EditRole);
+ QVariant displayData = index.data(Qt::DisplayRole);
+
+ if (data.isValid())
+ {
+
+ if (data.type() == QVariant::Color)
+ {
+ QWidget *colorBtn = qobject_cast(editor);
+ QVariant colorVariant;
+ colorVariant.setValue(colorBtn->palette().color(QPalette::Button));
+ model->setData(index, colorVariant);
+ }
+
+ else if (data.type() == QVariant::Int)
+ {
+ QSpinBox* spinBox = qobject_cast(editor);
+ int intValue = spinBox->value();
+
+ QVariant intValueVariant;
+ intValueVariant.setValue(static_cast(intValue));
+ model->setData(index, intValueVariant);
+ }
+
+ else if (static_cast(data.type()) == QMetaType::Float)
+ {
+ QDoubleSpinBox* spinBox = qobject_cast(editor);
+ double doubleValue = spinBox->value();
+
+ std::cout << "SET MODEL DATA << FLOAT : " << doubleValue << std::endl;
+
+ QVariant doubleValueVariant;
+ doubleValueVariant.setValue(static_cast(doubleValue));
+ std::cout << "SET MODEL DATA << Variant : " << doubleValue << std::endl;
+ model->setData(index, doubleValueVariant);
+ }
+
+ else if (data.type() == QVariant::StringList)
+ {
+ QString displayData = data.value();
+
+ QComboBox* comboBox = qobject_cast(editor);
+ QString comboBoxValue = comboBox->currentText();
+
+ QVariant comboBoxValueVariant;
+ comboBoxValueVariant.setValue(comboBoxValue);
+ model->setData(index, comboBoxValueVariant);
+ }
+
+ else
+ QStyledItemDelegate::setModelData(editor, model, index);
+ }
+
+}
+
+void QmitkMapPropertyDelegate::commitAndCloseEditor()
+{
+ QWidget* editor = 0;
+ if (QPushButton *pushBtn = qobject_cast(sender()))
+ {
+ editor = pushBtn;
+ }
+
+ if (editor)
+ {
+ emit commitData(editor);
+ emit closeEditor(editor);
+ }
+
+}
+
+void QmitkMapPropertyDelegate::updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option,
+ const QModelIndex & /*index*/) const
+{
+ editor->setGeometry(option.rect);
+}
+
+void QmitkMapPropertyDelegate::ComboBoxCurrentIndexChanged(int /*index*/)
+{
+ if (QComboBox *comboBox = qobject_cast(sender()))
+ {
+ emit commitData(comboBox);
+ emit closeEditor(comboBox);
+ }
+}
+
+void QmitkMapPropertyDelegate::SpinBoxValueChanged(const QString& /*value*/)
+{
+ QAbstractSpinBox *spinBox = 0;
+ if ((spinBox = qobject_cast(sender()))
+ || (spinBox = qobject_cast(sender())))
+ {
+ emit commitData(spinBox);
+ emit closeEditor(spinBox);
+ }
+}
+
+void QmitkMapPropertyDelegate::showColorDialog()
+{
+
+}
+
+bool QmitkMapPropertyDelegate::eventFilter(QObject *o, QEvent *e)
+{
+ // filter all kind of events on our editor widgets
+ // when certain events occur, repaint all render windows, because rendering relevant properties might have changed
+ switch (e->type())
+ {
+ case QEvent::KeyRelease:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::Wheel:
+ case QEvent::FocusIn:
+ {
+ if (QWidget* editor = dynamic_cast(o))
+ {
+ emit commitData(editor);
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+
+ return false;
+}
diff --git a/Modules/MatchPointRegistration/Helper/QmitkMapPropertyDelegate.h b/Modules/MatchPointRegistration/Helper/QmitkMapPropertyDelegate.h
new file mode 100644
index 0000000000..d6db990788
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/QmitkMapPropertyDelegate.h
@@ -0,0 +1,86 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef QmitkPropertyDelegate_h
+#define QmitkPropertyDelegate_h
+
+
+/// Toolkit includes.
+#include
+#include "mitkBaseProperty.h"
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+
+
+/** \class QmitkPropertyDelegate
+ \brief An item delegate for rendering and editing mitk::Properties in a QTableView.
+
+ \see QmitkPropertiesTableModel*/
+class MITKMATCHPOINTREGISTRATION_EXPORT QmitkMapPropertyDelegate : public QStyledItemDelegate
+{
+ Q_OBJECT
+
+public:
+ ///
+ /// Creates a new PropertyDelegate.
+ ///
+ QmitkMapPropertyDelegate(QObject *parent = 0);
+
+ ///
+ /// Renders a specific property (overwritten from QItemDelegate)
+ ///
+ void paint(QPainter *painter, const QStyleOptionViewItem &option
+ , const QModelIndex &index) const;
+
+ ///
+ /// Create an editor for a specific property (overwritten from QItemDelegate)
+ ///
+ QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option
+ , const QModelIndex &index) const;
+
+ ///
+ /// Create an editor for a specific property (overwritten from QItemDelegate)
+ ///
+ void setEditorData(QWidget *editor, const QModelIndex &index) const;
+
+ ///
+ /// When the user accepts input this func commits the data to the model (overwritten from QItemDelegate)
+ ///
+ void setModelData(QWidget *editor, QAbstractItemModel* model
+ , const QModelIndex &index) const;
+
+ ///
+ /// \brief Fit an editor to some geometry (overwritten from QItemDelegate)
+ ///
+ void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
+
+protected:
+
+ bool eventFilter(QObject *o, QEvent *e);
+
+ private slots:
+ ///
+ /// Invoked when the user accepts editor input, that is when he does not pushes ESC.
+ ///
+ void commitAndCloseEditor();
+ void showColorDialog();
+ void ComboBoxCurrentIndexChanged(int index);
+ void SpinBoxValueChanged(const QString& value);
+
+};
+
+#endif /* QMITKPROPERTIESTABLEMODEL_H_ */
diff --git a/Modules/MatchPointRegistration/Helper/mitkAlgorithmHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkAlgorithmHelper.cpp
new file mode 100644
index 0000000000..f3b2a713e1
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkAlgorithmHelper.cpp
@@ -0,0 +1,388 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkAlgorithmHelper.h"
+
+//itk
+#include
+
+// Mitk
+#include
+#include
+
+// MatchPoint
+#include
+#include
+#include
+#include
+#include
+
+namespace mitk
+{
+
+ MITKAlgorithmHelper::MITKAlgorithmHelper(map::algorithm::RegistrationAlgorithmBase* algorithm) :
+ m_AlgorithmBase(algorithm)
+ {
+ m_AllowImageCasting = true;
+ }
+
+ map::core::RegistrationBase::Pointer
+ MITKAlgorithmHelper::
+ GetRegistration() const
+ {
+ map::core::RegistrationBase::Pointer spResult;
+
+ unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
+ unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
+
+ if (movingDim != targetDim)
+ {
+ mapDefaultExceptionStaticMacro( <<
+ "Error, algorithm instance has unequal dimensionality and is therefore not supported in the current version of MITKAlgorithmHelper.");
+ }
+
+ if (movingDim > 3)
+ {
+ mapDefaultExceptionStaticMacro( <<
+ "Error, algorithm instance has a dimensionality larger than 3 and is therefore not supported in the current version of MITKAlgorithmHelper.");
+ }
+
+ typedef ::map::algorithm::facet::RegistrationAlgorithmInterface<2, 2> RegistrationAlg2D2DInterface;
+ typedef ::map::algorithm::facet::RegistrationAlgorithmInterface<3, 3> RegistrationAlg3D3DInterface;
+
+ RegistrationAlg2D2DInterface* pRegAlgorithm2D2D = dynamic_cast
+ (m_AlgorithmBase.GetPointer());
+ RegistrationAlg3D3DInterface* pRegAlgorithm3D3D = dynamic_cast
+ (m_AlgorithmBase.GetPointer());
+
+ if (pRegAlgorithm2D2D)
+ {
+ spResult = pRegAlgorithm2D2D->getRegistration();
+ }
+
+ if (pRegAlgorithm3D3D)
+ {
+ spResult = pRegAlgorithm3D3D->getRegistration();
+ }
+
+ return spResult;
+ }
+
+ mitk::MAPRegistrationWrapper::Pointer
+ MITKAlgorithmHelper::
+ GetMITKRegistrationWrapper() const
+ {
+ map::core::RegistrationBase::Pointer spInternalResult = GetRegistration();
+ mitk::MAPRegistrationWrapper::Pointer spResult = mitk::MAPRegistrationWrapper::New();
+ spResult->SetRegistration(spInternalResult);
+ return spResult;
+ };
+
+
+ static const mitk::Image* GetDataAsImage(const mitk::BaseData* data)
+ {
+ return dynamic_cast(data);
+ };
+
+ static const mitk::PointSet* GetDataAsPointSet(const mitk::BaseData* data)
+ {
+ return dynamic_cast(data);
+ };
+
+ bool
+ MITKAlgorithmHelper::
+ CheckData(const mitk::BaseData* moving, const mitk::BaseData* target, CheckError::Type& error) const
+ {
+ if (! m_AlgorithmBase)
+ {
+ mapDefaultExceptionStaticMacro( << "Error, cannot check data. Helper has no algorithm defined.");
+ }
+
+ if (! moving)
+ {
+ mapDefaultExceptionStaticMacro( << "Error, cannot check data. Moving data pointer is NULL.");
+ }
+
+ if (! target)
+ {
+ mapDefaultExceptionStaticMacro( << "Error, cannot check data. Target data pointer is NULL.");
+ }
+
+ bool result = false;
+ m_Error = CheckError::unsupportedDataType;
+
+ unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
+ unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
+
+ if (movingDim != targetDim)
+ {
+ m_Error = CheckError::wrongDimension;
+ }
+ else
+ {
+ //First check if data are point sets or images
+ if (GetDataAsPointSet(target) && GetDataAsPointSet(moving))
+ {
+ typedef ::map::core::continuous::Elements<3>::InternalPointSetType InternalDefaultPointSetType;
+ typedef ::map::algorithm::facet::PointSetRegistrationAlgorithmInterface
+ PointSetRegInterface;
+
+ PointSetRegInterface* pPointSetInterface = dynamic_cast
+ (m_AlgorithmBase.GetPointer());
+
+ if (!pPointSetInterface)
+ {
+ result = false;
+ m_Error = CheckError::unsupportedDataType;
+ }
+ }
+ else if (GetDataAsImage(moving) && GetDataAsImage(target))
+ {
+ if (movingDim == 2)
+ {
+ AccessTwoImagesFixedDimensionByItk(GetDataAsImage(moving), GetDataAsImage(target), DoCheckImages,
+ 2);
+ }
+ else if (movingDim == 3)
+ {
+ AccessTwoImagesFixedDimensionByItk(GetDataAsImage(moving), GetDataAsImage(target), DoCheckImages,
+ 3);
+ }
+ else
+ {
+ m_Error = CheckError::wrongDimension;
+ }
+
+ if (m_Error == CheckError::none || (m_AllowImageCasting && m_Error == CheckError::onlyByCasting))
+ {
+ result = true;
+ }
+ }
+
+ }
+
+ error = m_Error;
+ return result;
+
+ };
+
+ void MITKAlgorithmHelper::SetAllowImageCasting(bool allowCasting)
+ {
+ this->m_AllowImageCasting = allowCasting;
+ };
+
+ bool MITKAlgorithmHelper::GetAllowImageCasting() const
+ {
+ return this->m_AllowImageCasting;
+ };
+
+ void MITKAlgorithmHelper::SetData(const mitk::BaseData* moving, const mitk::BaseData* target)
+ {
+ if (! m_AlgorithmBase)
+ {
+ mapDefaultExceptionStaticMacro( << "Error, cannot check data. Helper has no algorithm defined.");
+ }
+
+ if (! moving)
+ {
+ mapDefaultExceptionStaticMacro( << "Error, cannot check data. Moving data pointer is NULL.");
+ }
+
+ if (! target)
+ {
+ mapDefaultExceptionStaticMacro( << "Error, cannot check data. Target data pointer is NULL.");
+ }
+
+ unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
+ unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
+
+ if (movingDim != targetDim)
+ {
+ mapDefaultExceptionStaticMacro( <<
+ "Error, cannot set data. Current version of MITKAlgorithmHelper only supports images/point sets with same dimensionality.");
+ }
+
+ if (GetDataAsPointSet(target) && GetDataAsPointSet(moving))
+ {
+ typedef ::map::core::continuous::Elements<3>::InternalPointSetType InternalDefaultPointSetType;
+ typedef ::map::algorithm::facet::PointSetRegistrationAlgorithmInterface
+ PointSetRegInterface;
+
+ PointSetRegInterface* pPointSetInterface = dynamic_cast
+ (m_AlgorithmBase.GetPointer());
+
+ pPointSetInterface->setMovingPointSet(mitk::PointSetMappingHelper::ConvertPointSetMITKtoMAP(
+ GetDataAsPointSet(moving)->GetPointSet()));
+ pPointSetInterface->setTargetPointSet(mitk::PointSetMappingHelper::ConvertPointSetMITKtoMAP(
+ GetDataAsPointSet(target)->GetPointSet()));
+ }
+ else if (GetDataAsImage(moving) && GetDataAsImage(target))
+ {
+ if (movingDim == 2)
+ {
+ AccessTwoImagesFixedDimensionByItk(GetDataAsImage(moving), GetDataAsImage(target), DoSetImages, 2);
+ }
+ else if (movingDim == 3)
+ {
+ AccessTwoImagesFixedDimensionByItk(GetDataAsImage(moving), GetDataAsImage(target), DoSetImages, 3);
+ }
+ }
+ };
+
+ template
+ typename TOutImageType::Pointer MITKAlgorithmHelper::CastImage(const TInImageType* input) const
+ {
+ typedef itk::CastImageFilter< TInImageType, TOutImageType > CastFilterType;
+ typename CastFilterType::Pointer spImageCaster = CastFilterType::New();
+
+ spImageCaster->SetInput(input);
+
+ typename TOutImageType::Pointer spImage = spImageCaster->GetOutput();
+ spImageCaster->Update();
+
+ return spImage;
+ }
+
+ template
+ void MITKAlgorithmHelper::DoSetImages(const itk::Image* moving,
+ const itk::Image* target)
+ {
+ typedef itk::Image MovingImageType;
+ typedef itk::Image TargetImageType;
+ typedef itk::Image
+ InternalDefaultMovingImageType;
+ typedef itk::Image
+ InternalDefaultTargetImageType;
+
+ typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface
+ ImageRegInterface;
+ typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface
+ DefaultImageRegInterface;
+
+
+ ImageRegInterface* pImageInterface = dynamic_cast(m_AlgorithmBase.GetPointer());
+ DefaultImageRegInterface* pDefaultImageInterface = dynamic_cast
+ (m_AlgorithmBase.GetPointer());
+
+ if (pImageInterface)
+ {
+ //just set directly and you are done
+
+ /**@todo the duplication work arround is needed due to a insufficuence
+ in the AccessTwoImagesFixedDimensionByItk macro. The macro always cast
+ the passed image into non const (even if tha image was passed as const).
+ This behavior enforces the unnecessary use of an writeaccessor, which as a consequence
+ will lead to redundant access exceptions as long as the algorithm exists;
+ e.g. in the typical scenario with the MatchPoint Plugins*/
+ typedef itk::ImageDuplicator< MovingImageType > MovingDuplicatorType;
+ typedef itk::ImageDuplicator< TargetImageType > TargetDuplicatorType;
+ typename MovingDuplicatorType::Pointer mDuplicator = MovingDuplicatorType::New();
+ mDuplicator->SetInputImage(moving);
+ mDuplicator->Update();
+
+ typename TargetDuplicatorType::Pointer tDuplicator = TargetDuplicatorType::New();
+ tDuplicator->SetInputImage(target);
+ tDuplicator->Update();
+
+ typename MovingImageType::Pointer clonedMoving = mDuplicator->GetOutput();
+ typename TargetImageType::Pointer clonedTarget = tDuplicator->GetOutput();
+
+ pImageInterface->setTargetImage(clonedTarget);
+ pImageInterface->setMovingImage(clonedMoving);
+ }
+ else if (pDefaultImageInterface)
+ {
+ //you may convert it to the default image type and use it then
+ if (! m_AllowImageCasting)
+ {
+ mapDefaultExceptionStaticMacro( <<
+ "Error, cannot set images. MITKAlgorithmHelper has to convert them into MatchPoint default images, but is not allowed. Please reconfigure helper.");
+ }
+
+ typename InternalDefaultTargetImageType::Pointer spCastedTarget =
+ CastImage(target);
+ typename InternalDefaultMovingImageType::Pointer spCastedMoving =
+ CastImage(moving);
+ pDefaultImageInterface->setTargetImage(spCastedTarget);
+ pDefaultImageInterface->setMovingImage(spCastedMoving);
+ }
+ else
+ {
+ mapDefaultExceptionStaticMacro( << "Error, algorithm is not able to use the based images.");
+ }
+ }
+
+ template
+ void MITKAlgorithmHelper::DoCheckImages(const itk::Image* moving,
+ const itk::Image* target) const
+ {
+ typedef itk::Image MovingImageType;
+ typedef itk::Image TargetImageType;
+ typedef itk::Image
+ InternalDefaultMovingImageType;
+ typedef itk::Image
+ InternalDefaultTargetImageType;
+
+ typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface
+ ImageRegInterface;
+ typedef ::map::algorithm::facet::ImageRegistrationAlgorithmInterface
+ DefaultImageRegInterface;
+
+ ImageRegInterface* pImageInterface = dynamic_cast(m_AlgorithmBase.GetPointer());
+ DefaultImageRegInterface* pDefaultImageInterface = dynamic_cast
+ (m_AlgorithmBase.GetPointer());
+
+ if (pImageInterface)
+ {
+ //just set directly and you are done
+ m_Error = CheckError::none;
+ }
+ else if (pDefaultImageInterface)
+ {
+ //you may convert it to the default image type and use it then
+ m_Error = CheckError::onlyByCasting;
+ }
+ else
+ {
+ m_Error = CheckError::unsupportedDataType;
+ }
+ }
+
+
+ mapGenerateAlgorithmUIDPolicyMacro(DummyRegIDPolicy, "de.dkfz.dipp", "Identity", "1.0.0", "");
+
+ mitk::MAPRegistrationWrapper::Pointer GenerateIdentityRegistration3D()
+ {
+ typedef map::algorithm::DummyImageRegistrationAlgorithm::InternalImageType, map::core::discrete::Elements<3>::InternalImageType, DummyRegIDPolicy>
+ DummyRegType;
+ DummyRegType::Pointer regAlg = DummyRegType::New();
+ mitk::MITKAlgorithmHelper helper(regAlg);
+
+ map::core::discrete::Elements<3>::InternalImageType::Pointer dummyImg =
+ map::core::discrete::Elements<3>::InternalImageType::New();
+ dummyImg->Allocate();
+ regAlg->setTargetImage(dummyImg);
+ regAlg->setMovingImage(dummyImg);
+
+ mitk::MAPRegistrationWrapper::Pointer dummyReg = mitk::MAPRegistrationWrapper::New();
+ dummyReg->SetRegistration(regAlg->getRegistration());
+
+ return dummyReg;
+ }
+
+}
diff --git a/Modules/MatchPointRegistration/Helper/mitkAlgorithmHelper.h b/Modules/MatchPointRegistration/Helper/mitkAlgorithmHelper.h
new file mode 100644
index 0000000000..3881798f02
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkAlgorithmHelper.h
@@ -0,0 +1,107 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef mitkAlgorithmHelper_h
+#define mitkAlgorithmHelper_h
+
+
+//MatchPoint
+#include "mapRegistrationAlgorithmBase.h"
+#include "mapRegistrationBase.h"
+
+//MITK
+#include
+#include
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+#include "mitkMAPRegistrationWrapper.h"
+
+namespace mitk
+{
+ /*!
+ \brief MITKAlgorithmHelper
+ \remark Current implementation is not thread-save. Just use one Helper class per registration task.
+ \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+ */
+ class MITKMATCHPOINTREGISTRATION_EXPORT MITKAlgorithmHelper
+ {
+ public:
+
+ MITKAlgorithmHelper(map::algorithm::RegistrationAlgorithmBase* algorithm = NULL);
+
+ void SetData(const mitk::BaseData* moving, const mitk::BaseData* target);
+
+ void SetAllowImageCasting(bool allowCasting);
+ bool GetAllowImageCasting() const;
+
+ struct CheckError
+ {
+ enum Type
+ {
+ none = 0,
+ onlyByCasting = 1,
+ wrongDimension = 2,
+ unsupportedDataType = 3
+ };
+ };
+
+ bool CheckData(const mitk::BaseData* moving, const mitk::BaseData* target,
+ CheckError::Type& error) const;
+
+ map::core::RegistrationBase::Pointer GetRegistration() const;
+
+ mitk::MAPRegistrationWrapper::Pointer GetMITKRegistrationWrapper() const;
+
+ ~MITKAlgorithmHelper() {}
+
+ private:
+
+ MITKAlgorithmHelper& operator = (const MITKAlgorithmHelper&);
+ MITKAlgorithmHelper(const MITKAlgorithmHelper&);
+
+ /**Internal helper that casts itk images from one pixel type into an other
+ (used by DoSetImages if the images have the right dimension but wrong type and AllowImageCasting is activated)*/
+ template
+ typename TOutImageType::Pointer CastImage(const TInImageType* input) const;
+
+ /**Internal helper that is used by SetData if the data are images to set them properly.*/
+ template
+ void DoSetImages(const itk::Image* moving,
+ const itk::Image* target);
+
+ /**Internal helper that is used by SetData if the data are images to check if the image types are supported by the algorithm.*/
+ template
+ void DoCheckImages(const itk::Image* moving,
+ const itk::Image* target) const;
+
+ map::algorithm::RegistrationAlgorithmBase::Pointer m_AlgorithmBase;
+
+ bool m_AllowImageCasting;
+
+ mutable CheckError::Type m_Error;
+ };
+
+ /**Small helper function that generates Identity transforms in 3D.*/
+ mitk::MAPRegistrationWrapper::Pointer MITKMATCHPOINTREGISTRATION_EXPORT GenerateIdentityRegistration3D();
+
+}
+
+#endif
+
diff --git a/Modules/MatchPointRegistration/Helper/mitkImageMappingHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkImageMappingHelper.cpp
new file mode 100644
index 0000000000..54fe5d94df
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkImageMappingHelper.cpp
@@ -0,0 +1,392 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+#include "mapRegistration.h"
+
+#include "mitkImageMappingHelper.h"
+#include "mitkRegistrationHelper.h"
+
+template
+typename ::itk::InterpolateImageFunction< TImage >::Pointer generateInterpolator(mitk::ImageMappingInterpolator::Type interpolatorType)
+{
+ typedef ::itk::InterpolateImageFunction< TImage > BaseInterpolatorType;
+ typename BaseInterpolatorType::Pointer result;
+
+ switch (interpolatorType)
+ {
+ case mitk::ImageMappingInterpolator::NearestNeighbor:
+ {
+ result = ::itk::NearestNeighborInterpolateImageFunction::New();
+ break;
+ }
+ case mitk::ImageMappingInterpolator::BSpline_3:
+ {
+ typename ::itk::BSplineInterpolateImageFunction::Pointer spInterpolator = ::itk::BSplineInterpolateImageFunction::New();
+ spInterpolator->SetSplineOrder(3);
+ result = spInterpolator;
+ break;
+ }
+ case mitk::ImageMappingInterpolator::WSinc_Hamming:
+ {
+ result = ::itk::WindowedSincInterpolateImageFunction::New();
+ break;
+ }
+ case mitk::ImageMappingInterpolator::WSinc_Welch:
+ {
+ result = ::itk::WindowedSincInterpolateImageFunction >::New();
+ break;
+ }
+ default:
+ {
+ result = ::itk::LinearInterpolateImageFunction::New();
+ break;
+ }
+
+ }
+
+ return result;
+};
+
+template
+void doMITKMap(const ::itk::Image* input, mitk::ImageMappingHelper::ResultImageType::Pointer& result, const mitk::ImageMappingHelper::RegistrationType*& registration,
+ bool throwOnOutOfInputAreaError, const double& paddingValue, const mitk::ImageMappingHelper::ResultImageGeometryType*& resultGeometry,
+ bool throwOnMappingError, const double& errorValue, mitk::ImageMappingInterpolator::Type interpolatorType)
+{
+ typedef ::map::core::Registration ConcreteRegistrationType;
+ typedef ::map::core::ImageMappingTask, ::itk::Image > MappingTaskType;
+ typename MappingTaskType::Pointer spTask = MappingTaskType::New();
+
+ typedef typename MappingTaskType::ResultImageDescriptorType ResultImageDescriptorType;
+ typename ResultImageDescriptorType::Pointer resultDescriptor;
+
+ //check if image and result geometry fits the passed registration
+ /////////////////////////////////////////////////////////////////
+ if (registration->getMovingDimensions()!=VImageDimension)
+ {
+ map::core::OStringStream str;
+ str << "Dimension of MITK image ("<getMovingDimensions()<<").";
+ throw mitk::AccessByItkException(str.str());
+ }
+
+ if (registration->getTargetDimensions()!=VImageDimension)
+ {
+ map::core::OStringStream str;
+ str << "Dimension of MITK image ("<getTargetDimensions()<<").";
+ throw mitk::AccessByItkException(str.str());
+ }
+
+ const ConcreteRegistrationType* castedReg = dynamic_cast(registration);
+
+ if (registration->getTargetDimensions()==2 && resultGeometry)
+ {
+ mitk::ImageMappingHelper::ResultImageGeometryType::BoundsArrayType bounds = resultGeometry->GetBounds();
+
+ if (bounds[4]!=0 || bounds[5]!=0)
+ {
+ //array "bounds" is constructed as [min Dim1, max Dim1, min Dim2, max Dim2, min Dim3, max Dim3]
+ //therfore [4] and [5] must be 0
+
+ map::core::OStringStream str;
+ str << "Dimension of defined result geometry does not equal the target dimension of the registration object ("<getTargetDimensions()<<").";
+ throw mitk::AccessByItkException(str.str());
+ }
+ }
+
+ //check/create resultDescriptor
+ /////////////////////////
+ if (resultGeometry)
+ {
+ resultDescriptor = ResultImageDescriptorType::New();
+
+ typename ResultImageDescriptorType::PointType origin;
+ typename ResultImageDescriptorType::SizeType size;
+ typename ResultImageDescriptorType::SpacingType fieldSpacing;
+ typename ResultImageDescriptorType::DirectionType matrix;
+
+ mitk::ImageMappingHelper::ResultImageGeometryType::BoundsArrayType geoBounds = resultGeometry->GetBounds();
+ mitk::Vector3D geoSpacing = resultGeometry->GetSpacing();
+ mitk::Point3D geoOrigin = resultGeometry->GetOrigin();
+ mitk::AffineTransform3D::MatrixType geoMatrix = resultGeometry->GetIndexToWorldTransform()->GetMatrix();
+
+ for (unsigned int i = 0; i(geoOrigin[i]);
+ fieldSpacing[i] = static_cast(geoSpacing[i]);
+ size[i] = static_cast(geoBounds[(2*i)+1]-geoBounds[2*i])*fieldSpacing[i];
+ }
+
+ //Matrix extraction
+ matrix.SetIdentity();
+ unsigned int i;
+ unsigned int j;
+
+ /// \warning 2D MITK images could have a 3D rotation, since they have a 3x3 geometry matrix.
+ /// If it is only a rotation around the transversal plane normal, it can be express with a 2x2 matrix.
+ /// In this case, the ITK image conservs this information and is identical to the MITK image!
+ /// If the MITK image contains any other rotation, the ITK image will have no rotation at all.
+ /// Spacing is of course conserved in both cases.
+
+ // the following loop devides by spacing now to normalize columns.
+ // counterpart of InitializeByItk in mitkImage.h line 372 of revision 15092.
+
+ // Check if information is lost
+ if ( VImageDimension == 2)
+ {
+ if ( ( geoMatrix[0][2] != 0) ||
+ ( geoMatrix[1][2] != 0) ||
+ ( geoMatrix[2][0] != 0) ||
+ ( geoMatrix[2][1] != 0) ||
+ (( geoMatrix[2][2] != 1) && ( geoMatrix[2][2] != -1) ))
+ {
+ // The 2D MITK image contains 3D rotation information.
+ // This cannot be expressed in a 2D ITK image, so the ITK image will have no rotation
+ }
+ else
+ {
+ // The 2D MITK image can be converted to an 2D ITK image without information loss!
+ for ( i=0; i < 2; ++i)
+ {
+ for( j=0; j < 2; ++j )
+ {
+ matrix[i][j] = geoMatrix[i][j]/fieldSpacing[j];
+ }
+ }
+ }
+ }
+ else if (VImageDimension == 3)
+ {
+ // Normal 3D image. Conversion possible without problem!
+ for ( i=0; i < 3; ++i)
+ {
+ for( j=0; j < 3; ++j )
+ {
+ matrix[i][j] = geoMatrix[i][j]/fieldSpacing[j];
+ }
+ }
+ }
+ else
+ {
+ assert(0);
+ throw mitk::AccessByItkException("Usage of resultGeometry for 2D images is not yet implemented.");
+ /**@TODO Implement extraction of 2D-Rotation-Matrix out of 3D-Rotation-Matrix
+ * to cover this case as well.
+ * matrix = extract2DRotationMatrix(resultGeometry)*/
+ }
+
+ resultDescriptor->setOrigin(origin);
+ resultDescriptor->setSize(size);
+ resultDescriptor->setSpacing(fieldSpacing);
+ resultDescriptor->setDirection(matrix);
+ }
+
+ //do the mapping
+ /////////////////////////
+ typedef ::itk::InterpolateImageFunction< ::itk::Image > BaseInterpolatorType;
+ typename BaseInterpolatorType::Pointer interpolator = generateInterpolator< ::itk::Image >(interpolatorType);
+ assert(interpolator.IsNotNull());
+ spTask->setImageInterpolator(interpolator);
+ spTask->setInputImage(input);
+ spTask->setRegistration(castedReg);
+ spTask->setResultImageDescriptor(resultDescriptor);
+ spTask->setThrowOnMappingError(throwOnMappingError);
+ spTask->setErrorValue(errorValue);
+ spTask->setThrowOnPaddingError(throwOnOutOfInputAreaError);
+ spTask->setPaddingValue(paddingValue);
+
+ spTask->execute();
+ mitk::CastToMitkImage<>(spTask->getResultImage(),result);
+}
+
+mitk::ImageMappingHelper::ResultImageType::Pointer
+ mitk::ImageMappingHelper::map(const InputImageType* input, const RegistrationType* registration,
+ bool throwOnOutOfInputAreaError, const double& paddingValue, const ResultImageGeometryType* resultGeometry,
+ bool throwOnMappingError, const double& errorValue, mitk::ImageMappingInterpolator::Type interpolatorType)
+{
+ if (!registration)
+ {
+ mitkThrow() << "Cannot map image. Passed registration wrapper pointer is NULL.";
+ }
+ if (!input)
+ {
+ mitkThrow() << "Cannot map image. Passed image pointer is NULL.";
+ }
+
+ ResultImageType::Pointer result;
+
+ if(input->GetTimeSteps()==1)
+ { //map the image and done
+ AccessByItk_n(input, doMITKMap, (result, registration, throwOnOutOfInputAreaError, paddingValue, resultGeometry, throwOnMappingError, errorValue, interpolatorType));
+ }
+ else
+ { //map every time step and compose
+
+ mitk::TimeGeometry::ConstPointer timeGeometry = input->GetTimeGeometry();
+ mitk::TimeGeometry::Pointer mappedTimeGeometry = timeGeometry->Clone();
+
+ for (unsigned int i = 0; iGetTimeSteps(); ++i)
+ {
+ ResultImageGeometryType::Pointer mappedGeometry = resultGeometry->Clone();
+ mappedTimeGeometry->SetTimeStepGeometry(mappedGeometry,i);
+ }
+
+ result = mitk::Image::New();
+ result->Initialize(input->GetPixelType(),*mappedTimeGeometry, 1, input->GetTimeSteps());
+
+ for (unsigned int i = 0; iGetTimeSteps(); ++i)
+ {
+ mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New();
+ imageTimeSelector->SetInput(input);
+ imageTimeSelector->SetTimeNr(i);
+ imageTimeSelector->UpdateLargestPossibleRegion();
+
+ InputImageType::Pointer timeStepInput = imageTimeSelector->GetOutput();
+ ResultImageType::Pointer timeStepResult;
+ AccessByItk_n(timeStepInput, doMITKMap, (timeStepResult, registration, throwOnOutOfInputAreaError, paddingValue, resultGeometry, throwOnMappingError, errorValue, interpolatorType));
+ result->SetVolume(timeStepResult->GetVolumeData()->GetData(),i);
+ }
+ }
+
+ return result;
+}
+
+mitk::ImageMappingHelper::ResultImageType::Pointer
+ mitk::ImageMappingHelper::map(const InputImageType* input, const MITKRegistrationType* registration,
+ bool throwOnOutOfInputAreaError, const double& paddingValue, const ResultImageGeometryType* resultGeometry,
+ bool throwOnMappingError, const double& errorValue, mitk::ImageMappingInterpolator::Type interpolatorType)
+{
+ if (!registration)
+ {
+ mitkThrow() << "Cannot map image. Passed registration wrapper pointer is NULL.";
+ }
+ if (!registration->GetRegistration())
+ {
+ mitkThrow() << "Cannot map image. Passed registration wrapper containes no registration.";
+ }
+ if (!input)
+ {
+ mitkThrow() << "Cannot map image. Passed image pointer is NULL.";
+ }
+
+ ResultImageType::Pointer result = map(input, registration->GetRegistration(), throwOnOutOfInputAreaError, paddingValue, resultGeometry, throwOnMappingError, errorValue);
+ return result;
+}
+
+
+mitk::ImageMappingHelper::ResultImageType::Pointer
+ mitk::ImageMappingHelper::
+ refineGeometry(const InputImageType* input, const RegistrationType* registration,
+ bool throwOnError)
+{
+ mitk::ImageMappingHelper::ResultImageType::Pointer result = NULL;
+
+ if (!registration)
+ {
+ mitkThrow() << "Cannot refine image geometry. Passed registration pointer is NULL.";
+ }
+ if (!input)
+ {
+ mitkThrow() << "Cannot refine image geometry. Passed image pointer is NULL.";
+ }
+
+ mitk::MITKRegistrationHelper::Affine3DTransformType::Pointer spTransform = mitk::MITKRegistrationHelper::getAffineMatrix(registration,false);
+ if(spTransform.IsNull() && throwOnError)
+ {
+ mitkThrow() << "Cannot refine image geometry. Registration does not contain a suitable direct mapping kernel (3D affine transformation or compatible required).";
+ }
+
+ if(spTransform.IsNotNull())
+ {
+ //copy input image
+ result = input->Clone();
+
+ //refine geometries
+ for(unsigned int i = 0; i < result->GetTimeSteps(); ++i)
+ { //refine every time step
+ result->GetGeometry(i)->Compose(spTransform);
+ }
+ result->GetTimeGeometry()->Update();
+ }
+
+ return result;
+}
+
+mitk::ImageMappingHelper::ResultImageType::Pointer
+ mitk::ImageMappingHelper::
+ refineGeometry(const InputImageType* input, const MITKRegistrationType* registration,
+ bool throwOnError)
+{
+ if (!registration)
+ {
+ mitkThrow() << "Cannot refine image geometry. Passed registration wrapper pointer is NULL.";
+ }
+ if (!registration->GetRegistration())
+ {
+ mitkThrow() << "Cannot refine image geometry. Passed registration wrapper containes no registration.";
+ }
+ if (!input)
+ {
+ mitkThrow() << "Cannot refine image geometry. Passed image pointer is NULL.";
+ }
+
+ ResultImageType::Pointer result = refineGeometry(input, registration->GetRegistration(), throwOnError);
+ return result;
+}
+
+bool
+ mitk::ImageMappingHelper::
+ canRefineGeometry(const RegistrationType* registration)
+{
+ bool result = true;
+
+ if (!registration)
+ {
+ mitkThrow() << "Cannot check refine capability of registration. Passed registration pointer is NULL.";
+ }
+
+ //if the helper does not return null, we can refine the geometry.
+ result = mitk::MITKRegistrationHelper::getAffineMatrix(registration,false).IsNotNull();
+
+ return result;
+}
+
+bool
+ mitk::ImageMappingHelper::
+ canRefineGeometry(const MITKRegistrationType* registration)
+{
+ if (!registration)
+ {
+ mitkThrow() << "Cannot check refine capability of registration. Passed registration wrapper pointer is NULL.";
+ }
+ if (!registration->GetRegistration())
+ {
+ mitkThrow() << "Cannot check refine capability of registration. Passed registration wrapper containes no registration.";
+ }
+
+ return canRefineGeometry(registration->GetRegistration());
+}
+
diff --git a/Modules/MatchPointRegistration/Helper/mitkImageMappingHelper.h b/Modules/MatchPointRegistration/Helper/mitkImageMappingHelper.h
new file mode 100644
index 0000000000..c1bb869af1
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkImageMappingHelper.h
@@ -0,0 +1,117 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef MITK_IMAGE_MAPPING_HELPER_H
+#define MITK_IMAGE_MAPPING_HELPER_H
+
+#include "mapImageMappingTask.h"
+#include "mapRegistrationBase.h"
+#include "mitkImage.h"
+#include "mitkGeometry3D.h"
+
+#include "mitkMAPRegistrationWrapper.h"
+
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+ struct ImageMappingInterpolator
+ {
+ enum Type
+ {
+ UserDefined = 0, //< User may specify the interpolator to use
+ NearestNeighbor = 1, //< use nearest neighbor
+ Linear = 2, //< use linear
+ BSpline_3 = 3, //< use a 3rd order spline
+ WSinc_Hamming = 4, //< use a wsinc with hamming window
+ WSinc_Welch = 5 //< use a wsinc with welch window
+ };
+ };
+
+ namespace ImageMappingHelper
+ {
+ typedef ::map::core::RegistrationBase RegistrationType;
+ typedef ::mitk::MAPRegistrationWrapper MITKRegistrationType;
+
+ typedef ::mitk::BaseGeometry ResultImageGeometryType;
+ typedef ::mitk::Image InputImageType;
+ typedef ::mitk::Image ResultImageType;
+
+ /**Helper that maps a given input image
+ * @param input Image that should be mapped.
+ * @param registration Pointer to the registration instance that should be used for mapping
+ * @param throwOnOutOfInputAreaError Indicates if mapping should fail with an exception (true), if the input image does not cover the whole requested region to be mapped into the result image.
+ * @param paddingValue Indicates the value that should be used if an out of input error occurs (and throwOnOutOfInputAreaError is false).
+ * @param resultGeometry Pointer to the Geometry object that specifies the grid of the result image. If not defined the geometry of the input image will be used.
+ * @param throwOnMappingError Indicates if mapping should fail with an exception (true), if the registration does not cover/support the whole requested region for mapping into the result image.
+ * @param errorValue Indicates the value that should be used if an mapping error occurs (and throwOnMappingError is false).
+ * @param interpolatorType Indicates the type of interpolation strategy that should be used.
+ * @pre input must be valid
+ * @pre registration must be valid
+ * @pre Dimensionality of the registration must match with the input imageinput must be valid
+ * @remark Depending in the settings of throwOnOutOfInputAreaError and throwOnMappingError it may also throw
+ * due to inconsistencies in the mapping process. See parameter description.
+ * @result Pointer to the resulting mapped image.h*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType* input, const RegistrationType* registration,
+ bool throwOnOutOfInputAreaError = false, const double& paddingValue = 0,
+ const ResultImageGeometryType* resultGeometry = NULL,
+ bool throwOnMappingError = true, const double& errorValue = 0, mitk::ImageMappingInterpolator::Type interpolatorType = mitk::ImageMappingInterpolator::Linear);
+
+ /**Helper that maps a given input image.
+ * @overload
+ * @param input Image that should be mapped.
+ * @param registration Pointer to the registration instance that should be used for mapping
+ * @param throwOnOutOfInputAreaError Indicates if mapping should fail with an exception (true), if the input image does not cover the whole requested region to be mapped into the result image.
+ * @param paddingValue Indicates the value that should be used if an out of input error occurs (and throwOnOutOfInputAreaError is false).
+ * @param resultGeometry Pointer to the Geometry object that specifies the grid of the result image. If not defined the geometry of the input image will be used.
+ * @param throwOnMappingError Indicates if mapping should fail with an exception (true), if the registration does not cover/support the whole requested region for mapping into the result image.
+ * @param errorValue Indicates the value that should be used if an mapping error occurs (and throwOnMappingError is false).
+ * @param interpolatorType Indicates the type of interpolation strategy that should be used.
+ * @pre input must be valid
+ * @pre registration must be valid
+ * @pre Dimensionality of the registration must match with the input imageinput must be valid
+ * @remark Depending in the settings of throwOnOutOfInputAreaError and throwOnMappingError it may also throw
+ * due to inconsistencies in the mapping process. See parameter description.
+ * @result Pointer to the resulting mapped image.h*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer map(const InputImageType* input, const MITKRegistrationType* registration,
+ bool throwOnOutOfInputAreaError = false, const double& paddingValue = 0,
+ const ResultImageGeometryType* resultGeometry = NULL,
+ bool throwOnMappingError = true, const double& errorValue = 0, mitk::ImageMappingInterpolator::Type interpolatorType = mitk::ImageMappingInterpolator::Linear);
+
+ /**Method clones the input image and applies the registration by applying it to the Geometry3D of the image.
+ Thus this method only produces a result if the passed registration has an direct mapping kernel that
+ can be converted into an affine matrix transformation.
+ @pre input must point to a valid instance
+ @pre registration must point to a valid instance
+ @pre registration must be decomposable into rotation matrix and offset or throwOnError must be false.
+ @result Pointer to the result image with refined geometry. May be null if the result cannot be
+ generated (e.g. the registration cannot be transformed in a affine matrix transformation)*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer refineGeometry(const InputImageType* input, const RegistrationType* registration, bool throwOnError = true);
+ /**@overload*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ResultImageType::Pointer refineGeometry(const InputImageType* input, const MITKRegistrationType* registration, bool throwOnError = true);
+
+ /**Method allows to pre checks if a registration could be used with refineGeometry. If this method returns true,
+ * the registration can be used to refine the geometry of images.*/
+ MITKMATCHPOINTREGISTRATION_EXPORT bool canRefineGeometry(const RegistrationType* registration);
+ /**@overload*/
+ MITKMATCHPOINTREGISTRATION_EXPORT bool canRefineGeometry(const MITKRegistrationType* registration);
+
+ }
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Modules/MatchPointRegistration/Helper/mitkMaskedAlgorithmHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkMaskedAlgorithmHelper.cpp
new file mode 100644
index 0000000000..80137f2818
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkMaskedAlgorithmHelper.cpp
@@ -0,0 +1,172 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkMaskedAlgorithmHelper.h"
+
+#include
+
+// Mitk
+#include
+
+// MatchPoint
+#include "mapMaskedRegistrationAlgorithmInterface.h"
+#include
+
+namespace mitk
+{
+
+ MaskedAlgorithmHelper::MaskedAlgorithmHelper(map::algorithm::RegistrationAlgorithmBase* algorithm) : m_AlgorithmBase(algorithm)
+ {
+ }
+
+ bool
+ MaskedAlgorithmHelper::
+ CheckSupport(const mitk::Image* movingMask, const mitk::Image* targetMask) const
+ {
+ if (! m_AlgorithmBase) mapDefaultExceptionStaticMacro(<< "Error, cannot check data. Helper has no algorithm defined.");
+
+ unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
+ unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
+
+ bool result = movingDim == targetDim;
+
+ if ( movingMask)
+ {
+ result = result && (movingMask->GetDimension() == movingDim);
+
+ if (movingDim == 2)
+ {
+ typedef itk::Image MaskImageType;
+ mitk::PixelType maskPixelType = mitk::MakePixelType();
+
+ result = result && (maskPixelType == movingMask->GetPixelType());
+ }
+ else if (movingDim == 3)
+ {
+ typedef itk::Image MaskImageType;
+ mitk::PixelType maskPixelType = mitk::MakePixelType();
+
+ result = result && (maskPixelType == movingMask->GetPixelType());
+ }
+ }
+
+ if ( targetMask)
+ {
+ result = result && (targetMask->GetDimension() == targetDim);
+
+ if (movingDim == 2)
+ {
+ typedef itk::Image MaskImageType;
+ mitk::PixelType maskPixelType = mitk::MakePixelType();
+
+ result = result && (maskPixelType == targetMask->GetPixelType());
+ }
+ else if (movingDim == 3)
+ {
+ typedef itk::Image MaskImageType;
+ mitk::PixelType maskPixelType = mitk::MakePixelType();
+
+ result = result && (maskPixelType == targetMask->GetPixelType());
+ }
+ }
+
+ if (movingDim == 2)
+ {
+ typedef ::map::algorithm::facet::MaskedRegistrationAlgorithmInterface<2, 2> MaskedInterface;
+ const MaskedInterface* pMaskedReg = dynamic_cast(m_AlgorithmBase.GetPointer());
+
+ result = result && pMaskedReg;
+ }
+ else if (movingDim == 3)
+ {
+ typedef ::map::algorithm::facet::MaskedRegistrationAlgorithmInterface<3, 3> MaskedInterface;
+ const MaskedInterface* pMaskedReg = dynamic_cast(m_AlgorithmBase.GetPointer());
+
+ result = result && pMaskedReg;
+ }
+ else
+ {
+ result = false;
+ }
+
+ return result;
+ };
+
+ bool MaskedAlgorithmHelper::SetMasks(const mitk::Image* movingMask, const mitk::Image* targetMask)
+ {
+ if (! m_AlgorithmBase) mapDefaultExceptionStaticMacro(<< "Error, cannot set data. Helper has no algorithm defined.");
+
+ if (! CheckSupport(movingMask, targetMask)) return false;
+
+ unsigned int movingDim = m_AlgorithmBase->getMovingDimensions();
+ unsigned int targetDim = m_AlgorithmBase->getTargetDimensions();
+
+ if (movingDim!=targetDim) return false;
+
+ if (movingDim == 2)
+ {
+ return DoSetMasks<2,2>(movingMask, targetMask);
+ }
+ else if (movingDim == 3)
+ {
+ return DoSetMasks<3,3>(movingMask, targetMask);
+ }
+ return false;
+ };
+
+ template
+ bool MaskedAlgorithmHelper::DoSetMasks(const mitk::Image* movingMask, const mitk::Image* targetMask)
+ {
+ typedef itk::SpatialObject MovingSpatialType;
+ typedef itk::SpatialObject TargetSpatialType;
+
+ typedef ::map::algorithm::facet::MaskedRegistrationAlgorithmInterface MaskedRegInterface;
+ MaskedRegInterface* pAlg = dynamic_cast(m_AlgorithmBase.GetPointer());
+
+ if (!pAlg) return false;
+
+ if (movingMask)
+ {
+ AccessFixedTypeByItk(movingMask, DoConvertMask, (MaskPixelType), (VImageDimension1));
+ typename MovingSpatialType::Pointer movingSpatial = dynamic_cast(m_convertResult.GetPointer());
+ if (! movingSpatial) mapDefaultExceptionStaticMacro(<< "Error, cannot convert moving mask.");
+ pAlg->setMovingMask(movingSpatial);
+ }
+
+ if (targetMask)
+ {
+ AccessFixedTypeByItk(targetMask, DoConvertMask, (MaskPixelType), (VImageDimension2));
+ typename TargetSpatialType::Pointer targetSpatial = dynamic_cast(m_convertResult.GetPointer());
+ if (! targetSpatial) mapDefaultExceptionStaticMacro(<< "Error, cannot convert moving mask.");
+ pAlg->setTargetMask(targetSpatial);
+ }
+
+ return true;
+ }
+
+ template
+ void MaskedAlgorithmHelper::DoConvertMask(const itk::Image* mask)
+ {
+ typedef itk::Image ImageType;
+ typedef itk::ImageMaskSpatialObject SpatialType;
+
+ typename SpatialType::Pointer spatial = SpatialType::New();
+ spatial->SetImage(mask);
+
+ m_convertResult = spatial.GetPointer();
+ }
+
+}
diff --git a/Modules/MatchPointRegistration/Helper/mitkMaskedAlgorithmHelper.h b/Modules/MatchPointRegistration/Helper/mitkMaskedAlgorithmHelper.h
new file mode 100644
index 0000000000..54c4a56091
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkMaskedAlgorithmHelper.h
@@ -0,0 +1,80 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef mitkMaskedAlgorithmHelper_h
+#define mitkMaskedAlgorithmHelper_h
+
+
+//MatchPoint
+#include "mapRegistrationAlgorithmBase.h"
+
+//MITK
+#include
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+ /*!
+ \brief MaskedAlgorithmHelper
+ Helper class as an easy bridge to set mitk images as masks for registration algorithms. It is assumed that the
+ Image indicates the mask by pixel values != 0.
+ \remark Currently only 2D-2D and 3D-3D algorithms are supported.
+ \remark Currently only masks with pixel type unsigned char (default mitk segmentation images) are supported.
+ \remark Current implementation is not thread-save. Just use one Helper class per registration task.
+ */
+ class MITKMATCHPOINTREGISTRATION_EXPORT MaskedAlgorithmHelper
+ {
+ public:
+
+ MaskedAlgorithmHelper(map::algorithm::RegistrationAlgorithmBase* algorithm = NULL);
+
+ /** Set one or both masks to an algorithm.
+ * If the algorithm does not support masks it will be ignored.
+ * @remark Set a mask to NULL if you don't want to set it.
+ * @return Indicates if the masks could be set/was supported by algorithm.*/
+ bool SetMasks(const mitk::Image* movingMask, const mitk::Image* targetMask);
+
+ /** Checks if the algorithm supports masks of the passed type.*/
+ bool CheckSupport(const mitk::Image* movingMask, const mitk::Image* targetMask) const;
+
+ ~MaskedAlgorithmHelper() {}
+
+ private:
+ typedef unsigned char MaskPixelType;
+
+ MaskedAlgorithmHelper& operator = (const MaskedAlgorithmHelper&);
+ MaskedAlgorithmHelper(const MaskedAlgorithmHelper&);
+
+ /**Internal helper that is used by SetMasks if the data are images to set them properly.*/
+ template
+ bool DoSetMasks(const mitk::Image* movingMask, const mitk::Image* targetMask);
+
+ /**Internal helper that is used by SetData if the data are images to set them properly.*/
+ template
+ void DoConvertMask(const itk::Image* mask);
+ /**Helper member that containes the result of the last call of DoConvertMask().*/
+ itk::DataObject::Pointer m_convertResult;
+
+ map::algorithm::RegistrationAlgorithmBase::Pointer m_AlgorithmBase;
+ };
+
+}
+
+#endif
+
diff --git a/Modules/MatchPointRegistration/Helper/mitkPointSetMappingHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkPointSetMappingHelper.cpp
new file mode 100644
index 0000000000..f2a1fb5564
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkPointSetMappingHelper.cpp
@@ -0,0 +1,148 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mapRegistration.h"
+
+#include "mitkPointSetMappingHelper.h"
+#include "mitkRegistrationHelper.h"
+
+
+#include "mapPointSetMappingTask.h"
+
+::map::core::continuous::Elements<3>::InternalPointSetType::Pointer mitk::PointSetMappingHelper::ConvertPointSetMITKtoMAP(const mitk::PointSet::DataType* mitkSet)
+{
+ if (! mitkSet) mapDefaultExceptionStaticMacro(<< "Error, cannot convert point set. Passed mitk point set is null.");
+
+ ::map::core::continuous::Elements<3>::InternalPointSetType::Pointer mapSet = ::map::core::continuous::Elements<3>::InternalPointSetType::New();
+ ::map::core::continuous::Elements<3>::InternalPointSetType::PointsContainer::Pointer mapContainer = ::map::core::continuous::Elements<3>::InternalPointSetType::PointsContainer::New();
+ ::map::core::continuous::Elements<3>::InternalPointSetType::PointDataContainer::Pointer mapDataContainer = ::map::core::continuous::Elements<3>::InternalPointSetType::PointDataContainer::New();
+ mapSet->SetPoints(mapContainer);
+ mapSet->SetPointData(mapDataContainer);
+
+ unsigned int pointCount = mitkSet->GetNumberOfPoints();
+
+ for (unsigned int pointId = 0; pointId < pointCount; ++pointId)
+ {
+ mapSet->SetPoint(pointId, mitkSet->GetPoint(pointId));
+
+ mitk::PointSet::PointDataType data;
+ if (mitkSet->GetPointData(pointId,&data))
+ {
+ mapSet->SetPointData(pointId,data.id);
+ }
+ }
+
+ return mapSet;
+}
+
+::mitk::PointSet::Pointer
+ mitk::PointSetMappingHelper::map(const ::mitk::PointSet* input, const mitk::PointSetMappingHelper::RegistrationType* registration, int timeStep,
+ bool throwOnMappingError, const ::mitk::PointSet::PointDataType& errorPointValue)
+{
+ if (!registration)
+ {
+ mitkThrow() << "Cannot map point set. Passed registration wrapper pointer is NULL.";
+ }
+ if (!input)
+ {
+ mitkThrow() << "Cannot map point set. Passed point set pointer is NULL.";
+ }
+ if (input->GetTimeSteps()<=timeStep && timeStep>=0)
+ {
+ mitkThrow() << "Cannot set point set. Selected time step is larger then mitk point set. MITK time step count: "<GetTimeSteps()<<"; selected time step: "<Clone();
+
+ typedef ::map::core::continuous::Elements<3>::InternalPointSetType MAPPointSetType;
+ typedef ::map::core::Registration<3,3> ConcreteRegistrationType;
+ const ConcreteRegistrationType* castedReg = dynamic_cast(registration);
+ if (!castedReg)
+ {
+ mitkThrow() <<"Moving and/or fixed dimension of the registration is not 3. Cannot map point 3D set.";
+ }
+
+ typedef ::map::core::PointSetMappingTask MappingTaskType;
+ MappingTaskType::ErrorPointValueType internalErrorValue = itk::NumericTraits::NonpositiveMin();
+ MappingTaskType::Pointer spTask = MappingTaskType::New();
+ spTask->setRegistration(castedReg);
+ spTask->setThrowOnMappingError(throwOnMappingError);
+ spTask->setErrorPointValue(internalErrorValue);
+
+ unsigned int timePos = timeStep;
+ unsigned int timeEndPos = timeStep+1;
+ if (timeStep < 0)
+ {
+ timePos = 0;
+ timeEndPos = input->GetTimeSteps();
+ }
+
+ while (timePosGetPointSet(timePos));
+ spTask->setInputPointSet(inputTempSet);
+ spTask->execute();
+
+ MAPPointSetType::Pointer mappedSet = spTask->getResultPointSet();
+
+ unsigned int pointCount = input->GetSize(timePos);
+
+ for (unsigned int pointId = 0; pointId < pointCount; ++pointId)
+ {
+ result->SetPoint(pointId, mappedSet->GetPoint(pointId), timePos);
+ bool invalid = true;
+ MAPPointSetType::PixelType mappedData;
+ if (mappedSet->GetPointData(pointId,&mappedData))
+ {
+ invalid = mappedData == internalErrorValue;
+ }
+
+ if (invalid)
+ {
+ result->GetPointSet(timePos)->GetPointData()->SetElement(pointId,errorPointValue);
+ }
+ else
+ {
+ result->GetPointSet(timePos)->GetPointData()->SetElement(pointId,input->GetPointSet(timePos)->GetPointData()->GetElement(pointId));
+ }
+ }
+
+ ++timePos;
+ }
+
+ return result;
+}
+
+::mitk::PointSet::Pointer
+ mitk::PointSetMappingHelper::map(const ::mitk::PointSet* input, const MITKRegistrationType* registration, int timeStep,
+ bool throwOnMappingError, const ::mitk::PointSet::PointDataType& errorPointValue)
+{
+ if (!registration)
+ {
+ mitkThrow() << "Cannot map point set. Passed registration wrapper pointer is NULL.";
+ }
+ if (!registration->GetRegistration())
+ {
+ mitkThrow() << "Cannot map point set. Passed registration wrapper containes no registration.";
+ }
+ if (!input)
+ {
+ mitkThrow() << "Cannot map point set. Passed point set pointer is NULL.";
+ }
+
+ ::mitk::PointSet::Pointer result = map(input, registration->GetRegistration(), timeStep, throwOnMappingError, errorPointValue);
+ return result;
+}
diff --git a/Modules/MatchPointRegistration/Helper/mitkPointSetMappingHelper.h b/Modules/MatchPointRegistration/Helper/mitkPointSetMappingHelper.h
new file mode 100644
index 0000000000..b12df31d4e
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkPointSetMappingHelper.h
@@ -0,0 +1,64 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef MITK_POINTSET_MAPPING_HELPER_H
+#define MITK_POINTSET_MAPPING_HELPER_H
+
+#include "mapRegistrationBase.h"
+#include
+
+#include "mitkMAPRegistrationWrapper.h"
+
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+
+ namespace PointSetMappingHelper
+ {
+ typedef ::map::core::RegistrationBase RegistrationType;
+ typedef ::mitk::MAPRegistrationWrapper MITKRegistrationType;
+
+ /**Helper that converts the data of an mitk point set into the default point set type of matchpoint.*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ::map::core::continuous::Elements<3>::InternalPointSetType::Pointer ConvertPointSetMITKtoMAP(const mitk::PointSet::DataType* mitkSet);
+
+ /**Helper that maps a given input point set
+ * @param input Point set that should be mapped.
+ * @param registration Pointer to the registration instance that should be used for mapping
+ * @param timeStep Indicates which time step of the point set should be mapped (the rest will just be copied). -1 (default) indicates that all time steps should be mapped.
+ * @param throwOnMappingError Indicates if mapping should fail with an exception (true), if the registration does not cover/support the whole requested region for mapping into the result image.
+ * if set to false, points that cause an mapping error will be transfered without mapping but get the passed errorPointValue as data to indicate unmappable points;
+ * @param errorPointValue Indicates the point data that should be used if an mapping error occurs (and throwOnMappingError is false).
+ * @pre input must be valid
+ * @pre registration must be valid
+ * @pre timeStep must be a valid time step of input or -1
+ * @pre Dimensionality of the registration must match with the input imageinput must be valid
+ * @remark Depending in the settings of throwOnMappingError it may also throw
+ * due to inconsistencies in the mapping process. See parameter description.
+ * @result Pointer to the resulting mapped point set*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ::mitk::PointSet::Pointer map(const ::mitk::PointSet* input, const RegistrationType* registration, int timeStep = -1,
+ bool throwOnMappingError = true, const ::mitk::PointSet::PointDataType& errorPointValue = ::mitk::PointSet::PointDataType());
+
+ /**Helper that maps a given input point set
+ * @overload*/
+ MITKMATCHPOINTREGISTRATION_EXPORT ::mitk::PointSet::Pointer map(const ::mitk::PointSet* input, const MITKRegistrationType* registration, int timeStep = -1,
+ bool throwOnMappingError = true, const ::mitk::PointSet::PointDataType& errorPointValue = ::mitk::PointSet::PointDataType());
+ }
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Modules/MatchPointRegistration/Helper/mitkQMAPAlgorithmModel.cpp b/Modules/MatchPointRegistration/Helper/mitkQMAPAlgorithmModel.cpp
new file mode 100644
index 0000000000..c139aa4d4d
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkQMAPAlgorithmModel.cpp
@@ -0,0 +1,341 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#include "mitkQMAPAlgorithmModel.h"
+
+#include "mapMetaProperty.h"
+
+namespace mitk
+{
+
+QMAPAlgorithmModel::
+QMAPAlgorithmModel(QObject *parent) :
+ QAbstractTableModel(parent),
+ m_pMetaInterface(NULL)
+{
+
+}
+
+void
+QMAPAlgorithmModel::
+SetAlgorithm(map::algorithm::RegistrationAlgorithmBase *pAlgorithm)
+{
+ this->SetAlgorithm(dynamic_cast(pAlgorithm));
+};
+
+void
+QMAPAlgorithmModel::
+SetAlgorithm(map::algorithm::facet::MetaPropertyAlgorithmInterface *pMetaInterface)
+{
+ emit beginResetModel();
+
+ m_pMetaInterface = pMetaInterface;
+ this->UpdateMetaProperties();
+
+ emit endResetModel();
+};
+
+int
+QMAPAlgorithmModel::
+rowCount(const QModelIndex &parent) const
+{
+ if(parent.isValid())
+ {
+ return 0;
+ }
+
+ return m_MetaProperties.size();
+}
+
+int
+QMAPAlgorithmModel::
+columnCount(const QModelIndex &parent) const
+{
+ if(parent.isValid())
+ return 0;
+
+ return 2;
+}
+
+QVariant
+QMAPAlgorithmModel::
+data(const QModelIndex &index, int role) const
+{
+ if(!index.isValid())
+ return QVariant();
+
+ if(!m_pMetaInterface)
+ {
+ return QVariant();
+ }
+
+ QVariant result;
+
+ if(index.row()getName().c_str());
+ }
+ break;
+ case 1:
+ if (Qt::DisplayRole == role && !pInfo->isReadable())
+ {
+ result = QVariant("value is not accessible");
+ }
+ else if (pInfo->isReadable() && (Qt::DisplayRole == role || (Qt::EditRole == role && pInfo->isWritable())))
+ { //should also be readable to be sensible editable in the GUI
+ result = GetPropertyValue(pInfo,role);
+ }
+ break;
+ }
+ }
+
+ return result;
+}
+
+Qt::ItemFlags
+QMAPAlgorithmModel::
+flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags flags = QAbstractItemModel::flags(index);
+
+ if(index.row()isWritable())
+ {
+ flags |= Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+ }
+ }
+ }
+
+ return flags;
+}
+
+QVariant
+QMAPAlgorithmModel::
+headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if( (Qt::DisplayRole == role) &&
+ (Qt::Horizontal == orientation))
+ {
+ if (section==0)
+ {
+ return QVariant("Property");
+ }
+ else if (section==1)
+ {
+ return QVariant("Value");
+ }
+ }
+ return QVariant();
+}
+
+bool
+QMAPAlgorithmModel::
+setData(const QModelIndex &index, const QVariant &value, int role)
+{
+ if(!index.isValid() || (m_MetaProperties.size() <= index.row()) || (1 != index.column()))
+ {
+ return false;
+ }
+
+ if(Qt::EditRole == role)
+ {
+ map::algorithm::MetaPropertyInfo* pInfo = m_MetaProperties[index.row()];
+
+ bool result = SetPropertyValue(pInfo,value);
+
+ if (result)
+ {
+ emit beginResetModel();
+ this->UpdateMetaProperties();
+ emit endResetModel();
+ }
+
+ return result;
+ }
+
+ return false;
+};
+
+
+void
+QMAPAlgorithmModel::
+UpdateMetaProperties() const
+{
+ if(m_pMetaInterface)
+ {
+ m_MetaProperties = m_pMetaInterface->getPropertyInfos();
+ }
+ else
+ {
+ m_MetaProperties.clear();
+ }
+}
+
+QVariant
+QMAPAlgorithmModel::
+GetPropertyValue(const map::algorithm::MetaPropertyInfo* pInfo, int role) const
+{
+ if(!m_pMetaInterface)
+ {
+ return QVariant();
+ }
+
+ map::algorithm::facet::MetaPropertyAlgorithmInterface::MetaPropertyPointer prop = m_pMetaInterface->getProperty(pInfo);
+
+ if(!prop)
+ {
+ return QVariant();
+ }
+
+ QVariant result;
+
+ if (role == Qt::DisplayRole)
+ {
+ result = QVariant(QString("Error. Cannot unwrap MetaProperty. Name: ")+QString::fromStdString(pInfo->getName()));
+ }
+
+ if (prop->getMetaPropertyTypeInfo()==typeid(bool))
+ {
+ bool val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(val);
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(int))
+ {
+ int val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(val);
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(unsigned int))
+ {
+ unsigned int val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(val);
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(long))
+ {
+ long val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(qlonglong(val));
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(unsigned long))
+ {
+ unsigned long val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(qulonglong(val));
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(float))
+ {
+ float val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(val);
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(double))
+ {
+ double val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(val);
+ }
+ }
+ else if (prop->getMetaPropertyTypeInfo()==typeid(map::core::String))
+ {
+ map::core::String val;
+ if (map::core::unwrapCastedMetaProperty(prop,val))
+ {
+ result = QVariant(QString::fromStdString(val));
+ }
+ }
+ else
+ {
+ if (role == Qt::DisplayRole)
+ {
+ result = QVariant(QString("Error. Cannot offer MetaProperty because of unsupported type. Property name: ")+QString::fromStdString(pInfo->getName())+QString("; type name: ")+QString(prop->getMetaPropertyTypeName()));
+ }
+ }
+ return result;
+};
+
+template
+bool
+QMAPAlgorithmModel::
+CheckCastAndSetProp(const map::algorithm::MetaPropertyInfo* pInfo, const QVariant& value)
+{
+ bool result = false;
+ if (pInfo->getTypeInfo()==typeid(TValueType) && value.canConvert())
+ {
+ /**@TODO: Not save, because canConvert may say true but the actual value is not really convertible (e.g. string to int for the value "a")*/
+ TValueType val = value.value();
+ map::core::MetaPropertyBase::Pointer spMetaProp = map::core::MetaProperty::New(val).GetPointer();
+
+ result = m_pMetaInterface->setProperty(pInfo,spMetaProp);
+ }
+ return result;
+};
+
+bool
+QMAPAlgorithmModel::
+SetPropertyValue(const map::algorithm::MetaPropertyInfo* pInfo, const QVariant& value)
+{
+ if(!m_pMetaInterface)
+ {
+ return false;
+ }
+
+ bool result = CheckCastAndSetProp(pInfo,value);
+
+ if (!result) result = CheckCastAndSetProp(pInfo,value);
+ if (!result) result = CheckCastAndSetProp(pInfo,value);
+ if (!result) result = CheckCastAndSetProp(pInfo,value);
+ if (!result) result = CheckCastAndSetProp(pInfo,value);
+ if (!result) result = CheckCastAndSetProp(pInfo,value);
+ if (!result) result = CheckCastAndSetProp(pInfo,value);
+ if (!result && pInfo->getTypeInfo()==typeid(map::core::String))
+ {
+ map::core::String val = value.toString().toStdString();
+ map::core::MetaPropertyBase::Pointer spMetaProp = map::core::MetaProperty::New(val).GetPointer();
+
+ result = m_pMetaInterface->setProperty(pInfo,spMetaProp);
+ };
+
+ return result;
+};
+
+}
diff --git a/Modules/MatchPointRegistration/Helper/mitkQMAPAlgorithmModel.h b/Modules/MatchPointRegistration/Helper/mitkQMAPAlgorithmModel.h
new file mode 100644
index 0000000000..22ce639e56
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkQMAPAlgorithmModel.h
@@ -0,0 +1,80 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#ifndef mitkQMAPAlgorithmModel_h
+#define mitkQMAPAlgorithmModel_h
+
+#include
+#include
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+
+// MatchPoint
+#include
+#include
+
+namespace mitk
+{
+/*!
+ \class QMAPAlgorithmModel
+ Helper class that implements a model to handle the MetaProperty interface of a MatchPoint algorithm
+ in contect of the QT view-model-concept. A algorithm can be set as data source for the model.
+ The model retrieves all information through the MetaPropertyInterface. Changes in the view will
+ be propagated by the model into the algorithm.
+ \remarks The model only keep a simple pointer to the MetaPropertyInterface of the algorithm.
+ You have to ensure to reset the algorithm if the pointer goes invalid.
+ \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+*/
+class MITKMATCHPOINTREGISTRATION_EXPORT QMAPAlgorithmModel : public QAbstractTableModel
+{
+ Q_OBJECT
+
+ public:
+ QMAPAlgorithmModel(QObject *parent = NULL);
+ virtual ~QMAPAlgorithmModel() {};
+
+ void SetAlgorithm(map::algorithm::RegistrationAlgorithmBase *pAlgorithm);
+ void SetAlgorithm(map::algorithm::facet::MetaPropertyAlgorithmInterface *pMetaInterface);
+
+ virtual Qt::ItemFlags flags(const QModelIndex &index) const;
+ virtual QVariant data(const QModelIndex &index, int role) const;
+ virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+
+private:
+ void UpdateMetaProperties() const ;
+
+ /** Method uses m_pMetaInterface to retrieve the MetaProperty and unwraps it into an
+ * suitable QVariant depending on the passed QT role. If the MetaProperty type is not supported, the QVariant is invalid.
+ */
+ QVariant GetPropertyValue(const map::algorithm::MetaPropertyInfo* pInfo, int role) const;
+
+ template bool CheckCastAndSetProp(const map::algorithm::MetaPropertyInfo* pInfo, const QVariant& value);
+
+ bool SetPropertyValue(const map::algorithm::MetaPropertyInfo* pInfo, const QVariant& value);
+
+ map::algorithm::facet::MetaPropertyAlgorithmInterface *m_pMetaInterface;
+ mutable map::algorithm::facet::MetaPropertyAlgorithmInterface::MetaPropertyVectorType m_MetaProperties;
+};
+
+};
+
+#endif // mitkQMAPAlgorithmModel_h
+
diff --git a/Modules/MatchPointRegistration/Helper/mitkRegistrationHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkRegistrationHelper.cpp
new file mode 100644
index 0000000000..fea344ebee
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkRegistrationHelper.cpp
@@ -0,0 +1,138 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#include "mitkRegistrationHelper.h"
+
+//MatchPoint
+#include "mapRegistrationKernel.h"
+
+namespace mitk
+{
+
+ MITKRegistrationHelper::Affine3DTransformType::Pointer
+ MITKRegistrationHelper::
+ getAffineMatrix(const mitk::MAPRegistrationWrapper* wrapper, bool inverseKernel)
+ {
+ Affine3DTransformType::Pointer result = NULL;
+
+ if (wrapper)
+ {
+ result = getAffineMatrix(wrapper->GetRegistration(), inverseKernel);
+ }
+ return result;
+ }
+
+ MITKRegistrationHelper::Affine3DTransformType::Pointer
+ MITKRegistrationHelper::
+ getAffineMatrix(const RegistrationBaseType* registration, bool inverseKernel)
+ {
+ Affine3DTransformType::Pointer result = NULL;
+
+ if (registration && is3D(registration))
+ {
+ const Registration3DType* pReg = dynamic_cast(registration);
+ if (pReg)
+ {
+ if (inverseKernel)
+ {
+ result = getAffineMatrix(pReg->getInverseMapping());
+ }
+ else
+ {
+ result = getAffineMatrix(pReg->getDirectMapping());
+ }
+ }
+ }
+ return result;
+ }
+
+
+ MITKRegistrationHelper::Affine3DTransformType::Pointer MITKRegistrationHelper::getAffineMatrix(const RegistrationKernel3DBase& kernel)
+ {
+ Affine3DTransformType::Pointer result = NULL;
+
+ typedef ::map::core::RegistrationKernel<3,3> KernelType;
+
+ const KernelType* pModelKernel = dynamic_cast(&kernel);
+
+ if (pModelKernel)
+ {
+
+ KernelType::TransformType::MatrixType matrix;
+ KernelType::TransformType::OutputVectorType offset;
+
+ if(pModelKernel->getAffineMatrixDecomposition(matrix,offset))
+ {
+ result = Affine3DTransformType::New();
+ Affine3DTransformType::MatrixType resultMatrix;
+ Affine3DTransformType::OffsetType resultOffset;
+
+ /**@TODO If MatchPoint and MITK get same scalar
+ values the casting of matrix and offset values is
+ obsolete and should be removed.*/
+ //The conversion of matrix and offset is needed
+ //because mitk uses float and MatchPoint currently
+ //double as scalar value.
+ for (unsigned int i=0; i(matrix.GetVnlMatrix().begin()[i]);
+ }
+ resultOffset.CastFrom(offset); //needed because mitk uses float and MatchPoint currently double as scalar value
+
+ result->SetMatrix(resultMatrix);
+ result->SetOffset(resultOffset);
+ }
+ }
+ return result;
+ }
+
+ bool MITKRegistrationHelper::is3D(const mitk::MAPRegistrationWrapper* wrapper)
+ {
+ bool result = false;
+
+ if (wrapper)
+ {
+ result = wrapper->GetMovingDimensions()==3 && wrapper->GetTargetDimensions()==3;
+ }
+ return result;
+ }
+
+ bool MITKRegistrationHelper::is3D(const RegistrationBaseType* reBase)
+ {
+ bool result = false;
+
+ if (reBase)
+ {
+ result = reBase->getMovingDimensions()==3 && reBase->getTargetDimensions()==3;
+ }
+ return result;
+ }
+
+ bool MITKRegistrationHelper::IsRegNode(const mitk::DataNode* node)
+ {
+ if (!node) return false;
+
+ mitk::BaseData* data = node->GetData();
+
+ if (data != NULL)
+ {
+ return std::string("MAPRegistrationWrapper").compare(data->GetNameOfClass()) == 0;
+ }
+
+ return false;
+ }
+}
diff --git a/Modules/MatchPointRegistration/Helper/mitkRegistrationHelper.h b/Modules/MatchPointRegistration/Helper/mitkRegistrationHelper.h
new file mode 100644
index 0000000000..296b4c0d53
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkRegistrationHelper.h
@@ -0,0 +1,82 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef _mitkRegistrationHelper_h
+#define _mitkRegistrationHelper_h
+
+//ITK
+#include "itkScalableAffineTransform.h"
+
+//MatchPoint
+#include "mapRegistrationAlgorithmBase.h"
+#include "mapRegistration.h"
+
+//MITK
+#include
+#include
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+#include "mitkMAPRegistrationWrapper.h"
+
+namespace mitk
+{
+/*!
+ \brief MITKRegistrationHelper
+ \warning This class is not yet documented. Use "git blame" and ask the author to provide basic documentation.
+*/
+class MITKMATCHPOINTREGISTRATION_EXPORT MITKRegistrationHelper
+{
+public:
+
+ typedef ::itk::ScalableAffineTransform< ::mitk::ScalarType,3 > Affine3DTransformType;
+ typedef ::map::core::Registration<3,3> Registration3DType;
+ typedef ::map::core::RegistrationBase RegistrationBaseType;
+
+ /** Extracts the affine transformation, if possible, of the selected kernel.
+ @param wrapper Pointer to the registration that is target of the extraction
+ @param inverseKernel Indicates from which kernel the matrix should be extract. True: inverse kernel, False: direct kernel.
+ @return Pointer to the extracted transform. If it is not possible to convert the kernel into an affine transform a null pointer is returned.
+ @pre wrapper must point to a valid instance.
+ @pre wrapper must be a 3D-3D registration.*/
+ static Affine3DTransformType::Pointer getAffineMatrix(const mitk::MAPRegistrationWrapper* wrapper, bool inverseKernel);
+ static Affine3DTransformType::Pointer getAffineMatrix(const RegistrationBaseType* registration, bool inverseKernel);
+
+ static bool is3D(const mitk::MAPRegistrationWrapper* wrapper);
+ static bool is3D(const RegistrationBaseType* regBase);
+
+ /** Checks if the passed Node contains a MatchPoint registration
+ @param Pointer to the node to be checked.*
+ @return true: node contains a MAPRegistrationWrapper. false: "node" does not point to a valid instance or does not contain
+ a registration wrapper.*/;
+ static bool IsRegNode(const mitk::DataNode* node);
+
+private:
+ typedef ::map::core::Registration<3,3>::DirectMappingType RegistrationKernel3DBase;
+ static Affine3DTransformType::Pointer getAffineMatrix(const RegistrationKernel3DBase& kernel);
+
+ MITKRegistrationHelper();
+ ~MITKRegistrationHelper();
+ MITKRegistrationHelper& operator = (const MITKRegistrationHelper&);
+ MITKRegistrationHelper(const MITKRegistrationHelper&);
+
+};
+
+}
+
+#endif
+
diff --git a/Modules/MatchPointRegistration/Helper/mitkResultNodeGenerationHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkResultNodeGenerationHelper.cpp
new file mode 100644
index 0000000000..fcf8b0a2db
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkResultNodeGenerationHelper.cpp
@@ -0,0 +1,81 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkResultNodeGenerationHelper.h"
+
+#include
+#include
+#include
+
+mitk::DataNode::Pointer
+ mitk::generateRegistrationResultNode(const std::string& nodeName, mitk::MAPRegistrationWrapper::Pointer resultReg, const std::string& algorithmUID, const std::string& movingNodeUID, const std::string& targetNodeUID)
+{
+ if (resultReg.IsNull())
+ {
+ mitkThrow() << "Cannot generate registration result node. Passed registration wrapper points to NULL.";
+ }
+
+ mitk::DataNode::Pointer m_spRegNode = mitk::DataNode::New();
+ m_spRegNode->SetData(resultReg);
+ m_spRegNode->SetName(nodeName);
+ m_spRegNode->AddProperty(mitk::nodeProp_RegAlgUsed,mitk::StringProperty::New(algorithmUID));
+ m_spRegNode->AddProperty(mitk::nodeProp_RegAlgMovingData,mitk::StringProperty::New(movingNodeUID));
+ m_spRegNode->AddProperty(mitk::nodeProp_RegAlgTargetData,mitk::StringProperty::New(targetNodeUID));
+ m_spRegNode->AddProperty(mitk::nodeProp_RegUID,mitk::StringProperty::New(resultReg->GetRegistration()->getRegistrationUID()));
+
+ return m_spRegNode;
+};
+
+
+mitk::DataNode::Pointer
+ mitk::generateMappedResultNode(const std::string& nodeName, mitk::BaseData::Pointer mappedData, const std::string& regUID, const std::string& inputNodeUID, const bool refinedGeometry, const std::string& interpolator)
+{
+ if (mappedData.IsNull())
+ {
+ mitkThrow() << "Cannot generate mapping result node. Passed mapped data points to NULL.";
+ }
+
+ mitk::DataNode::Pointer mappedDataNode = mitk::DataNode::New();
+
+ mappedDataNode->SetData(mappedData);
+ mappedDataNode->SetName(nodeName);
+ if (!regUID.empty())
+ {
+ mappedDataNode->AddProperty(mitk::nodeProp_RegUID, mitk::StringProperty::New(regUID));
+ }
+ mappedDataNode->AddProperty(mitk::nodeProp_MappingInputData,mitk::StringProperty::New(inputNodeUID));
+ if (refinedGeometry)
+ {
+ mappedDataNode->AddProperty(mitk::nodeProp_MappingInterpolator,mitk::StringProperty::New("None"));
+ mappedDataNode->AddProperty(mitk::nodeProp_MappingRefinedGeometry,mitk::BoolProperty::New(true));
+ }
+ else
+ {
+ mitk::Image* image = dynamic_cast(mappedData.GetPointer());
+
+ if(image)
+ {
+ mappedDataNode->AddProperty(mitk::nodeProp_MappingInterpolator,mitk::StringProperty::New(interpolator));
+ }
+ else
+ {
+ mappedDataNode->AddProperty(mitk::nodeProp_MappingInterpolator,mitk::StringProperty::New("None"));
+ mappedDataNode->SetColor(0.0,0.0,1.0);
+ }
+ }
+
+ return mappedDataNode;
+};
diff --git a/Modules/MatchPointRegistration/Helper/mitkResultNodeGenerationHelper.h b/Modules/MatchPointRegistration/Helper/mitkResultNodeGenerationHelper.h
new file mode 100644
index 0000000000..8af0eb0655
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkResultNodeGenerationHelper.h
@@ -0,0 +1,51 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef MITK_RESULT_NODE_GENERATION_HELPER_H
+#define MITK_RESULT_NODE_GENERATION_HELPER_H
+
+#include "mitkDataNode.h"
+#include "mitkMAPRegistrationWrapper.h"
+
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+ /**Method generates a proper result node for the given registration wrapper.
+ @param nodeName Name of the result node
+ @param resultReg Pointer to the registration wrapper that should be data of the node.
+ @param algorithmUID UID string of the algorithm used to generate the result.
+ @param movingNodeUID UID string of the node used as moving input for the registration algorithm.
+ @param targetNodeUID UID string of the node used as moving input for the registration algorithm.
+ @pre registration must point to a valid instance
+ @result Pointer to a data node with all properties properly set.*/
+ MITKMATCHPOINTREGISTRATION_EXPORT mitk::DataNode::Pointer generateRegistrationResultNode(const std::string& nodeName, mitk::MAPRegistrationWrapper::Pointer resultReg, const std::string& algorithmUID, const std::string& movingNodeUID, const std::string& targetNodeUID);
+
+ /**Method generates a proper result node for the given registration wrapper.
+ @param nodeName Name of the result node
+ @param mappedData Pointer to the mapped data that should be data of the node.
+ @param regUID UID string of the registration used to map the data.
+ @param inputNodeUID UID string of the node used as input for the mapping.
+ @param refinedGeometry Indicates if the data was really mapped or the geometry was refined.
+ @param interpolator Name of the used interpolation strategy.
+ @pre mappedData must point to a valid instance
+ @result Pointer to a data node with all properties properly set.*/
+ MITKMATCHPOINTREGISTRATION_EXPORT mitk::DataNode::Pointer generateMappedResultNode(const std::string& nodeName, mitk::BaseData::Pointer mappedData, const std::string& regUID, const std::string& inputNodeUID, const bool refinedGeometry, const std::string& interpolator = "Unkown");
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Modules/MatchPointRegistration/Helper/mitkTimeFramesRegistrationHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkTimeFramesRegistrationHelper.cpp
new file mode 100644
index 0000000000..6ecc8bd40b
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkTimeFramesRegistrationHelper.cpp
@@ -0,0 +1,238 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "itkCommand.h"
+
+#include "mitkTimeFramesRegistrationHelper.h"
+#include
+#include
+
+#include
+#include
+
+mitk::Image::Pointer
+mitk::TimeFramesRegistrationHelper::GetFrameImage(const mitk::Image* image,
+ mitk::TimePointType timePoint) const
+{
+ mitk::ImageTimeSelector::Pointer imageTimeSelector = mitk::ImageTimeSelector::New();
+ imageTimeSelector->SetInput(image);
+ imageTimeSelector->SetTimeNr(timePoint);
+ imageTimeSelector->UpdateLargestPossibleRegion();
+
+ mitk::Image::Pointer frameImage = imageTimeSelector->GetOutput();
+ return frameImage;
+};
+
+void
+mitk::TimeFramesRegistrationHelper::Generate()
+{
+ CheckValidInputs();
+
+ //prepare processing
+ mitk::Image::Pointer targetFrame = GetFrameImage(this->m_4DImage, 0);
+
+ this->m_Registered4DImage = this->m_4DImage->Clone();
+
+ Image::ConstPointer mask;
+
+ if (m_TargetMask.IsNotNull())
+ {
+ if (m_TargetMask->GetTimeSteps() > 1)
+ {
+ mask = GetFrameImage(m_TargetMask, 0);
+ }
+ else
+ {
+ mask = m_TargetMask;
+ }
+ }
+
+ double progressDelta = 1.0 / ((this->m_4DImage->GetTimeSteps() - 1) * 3.0);
+ m_Progress = 0.0;
+
+ //process the frames
+ for (unsigned int i = 1; i < this->m_4DImage->GetTimeSteps(); ++i)
+ {
+ Image::Pointer movingFrame = GetFrameImage(this->m_4DImage, i);
+ Image::Pointer mappedFrame;
+
+ IgnoreListType::iterator finding = std::find(m_IgnoreList.begin(), m_IgnoreList.end(), i);
+
+
+ if (finding == m_IgnoreList.end())
+ {
+ //frame should be processed
+ RegistrationPointer reg = DoFrameRegistration(movingFrame, targetFrame, mask);
+
+ m_Progress += progressDelta;
+ this->InvokeEvent(::mitk::FrameRegistrationEvent(0,
+ "Registred frame #" +::map::core::convert::toStr(i)));
+
+ mappedFrame = DoFrameMapping(movingFrame, reg, targetFrame);
+
+ m_Progress += progressDelta;
+ this->InvokeEvent(::mitk::FrameMappingEvent(0,
+ "Mapped frame #" + ::map::core::convert::toStr(i)));
+
+ mitk::ImageReadAccessor accessor(mappedFrame, mappedFrame->GetVolumeData(0, 0, nullptr,
+ mitk::Image::ReferenceMemory));
+
+
+ this->m_Registered4DImage->SetVolume(accessor.GetData(), i);
+ this->m_Registered4DImage->GetTimeGeometry()->SetTimeStepGeometry(mappedFrame->GetGeometry(), i);
+
+ m_Progress += progressDelta;
+ }
+ else
+ {
+ m_Progress += 3 * progressDelta;
+ }
+
+ this->InvokeEvent(::itk::ProgressEvent());
+
+ }
+
+};
+
+mitk::Image::Pointer
+mitk::TimeFramesRegistrationHelper::GetRegisteredImage()
+{
+ if (this->HasOutdatedResult())
+ {
+ Generate();
+ }
+
+ return m_Registered4DImage;
+};
+
+void
+mitk::TimeFramesRegistrationHelper::
+SetIgnoreList(const IgnoreListType& il)
+{
+ m_IgnoreList = il;
+ this->Modified();
+}
+
+void
+mitk::TimeFramesRegistrationHelper::ClearIgnoreList()
+{
+ m_IgnoreList.clear();
+ this->Modified();
+};
+
+
+mitk::TimeFramesRegistrationHelper::RegistrationPointer
+mitk::TimeFramesRegistrationHelper::DoFrameRegistration(const mitk::Image* movingFrame,
+ const mitk::Image* targetFrame, const mitk::Image* targetMask) const
+{
+ mitk::MITKAlgorithmHelper algHelper(m_Algorithm);
+ algHelper.SetAllowImageCasting(true);
+ algHelper.SetData(movingFrame, targetFrame);
+
+ if (targetMask)
+ {
+ mitk::MaskedAlgorithmHelper maskHelper(m_Algorithm);
+ maskHelper.SetMasks(NULL, targetMask);
+ }
+
+ return algHelper.GetRegistration();
+};
+
+mitk::Image::Pointer mitk::TimeFramesRegistrationHelper::DoFrameMapping(
+ const mitk::Image* movingFrame, const RegistrationType* reg, const mitk::Image* targetFrame) const
+{
+ return mitk::ImageMappingHelper::map(movingFrame, reg, !m_AllowUndefPixels, m_PaddingValue,
+ targetFrame->GetGeometry(), !m_AllowUnregPixels, m_ErrorValue, m_InterpolatorType);
+};
+
+bool
+mitk::TimeFramesRegistrationHelper::HasOutdatedResult() const
+{
+ if (m_Registered4DImage.IsNull())
+ {
+ return true;
+ }
+
+ bool result = false;
+
+ if (m_Registered4DImage->GetMTime() > this->GetMTime())
+ {
+ result = true;
+ }
+
+
+ if (m_Algorithm.IsNotNull())
+ {
+ if (m_Algorithm->GetMTime() > this->GetMTime())
+ {
+ result = true;
+ }
+ }
+
+ if (m_4DImage.IsNotNull())
+ {
+ if (m_4DImage->GetMTime() > this->GetMTime())
+ {
+ result = true;
+ }
+ }
+
+ if (m_TargetMask.IsNotNull())
+ {
+ if (m_TargetMask->GetMTime() > this->GetMTime())
+ {
+ result = true;
+ }
+ }
+
+ return result;
+};
+
+void
+mitk::TimeFramesRegistrationHelper::CheckValidInputs() const
+{
+ if (m_4DImage.IsNull())
+ {
+ mitkThrow() << "Cannot register image. Input 4D image is not set.";
+ }
+
+ if (m_Algorithm.IsNull())
+ {
+ mitkThrow() << "Cannot register image. Algorithm is not set.";
+ }
+
+ if (m_4DImage->GetTimeSteps() <= 1)
+ {
+ mitkThrow() << "Cannot register image. Input 4D image must have 2 or more time steps.";
+ }
+
+ for (IgnoreListType::const_iterator pos = this->m_IgnoreList.begin();
+ pos != this->m_IgnoreList.end(); ++pos)
+ {
+ if (*pos < 0 || *pos >= m_4DImage->GetTimeSteps())
+ {
+ mitkThrow() <<
+ "Cannot register image. Ignore list containes at least one inexistant frame. Invalid frame index: "
+ << *pos;
+ }
+ }
+};
+
+double
+mitk::TimeFramesRegistrationHelper::GetProgress() const
+{
+ return m_Progress;
+};
diff --git a/Modules/MatchPointRegistration/Helper/mitkTimeFramesRegistrationHelper.h b/Modules/MatchPointRegistration/Helper/mitkTimeFramesRegistrationHelper.h
new file mode 100644
index 0000000000..c59ceebfcb
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkTimeFramesRegistrationHelper.h
@@ -0,0 +1,159 @@
+/*===================================================================
+
+ The Medical Imaging Interaction Toolkit (MITK)
+
+ Copyright (c) German Cancer Research Center,
+ Division of Medical and Biological Informatics.
+ All rights reserved.
+
+ This software is distributed WITHOUT ANY WARRANTY; without
+ even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE.
+
+ See LICENSE.txt or http://www.mitk.org for details.
+
+ ===================================================================*/
+
+#ifndef __MITK_TIME_FRAMES_REGISTRATION_HELPER_H_
+#define __MITK_TIME_FRAMES_REGISTRATION_HELPER_H_
+
+
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+
+ mapEventMacro(FrameRegistrationEvent, ::map::events::TaskBatchEvent, MITKMATCHPOINTREGISTRATION_EXPORT);
+ mapEventMacro(FrameMappingEvent, ::map::events::TaskBatchEvent, MITKMATCHPOINTREGISTRATION_EXPORT);
+
+ /** Helper class that assumes that registeres time frames of an passed image and returns the resulting new image.
+ * A typical use case for the helper class is motion correction in 3D+t images. Each selected frame will be registered
+ * to the first frame of the image. The user can define frames that may be not registered. These frames will be copied directly.
+ * Per default all frames will be registered.
+ * The user may set a mask for the target frame (1st frame). If this mask image has mulitple time steps, the first time step will be used.
+ * The helper class invokes three eventtypes: \n
+ * - mitk::FrameRegistrationEvent: when ever a frame was registered.
+ * - mitk::FrameMappingEvent: when ever a frame was mapped registered.
+ * - itk::ProgressEvent: when ever a new frame was added to the result image.
+ */
+ class MITKMATCHPOINTREGISTRATION_EXPORT TimeFramesRegistrationHelper : public itk::Object
+ {
+ public:
+ mitkClassMacroItkParent(TimeFramesRegistrationHelper, itk::Object);
+
+ itkNewMacro(Self);
+
+ typedef ::map::algorithm::RegistrationAlgorithmBase RegistrationAlgorithmBaseType;
+ typedef RegistrationAlgorithmBaseType::Pointer RegistrationAlgorithmPointer;
+ typedef ::map::core::RegistrationBase RegistrationType;
+ typedef RegistrationType::Pointer RegistrationPointer;
+
+ typedef std::vector IgnoreListType;
+
+ itkSetConstObjectMacro(4DImage, Image);
+ itkGetConstObjectMacro(4DImage, Image);
+
+ itkSetConstObjectMacro(TargetMask, Image);
+ itkGetConstObjectMacro(TargetMask, Image);
+
+ itkSetObjectMacro(Algorithm, RegistrationAlgorithmBaseType);
+ itkGetObjectMacro(Algorithm, RegistrationAlgorithmBaseType);
+
+ itkSetMacro(AllowUndefPixels, bool);
+ itkGetConstMacro(AllowUndefPixels, bool);
+
+ itkSetMacro(PaddingValue, double);
+ itkGetConstMacro(PaddingValue, double);
+
+ itkSetMacro(AllowUnregPixels, bool);
+ itkGetConstMacro(AllowUnregPixels, bool);
+
+ itkSetMacro(ErrorValue, double);
+ itkGetConstMacro(ErrorValue, double);
+
+ itkSetMacro(InterpolatorType, mitk::ImageMappingInterpolator::Type);
+ itkGetConstMacro(InterpolatorType, mitk::ImageMappingInterpolator::Type);
+
+ /** cleares the ignore list. Therefore all frames will be processed.*/
+ void ClearIgnoreList();
+ void SetIgnoreList(const IgnoreListType& il);
+ itkGetConstMacro(IgnoreList, IgnoreListType);
+
+ virtual double GetProgress() const;
+
+ /** Commences the generation of the registered 4D image. Stores the result internally.
+ * After this method call is finished the result can be retrieved via
+ * GetRegisteredImage.
+ * @pre 4D image must be set
+ * @pre 4D image must has more then one frame
+ * @pre Reg algorithm must be set
+ * @pre Ignore list values must be within the time geometry of the image
+ * @post Result image was generated.*/
+ void Generate();
+
+ /** Returns the generated images. Triggers Generate() if result is outdated.
+ * @pre 4D image must be set
+ * @pre 4D image must has more then one frame
+ * @pre Reg algorithm must be set
+ * @pre Ignore list values must be within the time geometry of the image
+ */
+ Image::Pointer GetRegisteredImage();
+
+ protected:
+ TimeFramesRegistrationHelper() : m_Progress(0), m_AllowUndefPixels(true), m_PaddingValue(0),
+ m_AllowUnregPixels(true), m_ErrorValue(0), m_InterpolatorType(mitk::ImageMappingInterpolator::Linear)
+ {
+ m_4DImage = NULL;
+ m_TargetMask = NULL;
+ m_Registered4DImage = NULL;
+ };
+
+ ~TimeFramesRegistrationHelper() {};
+
+ RegistrationPointer DoFrameRegistration(const mitk::Image* movingFrame,
+ const mitk::Image* targetFrame, const mitk::Image* targetMask) const;
+
+ mitk::Image::Pointer DoFrameMapping(const mitk::Image* movingFrame, const RegistrationType* reg,
+ const mitk::Image* targetFrame) const;
+
+ bool HasOutdatedResult() const;
+ /** Check if the fit can be generated and all needed inputs are valid.
+ * Throw an exception for a non valid or missing input.*/
+ void CheckValidInputs() const;
+
+ mitk::Image::Pointer GetFrameImage(const mitk::Image* image, mitk::TimePointType timePoint) const;
+
+ RegistrationAlgorithmPointer m_Algorithm;
+
+ private:
+ Image::ConstPointer m_4DImage;
+ Image::ConstPointer m_TargetMask;
+ Image::Pointer m_Registered4DImage;
+
+ IgnoreListType m_IgnoreList;
+
+ /**Indicates if the mapper should allow undefined pixels (true) or mapping should fail (false)*/
+ bool m_AllowUndefPixels;
+ /** Value of undefined pixels. Only relevant if m_allowUndefPixels is true. */
+ double m_PaddingValue;
+ /**Indicates if the mapper should allow pixels that are not covered by the registration (true) or mapping should fail (false)*/
+ bool m_AllowUnregPixels;
+ /** Value of unreged pixels. Only relevant if m_allowUnregPixels is true. */
+ double m_ErrorValue;
+ /** Type of interpolator. Only relevant for images and if m_doGeometryRefinement is false. */
+ mitk::ImageMappingInterpolator::Type m_InterpolatorType;
+
+ double m_Progress;
+ };
+
+}
+
+#endif // __MITK_PARAMETER_FIT_IMAGE_GENERATOR_H_
diff --git a/Modules/MatchPointRegistration/Helper/mitkUIDHelper.cpp b/Modules/MatchPointRegistration/Helper/mitkUIDHelper.cpp
new file mode 100644
index 0000000000..b9bb54215d
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkUIDHelper.cpp
@@ -0,0 +1,57 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+#include "mitkUIDHelper.h"
+
+
+// Mitk
+#include
+#include
+
+mitk::NodeUIDType mitk::EnsureUID(mitk::DataNode* node)
+{
+ if (!node)
+ {
+ mitkThrow() << "Cannot ensure node UID. Passed node pointer is NULL.";
+ }
+
+ std::string propUID = "";
+ if (!node->GetStringProperty(mitk::nodeProp_UID,propUID))
+ {
+ mitk::UIDGenerator generator;
+ propUID = generator.GetUID();
+
+ node->SetStringProperty(mitk::nodeProp_UID,propUID.c_str());
+ }
+
+ return propUID;
+};
+
+bool mitk::CheckUID(const mitk::DataNode* node, const NodeUIDType& uid)
+{
+ bool result = false;
+
+ if (node)
+ {
+ std::string propUID = "";
+ if (node->GetStringProperty(mitk::nodeProp_UID,propUID))
+ {
+ result = propUID == uid;
+ }
+ }
+
+ return result;
+};
diff --git a/Modules/MatchPointRegistration/Helper/mitkUIDHelper.h b/Modules/MatchPointRegistration/Helper/mitkUIDHelper.h
new file mode 100644
index 0000000000..9a27a57f8e
--- /dev/null
+++ b/Modules/MatchPointRegistration/Helper/mitkUIDHelper.h
@@ -0,0 +1,43 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef mitkUIDHelper_h
+#define mitkUIDHelper_h
+
+//MITK
+#include
+
+//MITK
+#include "MitkMatchPointRegistrationExports.h"
+#include "mitkMatchPointPropertyTags.h"
+
+namespace mitk
+{
+
+ typedef std::string NodeUIDType;
+
+ /** Gets the content of the property "matchpoint.uid". If it does not exist, the property will be added with a new UID.
+ @pre Passed node is a valid pointer.*/
+ NodeUIDType MITKMATCHPOINTREGISTRATION_EXPORT EnsureUID(mitk::DataNode* node);
+
+ /** Helper that checks if the content of property "matchpoint.uid" equals the passed uid. If the property does not exist or node is invalid, return will be false.*/
+ bool MITKMATCHPOINTREGISTRATION_EXPORT CheckUID(const mitk::DataNode* node, const NodeUIDType& uid);
+
+}
+
+#endif
+
diff --git a/Modules/MatchPointRegistration/Rendering/mitkRegEvalStyleProperty.cpp b/Modules/MatchPointRegistration/Rendering/mitkRegEvalStyleProperty.cpp
new file mode 100644
index 0000000000..465a27d395
--- /dev/null
+++ b/Modules/MatchPointRegistration/Rendering/mitkRegEvalStyleProperty.cpp
@@ -0,0 +1,68 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#include "mitkRegEvalStyleProperty.h"
+
+
+mitk::RegEvalStyleProperty::RegEvalStyleProperty( )
+{
+ AddTypes();
+ SetValue( 0 );
+}
+
+
+mitk::RegEvalStyleProperty::RegEvalStyleProperty( const IdType& value )
+{
+ AddTypes();
+ if ( IsValidEnumerationValue( value ) )
+ {
+ SetValue( value ) ;
+ }
+ else
+ {
+ SetValue( 0 );
+ }
+}
+
+mitk::RegEvalStyleProperty::RegEvalStyleProperty( const std::string& value )
+{
+ AddTypes();
+ if ( IsValidEnumerationValue( value ) )
+ {
+ SetValue( value );
+ }
+ else
+ {
+ SetValue( 0 );
+ }
+}
+
+void mitk::RegEvalStyleProperty::AddTypes()
+{
+ AddEnum( "Blend", static_cast( 0 ) );
+ AddEnum( "Color Blend", static_cast( 1 ) );
+ AddEnum( "Checkerboard", static_cast( 2 ) );
+ AddEnum( "Wipe", static_cast( 3 ) );
+ AddEnum( "Difference", static_cast( 4 ) );
+ AddEnum( "Contour", static_cast( 5 ) );
+}
+
+
+bool mitk::RegEvalStyleProperty::AddEnum( const std::string& name, const IdType& id )
+{
+ return Superclass::AddEnum( name, id );
+}
diff --git a/Modules/MatchPointRegistration/Rendering/mitkRegEvalStyleProperty.h b/Modules/MatchPointRegistration/Rendering/mitkRegEvalStyleProperty.h
new file mode 100644
index 0000000000..e8227b5aa5
--- /dev/null
+++ b/Modules/MatchPointRegistration/Rendering/mitkRegEvalStyleProperty.h
@@ -0,0 +1,100 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef _MITK_REG_EVAL_STYLE_PROPERTY__H_
+#define _MITK_REG_EVAL_STYLE_PROPERTY__H_
+
+// MITK
+#include
+
+// MITK
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable: 4522)
+#endif
+
+/**
+ * Encapsulates the enumeration for visualization styles. Valid values are:
+ * 0/Blend 1/Color Blend 2/Checkerboard, 3/Wipe, 4/Difference, 5/Contour
+ * Default is "Blend"
+ */
+class MITKMATCHPOINTREGISTRATION_EXPORT RegEvalStyleProperty : public EnumerationProperty
+{
+public:
+
+ mitkClassMacro( RegEvalStyleProperty, EnumerationProperty );
+
+ itkNewMacro(RegEvalStyleProperty);
+
+ mitkNewMacro1Param(RegEvalStyleProperty, const IdType&);
+
+ mitkNewMacro1Param(RegEvalStyleProperty, const std::string&);
+
+
+ using BaseProperty::operator=;
+
+protected:
+
+ /**
+ * Constructor. Sets the representation to a default value of 0
+ */
+ RegEvalStyleProperty( );
+
+ /**
+ * Constructor. Sets the enumeration to the given value. If it is not
+ * valid, the enumeration is set to 0
+ */
+ RegEvalStyleProperty( const IdType& value );
+
+ /**
+ * Constructor. Sets the enumeration to the given value. If it is not
+ * valid, the enumeration is set to 0
+ */
+ RegEvalStyleProperty( const std::string& value );
+
+ /**
+ * this function is overridden as protected, so that the user may not add
+ * additional invalid interpolation types.
+ */
+ virtual bool AddEnum( const std::string& name, const IdType& id );
+
+ /**
+ * Adds the enumeration types
+ */
+ virtual void AddTypes();
+
+private:
+
+ // purposely not implemented
+ RegEvalStyleProperty(const RegEvalStyleProperty&);
+ RegEvalStyleProperty& operator=(const RegEvalStyleProperty&);
+};
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+} // end of namespace mitk
+
+#endif
+
+
diff --git a/Modules/MatchPointRegistration/Rendering/mitkRegEvalWipeStyleProperty.cpp b/Modules/MatchPointRegistration/Rendering/mitkRegEvalWipeStyleProperty.cpp
new file mode 100644
index 0000000000..84233be399
--- /dev/null
+++ b/Modules/MatchPointRegistration/Rendering/mitkRegEvalWipeStyleProperty.cpp
@@ -0,0 +1,65 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#include "mitkRegEvalWipeStyleProperty.h"
+
+
+mitk::RegEvalWipeStyleProperty::RegEvalWipeStyleProperty( )
+{
+ AddTypes();
+ SetValue( 0 );
+}
+
+
+mitk::RegEvalWipeStyleProperty::RegEvalWipeStyleProperty( const IdType& value )
+{
+ AddTypes();
+ if ( IsValidEnumerationValue( value ) )
+ {
+ SetValue( value ) ;
+ }
+ else
+ {
+ SetValue( 0 );
+ }
+}
+
+mitk::RegEvalWipeStyleProperty::RegEvalWipeStyleProperty( const std::string& value )
+{
+ AddTypes();
+ if ( IsValidEnumerationValue( value ) )
+ {
+ SetValue( value );
+ }
+ else
+ {
+ SetValue( 0 );
+ }
+}
+
+void mitk::RegEvalWipeStyleProperty::AddTypes()
+{
+ AddEnum( "Cross", static_cast( 0 ) );
+ AddEnum( "Horizontal wipe", static_cast( 1 ) );
+ AddEnum( "Vertical wipe", static_cast( 2 ) );
+}
+
+
+bool mitk::RegEvalWipeStyleProperty::AddEnum( const std::string& name, const IdType& id )
+{
+ return Superclass::AddEnum( name, id );
+}
diff --git a/Modules/MatchPointRegistration/Rendering/mitkRegEvalWipeStyleProperty.h b/Modules/MatchPointRegistration/Rendering/mitkRegEvalWipeStyleProperty.h
new file mode 100644
index 0000000000..25e114cadc
--- /dev/null
+++ b/Modules/MatchPointRegistration/Rendering/mitkRegEvalWipeStyleProperty.h
@@ -0,0 +1,100 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+
+#ifndef _MITK_REG_EVAL_WIPE_STYLE_PROPERTY__H_
+#define _MITK_REG_EVAL_WIPE_STYLE_PROPERTY__H_
+
+// MITK
+#include
+
+// MITK
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+
+#ifdef _MSC_VER
+# pragma warning(push)
+# pragma warning(disable: 4522)
+#endif
+
+/**
+ * Encapsulates the enumeration for visualization styles. Valid values are:
+ * 0/Cross 1/horizontal wipe 2/vertical wipe
+ * Default is "Cross"
+ */
+class MITKMATCHPOINTREGISTRATION_EXPORT RegEvalWipeStyleProperty : public EnumerationProperty
+{
+public:
+
+ mitkClassMacro( RegEvalWipeStyleProperty, EnumerationProperty );
+
+ itkNewMacro(RegEvalWipeStyleProperty);
+
+ mitkNewMacro1Param(RegEvalWipeStyleProperty, const IdType&);
+
+ mitkNewMacro1Param(RegEvalWipeStyleProperty, const std::string&);
+
+
+ using BaseProperty::operator=;
+
+protected:
+
+ /**
+ * Constructor. Sets the representation to a default value of 0
+ */
+ RegEvalWipeStyleProperty( );
+
+ /**
+ * Constructor. Sets the enumeration to the given value. If it is not
+ * valid, the enumeration is set to 0
+ */
+ RegEvalWipeStyleProperty( const IdType& value );
+
+ /**
+ * Constructor. Sets the enumeration to the given value. If it is not
+ * valid, the enumeration is set to 0
+ */
+ RegEvalWipeStyleProperty( const std::string& value );
+
+ /**
+ * this function is overridden as protected, so that the user may not add
+ * additional invalid interpolation types.
+ */
+ virtual bool AddEnum( const std::string& name, const IdType& id );
+
+ /**
+ * Adds the enumeration types
+ */
+ virtual void AddTypes();
+
+private:
+
+ // purposely not implemented
+ RegEvalWipeStyleProperty(const RegEvalWipeStyleProperty&);
+ RegEvalWipeStyleProperty& operator=(const RegEvalWipeStyleProperty&);
+};
+
+#ifdef _MSC_VER
+# pragma warning(pop)
+#endif
+
+} // end of namespace mitk
+
+#endif
+
+
diff --git a/Modules/MatchPointRegistration/Rendering/mitkRegEvaluationMapper2D.cpp b/Modules/MatchPointRegistration/Rendering/mitkRegEvaluationMapper2D.cpp
new file mode 100644
index 0000000000..f4d718687d
--- /dev/null
+++ b/Modules/MatchPointRegistration/Rendering/mitkRegEvaluationMapper2D.cpp
@@ -0,0 +1,825 @@
+/*===================================================================
+
+The Medical Imaging Interaction Toolkit (MITK)
+
+Copyright (c) German Cancer Research Center,
+Division of Medical and Biological Informatics.
+All rights reserved.
+
+This software is distributed WITHOUT ANY WARRANTY; without
+even the implied warranty of MERCHANTABILITY or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+See LICENSE.txt or http://www.mitk.org for details.
+
+===================================================================*/
+
+//MITK
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "mitkImageStatisticsHolder.h"
+#include "mitkPlaneClipping.h"
+
+#include "mitkRegVisPropertyTags.h"
+#include "mitkRegVisHelper.h"
+#include "mitkRegEvalStyleProperty.h"
+#include "mitkRegEvalWipeStyleProperty.h"
+
+//MITK Rendering
+#include "mitkRegEvaluationMapper2D.h"
+#include "vtkMitkThickSlicesFilter.h"
+#include "vtkMitkLevelWindowFilter.h"
+#include "vtkNeverTranslucentTexture.h"
+
+//VTK
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include