diff --git a/CMakeLists.txt b/CMakeLists.txt index 4848b9f747..f09939368a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,606 +1,610 @@ cmake_minimum_required(VERSION 2.8.2) #----------------------------------------------------------------------------- # 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) endif() #----------------------------------------------------------------------------- # See http://cmake.org/cmake/help/cmake-2-8-docs.html#section_Policies for details #----------------------------------------------------------------------------- set(project_policies CMP0001 # NEW: CMAKE_BACKWARDS_COMPATIBILITY should no longer be used. CMP0002 # NEW: Logical target names must be globally unique. CMP0003 # NEW: Libraries linked via full path no longer produce linker search paths. CMP0004 # NEW: Libraries linked may NOT have leading or trailing whitespace. CMP0005 # NEW: Preprocessor definition values are now escaped automatically. CMP0006 # NEW: Installing MACOSX_BUNDLE targets requires a BUNDLE DESTINATION. CMP0007 # NEW: List command no longer ignores empty elements. CMP0008 # NEW: Libraries linked by full-path must have a valid library file name. CMP0009 # NEW: FILE GLOB_RECURSE calls should not follow symlinks by default. CMP0010 # NEW: Bad variable reference syntax is an error. CMP0011 # NEW: Included scripts do automatic cmake_policy PUSH and POP. CMP0012 # NEW: if() recognizes numbers and boolean constants. CMP0013 # NEW: Duplicate binary directories are not allowed. CMP0014 # NEW: Input directories must have CMakeLists.txt ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(CMAKE_MODULE_PATH ${MITK_SOURCE_DIR}/CMake ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(DEFINED 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_USE_SUPERBUILD) set(output_dir ${MITK_BINARY_DIR}/bin) if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_BINARY_DIR}/MITK-build/bin) endif() else() if(NOT DEFINED MITK_CMAKE_${type}_OUTPUT_DIRECTORY) SET(output_dir ${MITK_BINARY_DIR}/bin) else() SET(output_dir ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) endif() endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${output_dir} CACHE INTERNAL "Single output directory for building all libraries.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) # some targets in Utilities also depend on Qt. Use this option # to decide if they should be build option(MITK_USE_QT "Use Trolltech's Qt library" ON) if(MITK_USE_QT) # find the package at the very beginning, so that QT4_FOUND is available find_package(Qt4 4.6.0 REQUIRED) endif() option(MITK_INSTALL_RPATH_RELATIVE "Use relative rpath entries for installation packages" OFF) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) option(MITK_BUILD_TUTORIAL "Build the MITK tutorial" ON) option(MITK_USE_Boost "Use the Boost C++ library" OFF) option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) option(MITK_USE_CTK "Use CTK in MITK" ${MITK_USE_BLUEBERRY}) option(MITK_USE_DCMTK "EXEPERIMENTAL, superbuild only: Use DCMTK in MITK" OFF) option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) mark_as_advanced(MITK_INSTALL_RPATH_RELATIVE MITK_BUILD_ALL_PLUGINS MITK_USE_CTK MITK_USE_DCMTK ) + +set(MITK_ACCESSBYITK_PIXEL_TYPES + "double, float, int, unsigned int, short, unsigned short, char, unsigned char" + CACHE STRING "List of pixel types used in AccessByItk macros") # consistency checks if(MITK_USE_BLUEBERRY AND NOT MITK_USE_CTK) MESSAGE(FATAL_ERROR "BlueBerry depends on CTK. Please set MITK_USE_CTK to ON.") endif() #----------------------------------------------------------------------------- # Additional CXX/C Flags #----------------------------------------------------------------------------- set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags") mark_as_advanced(ADDITIONAL_C_FLAGS) set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") mark_as_advanced(ADDITIONAL_CXX_FLAGS) #----------------------------------------------------------------------------- # Project.xml #----------------------------------------------------------------------------- # A list of topologically ordered targets set(CTEST_PROJECT_SUBPROJECTS) if(MITK_USE_BLUEBERRY) list(APPEND CTEST_PROJECT_SUBPROJECTS BlueBerry) endif() 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 ) # 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} ${PROJECT_NAME} "${subproject_list}" ${MITK_USE_SUPERBUILD}) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(mitkFunctionCheckCompilerFlags) include(mitkFunctionGetGccVersion) include(MacroParseArguments) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkFunctionOrganizeSources) include(mitkFunctionGetVersion) include(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionInstallProvisioningFiles) include(mitkMacroCreateModuleConf) include(mitkMacroCreateModule) include(mitkMacroCheckModule) include(mitkMacroCreateModuleTests) include(mitkFunctionAddCustomModuleTest) include(mitkMacroUseModule) include(mitkMacroMultiplexPicType) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) #----------------------------------------------------------------------------- # Prerequesites #----------------------------------------------------------------------------- find_package(ITK REQUIRED) find_package(VTK REQUIRED) #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and ExtApp 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) #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- if(MITK_INSTALL_RPATH_RELATIVE) set(CMAKE_INSTALL_RPATH ".") else() set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/bin") endif() # on Mac OSX all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(APPLE) if(MITK_BUILD_org.mitk.gui.qt.extapplication) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} ExtApp) endif() if(MITK_BUILD_org.mitk.gui.qt.application) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} CoreApp) endif() endif(APPLE) #----------------------------------------------------------------------------- # Set symbol visibility Flags #----------------------------------------------------------------------------- # MinGW does not export all symbols automatically, so no need to set flags if(CMAKE_COMPILER_IS_GNUCXX AND NOT MINGW) set(VISIBILITY_CXX_FLAGS ) #"-fvisibility=hidden -fvisibility-inlines-hidden") 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} ${ADDITIONAL_C_FLAGS}") set(MITK_CXX_FLAGS "${VISIBILITY_CXX_FLAGS} ${COVERAGE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAGS}") if(CMAKE_COMPILER_IS_GNUCXX) set(cflags "-Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -D_FORTIFY_SOURCE=2") mitkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so # is introduced. If gcc is smaller than 4.4.0 and the build type is Release let's not include the flag. # Doing so should allow to build package made for distribution using older linux distro. if(${GCC_VERSION} VERSION_GREATER "4.4.0" OR (CMAKE_BUILD_TYPE STREQUAL "Debug" AND ${GCC_VERSION} VERSION_LESS "4.4.0")) mitkFunctionCheckCompilerFlags("-fstack-protector-all" cflags) endif() if(MINGW) # suppress warnings about auto imported symbols set(MITK_CXX_FLAGS "-Wl,--enable-auto-import ${MITK_CXX_FLAGS}") # we need to define a Windows version set(MITK_CXX_FLAGS "-D_WIN32_WINNT=0x0500 ${MITK_CXX_FLAGS}") endif() set(MITK_C_FLAGS "${cflags} ${MITK_C_FLAGS}") #set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wold-style-cast -Wstrict-null-sentinel -Wsign-promo ${MITK_CXX_FLAGS}") set(MITK_CXX_FLAGS "${cflags} -Woverloaded-virtual -Wstrict-null-sentinel ${MITK_CXX_FLAGS}") endif() #----------------------------------------------------------------------------- # MITK Modules #----------------------------------------------------------------------------- set(MITK_MODULES_CONF_DIR ${MITK_BINARY_DIR}/modulesConf CACHE INTERNAL "Modules Conf") set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) option(MITK_ENABLE_GUI_TESTING OFF "Enable the MITK GUI tests") # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @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() 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() #----------------------------------------------------------------------------- # Compile Utilities and set-up MITK variables #----------------------------------------------------------------------------- add_subdirectory(Utilities) include(mitkSetupVariables) if(MITK_USE_BLUEBERRY) include(mitkSetupBlueBerry) endif() #----------------------------------------------------------------------------- # Set C/CXX Flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}") if(MITK_USE_QT) add_definitions(-DQWT_DLL) endif() #----------------------------------------------------------------------------- # Add custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject}) add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- link_directories(${MITK_LINK_DIRECTORIES}) add_subdirectory(Core) if(MITK_USE_QT AND QT4_FOUND) add_subdirectory(CoreUI/Qmitk) endif() add_subdirectory(Modules) if(MITK_USE_BLUEBERRY) set(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) include("${CMAKE_CURRENT_SOURCE_DIR}/CoreUI/Bundles/PluginList.cmake") set(mitk_core_plugins_fullpath ) foreach(core_plugin ${MITK_CORE_PLUGINS}) list(APPEND mitk_core_plugins_fullpath CoreUI/Bundles/${core_plugin}) endforeach() if(BUILD_TESTING) include(berryTestingHelpers) include("${CMAKE_CURRENT_SOURCE_DIR}/CoreUI/BundleTesting/PluginList.cmake") set(mitk_core_test_plugins_fullpath ) foreach(core_test_plugin ${MITK_CORE_TEST_PLUGINS}) # list(APPEND mitk_core_test_plugins_fullpath CoreUI/BundleTesting/${core_test_plugin}) endforeach() set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/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() set(BLUEBERRY_TEST_APP_ID "org.mitk.qt.application") endif() include("${CMAKE_CURRENT_SOURCE_DIR}/Modules/Bundles/PluginList.cmake") set(mitk_ext_plugins_fullpath ) foreach(ext_plugin ${MITK_EXT_PLUGINS}) list(APPEND mitk_ext_plugins_fullpath Modules/Bundles/${ext_plugin}) endforeach() ctkMacroSetupExternalPlugins(${mitk_core_plugins_fullpath} ${mitk_core_test_plugins_fullpath} ${mitk_ext_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) ctkFunctionExtractPluginTargets("${mitk_core_plugins_fullpath}" ON MITK_CORE_ENABLED_PLUGINS) ctkFunctionExtractPluginTargets("${mitk_ext_plugins_fullpath}" ON MITK_EXT_ENABLED_PLUGINS) list(APPEND MITK_EXT_ENABLED_PLUGINS ${MITK_CORE_ENABLED_PLUGINS}) set(MITK_COREAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.provisioning") FunctionCreateProvisioningFile( FILE ${MITK_COREAPP_PROVISIONING_FILE} INCLUDE "${BLUEBERRY_PLUGIN_PROVISIONING_FILE}" PLUGIN_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins" PLUGINS ${mitk_core_plugins_fullpath} ) set(MITK_EXTAPP_PROVISIONING_FILE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ExtApp.provisioning") FunctionCreateProvisioningFile( FILE ${MITK_EXTAPP_PROVISIONING_FILE} INCLUDE "${BLUEBERRY_PLUGIN_PROVISIONING_FILE}" PLUGIN_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins" PLUGINS ${mitk_core_plugins_fullpath} ${mitk_ext_plugins_fullpath} ) set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake") ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE}) # Used in the export command further below GetMyTargetLibraries("${CTK_PLUGIN_LIBRARIES}" MITK_PLUGIN_TARGETS) # add legacy BlueBerry bundles add_subdirectory(Modules/Bundles) endif() # Construct a list of paths containing runtime directories # for MITK applications on Windows set(MITK_RUNTIME_PATH "${VTK_LIBRARY_DIRS}/@VS_BUILD_TYPE@;${ITK_LIBRARY_DIRS}/@VS_BUILD_TYPE@;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/@VS_BUILD_TYPE@" ) if(QT4_FOUND) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${QT_LIBRARY_DIR}/../bin") endif() if(MITK_USE_BLUEBERRY) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${CTK_RUNTIME_LIBRARY_DIRS}/@VS_BUILD_TYPE@;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins/@VS_BUILD_TYPE@") endif() if(GDCM_DIR) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${GDCM_DIR}/bin/@VS_BUILD_TYPE@") endif() if(OpenCV_DIR) set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${OpenCV_DIR}/bin/@VS_BUILD_TYPE@") endif() # DCMTK is statically build #if(DCMTK_DIR) # set(MITK_RUNTIME_PATH "${MITK_RUNTIME_PATH};${DCMTK_DIR}/bin/@VS_BUILD_TYPE@") #endif() # Add applications directory add_subdirectory(Applications) #----------------------------------------------------------------------------- # Python Wrapping #----------------------------------------------------------------------------- set(MITK_WRAPPING_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Wrapping) set(MITK_WRAPPING_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/Wrapping) option(MITK_USE_PYTHON "Build cswig Python wrapper support (requires CableSwig)." OFF) if(MITK_USE_PYTHON) add_subdirectory(Wrapping) endif() #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- add_subdirectory(Documentation) #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables include(mitkSetupCPack) if(MITK_BUILD_org.mitk.gui.qt.application) list(APPEND CPACK_CREATE_DESKTOP_LINKS "CoreApp") endif() if(MITK_BUILD_org.mitk.gui.qt.extapplication) list(APPEND CPACK_CREATE_DESKTOP_LINKS "ExtApp") endif() configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) if(MITK_USE_BLUEBERRY) set(enabled_plugins ${BLUEBERRY_PLUGIN_TARGETS} ${MITK_PLUGIN_TARGETS} ${MITK_MODULES_ENABLED_PLUGINS} ) # This is for installation support of external projects depending on # MITK plugins. The export file should not be used for linking to MITK # libraries without using LINK_DIRECTORIES, since the exports are incomplete # yet(depending libraries are not exported). foreach(plugin ${enabled_plugins}) string(REPLACE "." "_" plugin_target ${plugin}) export(TARGETS ${plugin_target} APPEND FILE ${MITK_EXPORTS_FILE}) endforeach() endif() 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_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(VECMATH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/vecmath) 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) # 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") 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) diff --git a/Core/Code/Algorithms/mitkImageAccessByItk.h b/Core/Code/Algorithms/mitkImageAccessByItk.h index 0d92070cee..fa7d29c5a5 100644 --- a/Core/Code/Algorithms/mitkImageAccessByItk.h +++ b/Core/Code/Algorithms/mitkImageAccessByItk.h @@ -1,1108 +1,1235 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision$ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #ifndef MITKIMAGEACCESSBYITK_H_HEADER_INCLUDED #define MITKIMAGEACCESSBYITK_H_HEADER_INCLUDED #include #include #include "mitkPixelTypeList.h" #include namespace mitk { class AccessByItkException : public virtual std::runtime_error { public: AccessByItkException(const std::string& msg) : std::runtime_error(msg) {} ~AccessByItkException() throw() {} }; } #ifndef DOXYGEN_SKIP #define _accessByItkWarning \ { \ itkGenericOutputMacro(<< "Pixel type " << pixelType.GetItkTypeAsString() \ << " not supported by AccessByItk") \ } #define _accessByItkWarningParam(pixelType, accessor) \ { \ itkGenericOutputMacro(<< "Pixel type " << pixelType.GetItkTypeAsString() \ << " not supported by " << accessor) \ } #define _accessByItkTypeException(pixelType, ...) \ { \ std::string msg("Pixel type "); \ msg.append(pixelType.GetItkTypeAsString()); \ msg.append(" is not in (" #__VA_ARGS__ ")"); \ throw mitk::AccessByItkException(msg); \ } #define _accessByItkDimensionException(dim, ...) \ { \ std::stringstream msg; \ msg << "Dimension " << (dim) << " is not in (" << #__VA_ARGS__ << ")"; \ throw mitk::AccessByItkException(msg.str()); \ } #define _checkValidDimension(mitkImage) \ { \ if (mitkImage->GetDimension() < 2 || mitkImage->GetDimension() > 3) \ _accessByItkDimensionException(mitkImage->GetDimension(), 2, 3); \ } #define _checkSpecificDimension(mitkImage, dim) \ { \ if (mitkImage->GetDimension() != dim) \ _accessByItkDimensionException(mitkImage->GetDimension(), dim); \ } #define _checkValidDimension2(mitkImage) \ { \ if (mitkImage->GetDimension() != 2) \ _accessByItkDimensionException(mitkImage->GetDimension(), 2); \ } #define _checkValidDimension3(mitkImage) \ { \ if (mitkImage->GetDimension() != 3) \ _accessByItkDimensionException(mitkImage->GetDimension(), 3); \ } #define _checkValidPixelType(expr, pixelType, ...) \ { \ if (!(expr)) \ _accessByItkTypeException(pixelType, __VA_ARGS__); \ } #define _accessByItk(mitkImage, itkImageTypeFunction, pixeltype, dimension) \ if ( pixelType == typeid(pixeltype) ) \ { \ typedef itk::Image ImageType; \ typedef mitk::ImageToItk ImageToItkType; \ itk::SmartPointer imagetoitk = ImageToItkType::New(); \ imagetoitk->SetInput(mitkImage); \ imagetoitk->Update(); \ itkImageTypeFunction(imagetoitk->GetOutput()); \ } \ #define _accessAllTypesByItk(mitkImage, itkImageTypeFunction, dimension) \ _accessByItk(mitkImage, itkImageTypeFunction, double, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, float, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, int, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, unsigned int, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, short, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, unsigned short, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, char, dimension) else \ _accessByItk(mitkImage, itkImageTypeFunction, unsigned char, dimension) else \ _accessByItkTypeException(mitkImage->GetPixelType(), double, float, int, unsigned int, short, unsigned short, char, unsigned char) -#define _accessSpecificTypesByItk(mitkImage, dimension, ...) \ +#define _accessSpecificPixelTypesByItk(mitkImage, dimension, ...) \ { \ typedef mitk::PixelTypeList<__VA_ARGS__> MyTypes; \ mitk::PixelTypeSwitch typeSwitch; \ mitk::AccessItkImageFunctor memberFunctor(this, mitkImage); \ int i = 0; \ int typeCount = mitk::PixelTypeLength::value; \ for(; i < typeCount; ++i) \ { \ if (typeSwitch(i, memberFunctor)) break; \ } \ _checkValidPixelType(i != typeCount, mitkImage->GetPixelType(), __VA_ARGS__) \ } #endif //DOXYGEN_SKIP /** + * @deprecated Use AccessDefaultPixelTypesByItk instead + * * @brief Access an mitk-image by an itk-image * * Define a templated function or method (@a itkImageTypeFunction) * within which the mitk-image (@a mitkImage) is accessed: * \code * template < typename TPixel, unsigned int VImageDimension > * void ExampleFunction( itk::Image* itkImage ); * \endcode * Within the itk::Image passed to the function/method has the same * data-pointer as the mitk-image. So you have full read- and write- * access to the data vector of the mitk-image using the itk-image. * Call by: * \code * mitk::Image* inputMitkImage = ... - * AccessByItk(inputMitkImage, ExampleFunction); + * try + * { + * AccessByItk(inputMitkImage, ExampleFunction); + * } + * catch (const mitk::AccessByItkException& e) + * { + * // mitk::Image is of wrong pixel type or dimension, + * // insert error handling here + * } * \endcode * @note If your inputMitkImage is an mitk::Image::Pointer, use * inputMitkImage.GetPointer() * @note If you need to pass an additional parameter to your * access-function (@a itkImageTypeFunction), use AccessByItk_1. * @note If you know the dimension of your input mitk-image, * it is better to use AccessFixedDimensionByItk (less code * is generated). * \sa AccessFixedDimensionByItk * \sa AccessFixedTypeByItk * \sa AccessFixedPixelTypeByItk * \sa AccessByItk_1 * \sa AccessByItk_2 * @ingroup Adaptor */ #define AccessByItk(mitkImage, itkImageTypeFunction) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ _accessAllTypesByItk(mitkImage, itkImageTypeFunction, 2); \ } \ else \ { \ _accessAllTypesByItk(mitkImage, itkImageTypeFunction, 3) \ } \ } +/** + * \brief Access an mitk image by an itk image + * + * This variadic macro allows you to access a mitk::Image instance as an itk::Image + * in a templated member functions. You must use this macro inside a class member function and + * the class must contain a \em Self typedef and a public \em AccessItkImage template function, + * which is instantiated for all default pixel types listed in the CMake variable + * MITK_ACCESSBYITK_PIXEL_TYPES. + * + * The following example accesses an mitk-image as an ITK image: + * \code + * class MyClass + * { + * typedef MyClass Self; + * + * public: + * + * template + * void AccessItkImage(itk::Image* itkImage) + * { + * ... do something + * } + * + * void Calculate() + * { + * mitk::Image* mitkImage = ... + * try + * { + * AccessDefaultPixelTypesByItk(mitkImage) + * } + * catch (const mitk::AccessByItkException& e) + * { + * // The mitk::Image is of wrong pixel type or dimension, + * // add error handling here. + * } + * } + * }; + * \endcode + * + * \sa AccessSpecificPixelTypesByItk + * \sa AccessIntegralPixelTypesByItk + * \sa AccessFloatingPixelTypesByItk + */ +#define AccessDefaultPixelTypesByItk(mitkImage) \ +{ \ + _checkValidDimension(mitkImage); \ + if((mitkImage)->GetDimension()==2) \ + { \ + _accessSpecificPixelTypesByItk(mitkImage, 2, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ + else \ + { \ + _accessSpecificPixelTypesByItk(mitkImage, 3, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ +} + /** * \brief Access an mitk image by an itk image * * This variadic macro allows you to define a set of allowed pixel types for * your mitk::Image. You must use this macro inside a class member function and * the class must contain a \em Self typedef and a public \em AccessItkImage template function. * * The following example accesses an mitk-image as an ITK image, restricting the * allowed pixel types to signed integral datatypes: * \code * class MyClass * { * typedef MyClass Self; * * public: * * template * void AccessItkImage(itk::Image* itkImage) * { * ... do something * } * * void Calculate() * { * mitk::Image* mitkImage = ... - * AccessSpecificTypesByItk(mitkImage, int, short, char) - * } + * try + * { + * AccessSpecificPixelTypesByItk(mitkImage, int, short, char) + * } + * catch (const mitk::AccessByItkException& e) + * { + * // The mitk::Image is of wrong pixel type or dimension, + * // add error handling here. + * } + * } * }; * \endcode * * If you enable ITK_USE_STRICT_CONCEPT_CHECKING in your ITK build, you have to use this * macro or its variants to avoid compiling ITK filters with incorrect types. * - * \sa AccessIntegralTypesByItk - * \sa AccessFloatingTypesByItk + * \sa AccessDefaultPixelTypesByItk + * \sa AccessIntegralPixelTypesByItk + * \sa AccessFloatingPixelTypesByItk */ -#define AccessSpecificTypesByItk(mitkImage, ...) \ +#define AccessSpecificPixelTypesByItk(mitkImage, ...) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk(mitkImage, 2, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk(mitkImage, 2, __VA_ARGS__); \ } \ else \ { \ - _accessSpecificTypesByItk(mitkImage, 3, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk(mitkImage, 3, __VA_ARGS__); \ } \ } /** * \brief Access an mitk::Image with an integral pixel type by an ITK image * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessIntegralTypesByItk(mitkImage) \ +#define AccessIntegralPixelTypesByItk(mitkImage) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk(mitkImage, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk(mitkImage, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ else \ { \ - _accessSpecificTypesByItk(mitkImage, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk(mitkImage, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ } /** * \brief Access an mitk::Image with a floating point pixel type by an ITK image * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessFloatingTypesByItk(mitkImage) \ +#define AccessFloatingPixelTypesByItk(mitkImage) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk(mitkImage, 2, double, float); \ + _accessSpecificPixelTypesByItk(mitkImage, 2, double, float); \ } \ else \ { \ - _accessSpecificTypesByItk(mitkImage, 3, double, float); \ + _accessSpecificPixelTypesByItk(mitkImage, 3, double, float); \ } \ } //##Documentation //## @brief Access an mitk-image with known dimension by an itk-image //## //## For usage, see AccessByItk. //## @param dimension dimension of the mitk-image. //## //## If the image has a different dimension, a mitk::AccessByItkException exception is thrown. //## //## If you do not know the dimension for sure, use AccessByItk. //## \sa AccessByItk //## \sa AccessFixedDimensionByItk //## \sa AccessFixedTypeByItk //## \sa AccessFixedPixelTypeByItk //## @ingroup Adaptor #define AccessFixedDimensionByItk(mitkImage, itkImageTypeFunction, dimension) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _accessAllTypesByItk(mitkImage, itkImageTypeFunction, dimension) \ } //##Documentation //## @brief Access an mitk-image with known type (pixel type and dimension) //## by an itk-image //## //## For usage, see AccessByItk. //## @param dimension The dimension of the mitk-image. If the image //## has a different dimension, a mitk::AccessByItkException exception is thrown. //## If you do not know the dimension for sure, use AccessByItk. //## \sa AccessByItk //## \sa AccessFixedDimensionByItk //## \sa AccessFixedTypeByItk //## \sa AccessFixedPixelTypeByItk //## @ingroup Adaptor #define AccessFixedTypeByItk(mitkImage, itkImageTypeFunction, pixeltype, dimension) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype) \ _accessByItk(mitkImage, itkImageTypeFunction, pixeltype, dimension) \ } //##Documentation +//## @deprecated Use AccessSpecificPixelTypesByItk instead //## @brief Access an mitk-image with known pixeltype (but unknown dimension) //## by an itk-image and pass two additional parameters to the access-function //## //## For usage, see AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## //## If the image has a different pixel type, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type for sure, use AccessByItk. //## \sa AccessByItk //## \sa AccessFixedDimensionByItk //## \sa AccessFixedTypeByItk //## \sa AccessFixedPixelTypeByItk //## @ingroup Adaptor #define AccessFixedPixelTypeByItk(mitkImage, itkImageTypeFunction, pixeltype) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ if((mitkImage)->GetDimension()==2) \ { \ _accessByItk(mitkImage, itkImageTypeFunction, pixeltype, 2) \ } \ else \ { \ _accessByItk(mitkImage, itkImageTypeFunction, pixeltype, 3) \ } \ } //----------------------- version with 1 additional paramater ------------------ #ifndef DOXYGEN_SKIP #define _accessByItk_1(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1) \ if ( pixelType == typeid(pixeltype) ) \ { \ typedef itk::Image ImageType; \ typedef mitk::ImageToItk ImageToItkType; \ itk::SmartPointer imagetoitk = ImageToItkType::New(); \ imagetoitk->SetInput(mitkImage); \ imagetoitk->Update(); \ itkImageTypeFunction(imagetoitk->GetOutput(), param1); \ } #define _accessAllTypesByItk_1(mitkImage, itkImageTypeFunction, dimension, param1) \ _accessByItk_1(mitkImage, itkImageTypeFunction, double, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, float, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, int, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, unsigned int, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, short, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, unsigned short, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, char, dimension, param1) else \ _accessByItk_1(mitkImage, itkImageTypeFunction, unsigned char, dimension, param1) else \ _accessByItkTypeException(mitkImage->GetPixelType(), double, float, int, unsigned int, short, unsigned short, char, unsigned char) -#define _accessSpecificTypesByItk_1(mitkImage, paramtype1, param1, dimension, ...) \ +#define _accessSpecificPixelTypesByItk_1(mitkImage, paramtype1, param1, dimension, ...) \ { \ typedef mitk::PixelTypeList<__VA_ARGS__> MyTypes; \ mitk::PixelTypeSwitch typeSwitch; \ mitk::AccessItkImageFunctor memberFunctor(this, mitkImage, param1); \ int i = 0; \ int typeCount = mitk::PixelTypeLength::value; \ for(; i < typeCount; ++i) \ { \ if (typeSwitch(i, memberFunctor)) break; \ } \ - _checkValidPixelType(i != typeCount, mitkImage->GetPixelType(), __VA_ARGS__); \ + _checkValidPixelType(i != typeCount, mitkImage->GetPixelType(), __VA_ARGS__); \ } #endif //DOXYGEN_SKIP //##Documentation +//## @deprecated Use AccessDefaultPixelTypesByItk_1 instead //## @brief Access an mitk-image by an itk-image and pass one //## additional parameter to the access-function //## //## For usage, see AccessByItk. The only difference to AccessByItk //## is that an additional parameter (@a param1) is passed. //## @note If you know the dimension of your input mitk-image, //## it is better to use AccessFixedDimensionByItk_1 (less code //## is generated). //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_1 //## \sa AccessFixedTypeByItk_1 //## \sa AccessFixedPixelTypeByItk_1 //## @ingroup Adaptor #define AccessByItk_1(mitkImage, itkImageTypeFunction, param1) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ if(mitkImage->GetDimension()==2) \ { \ _accessAllTypesByItk_1(mitkImage, itkImageTypeFunction, 2, param1); \ } \ else \ { \ _accessAllTypesByItk_1(mitkImage, itkImageTypeFunction, 3, param1) \ } \ } +/** + * \brief Access an mitk image by an itk image and pass one + * additional parameter to the access-function. + * + * \sa AccessDefaultPixelTypesByItk + */ +#define AccessDefaultPixelTypesByItk_1(mitkImage, paramType1, param1) \ +{ \ + _checkValidDimension(mitkImage); \ + if((mitkImage)->GetDimension()==2) \ + { \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 2, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ + else \ + { \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 3, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ +} + /** * \brief Access an mitk-image by an itk-image and pass one * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessSpecificTypesByItk_1(mitkImage, paramType1, param1, ...) \ +#define AccessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, ...) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_1(mitkImage, paramType1, param1, 2, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 2, __VA_ARGS__); \ } \ else \ { \ - _accessSpecificTypesByItk_1(mitkImage, paramType1, param1, 3, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 3, __VA_ARGS__); \ } \ } /** * \brief Access an mitk-image witn an integral pixel type by an itk-image and pass one * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessIntegralTypesByItk_1(mitkImage, paramType1, param1) \ +#define AccessIntegralPixelTypesByItk_1(mitkImage, paramType1, param1) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_1(mitkImage, paramType1, param1, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ else \ { \ - _accessSpecificTypesByItk_1(mitkImage, paramType1, param1, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ } /** * \brief Access an mitk-image with a floating point pixel type by an itk-image and pass one * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessFloatingTypesByItk_1(mitkImage, paramType1, param1) \ +#define AccessFloatingPixelTypesByItk_1(mitkImage, paramType1, param1) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_1(mitkImage, paramType1, param1, 2, double, float); \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 2, double, float); \ } \ else \ { \ - _accessSpecificTypesByItk_1(mitkImage, paramType1, param1, 3, double, float); \ + _accessSpecificPixelTypesByItk_1(mitkImage, paramType1, param1, 3, double, float); \ } \ } //##Documentation //## @brief Access an mitk-image with known dimension by an itk-image //## and pass one additional parameter to the access-function //## //## For usage, see AccessByItk_1 and AccessByItk. //## @param dimension dimension of the mitk-image. //## //## If the image has a different dimension, a mitk::AccessByItkException exception is thrown. //## //## If you do not know the dimension for sure, use AccessByItk_1. //## \sa AccessByItk_2 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_1 //## \sa AccessFixedTypeByItk_1 //## \sa AccessFixedPixelTypeByItk_1 //## @ingroup Adaptor #define AccessFixedDimensionByItk_1(mitkImage, itkImageTypeFunction, dimension, param1) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _accessAllTypesByItk_1(mitkImage, itkImageTypeFunction, dimension, param1) \ } //##Documentation //## @brief Access an mitk-image with known type (pixel type and dimension) //## by an itk-image and pass one additional parameters to the access-function //## //## For usage, see AccessByItk_1 and AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## @param dimension dimension of the mitk-image. //## //## If the image has a different pixel type or dimension, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type and dimension for sure, use AccessByItk_1. //## \sa AccessByItk_1 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_1 //## \sa AccessFixedTypeByItk_1 //## \sa AccessFixedPixelTypeByItk_1 //## @ingroup Adaptor #define AccessFixedTypeByItk_1(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ _accessByItk_1(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1) \ } //##Documentation +//## @deprecated Use AccessSpecificPixelTypesByItk_1 instead //## @brief Access an mitk-image with known pixeltype (but unknown dimension) //## by an itk-image and pass one additional parameters to the access-function //## //## For usage, see AccessByItk_1 and AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## //## If the image has a different pixel type, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type for sure, use AccessByItk_1. //## \sa AccessByItk_1 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_1 //## \sa AccessFixedTypeByItk_1 //## \sa AccessFixedPixelTypeByItk_1 //## @ingroup Adaptor #define AccessFixedPixelTypeByItk_1(mitkImage, itkImageTypeFunction, pixeltype, param1) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ if(mitkImage->GetDimension()==2) \ { \ _accessByItk_1(mitkImage, itkImageTypeFunction, pixeltype, 2, param1) \ } \ else \ { \ _accessByItk_1(mitkImage, itkImageTypeFunction, pixeltype, 3, param1) \ } \ } //----------------------- version with 2 additional paramaters ----------------- #ifndef DOXYGEN_SKIP #define _accessByItk_2(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1, param2) \ if ( pixelType == typeid(pixeltype) ) \ { \ typedef itk::Image ImageType; \ typedef mitk::ImageToItk ImageToItkType; \ itk::SmartPointer imagetoitk = ImageToItkType::New(); \ imagetoitk->SetInput(mitkImage); \ imagetoitk->Update(); \ itkImageTypeFunction(imagetoitk->GetOutput(), param1, param2); \ } #define _accessAllTypesByItk_2(mitkImage, itkImageTypeFunction, dimension, param1, param2) \ _accessByItk_2(mitkImage, itkImageTypeFunction, double, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, float, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, int, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, unsigned int, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, short, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, unsigned short, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, char, dimension, param1, param2) else \ _accessByItk_2(mitkImage, itkImageTypeFunction, unsigned char, dimension, param1, param2) else \ _accessByItkTypeException(mitkImage->GetPixelType(), double, float, int, unsigned int, short, unsigned short, char, unsigned char) -#define _accessSpecificTypesByItk_2(mitkImage, paramtype1, param1, paramtype2, param2, dimension, ...) \ +#define _accessSpecificPixelTypesByItk_2(mitkImage, paramtype1, param1, paramtype2, param2, dimension, ...) \ { \ typedef mitk::PixelTypeList<__VA_ARGS__> MyTypes; \ mitk::PixelTypeSwitch typeSwitch; \ mitk::AccessItkImageFunctor memberFunctor(this, mitkImage, param1, param2); \ int i = 0; \ int typeCount = mitk::PixelTypeLength::value; \ for(; i < typeCount; ++i) \ { \ if (typeSwitch(i, memberFunctor)) break; \ } \ _checkValidPixelType(i != typeCount, mitkImage->GetPixelType(), __VA_ARGS__); \ } #endif //DOXYGEN_SKIP //##Documentation +//## @deprecated Use AccessDefaultPixelTypesByItk_2 instead //## @brief Access an mitk-image by an itk-image and pass two //## additional parameters to the access-function //## //## For usage, see AccessByItk. The only difference to AccessByItk //## is that two additional parameters (@a param1, @a param2) are passed. //## @note If you know the dimension of your input mitk-image, //## it is better to use AccessFixedDimensionByItk_2 (less code //## is generated). //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_2 //## \sa AccessFixedTypeByItk_2 //## \sa AccessFixedPixelTypeByItk_2 //## @ingroup Adaptor #define AccessByItk_2(mitkImage, itkImageTypeFunction, param1, param2) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ if(mitkImage->GetDimension()==2) \ { \ _accessAllTypesByItk_2(mitkImage, itkImageTypeFunction, 2, param1, param2); \ } \ else \ { \ _accessAllTypesByItk_2(mitkImage, itkImageTypeFunction, 3, param1, param2) \ } \ } +/** + * \brief Access an mitk image by an itk image and pass two + * additional parameter to the access-function. + * + * \sa AccessDefaultPixelTypesByItk + */ +#define AccessDefaultPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2) \ +{ \ + _checkValidDimension(mitkImage); \ + if((mitkImage)->GetDimension()==2) \ + { \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ + else \ + { \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ +} + /** * \brief Access an mitk-image by an itk-image and pass two * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, ...) \ +#define AccessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, ...) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, __VA_ARGS__); \ } \ else \ { \ - _accessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, __VA_ARGS__); \ } \ } /** * \brief Access an mitk-image with an integral pixel type by an itk-image and pass two * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessIntegralTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2) \ +#define AccessIntegralPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ else \ { \ - _accessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ } /** * \brief Access an mitk-image with a floating point pixel type by an itk-image and pass two * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessFloatingTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2) \ +#define AccessFloatingPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, double, float); \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 2, double, float); \ } \ else \ { \ - _accessSpecificTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, double, float); \ + _accessSpecificPixelTypesByItk_2(mitkImage, paramType1, param1, paramType2, param2, 3, double, float); \ } \ } //##Documentation //## @brief Access an mitk-image with known dimension by an itk-image //## and pass two additional parameters to the access-function //## //## For usage, see AccessByItk_2 and AccessByItk. //## @param dimension dimension of the mitk-image. //## //## If the image has a different dimension, a mitk::AccessByItkException exception is thrown. //## //## If you do not know the dimension for sure, use AccessByItk_2. //## \sa AccessByItk_2 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_2 //## \sa AccessFixedTypeByItk_2 //## \sa AccessFixedPixelTypeByItk_2 //## @ingroup Adaptor #define AccessFixedDimensionByItk_2(mitkImage, itkImageTypeFunction, dimension, param1, param2) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _accessAllTypesByItk_2(mitkImage, itkImageTypeFunction, dimension, param1, param2) \ } //##Documentation //## @brief Access an mitk-image with known type (pixel type and dimension) //## by an itk-image and pass two additional parameters to the access-function //## //## For usage, see AccessByItk_2 and AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## @param dimension dimension of the mitk-image. //## //## If the image has a different pixel type or dimension, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type and dimension for sure, use AccessByItk_2. //## \sa AccessByItk_2 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_2 //## \sa AccessFixedTypeByItk_2 //## \sa AccessFixedPixelTypeByItk_2 //## @ingroup Adaptor #define AccessFixedTypeByItk_2(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1, param2) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ _accessByItk_2(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1, param2) \ } //##Documentation +//## @deprecated Use AccessSpecificPixelTypesByItk_2 instead //## @brief Access an mitk-image with known pixel type (but unknown dimension) //## by an itk-image and pass two additional parameters to the access-function //## //## For usage, see AccessByItk_2 and AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## //## If the image has a different pixel type, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type for sure, use AccessByItk_2. //## \sa AccessByItk_2 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_2 //## \sa AccessFixedTypeByItk_2 //## \sa AccessFixedPixelTypeByItk_2 //## @ingroup Adaptor #define AccessFixedPixelTypeByItk_2(mitkImage, itkImageTypeFunction, pixeltype, param1, param2) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ if(mitkImage->GetDimension()==2) \ { \ _accessByItk_2(mitkImage, itkImageTypeFunction, pixeltype, 2, param1, param2) \ } \ else \ { \ _accessByItk_2(mitkImage, itkImageTypeFunction, pixeltype, 3, param1, param2) \ } \ } #define _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, pixeltype2, dimension) \ if ( pixelType2 == typeid(pixeltype2) ) \ { \ typedef itk::Image ImageType1; \ typedef itk::Image ImageType2; \ typedef mitk::ImageToItk ImageToItkType1; \ typedef mitk::ImageToItk ImageToItkType2; \ itk::SmartPointer imagetoitk1 = ImageToItkType1::New(); \ imagetoitk1->SetInput(mitkImage1); \ imagetoitk1->Update(); \ itk::SmartPointer imagetoitk2 = ImageToItkType2::New(); \ imagetoitk2->SetInput(mitkImage2); \ imagetoitk2->Update(); \ itkImageTypeFunction(imagetoitk1->GetOutput(), imagetoitk2->GetOutput()); \ } #define _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, dimension) \ if ( pixelType1 == typeid(pixeltype) ) \ { \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, double, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, float, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, int, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, unsigned int, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, short, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, unsigned short, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, char, dimension) else \ _accessTwoImagesByItk2(mitkImage1, mitkImage2, itkImageTypeFunction, pixeltype, unsigned char, dimension) else \ _accessByItkTypeException(pixelType2, double, float, int, unsigned int, short, unsigned short, char, unsigned char) \ } #define _accessTwoImagesAllTypesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension) \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, double, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, float, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, int, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, unsigned int, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, short, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, unsigned short, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, char, dimension) else \ _accessTwoImagesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, unsigned char, dimension) else \ _accessByItkTypeException(pixelType1, double, float, int, unsigned int, short, unsigned short, char, unsigned char) //----------------------- version with 3 additional parameters ----------------- #ifndef DOXYGEN_SKIP #define _accessByItk_3(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1, param2, param3) \ - if ( pixelType == typeid(pixeltype) ) \ - { \ + if ( pixelType == typeid(pixeltype) ) \ + { \ typedef itk::Image ImageType; \ typedef mitk::ImageToItk ImageToItkType; \ itk::SmartPointer imagetoitk = ImageToItkType::New(); \ imagetoitk->SetInput(mitkImage); \ imagetoitk->Update(); \ itkImageTypeFunction(imagetoitk->GetOutput(), param1, param2, param3); \ } #define _accessAllTypesByItk_3(mitkImage, itkImageTypeFunction, dimension, param1, param2, param3) \ _accessByItk_3(mitkImage, itkImageTypeFunction, double, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, float, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, int, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, unsigned int, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, short, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, unsigned short, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, char, dimension, param1, param2, param3) else \ _accessByItk_3(mitkImage, itkImageTypeFunction, unsigned char, dimension, param1, param2, param3) else \ _accessByItkTypeException(mitkImage->GetPixelType(), double, float, int, unsigned int, short, unsigned short, char, unsigned char) -#define _accessSpecificTypesByItk_3(mitkImage, paramtype1, param1, paramtype2, param2, paramtype3, param3, dimension, ...) \ +#define _accessSpecificPixelTypesByItk_3(mitkImage, paramtype1, param1, paramtype2, param2, paramtype3, param3, dimension, ...) \ { \ typedef mitk::PixelTypeList<__VA_ARGS__> MyTypes; \ mitk::PixelTypeSwitch typeSwitch; \ mitk::AccessItkImageFunctor memberFunctor(this, mitkImage, param1, param2, param3); \ int i = 0; \ int typeCount = mitk::PixelTypeLength::value; \ for(; i < typeCount; ++i) \ { \ if (typeSwitch(i, memberFunctor)) break; \ } \ _checkValidPixelType(i != typeCount, mitkImage->GetPixelType(), __VA_ARGS__); \ } #endif //DOXYGEN_SKIP //##Documentation +//## @deprecated Use AccessDefaultPixelTypesByItk_3 instead //## @brief Access an mitk-image by an itk-image and pass three //## additional parameters to the access-function //## //## For usage, see AccessByItk. The only difference to AccessByItk //## is that two additional parameters (@a param1, @a param2) are passed. //## @note If you know the dimension of your input mitk-image, //## it is better to use AccessFixedDimensionByItk_3 (less code //## is generated). //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_3 //## \sa AccessFixedPixelTypeByItk_3 //## @ingroup Adaptor #define AccessByItk_3(mitkImage, itkImageTypeFunction, param1, param2, param3) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ if(mitkImage->GetDimension()==2) \ { \ _accessAllTypesByItk_3(mitkImage, itkImageTypeFunction, 2, param1, param2, param3); \ } \ else \ { \ _accessAllTypesByItk_3(mitkImage, itkImageTypeFunction, 3, param1, param2, param3) \ } \ } +/** + * \brief Access an mitk image by an itk image and pass three + * additional parameter to the access-function. + * + * \sa AccessDefaultPixelTypesByItk + */ +#define AccessDefaultPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3) \ +{ \ + _checkValidDimension(mitkImage); \ + if((mitkImage)->GetDimension()==2) \ + { \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ + else \ + { \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, MITK_ACCESSBYITK_PIXEL_TYPES); \ + } \ +} + /** * \brief Access an mitk-image by an itk-image and pass three * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, ...) \ +#define AccessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, ...) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, __VA_ARGS__); \ } \ else \ { \ - _accessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, __VA_ARGS__); \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, __VA_ARGS__); \ } \ } /** * \brief Access an mitk-image with an integral pixel type by an itk-image and pass three * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessIntegralTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3) \ +#define AccessIntegralPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ else \ { \ - _accessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, int, unsigned int, short, unsigned short, char, unsigned char); \ } \ } /** * \brief Access an mitk-image with a floating point pixel type by an itk-image and pass three * additional parameter to the access-function. * - * See AccessSpecificTypesByItk for details. + * See AccessSpecificPixelTypesByItk for details. * - * \sa AccessSpecificTypesByItk + * \sa AccessSpecificPixelTypesByItk */ -#define AccessFloatingTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3) \ +#define AccessFloatingPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3) \ { \ - const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ _checkValidDimension(mitkImage); \ if((mitkImage)->GetDimension()==2) \ { \ - _accessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, double, float); \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 2, double, float); \ } \ else \ { \ - _accessSpecificTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, double, float); \ + _accessSpecificPixelTypesByItk_3(mitkImage, paramType1, param1, paramType2, param2, paramType3, param3, 3, double, float); \ } \ } //##Documentation //## @brief Access an mitk-image with known dimension by an itk-image //## and pass three additional parameters to the access-function //## //## For usage, see AccessByItk_3 and AccessByItk. //## @param dimension dimension of the mitk-image. //## //## If the image has a different dimension, a mitk::AccessByItkException exception is thrown. //## //## If you do not know the dimension for sure, use AccessByItk_3. //## \sa AccessByItk_3 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_3 //## \sa AccessFixedTypeByItk_3 //## \sa AccessFixedPixelTypeByItk_3 //## @ingroup Adaptor #define AccessFixedDimensionByItk_3(mitkImage, itkImageTypeFunction, dimension, param1, param2, param3) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _accessAllTypesByItk_3(mitkImage, itkImageTypeFunction, dimension, param1, param2, param3) \ } //##Documentation //## @brief Access an mitk-image with known type (pixel type and dimension) //## by an itk-image and pass three additional parameters to the access-function //## //## For usage, see AccessByItk_3 and AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## @param dimension dimension of the mitk-image. //## //## If the image has a different pixel type or dimension, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type and dimension for sure, use AccessByItk_3. //## \sa AccessByItk_3 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_3 //## \sa AccessFixedPixelTypeByItk_3 //## @ingroup Adaptor #define AccessFixedTypeByItk_3(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1, param2, param3) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkSpecificDimension(mitkImage, dimension); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ _accessByItk_3(mitkImage, itkImageTypeFunction, pixeltype, dimension, param1, param2, param3) \ } //##Documentation +//## @deprecated Use AccessSpecificPixelTypesByItk_3 instead //## @brief Access an mitk-image with known pixel type (but unknown dimension) //## by an itk-image and pass three additional parameters to the access-function //## //## For usage, see AccessByItk_3 and AccessByItk. //## @param pixeltype pixel type of the mitk-image. //## //## If the image has a different pixel type, a mitk::AccessByItkException exception is //## thrown. //## If you do not know the pixel type for sure, use AccessByItk_3. //## \sa AccessByItk_3 //## \sa AccessByItk //## \sa AccessFixedDimensionByItk_3 //## \sa AccessFixedTypeByItk_3 //## \sa AccessFixedPixelTypeByItk_3 //## @ingroup Adaptor #define AccessFixedPixelTypeByItk_3(mitkImage, itkImageTypeFunction, pixeltype, param1, param2, param3) \ { \ const mitk::PixelType& pixelType = mitkImage->GetPixelType(); \ const mitk::Image* constImage = mitkImage; \ const_cast(constImage)->Update(); \ _checkValidDimension(mitkImage); \ _checkValidPixelType(pixelType == typeid(pixeltype), pixelType, pixeltype); \ if(mitkImage->GetDimension()==2) \ { \ _accessByItk_3(mitkImage, itkImageTypeFunction, pixeltype, 2, param1, param2, param3) \ } \ else \ { \ _accessByItk_3(mitkImage, itkImageTypeFunction, pixeltype, 3, param1, param2, param3) \ } \ } //##Documentation //## @brief Access two mitk-images with known dimension by itk-images //## //## For usage, see AccessByItk. //## @param dimension dimension of the mitk-image. //## //## If one of the images has a different dimension, a mitk::AccessByItkException exception is thrown. //## //## If you do not know the dimension for sure, use AccessByItk. //## \sa AccessByItk //## \sa AccessFixedDimensionByItk //## \sa AccessFixedTypeByItk //## \sa AccessFixedPixelTypeByItk //## @ingroup Adaptor #define AccessTwoImagesFixedDimensionByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension) \ { \ const mitk::PixelType& pixelType1 = mitkImage1->GetPixelType(); \ const mitk::PixelType& pixelType2 = mitkImage2->GetPixelType(); \ const mitk::Image* constImage1 = mitkImage1; \ const mitk::Image* constImage2 = mitkImage2; \ const_cast(constImage1)->Update(); \ const_cast(constImage2)->Update(); \ _checkSpecificDimension(mitkImage1, dimension); \ _checkSpecificDimension(mitkImage2, dimension); \ _accessTwoImagesAllTypesByItk(mitkImage1, mitkImage2, itkImageTypeFunction, dimension) \ } #ifdef mitkCore_EXPORTS #define MITK_CORE_EXPORT_EXTERN #else #define MITK_CORE_EXPORT_EXTERN extern #endif //----------------------- cast functions. Will be moved to mitkImageCast.h ----------------- namespace mitk { #ifndef DOXYGEN_SKIP template < typename TPixel, unsigned int VImageDimension, class ItkOutputImageType > void _CastToItkImage2Access( itk::Image* itkInputImage, itk::SmartPointer& itkOutputImage); #endif //DOXYGEN_SKIP //##Documentation //## @brief Cast an mitk::Image to an itk::Image with a specific type. You don't have to initialize the itk::Image<..>::Pointer. //## @ingroup Adaptor template extern void MITK_CORE_EXPORT CastToItkImage(const mitk::Image * mitkImage, itk::SmartPointer& itkOutputImage); } //----------------------- include to be removed ----------------------- #include #endif // of MITKIMAGEACCESSBYITK_H_HEADER_INCLUDED diff --git a/Core/Code/Testing/mitkAccessByItkTest.cpp b/Core/Code/Testing/mitkAccessByItkTest.cpp index de9bb6ab24..60544f64c8 100644 --- a/Core/Code/Testing/mitkAccessByItkTest.cpp +++ b/Core/Code/Testing/mitkAccessByItkTest.cpp @@ -1,367 +1,399 @@ /*========================================================================= Program: Medical Imaging & Interaction Toolkit Language: C++ Date: $Date$ Version: $Revision: 17495 $ Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. See MITKCopyright.txt or http://www.mitk.org/copyright.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ #include #include "mitkTestingMacros.h" #include #include #define TestImageType(type, dim) \ MITK_TEST_CONDITION(typeid(type) == typeid(TPixel) && dim == VDimension, "Checking for correct type itk::Image<" #type "," #dim ">") class AccessByItkTest { public: typedef AccessByItkTest Self; typedef itk::Image IntImage2D; typedef itk::Image IntImage3D; typedef itk::Image FloatImage2D; typedef itk::Image FloatImage3D; enum EImageType { Unknown = 0, Int2D, Int3D, Float2D, Float3D }; void testAccessByItk() { mitk::Image::Pointer mitkIntImage2D = createMitkImage(); mitk::Image::ConstPointer mitkIntImage3D(createMitkImage()); mitk::Image::ConstPointer mitkFloatImage2D(createMitkImage()); mitk::Image::Pointer mitkFloatImage3D = createMitkImage(); AccessByItk(mitkIntImage2D, AccessItkImage); AccessByItk(mitkIntImage3D, AccessItkImage); AccessByItk(mitkFloatImage2D, AccessItkImage); AccessByItk(mitkFloatImage3D, AccessItkImage); AccessByItk_1(mitkIntImage2D, AccessItkImage, Int2D); AccessByItk_1(mitkIntImage3D, AccessItkImage, Int3D); AccessByItk_1(mitkFloatImage2D, AccessItkImage, Float2D); AccessByItk_1(mitkFloatImage3D, AccessItkImage, Float3D); AccessByItk_2(mitkIntImage2D, AccessItkImage, Int2D, 2); AccessByItk_2(mitkIntImage3D, AccessItkImage, Int3D, 2); AccessByItk_2(mitkFloatImage2D, AccessItkImage, Float2D, 2); AccessByItk_2(mitkFloatImage3D, AccessItkImage, Float3D, 2); AccessByItk_3(mitkIntImage2D, AccessItkImage, Int2D, 2, 3); AccessByItk_3(mitkIntImage3D, AccessItkImage, Int3D, 2, 3); AccessByItk_3(mitkFloatImage2D, AccessItkImage, Float2D, 2, 3); AccessByItk_3(mitkFloatImage3D, AccessItkImage, Float3D, 2, 3); } void testAccessFixedDimensionByItk() { mitk::Image::Pointer mitkIntImage2D = createMitkImage(); mitk::Image::ConstPointer mitkIntImage3D(createMitkImage()); mitk::Image::ConstPointer mitkFloatImage2D(createMitkImage()); mitk::Image::Pointer mitkFloatImage3D = createMitkImage(); AccessFixedDimensionByItk(mitkIntImage2D, AccessItkImage, 2); AccessFixedDimensionByItk(mitkIntImage3D, AccessItkImage, 3); AccessFixedDimensionByItk(mitkFloatImage2D, AccessItkImage, 2); AccessFixedDimensionByItk(mitkFloatImage3D, AccessItkImage, 3); AccessFixedDimensionByItk_1(mitkIntImage2D, AccessItkImage, 2, Int2D); AccessFixedDimensionByItk_1(mitkIntImage3D, AccessItkImage, 3, Int3D); AccessFixedDimensionByItk_1(mitkFloatImage2D, AccessItkImage, 2, Float2D); AccessFixedDimensionByItk_1(mitkFloatImage3D, AccessItkImage, 3, Float3D); AccessFixedDimensionByItk_2(mitkIntImage2D, AccessItkImage, 2, Int2D, 2); AccessFixedDimensionByItk_2(mitkIntImage3D, AccessItkImage, 3, Int3D, 2); AccessFixedDimensionByItk_2(mitkFloatImage2D, AccessItkImage, 2, Float2D, 2); AccessFixedDimensionByItk_2(mitkFloatImage3D, AccessItkImage, 3, Float3D, 2); AccessFixedDimensionByItk_3(mitkIntImage2D, AccessItkImage, 2, Int2D, 2, 3); AccessFixedDimensionByItk_3(mitkIntImage3D, AccessItkImage, 3, Int3D, 2, 3); AccessFixedDimensionByItk_3(mitkFloatImage2D, AccessItkImage, 2, Float2D, 2, 3); AccessFixedDimensionByItk_3(mitkFloatImage3D, AccessItkImage, 3, Float3D, 2, 3); // Test for wrong dimension MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedDimensionByItk(mitkFloatImage3D, AccessItkImage, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedDimensionByItk_1(mitkFloatImage3D, AccessItkImage, 2, Float3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedDimensionByItk_2(mitkFloatImage3D, AccessItkImage, 2, Float3D, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedDimensionByItk_3(mitkFloatImage3D, AccessItkImage, 2, Float3D, 2, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) } void testAccessFixedPixelTypeByItk() { mitk::Image::Pointer mitkIntImage2D = createMitkImage(); mitk::Image::ConstPointer mitkIntImage3D(createMitkImage()); mitk::Image::ConstPointer mitkFloatImage2D(createMitkImage()); mitk::Image::Pointer mitkFloatImage3D = createMitkImage(); AccessFixedPixelTypeByItk(mitkIntImage2D, AccessItkImage, int); AccessFixedPixelTypeByItk(mitkIntImage3D, AccessItkImage, int); AccessFixedPixelTypeByItk(mitkFloatImage2D, AccessItkImage, float); AccessFixedPixelTypeByItk(mitkFloatImage3D, AccessItkImage, float); AccessFixedPixelTypeByItk_1(mitkIntImage2D, AccessItkImage, int, Int2D); AccessFixedPixelTypeByItk_1(mitkIntImage3D, AccessItkImage, int, Int3D); AccessFixedPixelTypeByItk_1(mitkFloatImage2D, AccessItkImage, float, Float2D); AccessFixedPixelTypeByItk_1(mitkFloatImage3D, AccessItkImage, float, Float3D); AccessFixedPixelTypeByItk_2(mitkIntImage2D, AccessItkImage, int, Int2D, 2); AccessFixedPixelTypeByItk_2(mitkIntImage3D, AccessItkImage, int, Int3D, 2); AccessFixedPixelTypeByItk_2(mitkFloatImage2D, AccessItkImage, float, Float2D, 2); AccessFixedPixelTypeByItk_2(mitkFloatImage3D, AccessItkImage, float, Float3D, 2); AccessFixedPixelTypeByItk_3(mitkIntImage2D, AccessItkImage, int, Int2D, 2, 3); AccessFixedPixelTypeByItk_3(mitkIntImage3D, AccessItkImage, int, Int3D, 2, 3); AccessFixedPixelTypeByItk_3(mitkFloatImage2D, AccessItkImage, float, Float2D, 2, 3); AccessFixedPixelTypeByItk_3(mitkFloatImage3D, AccessItkImage, float, Float3D, 2, 3); // Test for wrong dimension MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedPixelTypeByItk(mitkFloatImage3D, AccessItkImage, int); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedPixelTypeByItk_1(mitkFloatImage3D, AccessItkImage, int, Float3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedPixelTypeByItk_2(mitkFloatImage3D, AccessItkImage, int, Float3D, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedPixelTypeByItk_3(mitkFloatImage3D, AccessItkImage, int, Float3D, 2, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) } void testAccessFixedTypeByItk() { mitk::Image::Pointer mitkIntImage2D = createMitkImage(); mitk::Image::ConstPointer mitkIntImage3D(createMitkImage()); mitk::Image::ConstPointer mitkFloatImage2D(createMitkImage()); mitk::Image::Pointer mitkFloatImage3D = createMitkImage(); AccessFixedTypeByItk(mitkIntImage2D, AccessItkImage, int, 2); AccessFixedTypeByItk(mitkIntImage3D, AccessItkImage, int, 3); AccessFixedTypeByItk(mitkFloatImage2D, AccessItkImage, float, 2); AccessFixedTypeByItk(mitkFloatImage3D, AccessItkImage, float, 3); AccessFixedTypeByItk_1(mitkIntImage2D, AccessItkImage, int, 2, Int2D); AccessFixedTypeByItk_1(mitkIntImage3D, AccessItkImage, int, 3, Int3D); AccessFixedTypeByItk_1(mitkFloatImage2D, AccessItkImage, float, 2, Float2D); AccessFixedTypeByItk_1(mitkFloatImage3D, AccessItkImage, float, 3, Float3D); AccessFixedTypeByItk_2(mitkIntImage2D, AccessItkImage, int, 2, Int2D, 2); AccessFixedTypeByItk_2(mitkIntImage3D, AccessItkImage, int, 3, Int3D, 2); AccessFixedTypeByItk_2(mitkFloatImage2D, AccessItkImage, float, 2, Float2D, 2); AccessFixedTypeByItk_2(mitkFloatImage3D, AccessItkImage, float, 3, Float3D, 2); AccessFixedTypeByItk_3(mitkIntImage2D, AccessItkImage, int, 2, Int2D, 2, 3); AccessFixedTypeByItk_3(mitkIntImage3D, AccessItkImage, int, 3, Int3D, 2, 3); AccessFixedTypeByItk_3(mitkFloatImage2D, AccessItkImage, float, 2, Float2D, 2, 3); AccessFixedTypeByItk_3(mitkFloatImage3D, AccessItkImage, float, 3, Float3D, 2, 3); // Test for wrong dimension MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk(mitkFloatImage3D, AccessItkImage, float, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk_1(mitkFloatImage3D, AccessItkImage, float, 2, Float3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk_2(mitkFloatImage3D, AccessItkImage, float, 2, Float3D, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk_3(mitkFloatImage3D, AccessItkImage, float, 2, Float3D, 2, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) // Test for wrong type MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk(mitkFloatImage3D, AccessItkImage, int, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk_1(mitkFloatImage3D, AccessItkImage, int, 3, Float3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk_2(mitkFloatImage3D, AccessItkImage, int, 3, Float3D, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) AccessFixedTypeByItk_3(mitkFloatImage3D, AccessItkImage, int, 3, Float3D, 2, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) } + void testAccessDefaultPixelTypesByItk() + { + mitk::Image::Pointer mitkIntImage2D = createMitkImage(); + mitk::Image::ConstPointer mitkIntImage3D(createMitkImage()); + mitk::Image::ConstPointer mitkFloatImage2D(createMitkImage()); + mitk::Image::Pointer mitkFloatImage3D = createMitkImage(); + + AccessDefaultPixelTypesByItk(mitkIntImage2D); + AccessDefaultPixelTypesByItk(mitkIntImage3D); + AccessDefaultPixelTypesByItk(mitkFloatImage2D); + AccessDefaultPixelTypesByItk(mitkFloatImage3D); + + AccessDefaultPixelTypesByItk_1(mitkIntImage2D, EImageType, Int2D); + AccessDefaultPixelTypesByItk_1(mitkIntImage3D, EImageType, Int3D); + AccessDefaultPixelTypesByItk_1(mitkFloatImage2D, EImageType, Float2D); + AccessDefaultPixelTypesByItk_1(mitkFloatImage3D, EImageType, Float3D); + + AccessDefaultPixelTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2); + AccessDefaultPixelTypesByItk_2(mitkIntImage3D, EImageType, Int3D, int, 2); + AccessDefaultPixelTypesByItk_2(mitkFloatImage2D, EImageType, Float2D, int, 2); + AccessDefaultPixelTypesByItk_2(mitkFloatImage3D, EImageType, Float3D, int, 2); + + AccessDefaultPixelTypesByItk_3(mitkIntImage2D, EImageType, Int2D, int, 2, int, 3); + AccessDefaultPixelTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3); + AccessDefaultPixelTypesByItk_3(mitkFloatImage2D, EImageType, Float2D, int, 2, int, 3); + AccessDefaultPixelTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3); + } + void testAccessSpecificPixelTypesByItk() { mitk::Image::Pointer mitkIntImage2D = createMitkImage(); mitk::Image::ConstPointer mitkIntImage3D(createMitkImage()); mitk::Image::ConstPointer mitkFloatImage2D(createMitkImage()); mitk::Image::Pointer mitkFloatImage3D = createMitkImage(); - AccessIntegralTypesByItk(mitkIntImage2D); - AccessIntegralTypesByItk(mitkIntImage3D); - AccessIntegralTypesByItk_1(mitkIntImage2D, EImageType, Int2D); - AccessIntegralTypesByItk_1(mitkIntImage3D, EImageType, Int3D); - AccessIntegralTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2); - AccessIntegralTypesByItk_2(mitkIntImage3D, EImageType, Int3D, int, 2); - AccessIntegralTypesByItk_3(mitkIntImage2D, EImageType, Int2D, int, 2, int, 3); - AccessIntegralTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3); - - AccessFloatingTypesByItk(mitkFloatImage2D); - AccessFloatingTypesByItk(mitkFloatImage3D); - AccessFloatingTypesByItk_1(mitkFloatImage2D, EImageType, Float2D); - AccessFloatingTypesByItk_1(mitkFloatImage3D, EImageType, Float3D); - AccessFloatingTypesByItk_2(mitkFloatImage2D, EImageType, Float2D, int, 2); - AccessFloatingTypesByItk_2(mitkFloatImage3D, EImageType, Float3D, int, 2); - AccessFloatingTypesByItk_3(mitkFloatImage2D, EImageType, Float2D, int, 2, int, 3); - AccessFloatingTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3); - - AccessSpecificTypesByItk(mitkIntImage2D, short, unsigned int, float, int, char); - AccessSpecificTypesByItk(mitkIntImage3D, short, unsigned int, float, int, char); - AccessSpecificTypesByItk_1(mitkIntImage2D, EImageType, Int2D, short, unsigned int, float, int, char); - AccessSpecificTypesByItk_1(mitkFloatImage3D, EImageType, Float3D, short, unsigned int, float, int, char); - AccessSpecificTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2, short, unsigned int, float, int, char); - AccessSpecificTypesByItk_2(mitkFloatImage3D, EImageType, Float3D, int, 2, short, unsigned int, float, int, char); - AccessSpecificTypesByItk_3(mitkIntImage2D, EImageType, Int2D, int, 2, int, 3, short, unsigned int, float, int, char); - AccessSpecificTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3, short, unsigned int, float, int, char); + AccessIntegralPixelTypesByItk(mitkIntImage2D); + AccessIntegralPixelTypesByItk(mitkIntImage3D); + AccessIntegralPixelTypesByItk_1(mitkIntImage2D, EImageType, Int2D); + AccessIntegralPixelTypesByItk_1(mitkIntImage3D, EImageType, Int3D); + AccessIntegralPixelTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2); + AccessIntegralPixelTypesByItk_2(mitkIntImage3D, EImageType, Int3D, int, 2); + AccessIntegralPixelTypesByItk_3(mitkIntImage2D, EImageType, Int2D, int, 2, int, 3); + AccessIntegralPixelTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3); + + AccessFloatingPixelTypesByItk(mitkFloatImage2D); + AccessFloatingPixelTypesByItk(mitkFloatImage3D); + AccessFloatingPixelTypesByItk_1(mitkFloatImage2D, EImageType, Float2D); + AccessFloatingPixelTypesByItk_1(mitkFloatImage3D, EImageType, Float3D); + AccessFloatingPixelTypesByItk_2(mitkFloatImage2D, EImageType, Float2D, int, 2); + AccessFloatingPixelTypesByItk_2(mitkFloatImage3D, EImageType, Float3D, int, 2); + AccessFloatingPixelTypesByItk_3(mitkFloatImage2D, EImageType, Float2D, int, 2, int, 3); + AccessFloatingPixelTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3); + + AccessSpecificPixelTypesByItk(mitkIntImage2D, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk(mitkIntImage3D, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk_1(mitkIntImage2D, EImageType, Int2D, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk_1(mitkFloatImage3D, EImageType, Float3D, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk_2(mitkFloatImage3D, EImageType, Float3D, int, 2, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk_3(mitkIntImage2D, EImageType, Int2D, int, 2, int, 3, short, unsigned int, float, int, char); + AccessSpecificPixelTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3, short, unsigned int, float, int, char); MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessIntegralTypesByItk(mitkFloatImage3D); + AccessIntegralPixelTypesByItk(mitkFloatImage3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessIntegralTypesByItk_1(mitkFloatImage3D, EImageType, Float3D); + AccessIntegralPixelTypesByItk_1(mitkFloatImage3D, EImageType, Float3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessIntegralTypesByItk_2(mitkFloatImage2D, EImageType, Float2D, int, 2); + AccessIntegralPixelTypesByItk_2(mitkFloatImage2D, EImageType, Float2D, int, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessIntegralTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3); + AccessIntegralPixelTypesByItk_3(mitkFloatImage3D, EImageType, Float3D, int, 2, int, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessFloatingTypesByItk(mitkIntImage3D); + AccessFloatingPixelTypesByItk(mitkIntImage3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessFloatingTypesByItk_1(mitkIntImage3D, EImageType, Int3D); + AccessFloatingPixelTypesByItk_1(mitkIntImage3D, EImageType, Int3D); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessFloatingTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2); + AccessFloatingPixelTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessFloatingTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3); + AccessFloatingPixelTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessSpecificTypesByItk(mitkIntImage3D, float, double, short); + AccessSpecificPixelTypesByItk(mitkIntImage3D, float, double, short); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessSpecificTypesByItk_1(mitkIntImage3D, EImageType, Int3D, float, double, short); + AccessSpecificPixelTypesByItk_1(mitkIntImage3D, EImageType, Int3D, float, double, short); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessSpecificTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2, float, double, short); + AccessSpecificPixelTypesByItk_2(mitkIntImage2D, EImageType, Int2D, int, 2, float, double, short); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) MITK_TEST_FOR_EXCEPTION_BEGIN(const mitk::AccessByItkException&) - AccessSpecificTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3, float, double, short); + AccessSpecificPixelTypesByItk_3(mitkIntImage3D, EImageType, Int3D, int, 2, int, 3, float, double, short); MITK_TEST_FOR_EXCEPTION_END(const mitk::AccessByItkException&) } template - void AccessItkImage(itk::Image* itkImage, + void AccessItkImage(itk::Image*, EImageType param1 = Unknown, int param2 = 0, int param3 = 0) { switch (param1) { case Int2D: TestImageType(int , 2) break; case Int3D: TestImageType(int, 3) break; case Float2D: TestImageType(float, 2) break; case Float3D: TestImageType(float, 3) break; + default: break; } if (param2) { MITK_TEST_CONDITION(param2 == 2, "Checking for correct second parameter") } if (param3) { MITK_TEST_CONDITION(param3 == 3, "Checking for correct third parameter") } } private: template mitk::Image::Pointer createMitkImage() { typename ImageType::Pointer itkImage = ImageType::New(); typename ImageType::IndexType start; start.Fill(0); typename ImageType::SizeType size; size.Fill(3); typename ImageType::RegionType region; region.SetSize(size); region.SetIndex(start); itkImage->SetRegions(region); itkImage->Allocate(); return mitk::GrabItkImageMemory(itkImage); } }; int mitkAccessByItkTest(int /*argc*/, char* /*argv*/[]) { - // MITK_TEST_BEGIN("AccessByItk") + MITK_TEST_BEGIN("AccessByItk") AccessByItkTest accessTest; MITK_TEST_OUTPUT(<< "Testing AccessByItk macro") accessTest.testAccessByItk(); + MITK_TEST_OUTPUT(<< "Testing AccessDefaultPixelTypesByItk macro") + accessTest.testAccessDefaultPixelTypesByItk(); + MITK_TEST_OUTPUT(<< "Testing AccessFixedDimensionByItk macro") accessTest.testAccessFixedDimensionByItk(); MITK_TEST_OUTPUT(<< "Testing AccessFixedTypeByItk macro") accessTest.testAccessFixedTypeByItk(); MITK_TEST_OUTPUT(<< "Testing AccessFixedPixelTypeByItk macro") accessTest.testAccessFixedPixelTypeByItk(); MITK_TEST_OUTPUT(<< "Testing AccessSpecificPixelTypesByItk macro") accessTest.testAccessSpecificPixelTypesByItk(); -// MITK_TEST_END() + MITK_TEST_END() return 0; } diff --git a/mitkConfig.h.in b/mitkConfig.h.in index 8ca3344777..be7b051fa1 100644 --- a/mitkConfig.h.in +++ b/mitkConfig.h.in @@ -1,20 +1,22 @@ /* mitkConfig.h this file is generated. Do not change! */ #define MITK_ROOT "${PROJECT_SOURCE_DIR}/" #cmakedefine MITK_BUILD_SHARED_CORE #cmakedefine USE_ITKZLIB #cmakedefine MITK_CHILI_PLUGIN #cmakedefine MITK_USE_TD_MOUSE +#define MITK_ACCESSBYITK_PIXEL_TYPES @MITK_ACCESSBYITK_PIXEL_TYPES@ + #define MITK_CHILI_PLUGIN_SDK_IPPIC_H "@MITK_CHILI_PLUGIN_SDK_IPPIC_H@" #define MITK_CHILI_PLUGIN_SDK_IPTYPES_H "@MITK_CHILI_PLUGIN_SDK_IPTYPES_H@" #define MITK_DOXYGEN_OUTPUT_DIR "@MITK_DOXYGEN_OUTPUT_DIR@" #define MITK_HELPPAGES_OUTPUT_DIR "@MITK_HELPPAGES_OUTPUT_DIR@" #define MITK_VERSION_MAJOR @MITK_VERSION_MAJOR@ #define MITK_VERSION_MINOR @MITK_VERSION_MINOR@ #define MITK_VERSION_PATCH @MITK_VERSION_PATCH@ #define MITK_VERSION_STRING "@MITK_VERSION_STRING@"