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/CMakeExternals/MatchPoint.cmake b/CMakeExternals/MatchPoint.cmake
new file mode 100644
index 0000000000..1688d8a9b5
--- /dev/null
+++ b/CMakeExternals/MatchPoint.cmake
@@ -0,0 +1,63 @@
+#-----------------------------------------------------------------------------
+# 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
+ SVN_REPOSITORY https://svn.inet.dkfz-heidelberg.de/sbr/Sources/SBR-Projects/MatchPoint/trunk
+ #SOURCE_DIR ${ep_prefix}/${proj}
+ )
+ endif()
+
+ ExternalProject_Add(${proj}
+ ${download_step}
+ INSTALL_COMMAND ""
+ 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}
+ )
+
+ # MatchPoint does not support "make install" yet
+ # set(${proj}_DIR ${ep_prefix})
+ # mitkFunctionInstallExternalCMakeProject(${proj})
+ ExternalProject_Get_Property(${proj} binary_dir)
+ set(MatchPoint_DIR ${binary_dir})
+
+else()
+
+ mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}")
+
+endif()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e0914ce1bd..c80b85383f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,1395 +1,1396 @@
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 2015.05.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)
if(MITK_USE_QT)
set(MITK_QT5_MINIMUM_VERSION 5.0.0)
set(MITK_QT5_COMPONENTS Concurrent OpenGL PrintSupport Script Sql Svg Widgets WebKitWidgets Xml XmlPatterns UiTools Help)
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()
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(mitkFunctionConvertXPSchema)
include(mitkFunctionCreateBlueBerryApplication)
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)
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
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.59" "1.59.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-qt4 qhelpgenerator4
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_COLLECTIONGENERATOR_EXECUTABLE
NAMES qcollectiongenerator qcollectiongenerator-qt4 qcollectiongenerator4
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
find_program(QT_ASSISTANT_EXECUTABLE
NAMES assistant-qt4 assistant4 assistant
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 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..d0054fd882
--- /dev/null
+++ b/Modules/MatchPointRegistration/CMakeLists.txt
@@ -0,0 +1,9 @@
+MITK_CREATE_MODULE(
+ INCLUDE_DIRS Rendering IO Helper
+ DEPENDS MitkCore MitkSceneSerializationBase
+ PACKAGE_DEPENDS
+ PRIVATE ITK VTK
+ PUBLIC MatchPoint
+)
+
+ADD_SUBDIRECTORY(Testing)
\ No newline at end of file
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..c30afa7d16
--- /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 "mapModelBasedRegistrationKernel.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::ModelBasedRegistrationKernel<3,3> ModelKernelType;
+
+ const ModelKernelType* pModelKernel = dynamic_cast(&kernel);
+
+ if (pModelKernel)
+ {
+
+ ModelKernelType::TransformType::MatrixType matrix;
+ ModelKernelType::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/IO/mitkMAPRegistrationWrapperIO.cpp b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperIO.cpp
new file mode 100644
index 0000000000..56329ec574
--- /dev/null
+++ b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperIO.cpp
@@ -0,0 +1,319 @@
+/*===================================================================
+
+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 "mapRegistration.h"
+#include "mapRegistrationFileWriter.h"
+#include "mapRegistrationFileReader.h"
+#include "mapLazyFileFieldKernelLoader.h"
+
+#include
+#include
+
+#include "mitkMAPRegistrationWrapperIO.h"
+#include "mitkMAPRegistrationWrapper.h"
+
+namespace mitk
+{
+
+ /** Helper structure to change (and reset) the
+ * local settings in a function scope*/
+ struct LocaleSwitch
+ {
+ LocaleSwitch(const std::string& newLocale)
+ : m_OldLocale(std::setlocale(LC_ALL, NULL))
+ , m_NewLocale(newLocale)
+ {
+ if (m_OldLocale == NULL)
+ {
+ m_OldLocale = "";
+ }
+ else if (m_NewLocale != m_OldLocale)
+ {
+ // set the locale
+ if (std::setlocale(LC_ALL, m_NewLocale.c_str()) == NULL)
+ {
+ MITK_INFO << "Could not set locale " << m_NewLocale;
+ m_OldLocale = NULL;
+ }
+ }
+ }
+
+ ~LocaleSwitch()
+ {
+ if (m_OldLocale != NULL && std::setlocale(LC_ALL, m_OldLocale) == NULL)
+ {
+ MITK_INFO << "Could not reset locale " << m_OldLocale;
+ }
+ }
+
+ private:
+ const char* m_OldLocale;
+ const std::string m_NewLocale;
+ };
+
+ /** Helper class that allows to use an functor in multiple combinations of
+ * moving and target dimensions on a passed MAPRegistrationWrapper instance.\n
+ * DimHelperSub is used DimHelper to iterate in a row of the dimension
+ * combination matrix.
+ */
+ template< unsigned int i, unsigned int j, template < unsigned int, unsigned int> class TFunctor>
+ class DimHelperSub
+ {
+ public:
+ static bool Execute(const mitk::MAPRegistrationWrapper* obj, const map::core::String& data)
+ {
+ if (TFunctor::Execute(obj, data))
+ {
+ return true;
+ }
+ return DimHelperSub::Execute(obj, data);
+ }
+ };
+
+ /** Specialized template version of DimSubHelper that indicates the end
+ * of the row in the dimension combination matrix, thus does nothing.
+ */
+ template< unsigned int i, template < unsigned int, unsigned int> class TFunctor>
+ class DimHelperSub
+ {
+ public:
+ static bool Execute(const mitk::MAPRegistrationWrapper* obj, const map::core::String& data)
+ {
+ //just unwind. Go to the next "row" with DimHelper
+ return false;
+ }
+ };
+
+ /** Helper class that allows to use an functor in multiple combinations of
+ * moving and target dimensions on a passed MAPRegistrationWrapper instance.\n
+ * It is helpful if you want to ensure that all combinations are checked/touched
+ * (e.g. 3D 3D, 3D 2D, 2D 3D, 2D 2D) without generating a large switch yard.
+ * Think of n*m matrix (indicating the posible combinations). DimHelper walks from
+ * one row to the next and uses DimHelperSub to iterate in a row.\n
+ * For every element of the matrix the functor is executed on the passed object.
+ */
+ template< unsigned int i, unsigned int j, template < unsigned int, unsigned int> class TFunctor>
+ class DimHelper{
+ public:
+ static bool Execute(const mitk::MAPRegistrationWrapper* obj, const map::core::String& data = "")
+ {
+ if (DimHelperSub::Execute(obj, data))
+ {
+ return true;
+ }
+ return DimHelper::Execute(obj, data);
+ }
+ };
+
+ /** Specialized template version of DimHelper that indicates the end
+ * of the dimension combination matrix, thus does nothing.
+ */
+ template< unsigned int j, template < unsigned int, unsigned int> class TFunctor>
+ class DimHelper<1,j, TFunctor >
+ {
+ public:
+ static bool Execute(const mitk::MAPRegistrationWrapper* obj, const map::core::String& data)
+ {
+ //just unwind. We are done.
+ return false;
+ }
+ };
+
+ /** Functor that checks of the dimension of the registration is supported and can
+ * be written.
+ */
+ template
+ class CanWrite
+ {
+ public:
+ static bool Execute(const mitk::MAPRegistrationWrapper* obj, const map::core::String& data = "")
+ {
+ bool result = false;
+
+ result = dynamic_cast *>(obj->GetRegistration()) != NULL;
+
+ return result;
+ }
+ };
+
+ /** Functor that writes the registration to a file if it has the right dimensionality.
+ */
+ template
+ class WriteReg
+ {
+ public:
+ static bool Execute(const mitk::MAPRegistrationWrapper* obj, const map::core::String& data)
+ {
+ const map::core::Registration* pReg = dynamic_cast*>(obj->GetRegistration());
+ if (pReg == NULL)
+ {
+ return false;
+ }
+
+ typedef map::io::RegistrationFileWriter WriterType;
+ typename WriterType::Pointer writer = WriterType::New();
+
+ writer->setExpandLazyKernels(false);
+
+ try
+ {
+ writer->write(pReg,data);
+ }
+ catch (itk::ExceptionObject e)
+ {
+ std::cout << e << std::endl;
+ throw;
+ }
+
+ return true;
+ }
+ };
+
+ MAPRegistrationWrapperIO::MAPRegistrationWrapperIO(const MAPRegistrationWrapperIO& other)
+ : AbstractFileIO(other)
+ {
+ }
+
+ MAPRegistrationWrapperIO::MAPRegistrationWrapperIO() : AbstractFileIO(mitk::MAPRegistrationWrapper::GetStaticNameOfClass())
+ {
+ std::string category = "MatchPoint Registration File";
+ CustomMimeType customMimeType;
+ customMimeType.SetCategory(category);
+ customMimeType.AddExtension("mapr");
+ this->AbstractFileIOWriter::SetMimeType(customMimeType);
+ this->AbstractFileIOWriter::SetDescription(category);
+
+ customMimeType.AddExtension("mapr.xml");
+ customMimeType.AddExtension("MAPR");
+ customMimeType.AddExtension("MAPR.XML");
+ this->AbstractFileIOReader::SetMimeType(customMimeType);
+ this->AbstractFileIOReader::SetDescription(category);
+
+ this->RegisterService();
+ }
+
+
+ void MAPRegistrationWrapperIO::Write()
+ {
+ bool success = false;
+ const BaseData* input = this->GetInput();
+ if (input == NULL)
+ {
+ mitkThrow() << "Cannot write data. Data pointer is NULL.";
+ }
+
+ const mitk::MAPRegistrationWrapper* wrapper = dynamic_cast(input);
+ if (wrapper == NULL)
+ {
+ mitkThrow() << "Cannot write data. Data pointer is not a Registration wrapper.";
+ }
+
+ std::ostream* writeStream = this->GetOutputStream();
+ std::string fileName = this->GetOutputLocation();
+ if (writeStream)
+ {
+ fileName = this->GetLocalFileName();
+ }
+
+ // Switch the current locale to "C"
+ LocaleSwitch localeSwitch("C");
+
+ try
+ {
+ success = DimHelper<3,3,WriteReg>::Execute(wrapper, fileName);
+ }
+ catch (const std::exception& e)
+ {
+ mitkThrow() << e.what();
+ }
+
+ if (!success)
+ {
+ mitkThrow() << "Cannot write registration. Currently only registrations up to 4D are supported.";
+ }
+ }
+
+ AbstractFileIO::ConfidenceLevel MAPRegistrationWrapperIO::GetWriterConfidenceLevel() const
+ {
+ const mitk::MAPRegistrationWrapper* regWrapper = dynamic_cast(this->GetInput());
+
+ if (regWrapper == NULL)
+ {
+ return IFileWriter::Unsupported;
+ }
+
+ // Check if the registration dimension is supported
+ if (! DimHelper<3,3,CanWrite>::Execute(regWrapper))
+ {
+ return IFileWriter::Unsupported;
+ };
+
+ return IFileWriter::Supported;
+ }
+
+ std::vector MAPRegistrationWrapperIO::Read()
+ {
+ std::vector result;
+
+ LocaleSwitch("C");
+
+ std::string fileName = this->GetLocalFileName();
+ if ( fileName.empty() )
+ {
+ mitkThrow() << "Cannot read file. Filename has not been set!";
+ }
+
+ /* Remove the following kernel loader provider because in MITK no lazy file loading should be used
+ due to conflicts with session loading (end there usage of temporary directories)*/
+ map::io::RegistrationFileReader::LoaderStackType::unregisterProvider(map::io::LazyFileFieldKernelLoader<2,2>::getStaticProviderName());
+ map::io::RegistrationFileReader::LoaderStackType::unregisterProvider(map::io::LazyFileFieldKernelLoader<3,3>::getStaticProviderName());
+
+ map::io::RegistrationFileReader::Pointer spReader = map::io::RegistrationFileReader::New();
+ spReader->setPreferLazyLoading(true);
+ map::core::RegistrationBase::Pointer spReg = spReader->read(fileName);
+ mitk::MAPRegistrationWrapper::Pointer spRegWrapper = mitk::MAPRegistrationWrapper::New();
+ spRegWrapper->SetRegistration(spReg);
+
+ result.push_back(spRegWrapper.GetPointer());
+ return result;
+ }
+
+ AbstractFileIO::ConfidenceLevel MAPRegistrationWrapperIO::GetReaderConfidenceLevel() const
+ {
+ AbstractFileIO::ConfidenceLevel result = IFileReader::Unsupported;
+
+ std::string fileName = this->GetLocalFileName();
+ std::ifstream in( fileName.c_str() );
+ if ( in.good() )
+ {
+ result = IFileReader::Supported;
+ }
+
+ in.close();
+ return result;
+ }
+
+ MAPRegistrationWrapperIO* MAPRegistrationWrapperIO::IOClone() const
+ {
+ return new MAPRegistrationWrapperIO(*this);
+ }
+
+}
diff --git a/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperIO.h b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperIO.h
new file mode 100644
index 0000000000..153cde2780
--- /dev/null
+++ b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperIO.h
@@ -0,0 +1,53 @@
+/*===================================================================
+
+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_MAP_REGISTRATION_WRAPPER_IO_H
+#define _MITK_MAP_REGISTRATION_WRAPPER_IO_H
+
+#include
+
+#include "MitkMatchPointRegistrationExports.h"
+
+namespace mitk
+{
+ /**
+ * Offers IO capability for MatchPoint registration wrappers
+ */
+ class MAPRegistrationWrapperIO : public AbstractFileIO
+ {
+ public:
+
+ MAPRegistrationWrapperIO();
+
+ // -------------- AbstractFileReader -------------
+ using AbstractFileReader::Read;
+ virtual std::vector > Read();
+
+ virtual ConfidenceLevel GetReaderConfidenceLevel() const;
+
+ // -------------- AbstractFileWriter -------------
+ virtual void Write();
+ virtual ConfidenceLevel GetWriterConfidenceLevel() const;
+
+ private:
+ MAPRegistrationWrapperIO(const MAPRegistrationWrapperIO& other);
+ MAPRegistrationWrapperIO* IOClone() const;
+ };
+
+
+} // end of namespace mitk
+
+#endif
diff --git a/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperSerializer.cpp b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperSerializer.cpp
new file mode 100644
index 0000000000..c8707fa420
--- /dev/null
+++ b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperSerializer.cpp
@@ -0,0 +1,76 @@
+/*===================================================================
+
+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 "mitkMAPRegistrationWrapperSerializer.h"
+#include "mitkMAPRegistrationWrapperIO.h"
+
+#include "mitkMAPRegistrationWrapper.h"
+
+#include
+
+
+MITK_REGISTER_SERIALIZER(MAPRegistrationWrapperSerializer)
+
+
+mitk::MAPRegistrationWrapperSerializer::MAPRegistrationWrapperSerializer()
+{
+}
+
+
+mitk::MAPRegistrationWrapperSerializer::~MAPRegistrationWrapperSerializer()
+{
+}
+
+
+std::string mitk::MAPRegistrationWrapperSerializer::Serialize()
+{
+ const mitk::MAPRegistrationWrapper* wrapper = dynamic_cast( m_Data.GetPointer() );
+ if (wrapper == NULL)
+ {
+ MITK_ERROR << " Object at " << (const void*) this->m_Data
+ << " is not an mitk::MAPRegistrationWrapper. Cannot serialize as MAPRegistrationWrapper for MatchPoint registration objects.";
+ return "";
+ }
+
+ std::string filename( this->GetUniqueFilenameInWorkingDirectory() );
+ filename += "_";
+ filename += m_FilenameHint;
+ filename += ".mapr";
+
+ std::string fullname(m_WorkingDirectory);
+ fullname += "/";
+ fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str());
+
+ try
+ {
+ MAPRegistrationWrapperIO writer;
+ writer.SetOutputLocation(fullname);
+ writer.AbstractFileWriter::SetInput( const_cast( wrapper ) );
+ writer.Write();
+ }
+ catch (std::exception& e)
+ {
+ MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data
+ << " to "
+ << fullname
+ << ": "
+ << e.what();
+ return "";
+ }
+ return filename;
+}
+
diff --git a/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperSerializer.h b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperSerializer.h
new file mode 100644
index 0000000000..05c8ce2d49
--- /dev/null
+++ b/Modules/MatchPointRegistration/IO/mitkMAPRegistrationWrapperSerializer.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 __mitkMAPRegistrationWrapperSerializer_h
+#define __mitkMAPRegistrationWrapperSerializer_h
+
+#include "MitkMatchPointRegistrationExports.h"
+#include
+
+namespace mitk
+{
+/**
+ \brief Serializes mitk::MAPRegistrationWrapper for mitk::SceneIO
+*/
+class MITKMATCHPOINTREGISTRATION_EXPORT MAPRegistrationWrapperSerializer : public BaseDataSerializer
+{
+ public:
+ mitkClassMacro( MAPRegistrationWrapperSerializer, BaseDataSerializer );
+ itkFactorylessNewMacro(Self);
+ itkCloneMacro(Self);
+
+ virtual std::string Serialize();
+
+ protected:
+ MAPRegistrationWrapperSerializer();
+ virtual ~MAPRegistrationWrapperSerializer();
+};
+} // namespace
+#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