diff --git a/CMakeLists.txt b/CMakeLists.txt index 706b879..f792e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,306 +1,310 @@ #----------------------------------------------------------------------------- # This is the root RTToolbox CMakeList file. #----------------------------------------------------------------------------- PROJECT(RTToolbox) CMAKE_MINIMUM_REQUIRED(VERSION 3.1) # RTToolbox version number. SET(RTToolbox_VERSION_MAJOR "5") SET(RTToolbox_VERSION_MINOR "1") SET(RTToolbox_VERSION_PATCH "0") # Version string should not include patch level. The major.minor is # enough to distinguish available features of the toolbox. SET(RTToolbox_VERSION_STRING "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}") SET(RTToolbox_FULL_VERSION_STRING "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}.${RTToolbox_VERSION_PATCH}") SET(RTToolbox_PREFIX "RTTB") # default build type SET(CMAKE_BUILD_TYPE Release) MARK_AS_ADVANCED(BUILD_SHARED_LIBS) IF (WIN32) IF (MSVC_VERSION LESS 1800) MESSAGE(FATAL_ERROR "RTToolbox requires at least Visual Studio 2013.") ELSEIF (MSVC_VERSION GREATER_EQUAL 1910) IF (${CMAKE_VERSION} VERSION_LESS "3.10.3") MESSAGE(AUTHOR_WARNING "Please use CMake version 3.10.3 or newer for Visual Studio 2017 as new boost versions are not recognized using old CMake versions.") ENDIF() ENDIF() add_definitions(-D_SCL_SECURE_NO_WARNINGS) ELSE (WIN32) IF (CMAKE_COMPILER_IS_GNUCC) IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.3) MESSAGE(AUTHOR_WARNING "RTToolbox was tested with GCC 5 and GCC 7 only. You are using GCC " ${CMAKE_CXX_COMPILER_VERSION} ". You might need to change some code in order to compile RT Toolbox.") ENDIF() ELSE() MESSAGE(AUTHOR_WARNING "RTToolbox was only tested with GCC. This compiler might not work.") ENDIF() ENDIF(WIN32) #----------------------------------------------------------------------------- # CMake Function(s) and Macro(s) #----------------------------------------------------------------------------- include(cmake/MacroParseArguments.cmake) include(cmake/rttbMacroCreateModuleConf.cmake) include(cmake/rttbMacroCreateModule.cmake) include(cmake/rttbMacroCreateApplication.cmake) include(cmake/rttbMacroCheckModule.cmake) include(cmake/rttbMacroUseModule.cmake) include(cmake/rttbMacroCreateTestModule.cmake) include(cmake/rttbFunctionOrganizeSources.cmake) include(cmake/rttbMacroCreateApplicationTests.cmake) #----------------------------------------------------------------------------- # Basis config RTTB module infrastructure #----------------------------------------------------------------------------- set(RTTB_MODULES_CONF_DIR ${RTToolbox_BINARY_DIR}/modulesConf CACHE INTERNAL "Modules Conf") set(RTTB_MODULES_PACKAGE_DEPENDS_DIR ${RTToolbox_SOURCE_DIR}/cmake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${RTTB_MODULES_PACKAGE_DEPENDS_DIR}) #----------------------------------------------------------------------------- # Testing setup # Configure Dart testing support. This should be done before any # MESSAGE(FATAL_ERROR ...) commands are invoked. #----------------------------------------------------------------------------- #build no tests as default OPTION(BUILD_TESTING "build tests" OFF) IF(BUILD_TESTING) SET(CTEST_NEW_FORMAT 1) INCLUDE(CTest) ENABLE_TESTING() CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/RemoveTemporaryFiles.cmake.in ${RTToolbox_BINARY_DIR}/cmake/RemoveTemporaryFiles.cmake @ONLY IMMEDIATE) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/rttbSampleBuildTest.cmake.in ${RTToolbox_BINARY_DIR}/cmake/rttbSampleBuildTest.cmake @ONLY) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/CTestCustom.ctest.in ${RTToolbox_BINARY_DIR}/cmake/CTestCustom.ctest @ONLY) FILE(WRITE ${RTToolbox_BINARY_DIR}/CTestCustom.cmake "INCLUDE(\"${RTToolbox_BINARY_DIR}/cmake/CTestCustom.ctest\")\n") SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard") MARK_AS_ADVANCED(BUILDNAME) ENDIF(BUILD_TESTING) #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- IF(NOT LIBRARY_OUTPUT_PATH) SET (LIBRARY_OUTPUT_PATH ${RTToolbox_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.") ENDIF(NOT LIBRARY_OUTPUT_PATH) IF(NOT EXECUTABLE_OUTPUT_PATH) SET (EXECUTABLE_OUTPUT_PATH ${RTToolbox_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.") ENDIF(NOT EXECUTABLE_OUTPUT_PATH) MARK_AS_ADVANCED(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH) SET(RTToolbox_LIBRARY_PATH "${LIBRARY_OUTPUT_PATH}") SET(RTToolbox_EXECUTABLE_PATH "${EXECUTABLE_OUTPUT_PATH}") #----------------------------------------------------------------------------- # Find Doxygen. #----------------------------------------------------------------------------- FIND_PROGRAM(DOXYGEN_EXECUTABLE "doxygen") #----------------------------------------------------------------------------- # Installation vars. # RTToolbox_INSTALL_BIN_DIR - binary dir (executables) # RTToolbox_INSTALL_LIB_DIR - library dir (libs) # RTToolbox_INSTALL_INCLUDE_DIR - include dir (headers) # RTToolbox_INSTALL_NO_DEVELOPMENT - do not install development files # RTToolbox_INSTALL_NO_RUNTIME - do not install runtime files # RTToolbox_INSTALL_NO_DOCUMENTATION - do not install documentation files #----------------------------------------------------------------------------- IF(NOT RTTOOLBOX_INSTALL_BIN_DIR) SET(RTTOOLBOX_INSTALL_BIN_DIR "bin") ENDIF(NOT RTTOOLBOX_INSTALL_BIN_DIR) IF(NOT RTTOOLBOX_INSTALL_LIB_DIR) SET(RTTOOLBOX_INSTALL_LIB_DIR "lib") ENDIF(NOT RTTOOLBOX_INSTALL_LIB_DIR) IF(NOT RTTOOLBOX_INSTALL_PACKAGE_DIR) SET(RTTOOLBOX_INSTALL_PACKAGE_DIR "lib") ENDIF(NOT RTTOOLBOX_INSTALL_PACKAGE_DIR) IF(NOT RTTOOLBOX_INSTALL_INCLUDE_DIR) SET(RTTOOLBOX_INSTALL_INCLUDE_DIR "include") ENDIF(NOT RTTOOLBOX_INSTALL_INCLUDE_DIR) IF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) SET(RTTOOLBOX_INSTALL_NO_DEVELOPMENT 0) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) IF(NOT RTTOOLBOX_INSTALL_NO_RUNTIME) SET(RTTOOLBOX_INSTALL_NO_RUNTIME 0) ENDIF(NOT RTTOOLBOX_INSTALL_NO_RUNTIME) IF(NOT RTTOOLBOX_INSTALL_NO_DOCUMENTATION) SET(RTTOOLBOX_INSTALL_NO_DOCUMENTATION 0) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DOCUMENTATION) SET(RTTOOLBOX_INSTALL_NO_LIBRARIES) IF(RTTOOLBOX_BUILD_SHARED_LIBS) IF(RTTOOLBOX_INSTALL_NO_RUNTIME AND RTTOOLBOX_INSTALL_NO_DEVELOPMENT) SET(RTTOOLBOX_INSTALL_NO_LIBRARIES 1) ENDIF(RTTOOLBOX_INSTALL_NO_RUNTIME AND RTTOOLBOX_INSTALL_NO_DEVELOPMENT) ELSE(RTTOOLBOX_BUILD_SHARED_LIBS) IF(RTTOOLBOX_INSTALL_NO_DEVELOPMENT) SET(RTTOOLBOX_INSTALL_NO_LIBRARIES 1) ENDIF(RTTOOLBOX_INSTALL_NO_DEVELOPMENT) ENDIF(RTTOOLBOX_BUILD_SHARED_LIBS) # set RTToolbox_DIR so it can be used by subprojects SET(RTToolbox_DIR "${CMAKE_BINARY_DIR}" CACHE INTERNAL "RTToolbox dir to be used by subprojects") #----------------------------------------------------------------------------- # DCMTK MT-Flag treat #----------------------------------------------------------------------------- option(RTTB_DCMTK_COMPLIANCE_ENFORCE_MT "This enforces the whole RTToolbox to be compiled with /MT,/MTd to be compliant with DCMTK" OFF) string(FIND ${CMAKE_GENERATOR} "Visual Studio" RTTB_VS_USED) if(RTTB_DCMTK_COMPLIANCE_ENFORCE_MT AND RTTB_VS_USED EQUAL 0) message(STATUS "Enforce DCMTK compliance: /MT and /MTd flags are used") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) message(STATUS "CMAKE_C_FLAGS_DEBUG set to: ${CMAKE_C_FLAGS_DEBUG}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) message(STATUS "CMAKE_C_FLAGS_RELEASE set to: ${CMAKE_C_FLAGS_RELEASE}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL}) message(STATUS "CMAKE_C_FLAGS_MINSIZEREL set to: ${CMAKE_C_FLAGS_MINSIZEREL}") string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) message(STATUS "CMAKE_C_FLAGS_RELWITHDEBINFO set to: ${CMAKE_C_FLAGS_RELWITHDEBINFO}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) message(STATUS "CMAKE_CXX_FLAGS_DEBUG set to: ${CMAKE_CXX_FLAGS_DEBUG}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE}) message(STATUS "CMAKE_CXX_FLAGS_RELEASE set to: ${CMAKE_CXX_FLAGS_RELEASE}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL}) message(STATUS "CMAKE_CXX_FLAGS_MINSIZEREL set to: ${CMAKE_CXX_FLAGS_MINSIZEREL}") string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO set to: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") endif() #----------------------------------------------------------------------------- # Advanced RTToolbox configuration #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # RTToolbox build configuration options. IF (NOT RTTB_CXX_STANDARD) set(RTTB_CXX_STANDARD 11) ENDIF (NOT RTTB_CXX_STANDARD) set(CMAKE_CXX_STANDARD ${RTTB_CXX_STANDARD} CACHE STRING "") set(CMAKE_CXX_STANDARD_REQUIRED 1) OPTION(CMAKE_CXX_EXTENSIONS "" ON) MARK_AS_ADVANCED(CMAKE_CXX_STANDARD CMAKE_CXX_STANDARD_REQUIRED CMAKE_CXX_EXTENSIONS) IF (WIN32) OPTION(BUILD_SHARED_LIBS "Build RTToolbox with shared libraries." OFF) ELSE (WIN32) OPTION(BUILD_SHARED_LIBS "Build RTToolbox with shared libraries." ON) ENDIF (WIN32) IF(NOT BUILD_SHARED_LIBS) IF(UNIX) MESSAGE(FATAL_ERROR "RTToolbox currently does not support a static build on unix like systems. We are working on that...") ENDIF(UNIX) ENDIF(NOT BUILD_SHARED_LIBS) SET(RTTB_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) #Raise warning level (MSVC has W3 default warning level) IF (WIN32) IF(NOT BUILD_SHARED_LIBS) set(CMAKE_CXX_FLAGS "/W4 /EHsc") ENDIF() ELSE() IF (CMAKE_COMPILER_IS_GNUCC) set(CMAKE_CXX_FLAGS "-Wall") ENDIF() ENDIF() IF(NOT RTToolbox_NO_LIBRARY_VERSION) # This setting of SOVERSION assumes that any API change # will increment either the minor or major version number of RTToolbox. SET(RTToolbox_LIBRARY_PROPERTIES VERSION "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}.${RTToolbox_VERSION_PATCH}" SOVERSION "${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}" ) ENDIF(NOT RTToolbox_NO_LIBRARY_VERSION) #----------------------------------------------------------------------------- # Configure files with settings for use by the build. # #----------------------------------------------------------------------------- CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/RTToolboxConfigure.h.in ${RTToolbox_BINARY_DIR}/RTToolboxConfigure.h) IF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${RTToolbox_BINARY_DIR}/RTToolboxConfigure.h DESTINATION ${RTTOOLBOX_INSTALL_INCLUDE_DIR} COMPONENT Development) ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) #----------------------------------------------------------------------------- # The entire RTToolbox tree should use the same include path #----------------------------------------------------------------------------- #Default include dir. Others dirs will be defined by activated subprojects INCLUDE_DIRECTORIES(${RTToolbox_BINARY_DIR}) LINK_DIRECTORIES(${LIBARY_OUTPUT_PATH}) #Prepare the correct target information export by the subprojects SET(RTToolbox_TARGETS_FILE "${RTToolbox_BINARY_DIR}/RTToolboxTargets.cmake") FILE(WRITE ${RTToolbox_TARGETS_FILE} "# Generated by CMake, do not edit!") #----------------------------------------------------------------------------- # Dispatch the build into the proper subdirectories. #----------------------------------------------------------------------------- OPTION(BUILD_All_Modules "All modules will be built" OFF) OPTION(BUILD_Apps "Determine if the CLI applications will be generated." OFF) MESSAGE (STATUS "generating Project RTToolbox") ADD_SUBDIRECTORY (code) IF (BUILD_Apps) ADD_SUBDIRECTORY (apps) ENDIF() +IF (BUILD_All_Modules OR BUILD_IO_ITK) + OPTION(RTTB_ITK5_SUPPORT "Determine if ITK v5 should be supported." OFF) +ENDIF() + IF (BUILD_TESTING) ADD_SUBDIRECTORY (testing) ENDIF (BUILD_TESTING) ADD_SUBDIRECTORY (documentation) #----------------------------------------------------------------------------- # Help other projects use RTToolbox. #----------------------------------------------------------------------------- EXPORT(PACKAGE RTToolbox) # Create the RTToolboxConfig.cmake file containing the RTToolbox configuration. INCLUDE (${RTToolbox_SOURCE_DIR}/rttbGenerateRTToolboxConfig.cmake) IF(NOT RTToolbox_INSTALL_NO_DEVELOPMENT) INSTALL(FILES ${RTToolbox_BINARY_DIR}/RTToolboxConfig.cmake DESTINATION ${RTTOOLBOX_INSTALL_PACKAGE_DIR} COMPONENT Development ) ENDIF(NOT RTToolbox_INSTALL_NO_DEVELOPMENT) diff --git a/README.md b/README.md index 49e0999..156074b 100644 --- a/README.md +++ b/README.md @@ -1,269 +1,272 @@ # RTToolbox RTToolbox is a software library to support quantitative analysis of treatment outcome for radiotherapy. The RTToolbox was designed following object-oriented design (OOD) principles and was implemented in the language C++. Features include: * import of radiotherapy data (e.g. dose distributions and structure sets) from DICOM-RT format and other standard image processing formats * DVH calculation * Dose statistic calculation * arithmetic operations on dose distributions * structure relationship analyses (e.g. fully-contained, partially-contained) * Calculation of dose comparison indices such as Conformity Index (CI), Homogeneity Index (HI) and Conformation Number (CN) * Calculation of biological models including TCP, NTCP, EUD and BED Also, the RTToolbox provides apps e.g. for DVH/Dose Statistic calculation or Dose accumulation that provides a convenient access of RT scenarios without computer-science knowledge. ## Getting Started These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. ### Prerequisites #### Build system * [CMake](https://cmake.org), version 3.1 or higher #### Compiler * Visual Studio 2013 * Visual Studio 2015 * Visual Studio 2017 * GCC 5.4 * GCC 7.3 Other compilers may work as well, but are not tested. #### Linking Static/Dynamic library support Can be changed with advanced option `BUILD_SHARED_LIBS` :warning: building RTToolbox as dynamic library under Windows and as static library under Linux is an experimental feature. #### Third party libraries * [boost](http://www.boost.org ), version 1.64.0 or higher * [DCMTK](http://dicom.offis.de/dcmtk.php.en ), with RT support - 3.6.1_20121102 or newer * [ITK](https://itk.org ), version 4.4 or higher (*optional*) * for DoseInterpolation support with ITK transformation or ITK File IO support * [MatchPoint](http://mitk.org/download/thirdparty/MatchPoint_rev1610.tar.gz ), version 0.12 or higher (*optional*) * for DoseInterpolation support with MatchPoint registration objects :information_source: To make sure everything runs smoothly, please make sure that all libraries and the RTToolbox are either compiled with `/MD` or `/MT` flags. ##### Boost In case you work with Windows, we recommend using the [pre-build versions of boost](https://sourceforge.net/projects/boost/files/boost-binaries/). If you want to build the library yourself, consider the following: Build (using the same compiler options as RTToolbox, usually `STATIC LINKING` and `x64` architecture). The following components are needed: * `filesystem`, * `system`, * `thread` and * `program_options` * if you plan to build the apps (*optional*) :information_source: eventually, it might be needed to add the CMake variable `BOOST_LIBRARYDIR` and set it to the respective library path of boost. For Windows: To build Boost open a command prompt, change to your boost source directory and copy following command(s): Debug: `b2 -j12 --with-filesystem --with-system --with-thread --with-program_options --with-date_time --with-atomic --with-chrono toolset=msvc-14.1 address-model=64 variant=debug threading=multi link=shared define=_BIND_TO_CURRENT_VCLIBS_VERSION` Release: `b2 -j12 --with-filesystem --with-system --with-thread --with-program_options --with-date_time --with-atomic --with-chrono toolset=msvc-14.1 address-model=64 variant=release threading=multi link=shared` If you don´t require `program_options` delete `--with-program_options` from the command before executing it. ##### DCMTK For Windows: To compile DCMTK with `/MD` flags (standard for all other libs), you need to patch the CMAKE options of DCMTK (`PathToDCMTK\CMake\dcmtkPrepare.cmake`), either by replacing `"/MT"` with `"/MD"` or by explicitly replacing lines 135 to 171 with the following lines: ``` IF(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS AND NOT BUILD_SHARED_LIBS) # settings for Microsoft Visual Studio IF(CMAKE_GENERATOR MATCHES "Visual Studio .*") # get Visual Studio Version STRING(REGEX REPLACE "Visual Studio ([0-9]+).*" "\\1" VS_VERSION "${CMAKE_GENERATOR}") # these settings never change even for C or C++ SET(CMAKE_C_FLAGS_DEBUG "/MDd /Z7 /Od") SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /MD /O2") SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /MD /O2") SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /MDd /Z7 /Od") SET(CMAKE_CXX_FLAGS_DEBUG "/MDd /Z7 /Od") SET(CMAKE_CXX_FLAGS_RELEASE "/DNDEBUG /MD /O2") SET(CMAKE_CXX_FLAGS_MINSIZEREL "/DNDEBUG /MD /O2") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/DNDEBUG /MDd /Z7 /Od") # specific settings for the various Visual Studio versions IF(VS_VERSION EQUAL 6) SET(CMAKE_C_FLAGS "/nologo /W3 /GX /Gy /YX") SET(CMAKE_CXX_FLAGS "/nologo /W3 /GX /Gy /YX /Zm500") # /Zm500 increments heap size which is needed on some system to compile templates in dcmimgle ENDIF(VS_VERSION EQUAL 6) IF(VS_VERSION EQUAL 7) SET(CMAKE_C_FLAGS "/nologo /W3 /Gy") SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy") ENDIF(VS_VERSION EQUAL 7) IF(VS_VERSION GREATER 7) SET(CMAKE_C_FLAGS "/nologo /W3 /Gy /EHsc") SET(CMAKE_CXX_FLAGS "/nologo /W3 /Gy /EHsc") ENDIF(VS_VERSION GREATER 7) ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio .*") ENDIF(DCMTK_OVERWRITE_WIN32_COMPILER_FLAGS AND NOT BUILD_SHARED_LIBS) ``` `BUILD_APPS` can be switched off. Then build DCMTK. For Linux: install required dependencies (Ubuntu 18.04 and newer): `sudo apt-get install libpng-dev libtiff5-dev libxml2-dev libjpeg8-dev zlib1g-dev libwrap0-dev libssl-dev` install required dependencies (Ubuntu 17.10 and older): `sudo apt-get install libpng12-dev libtiff5-dev libxml2-dev libjpeg8-dev zlib1g-dev libwrap0-dev libssl-dev` Enable `BUILD_SHARED_LIBS`. `BUILD_APPS` can be switched off. ##### ITK Build ITK with default options. :warning: ensure that compiler enables C++11 features by setting `CMAKE_CXX_STANDARD=11` (default for supported compilers) +:warning: if you use ITK 5, turn on `RTTB_ITK5_SUPPORT` + :warning: Only use one ITK version consistently throughout all libraries and RTToolbox! Otherwise, linker errors will occur. ##### MatchPoint Configure MatchPoint. Please disable `BUILD_TESTING` before building it. :warning: ensure that compiler enables C++11 features by setting `CMAKE_CXX_STANDARD=11` (default for supported compilers) :warning: Only use one ITK version consistently throughout all libraries and RTToolbox! Otherwise, linker errors will occur. +:warning: MatchPoint currently does not support ITK 5 ### Building RT-Toolbox * Configure with CMake * Set `BOOST_INCLUDE_DIR` to the main boost directory. Eventually set `BOOST_LIBRARYDIR` to the respective path (e.g. `/lib64-msvc-14.1\` for Visual Studio 2017 and 64-bit) * Select all packages you like to build (Parameters `BUILD_*` ; e.g. `BUILD_IO_Dicom`). * `BUILD_IO_Dicom`: Reading and writing of DICOM-RT files * `BUILD_IO_HELAX`: Reading of Helax DICOM files * `BUILD_IO_ITK`: Generic reading/writing with ITK * `BUILD_Interpolation`: Dose Interpolation * `BUILD_InterpolationMatchPointTransformation`: Dose Interpolation with Match Point registration support. * `BUILD_Masks`: Voxelization support * `BUILD_Models`: Calculation of dosimetrical models like TCP, NTCP etc. * `BUILD_Apps`: To build the RTTB command line apps (five available) * `BioModelCalc`: calculate the radiobiological effect based on dose * `DoseAcc`: Do dose accumulation * `DoseMap`: Do dose mapping * `DoseTool`: Compute Dose statistics and DVH * `VoxelizerTool`: Voxelize an RTSTRUCT file Some modules of RT-Toolbox are mandatory (e.g. `RTTBCore`) and build automatically. :information_source: enabling `BUILD_All_Modules` builds all modules (except Apps and Testing modules). :information_source: if you build RTTB with VS dynamic, you must ensure that code that uses RTTB DLLs uses the same STL Set `DCMTK_DIR` to your dcmtk binary file directory and `DCMTK_SOURCE_DIR` to your dcmtk source directory. If you want to build RT-Toolbox with ITK and/or MatchPoint set your `ITK_DIR` to your itk binary file directory and/or `MatchPoint_DIR` to your binary matchpoint directory. All directory entries left empty do not require a manual input. Finally, Generate the compilation files for your environment and built it. ### Examples Some examples can be found in ´testing/examples´: * `RTBioModelExampleTest`: Computation of Biological model indices (TCP/NTCP) from a given DVH * `RTDoseIndexTest`: Computation of dose indices (Conformation Number, Conformal Index, Conformity index) from a given DVH * `RTDoseStatisticsDicomTest`: Computation of dose statistics (max dose/mean dose/min dose/Dx/Vx) based on dose data for a specified structure * `RTDVHTest`: Computation of statistics (max value/mean value/min value/Dx/Vx) based on a DVH Other examples include: * `DVHCalculatorTest` (`testing/core`): Computation of a DVH from dose and structure * `VoxelizationValidationTest` (`testing/validation`): Computation of a voxelization * `ITKDoseAccessorConverterTest`: (`testing/io/itk`): Saving image RTToolbox image data as an ITK file ## Running the tests [CTest](https://cmake.org/Wiki/CMake/Testing_With_CTest) is used as testing framework. See their documentation for general testing questions. :information_source: The used testing library Litmus is build automatically. :warning: currently, you have access to testing data only with ssh. That means that a [phabricator](https://phabricator.mitk.org/) account and access to `RTTB-data` repository is mandatory. Please contact rttb(at)dkfz.de for further information. Enabling testing is done as follows: * Enable `BUILD_TESTING` * Configure with CMake * Enable tests of interest * Generate CMake configuration * Build RT-Toolbox * Run tests (build `RUN_TESTS` project or call `ctest` in commandline) to ensure that everything is correct. :information_source: `BUILD_Tester_All` builds all test modules. ## Contributing Please add a github issue and send a pull request if you want to contribute. ## Versioning We use the Ubuntu Release versioning scheme. v2017.02 was released in February 2017. We aim at releasing stable versions once a year. For the versions available, see the [tags on this repository](https://github.com/MIC-DKFZ/RTTB/tags). ## Authors See the list of [contributors](https://github.com/MIC-DKFZ/RTTB/contributors) who participated in this project. ## License This project is licensed under the BSD License - see the [LICENSE](LICENSE) file for details ## Contact Software Development for Integrated Diagnostics and Therapy (SIDT), German Cancer Research Center (DKFZ), Heidelberg, Germany. Web: https://www.dkfz-heidelberg.de/en/mic/research/SIDT/sidt_projects.html E-mail: rttb(at)dkfz.de ## Acknowledgments * **Billie Thompson** - *Template of the readme* - [PurpleBooth](https://github.com/PurpleBooth) diff --git a/cmake/PackageDepends/RTTB_ITK_Config.cmake b/cmake/PackageDepends/RTTB_ITK_Config.cmake index a83bae7..9e2e23c 100644 --- a/cmake/PackageDepends/RTTB_ITK_Config.cmake +++ b/cmake/PackageDepends/RTTB_ITK_Config.cmake @@ -1,38 +1,44 @@ #----------------------------------------------------------------------------- # Find ITK. #----------------------------------------------------------------------------- FIND_PACKAGE(ITK 4.4 REQUIRED) IF(ITK_FOUND) INCLUDE(${ITK_USE_FILE}) ELSE(ITK_FOUND) MESSAGE(FATAL_ERROR "Cannot build without ITK. Please set ITK_DIR.") ENDIF(ITK_FOUND) +IF(${ITK_VERSION_MAJOR} GREATER 5 OR ${ITK_VERSION_MAJOR} EQUAL 5) + IF (NOT RTTB_ITK5_SUPPORT) + MESSAGE (WARNING "You have to activate RTTB_ITK5_SUPPORT for ITK 5 support!") + ENDIF() +ENDIF() + LIST(APPEND ALL_INCLUDE_DIRECTORIES ${ITK_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES ${ITK_LIBRARIES}) LINK_DIRECTORIES(${ITK_LIBRARY_DIRS}) OPTION(RTTB_USE_SYSTEM_GDCM "Activate checker to choose a GDCM installation that should be linked with ITK. (This is needed e.g. when building against an ITK that is distributed with MITK. MITK uses its own GDCM and not the one distributed with ITK.)" OFF) IF (RTTB_USE_SYSTEM_GDCM) MESSAGE (STATUS "RTTB uses system GDCM instead of ITK distribution.") FIND_PACKAGE(GDCM PATHS ${ITK_GDCM_DIR} ${GDCM_DIR} REQUIRED) INCLUDE(${GDCM_USE_FILE}) LIST(APPEND ALL_INCLUDE_DIRECTORIES ${GDCM_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES ${GDCM_LIBRARIES}) ENDIF (RTTB_USE_SYSTEM_GDCM) OPTION(RTTB_USE_SYSTEM_HDF5 "Activate checker to choose a HDF5 installation that should be linked with ITK. (This is needed e.g. when building against an ITK that is distributed with MITK. MITK uses its own HDF5 and not the one distributed with ITK.)" OFF) IF (RTTB_USE_SYSTEM_HDF5) MESSAGE (STATUS "RTTB uses system HDF5 instead of ITK distribution.") FIND_PACKAGE(HDF5 PATHS ${HDF5_DIR} REQUIRED) LIST(APPEND ALL_INCLUDE_DIRECTORIES ${HDF5_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES ${HDF5_LIBRARIES}) ENDIF (RTTB_USE_SYSTEM_HDF5) CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/ITKConfig.cmake.in ${RTTB_MODULES_CONF_DIR}/ITKConfig.cmake @ONLY) diff --git a/code/io/itk/CMakeLists.txt b/code/io/itk/CMakeLists.txt index ece1f8a..5a01901 100644 --- a/code/io/itk/CMakeLists.txt +++ b/code/io/itk/CMakeLists.txt @@ -1,2 +1,9 @@ -RTTB_CREATE_MODULE(RTTBITKIO DEPENDS RTTBCore PACKAGE_DEPENDS Boost ITK) - +IF(RTTB_ITK5_SUPPORT) + SET(ITK_DEPENDENT_HEADER_FILES "ITK5/itkDoseAccessorImageFilter.h" "ITK5/itkMaskAccessorImageSource.h" ) + SET(ITK_DEPENDENT_SOURCE_FILES "ITK5/itkDoseAccessorImageFilter.cpp" "ITK5/itkMaskAccessorImageSource.cpp") + RTTB_CREATE_MODULE(RTTBITKIO INTERNAL_INCLUDE_DIRS ITK5 DEPENDS RTTBCore PACKAGE_DEPENDS Boost ITK) +ELSE() + SET(ITK_DEPENDENT_HEADER_FILES "ITK4/itkDoseAccessorImageFilter.h" "ITK4/itkMaskAccessorImageSource.h") + SET(ITK_DEPENDENT_SOURCE_FILES "ITK4/itkDoseAccessorImageFilter.cpp" "ITK4/itkMaskAccessorImageSource.cpp") + RTTB_CREATE_MODULE(RTTBITKIO INTERNAL_INCLUDE_DIRS ITK4 DEPENDS RTTBCore PACKAGE_DEPENDS Boost ITK) +ENDIF() \ No newline at end of file diff --git a/code/io/itk/itkDoseAccessorImageFilter.cpp b/code/io/itk/ITK4/itkDoseAccessorImageFilter.cpp similarity index 96% copy from code/io/itk/itkDoseAccessorImageFilter.cpp copy to code/io/itk/ITK4/itkDoseAccessorImageFilter.cpp index 2be3390..642a13d 100644 --- a/code/io/itk/itkDoseAccessorImageFilter.cpp +++ b/code/io/itk/ITK4/itkDoseAccessorImageFilter.cpp @@ -1,76 +1,76 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// 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 "itkDoseAccessorImageFilter.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIteratorWithIndex.h" -#include "itkProgressReporter.h" - -namespace itk -{ - /** - * Constructor - */ - DoseAccessorImageFilter - ::DoseAccessorImageFilter() - { - this->SetNumberOfRequiredInputs(1); - } - - void - DoseAccessorImageFilter - ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) - { - ProgressReporter progress(this, threadId, - outputRegionForThread.GetNumberOfPixels()); - - using ImageRegionConstIteratorType = ImageRegionConstIteratorWithIndex; - using OutputImageRegionIteratorType = ImageRegionIterator; - - InputImagePointer inputPtr = dynamic_cast< InputImageType* >(ProcessObject::GetInput(0)); - ImageRegionConstIteratorType inputItr; - - if (inputPtr) - { - inputItr = ImageRegionConstIteratorType(inputPtr, outputRegionForThread); - } - - OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); - OutputImageRegionIteratorType outputItr; - - if (outputPtr) - { - outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); - } - - if (inputPtr && outputPtr) - { - while (!(outputItr.IsAtEnd())) - { - ImageRegionConstIteratorType::IndexType index = inputItr.GetIndex(); - rttb::VoxelGridIndex3D doseIndex(index[0], index[1], index[2]); - - outputItr.Set(m_Accessor->getValueAt(doseIndex)); - - ++outputItr; - ++inputItr; - - progress.CompletedPixel(); - } - } - } -} // end namespace itk - +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 "itkDoseAccessorImageFilter.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIteratorWithIndex.h" +#include "itkProgressReporter.h" + +namespace itk +{ + /** + * Constructor + */ + DoseAccessorImageFilter + ::DoseAccessorImageFilter() + { + this->SetNumberOfRequiredInputs(1); + } + + void + DoseAccessorImageFilter + ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, + ThreadIdType threadId) + { + ProgressReporter progress(this, threadId, + outputRegionForThread.GetNumberOfPixels()); + + using ImageRegionConstIteratorType = ImageRegionConstIteratorWithIndex; + using OutputImageRegionIteratorType = ImageRegionIterator; + + InputImagePointer inputPtr = dynamic_cast< InputImageType* >(ProcessObject::GetInput(0)); + ImageRegionConstIteratorType inputItr; + + if (inputPtr) + { + inputItr = ImageRegionConstIteratorType(inputPtr, outputRegionForThread); + } + + OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); + OutputImageRegionIteratorType outputItr; + + if (outputPtr) + { + outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); + } + + if (inputPtr && outputPtr) + { + while (!(outputItr.IsAtEnd())) + { + ImageRegionConstIteratorType::IndexType index = inputItr.GetIndex(); + rttb::VoxelGridIndex3D doseIndex(index[0], index[1], index[2]); + + outputItr.Set(m_Accessor->getValueAt(doseIndex)); + + ++outputItr; + ++inputItr; + + progress.CompletedPixel(); + } + } + } +} // end namespace itk + diff --git a/code/io/itk/itkDoseAccessorImageFilter.h b/code/io/itk/ITK4/itkDoseAccessorImageFilter.h similarity index 97% copy from code/io/itk/itkDoseAccessorImageFilter.h copy to code/io/itk/ITK4/itkDoseAccessorImageFilter.h index 9d072f6..33d8f73 100644 --- a/code/io/itk/itkDoseAccessorImageFilter.h +++ b/code/io/itk/ITK4/itkDoseAccessorImageFilter.h @@ -1,112 +1,112 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// 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 __itkDoseAccessorImageFilter_h -#define __itkDoseAccessorImageFilter_h - -#include "itkImageToImageFilter.h" - -#include "rttbDoseAccessorInterface.h" -#include "rttbITKImageAccessor.h" - -namespace itk -{ - /** \class DoseAccessorImageFilter - * \brief Perform a generic pixel-wise operation on the input image by setting its pixel values according to the dose accessor output. - * - * \ingroup IntensityImageFilters MultiThreaded - * \ingroup ITKImageIntensity - */ - - typedef rttb::io::itk::ITKImageAccessor::ITKImageType RTTBDoseImageType; - - class ITK_EXPORT DoseAccessorImageFilter: - public ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > - - { - public: - /** Standard class typedefs. */ - typedef DoseAccessorImageFilter Self; - typedef ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(DoseAccessorImageFilter, ImageToImageFilter); - - /** Some typedefs. */ - typedef RTTBDoseImageType InputImageType; - typedef InputImageType::Pointer InputImagePointer; - typedef InputImageType::RegionType InputImageRegionType; - typedef InputImageType::PixelType InputImagePixelType; - typedef RTTBDoseImageType OutputImageType; - typedef OutputImageType::Pointer OutputImagePointer; - typedef OutputImageType::RegionType OutputImageRegionType; - typedef OutputImageType::PixelType OutputImagePixelType; - - typedef rttb::core::DoseAccessorInterface DoseAccessorType; - typedef rttb::core::DoseAccessorInterface::Pointer DoseAccessorPointer; - - /** Get the accessor pointer. */ - DoseAccessorPointer GetAccessor() - { - return m_Accessor; - } - - /** Set the accessor pointer. */ - void SetAccessor(DoseAccessorPointer accessor) - { - if (m_Accessor != accessor) - { - m_Accessor = accessor; - this->Modified(); - } - } - - /** ImageDimension constants */ - itkStaticConstMacro( - InputImageDimension, unsigned int, InputImageType::ImageDimension); - itkStaticConstMacro( - OutputImageDimension, unsigned int, OutputImageType::ImageDimension); - - protected: - DoseAccessorImageFilter(); - ~DoseAccessorImageFilter() override {} - - /** DoseAccessorImageFilter can be implemented as a multi threaded filter. - * Therefore, this implementation provides a ThreadedGenerateData() routine - * which is called for each processing thread. The output image data is - * allocated automatically by the superclass prior to calling - * ThreadedGenerateData(). ThreadedGenerateData can only write to the - * portion of the output image specified by the parameter - * "outputRegionForThread" - * - * \sa ImageToImageFilter::ThreadedGenerateData(), - * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) override; - - private: - DoseAccessorImageFilter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - DoseAccessorPointer m_Accessor; - }; -} // end namespace itk - - -#endif +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 __itkDoseAccessorImageFilter_h +#define __itkDoseAccessorImageFilter_h + +#include "itkImageToImageFilter.h" + +#include "rttbDoseAccessorInterface.h" +#include "rttbITKImageAccessor.h" + +namespace itk +{ + /** \class DoseAccessorImageFilter + * \brief Perform a generic pixel-wise operation on the input image by setting its pixel values according to the dose accessor output. + * + * \ingroup IntensityImageFilters MultiThreaded + * \ingroup ITKImageIntensity + */ + + typedef rttb::io::itk::ITKImageAccessor::ITKImageType RTTBDoseImageType; + + class ITK_EXPORT DoseAccessorImageFilter: + public ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > + + { + public: + /** Standard class typedefs. */ + typedef DoseAccessorImageFilter Self; + typedef ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > Superclass; + typedef SmartPointer< Self > Pointer; + typedef SmartPointer< const Self > ConstPointer; + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(DoseAccessorImageFilter, ImageToImageFilter); + + /** Some typedefs. */ + typedef RTTBDoseImageType InputImageType; + typedef InputImageType::Pointer InputImagePointer; + typedef InputImageType::RegionType InputImageRegionType; + typedef InputImageType::PixelType InputImagePixelType; + typedef RTTBDoseImageType OutputImageType; + typedef OutputImageType::Pointer OutputImagePointer; + typedef OutputImageType::RegionType OutputImageRegionType; + typedef OutputImageType::PixelType OutputImagePixelType; + + typedef rttb::core::DoseAccessorInterface DoseAccessorType; + typedef rttb::core::DoseAccessorInterface::Pointer DoseAccessorPointer; + + /** Get the accessor pointer. */ + DoseAccessorPointer GetAccessor() + { + return m_Accessor; + } + + /** Set the accessor pointer. */ + void SetAccessor(DoseAccessorPointer accessor) + { + if (m_Accessor != accessor) + { + m_Accessor = accessor; + this->Modified(); + } + } + + /** ImageDimension constants */ + itkStaticConstMacro( + InputImageDimension, unsigned int, InputImageType::ImageDimension); + itkStaticConstMacro( + OutputImageDimension, unsigned int, OutputImageType::ImageDimension); + + protected: + DoseAccessorImageFilter(); + ~DoseAccessorImageFilter() override {} + + /** DoseAccessorImageFilter can be implemented as a multi threaded filter. + * Therefore, this implementation provides a ThreadedGenerateData() routine + * which is called for each processing thread. The output image data is + * allocated automatically by the superclass prior to calling + * ThreadedGenerateData(). ThreadedGenerateData can only write to the + * portion of the output image specified by the parameter + * "outputRegionForThread" + * + * \sa ImageToImageFilter::ThreadedGenerateData(), + * ImageToImageFilter::GenerateData() */ + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, + ThreadIdType threadId) override; + + private: + DoseAccessorImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + DoseAccessorPointer m_Accessor; + }; +} // end namespace itk + + +#endif diff --git a/code/io/itk/ITK4/itkMaskAccessorImageSource.cpp b/code/io/itk/ITK4/itkMaskAccessorImageSource.cpp new file mode 100644 index 0000000..5f6aaaf --- /dev/null +++ b/code/io/itk/ITK4/itkMaskAccessorImageSource.cpp @@ -0,0 +1,101 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 "itkMaskAccessorImageSource.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIteratorWithIndex.h" +#include "itkProgressReporter.h" +#include "itkExceptionObject.h" + +#include "rttbGeometricInfo.h" + +namespace itk +{ + /** + * Constructor + */ + MaskAccessorImageSource + ::MaskAccessorImageSource() + = default; + + void + MaskAccessorImageSource + ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, + ThreadIdType threadId) + { + ProgressReporter progress(this, threadId, + outputRegionForThread.GetNumberOfPixels()); + + using OutputImageRegionIteratorType = ImageRegionIterator; + + OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); + OutputImageRegionIteratorType outputItr; + + if (outputPtr) + { + outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); + + for (; !(outputItr.IsAtEnd()); ++outputItr) + { + OutputImageType::IndexType index = outputItr.GetIndex(); + rttb::VoxelGridIndex3D maskIndex(index[0], index[1], index[2]); + rttb::VoxelGridID id = 0; + + if (m_Accessor->getGeometricInfo().convert(maskIndex, id)) + { + auto finding = m_idMap.find(id); + if (finding != m_idMap.end()) + { + // Set the current pixel + outputItr.Set(m_MaskedVoxels->at(finding->second).getRelevantVolumeFraction()); + } + } + else + { + if (m_FailsOnInvalidIDs) + { + itkExceptionMacro(<<"invalid Mask index. Index:"<(ProcessObject::GetOutput(0)); + outputPtr->FillBuffer(0.0); + + //The id map approach and working with relevant voxel vector is a workarround till task T22067 is solved and and can be used again. + m_MaskedVoxels = m_Accessor->getRelevantVoxelVector(); + + m_idMap.clear(); + + for (rttb::core::MaskAccessorInterface::MaskVoxelList::size_type pos = 0; pos < m_MaskedVoxels->size(); ++pos) + { + m_idMap.insert(std::make_pair((*m_MaskedVoxels)[pos].getVoxelGridID(), pos)); + } + } +} // end namespace itk + diff --git a/code/io/itk/ITK4/itkMaskAccessorImageSource.h b/code/io/itk/ITK4/itkMaskAccessorImageSource.h new file mode 100644 index 0000000..20d6a06 --- /dev/null +++ b/code/io/itk/ITK4/itkMaskAccessorImageSource.h @@ -0,0 +1,105 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 __itkMaskAccessorImageSource_h +#define __itkMaskAccessorImageSource_h + +#include "itkGenerateImageSource.h" + +#include "rttbMaskAccessorInterface.h" +#include "rttbITKImageMaskAccessor.h" + +namespace itk +{ + /** \class MaskAccessorImageSource + * \brief Converts a given mask accessor into an itk image. + * + */ + + typedef rttb::io::itk::ITKImageMaskAccessor::ITKMaskImageType RTTBMaskImageType; + + class ITK_EXPORT MaskAccessorImageSource: + public GenerateImageSource< RTTBMaskImageType> + + { + public: + /** Standard class typedefs. */ + typedef MaskAccessorImageSource Self; + typedef GenerateImageSource< RTTBMaskImageType > Superclass; + typedef SmartPointer< Self > Pointer; + typedef SmartPointer< const Self > ConstPointer; + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(MaskAccessorImageSource, ImageToImageFilter); + + /** Some typedefs. */ + typedef RTTBMaskImageType OutputImageType; + typedef OutputImageType::Pointer OutputImagePointer; + typedef OutputImageType::RegionType OutputImageRegionType; + typedef OutputImageType::PixelType OutputImagePixelType; + + typedef rttb::core::MaskAccessorInterface AccessorType; + typedef rttb::core::MaskAccessorInterface::Pointer AccessorPointer; + + /** Get the accessor pointer. */ + itkGetConstMacro(Accessor, AccessorPointer); + + /** Set the accessor pointer. */ + void SetAccessor(AccessorPointer accessor) + { + if (m_Accessor != accessor) + { + m_Accessor = accessor; + this->Modified(); + } + } + + itkSetMacro(FailsOnInvalidIDs, bool); + itkGetConstMacro(FailsOnInvalidIDs, bool); + + itkSetMacro(InvalidMaskValue, OutputImageType::ValueType); + itkGetConstMacro(InvalidMaskValue, OutputImageType::ValueType); + + /** ImageDimension constants */ + itkStaticConstMacro( + OutputImageDimension, unsigned int, OutputImageType::ImageDimension); + + protected: + MaskAccessorImageSource(); + ~MaskAccessorImageSource() override {} + + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, + ThreadIdType threadId) override; + + void BeforeThreadedGenerateData() override; + + private: + MaskAccessorImageSource(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + typedef std::map VoxelMapType; + VoxelMapType m_idMap; + rttb::core::MaskAccessorInterface::MaskVoxelListPointer m_MaskedVoxels; + + AccessorPointer m_Accessor; + bool m_FailsOnInvalidIDs{true}; + OutputImageType::ValueType m_InvalidMaskValue{0}; + }; +} // end namespace itk + + +#endif diff --git a/code/io/itk/itkDoseAccessorImageFilter.cpp b/code/io/itk/ITK5/itkDoseAccessorImageFilter.cpp similarity index 85% rename from code/io/itk/itkDoseAccessorImageFilter.cpp rename to code/io/itk/ITK5/itkDoseAccessorImageFilter.cpp index 2be3390..21eab51 100644 --- a/code/io/itk/itkDoseAccessorImageFilter.cpp +++ b/code/io/itk/ITK5/itkDoseAccessorImageFilter.cpp @@ -1,76 +1,75 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// 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 "itkDoseAccessorImageFilter.h" -#include "itkImageRegionIterator.h" -#include "itkImageRegionConstIteratorWithIndex.h" -#include "itkProgressReporter.h" - -namespace itk -{ - /** - * Constructor - */ - DoseAccessorImageFilter - ::DoseAccessorImageFilter() - { - this->SetNumberOfRequiredInputs(1); - } - - void - DoseAccessorImageFilter - ::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) - { - ProgressReporter progress(this, threadId, - outputRegionForThread.GetNumberOfPixels()); - - using ImageRegionConstIteratorType = ImageRegionConstIteratorWithIndex; - using OutputImageRegionIteratorType = ImageRegionIterator; - - InputImagePointer inputPtr = dynamic_cast< InputImageType* >(ProcessObject::GetInput(0)); - ImageRegionConstIteratorType inputItr; - - if (inputPtr) - { - inputItr = ImageRegionConstIteratorType(inputPtr, outputRegionForThread); - } - - OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); - OutputImageRegionIteratorType outputItr; - - if (outputPtr) - { - outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); - } - - if (inputPtr && outputPtr) - { - while (!(outputItr.IsAtEnd())) - { - ImageRegionConstIteratorType::IndexType index = inputItr.GetIndex(); - rttb::VoxelGridIndex3D doseIndex(index[0], index[1], index[2]); - - outputItr.Set(m_Accessor->getValueAt(doseIndex)); - - ++outputItr; - ++inputItr; - - progress.CompletedPixel(); - } - } - } -} // end namespace itk - +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 "itkDoseAccessorImageFilter.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIteratorWithIndex.h" +#include "itkProgressReporter.h" + +namespace itk +{ + /** + * Constructor + */ + DoseAccessorImageFilter + ::DoseAccessorImageFilter() + { + this->SetNumberOfRequiredInputs(1); + } + + void + DoseAccessorImageFilter + ::DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) + { + //ProgressReporter progress(this, threadId, + // outputRegionForThread.GetNumberOfPixels()); + + using ImageRegionConstIteratorType = ImageRegionConstIteratorWithIndex; + using OutputImageRegionIteratorType = ImageRegionIterator; + + InputImagePointer inputPtr = dynamic_cast< InputImageType* >(ProcessObject::GetInput(0)); + ImageRegionConstIteratorType inputItr; + + if (inputPtr) + { + inputItr = ImageRegionConstIteratorType(inputPtr, outputRegionForThread); + } + + OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); + OutputImageRegionIteratorType outputItr; + + if (outputPtr) + { + outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); + } + + if (inputPtr && outputPtr) + { + while (!(outputItr.IsAtEnd())) + { + ImageRegionConstIteratorType::IndexType index = inputItr.GetIndex(); + rttb::VoxelGridIndex3D doseIndex(index[0], index[1], index[2]); + + outputItr.Set(m_Accessor->getValueAt(doseIndex)); + + ++outputItr; + ++inputItr; + + //progress.CompletedPixel(); + } + } + } +} // end namespace itk + diff --git a/code/io/itk/itkDoseAccessorImageFilter.h b/code/io/itk/ITK5/itkDoseAccessorImageFilter.h similarity index 88% rename from code/io/itk/itkDoseAccessorImageFilter.h rename to code/io/itk/ITK5/itkDoseAccessorImageFilter.h index 9d072f6..f3164af 100644 --- a/code/io/itk/itkDoseAccessorImageFilter.h +++ b/code/io/itk/ITK5/itkDoseAccessorImageFilter.h @@ -1,112 +1,111 @@ -// ----------------------------------------------------------------------- -// RTToolbox - DKFZ radiotherapy quantitative evaluation library -// -// Copyright (c) German Cancer Research Center (DKFZ), -// Software development for Integrated Diagnostics and Therapy (SIDT). -// ALL RIGHTS RESERVED. -// See rttbCopyright.txt or -// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html -// -// 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 __itkDoseAccessorImageFilter_h -#define __itkDoseAccessorImageFilter_h - -#include "itkImageToImageFilter.h" - -#include "rttbDoseAccessorInterface.h" -#include "rttbITKImageAccessor.h" - -namespace itk -{ - /** \class DoseAccessorImageFilter - * \brief Perform a generic pixel-wise operation on the input image by setting its pixel values according to the dose accessor output. - * - * \ingroup IntensityImageFilters MultiThreaded - * \ingroup ITKImageIntensity - */ - - typedef rttb::io::itk::ITKImageAccessor::ITKImageType RTTBDoseImageType; - - class ITK_EXPORT DoseAccessorImageFilter: - public ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > - - { - public: - /** Standard class typedefs. */ - typedef DoseAccessorImageFilter Self; - typedef ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > Superclass; - typedef SmartPointer< Self > Pointer; - typedef SmartPointer< const Self > ConstPointer; - /** Method for creation through the object factory. */ - itkNewMacro(Self); - - /** Run-time type information (and related methods). */ - itkTypeMacro(DoseAccessorImageFilter, ImageToImageFilter); - - /** Some typedefs. */ - typedef RTTBDoseImageType InputImageType; - typedef InputImageType::Pointer InputImagePointer; - typedef InputImageType::RegionType InputImageRegionType; - typedef InputImageType::PixelType InputImagePixelType; - typedef RTTBDoseImageType OutputImageType; - typedef OutputImageType::Pointer OutputImagePointer; - typedef OutputImageType::RegionType OutputImageRegionType; - typedef OutputImageType::PixelType OutputImagePixelType; - - typedef rttb::core::DoseAccessorInterface DoseAccessorType; - typedef rttb::core::DoseAccessorInterface::Pointer DoseAccessorPointer; - - /** Get the accessor pointer. */ - DoseAccessorPointer GetAccessor() - { - return m_Accessor; - } - - /** Set the accessor pointer. */ - void SetAccessor(DoseAccessorPointer accessor) - { - if (m_Accessor != accessor) - { - m_Accessor = accessor; - this->Modified(); - } - } - - /** ImageDimension constants */ - itkStaticConstMacro( - InputImageDimension, unsigned int, InputImageType::ImageDimension); - itkStaticConstMacro( - OutputImageDimension, unsigned int, OutputImageType::ImageDimension); - - protected: - DoseAccessorImageFilter(); - ~DoseAccessorImageFilter() override {} - - /** DoseAccessorImageFilter can be implemented as a multi threaded filter. - * Therefore, this implementation provides a ThreadedGenerateData() routine - * which is called for each processing thread. The output image data is - * allocated automatically by the superclass prior to calling - * ThreadedGenerateData(). ThreadedGenerateData can only write to the - * portion of the output image specified by the parameter - * "outputRegionForThread" - * - * \sa ImageToImageFilter::ThreadedGenerateData(), - * ImageToImageFilter::GenerateData() */ - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - ThreadIdType threadId) override; - - private: - DoseAccessorImageFilter(const Self&); //purposely not implemented - void operator=(const Self&); //purposely not implemented - - DoseAccessorPointer m_Accessor; - }; -} // end namespace itk - - -#endif +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 __itkDoseAccessorImageFilter_h +#define __itkDoseAccessorImageFilter_h + +#include "itkImageToImageFilter.h" + +#include "rttbDoseAccessorInterface.h" +#include "rttbITKImageAccessor.h" + +namespace itk +{ + /** \class DoseAccessorImageFilter + * \brief Perform a generic pixel-wise operation on the input image by setting its pixel values according to the dose accessor output. + * + * \ingroup IntensityImageFilters MultiThreaded + * \ingroup ITKImageIntensity + */ + + typedef rttb::io::itk::ITKImageAccessor::ITKImageType RTTBDoseImageType; + + class ITK_EXPORT DoseAccessorImageFilter: + public ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > + + { + public: + /** Standard class typedefs. */ + typedef DoseAccessorImageFilter Self; + typedef ImageToImageFilter< RTTBDoseImageType, RTTBDoseImageType > Superclass; + typedef SmartPointer< Self > Pointer; + typedef SmartPointer< const Self > ConstPointer; + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(DoseAccessorImageFilter, ImageToImageFilter); + + /** Some typedefs. */ + typedef RTTBDoseImageType InputImageType; + typedef InputImageType::Pointer InputImagePointer; + typedef InputImageType::RegionType InputImageRegionType; + typedef InputImageType::PixelType InputImagePixelType; + typedef RTTBDoseImageType OutputImageType; + typedef OutputImageType::Pointer OutputImagePointer; + typedef OutputImageType::RegionType OutputImageRegionType; + typedef OutputImageType::PixelType OutputImagePixelType; + + typedef rttb::core::DoseAccessorInterface DoseAccessorType; + typedef rttb::core::DoseAccessorInterface::Pointer DoseAccessorPointer; + + /** Get the accessor pointer. */ + DoseAccessorPointer GetAccessor() + { + return m_Accessor; + } + + /** Set the accessor pointer. */ + void SetAccessor(DoseAccessorPointer accessor) + { + if (m_Accessor != accessor) + { + m_Accessor = accessor; + this->Modified(); + } + } + + /** ImageDimension constants */ + itkStaticConstMacro( + InputImageDimension, unsigned int, InputImageType::ImageDimension); + itkStaticConstMacro( + OutputImageDimension, unsigned int, OutputImageType::ImageDimension); + + protected: + DoseAccessorImageFilter(); + ~DoseAccessorImageFilter() override {} + + /** DoseAccessorImageFilter can be implemented as a multi threaded filter. + * Therefore, this implementation provides a DynamicThreadedGenerateData() routine + * which is called for each processing thread. The output image data is + * allocated automatically by the superclass prior to calling + * DynamicThreadedGenerateData(). ThreadedGenerateData can only write to the + * portion of the output image specified by the parameter + * "outputRegionForThread" + * + * \sa ImageToImageFilter::DynamicThreadedGenerateData(), + * ImageToImageFilter::GenerateData() */ + void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override; + + private: + DoseAccessorImageFilter(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + DoseAccessorPointer m_Accessor; + }; +} // end namespace itk + + +#endif diff --git a/code/io/itk/ITK5/itkMaskAccessorImageSource.cpp b/code/io/itk/ITK5/itkMaskAccessorImageSource.cpp new file mode 100644 index 0000000..d1b8173 --- /dev/null +++ b/code/io/itk/ITK5/itkMaskAccessorImageSource.cpp @@ -0,0 +1,94 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 "itkMaskAccessorImageSource.h" +#include "itkImageRegionIterator.h" +#include "itkImageRegionConstIteratorWithIndex.h" +#include "itkExceptionObject.h" + +#include "rttbGeometricInfo.h" + +namespace itk +{ + /** + * Constructor + */ + MaskAccessorImageSource + ::MaskAccessorImageSource() + = default; + + void + MaskAccessorImageSource + ::DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) + { + using OutputImageRegionIteratorType = ImageRegionIterator; + + OutputImagePointer outputPtr = dynamic_cast< OutputImageType* >(ProcessObject::GetOutput(0)); + OutputImageRegionIteratorType outputItr; + + if (outputPtr) + { + outputItr = OutputImageRegionIteratorType(outputPtr, outputRegionForThread); + + for (; !(outputItr.IsAtEnd()); ++outputItr) + { + OutputImageType::IndexType index = outputItr.GetIndex(); + rttb::VoxelGridIndex3D maskIndex(index[0], index[1], index[2]); + rttb::VoxelGridID id = 0; + + if (m_Accessor->getGeometricInfo().convert(maskIndex, id)) + { + auto finding = m_idMap.find(id); + if (finding != m_idMap.end()) + { + // Set the current pixel + outputItr.Set(m_MaskedVoxels->at(finding->second).getRelevantVolumeFraction()); + } + } + else + { + if (m_FailsOnInvalidIDs) + { + itkExceptionMacro(<<"invalid Mask index. Index:"<(ProcessObject::GetOutput(0)); + outputPtr->FillBuffer(0.0); + + //The id map approach and working with relevant voxel vector is a workarround till task T22067 is solved and and can be used again. + m_MaskedVoxels = m_Accessor->getRelevantVoxelVector(); + + m_idMap.clear(); + + for (rttb::core::MaskAccessorInterface::MaskVoxelList::size_type pos = 0; pos < m_MaskedVoxels->size(); ++pos) + { + m_idMap.insert(std::make_pair((*m_MaskedVoxels)[pos].getVoxelGridID(), pos)); + } + } +} // end namespace itk + diff --git a/code/io/itk/ITK5/itkMaskAccessorImageSource.h b/code/io/itk/ITK5/itkMaskAccessorImageSource.h new file mode 100644 index 0000000..f890c87 --- /dev/null +++ b/code/io/itk/ITK5/itkMaskAccessorImageSource.h @@ -0,0 +1,104 @@ +// ----------------------------------------------------------------------- +// RTToolbox - DKFZ radiotherapy quantitative evaluation library +// +// Copyright (c) German Cancer Research Center (DKFZ), +// Software development for Integrated Diagnostics and Therapy (SIDT). +// ALL RIGHTS RESERVED. +// See rttbCopyright.txt or +// http://www.dkfz.de/en/sidt/projects/rttb/copyright.html +// +// 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 __itkMaskAccessorImageSource_h +#define __itkMaskAccessorImageSource_h + +#include "itkGenerateImageSource.h" + +#include "rttbMaskAccessorInterface.h" +#include "rttbITKImageMaskAccessor.h" + +namespace itk +{ + /** \class MaskAccessorImageSource + * \brief Converts a given mask accessor into an itk image. + * + */ + + typedef rttb::io::itk::ITKImageMaskAccessor::ITKMaskImageType RTTBMaskImageType; + + class ITK_EXPORT MaskAccessorImageSource: + public GenerateImageSource< RTTBMaskImageType> + + { + public: + /** Standard class typedefs. */ + typedef MaskAccessorImageSource Self; + typedef GenerateImageSource< RTTBMaskImageType > Superclass; + typedef SmartPointer< Self > Pointer; + typedef SmartPointer< const Self > ConstPointer; + /** Method for creation through the object factory. */ + itkNewMacro(Self); + + /** Run-time type information (and related methods). */ + itkTypeMacro(MaskAccessorImageSource, ImageToImageFilter); + + /** Some typedefs. */ + typedef RTTBMaskImageType OutputImageType; + typedef OutputImageType::Pointer OutputImagePointer; + typedef OutputImageType::RegionType OutputImageRegionType; + typedef OutputImageType::PixelType OutputImagePixelType; + + typedef rttb::core::MaskAccessorInterface AccessorType; + typedef rttb::core::MaskAccessorInterface::Pointer AccessorPointer; + + /** Get the accessor pointer. */ + itkGetConstMacro(Accessor, AccessorPointer); + + /** Set the accessor pointer. */ + void SetAccessor(AccessorPointer accessor) + { + if (m_Accessor != accessor) + { + m_Accessor = accessor; + this->Modified(); + } + } + + itkSetMacro(FailsOnInvalidIDs, bool); + itkGetConstMacro(FailsOnInvalidIDs, bool); + + itkSetMacro(InvalidMaskValue, OutputImageType::ValueType); + itkGetConstMacro(InvalidMaskValue, OutputImageType::ValueType); + + /** ImageDimension constants */ + itkStaticConstMacro( + OutputImageDimension, unsigned int, OutputImageType::ImageDimension); + + protected: + MaskAccessorImageSource(); + ~MaskAccessorImageSource() override {} + + void DynamicThreadedGenerateData(const OutputImageRegionType& outputRegionForThread) override; + + void BeforeThreadedGenerateData() override; + + private: + MaskAccessorImageSource(const Self&); //purposely not implemented + void operator=(const Self&); //purposely not implemented + + typedef std::map VoxelMapType; + VoxelMapType m_idMap; + rttb::core::MaskAccessorInterface::MaskVoxelListPointer m_MaskedVoxels; + + AccessorPointer m_Accessor; + bool m_FailsOnInvalidIDs{true}; + OutputImageType::ValueType m_InvalidMaskValue{0}; + }; +} // end namespace itk + + +#endif diff --git a/code/io/itk/files.cmake b/code/io/itk/files.cmake index 56e4ece..0d031e6 100644 --- a/code/io/itk/files.cmake +++ b/code/io/itk/files.cmake @@ -1,40 +1,38 @@ SET(CPP_FILES rttbFileDispatch.cpp rttbGenericImageReader.cpp rttbImageWriter.cpp rttbITKImageAccessor.cpp rttbITKImageAccessorConverter.cpp rttbITKImageAccessorGenerator.cpp rttbITKImageFileAccessorGenerator.cpp rttbITKImageFileMaskAccessorGenerator.cpp rttbITKImageMaskAccessor.cpp rttbITKImageMaskAccessorGenerator.cpp rttbITKImageMaskAccessorConverter.cpp rttbITKIOHelper.cpp - itkDoseAccessorImageFilter.cpp - itkMaskAccessorImageSource.cpp + ${ITK_DEPENDENT_SOURCE_FILES} ) SET(H_FILES rttbDoseAccessorConversionSettingInterface.h rttbDoseAccessorProcessorBase.h rttbDoseAccessorProcessorInterface.h rttbFileDispatch.h rttbGenericImageReader.h rttbImageReader.h rttbImageReader.tpp rttbImageWriter.h rttbITKException.h rttbITKImageAccessor.h rttbITKImageAccessorConverter.h rttbITKImageAccessorGenerator.h rttbITKImageFileAccessorGenerator.h rttbITKImageFileMaskAccessorGenerator.h rttbITKImageMaskAccessor.h rttbITKImageMaskAccessorConverter.h rttbITKImageMaskAccessorGenerator.h rttbITKIOHelper.h rttbITKIOHelper.tpp - itkDoseAccessorImageFilter.h - itkMaskAccessorImageSource.h -) + ${ITK_DEPENDENT_HEADER_FILES} +) \ No newline at end of file diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 0f6eab8..e3c392f 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -1,113 +1,113 @@ MESSAGE(STATUS "processing RTToolbox testing code") # Testing branch PROJECT(RTTBTesting) #----------------------------------------------------------------------------- # extract and build Litmus #----------------------------------------------------------------------------- include(ExternalProject) message(STATUS "Litmus will be automatically downloaded and built.") set(LITMUS_SOURCE_DIR "${CMAKE_BINARY_DIR}/external/Litmus-src") set(LITMUS_BUILD_DIR "${CMAKE_BINARY_DIR}/external/Litmus-build") set(LITMUS_CMAKE_DIR "${CMAKE_BINARY_DIR}/external/Litmus-cmake") IF (BUILD_Tester_All OR (BUILD_Tester_Interpolation AND BUILD_InterpolationMatchPointTransformation) OR (BUILD_Tester_IO AND BUILD_IO_ITK) OR (BUILD_Tester_Apps)) set(ENABLE_ITK "-DLIT_ENABLE_ITK_SUPPORT:BOOL=ON") set(ITK_DIRECTORY "-DITK_DIR:PATH=${ITK_DIR}") IF (RTTB_USE_SYSTEM_HDF5) set(SYSTEM_HDF5 "-DLIT_USE_SYSTEM_HDF5:BOOL=ON") set(LITMUS_HDF5_DIR "-DHDF5_DIR:PATH=${HDF5_DIR}") ENDIF() ENDIF() #extract and build Litmus ExternalProject_Add( Litmus URL ${RTToolbox_SOURCE_DIR}/utilities/Litmus/Litmus.tar.gz - URL_HASH SHA1=7ae626ec8fb2a6990ace12a58cf307dc48b65fac + URL_HASH SHA1=73CE5302C35D984090B70B4A44644DA916A5E0A3 SOURCE_DIR ${LITMUS_SOURCE_DIR} BINARY_DIR ${LITMUS_BUILD_DIR} PREFIX ${LITMUS_CMAKE_DIR} INSTALL_COMMAND "" UPDATE_COMMAND "" # Don't update SVN on every build CMAKE_ARGS -DBUILD_TESTING:BOOL=OFF -DCMAKE_CXX_STANDARD=11 ${ENABLE_ITK} ${ITK_DIRECTORY} ${SYSTEM_HDF5} ${LITMUS_HDF5_DIR} ) set(RTTBDATA_DIR "${CMAKE_BINARY_DIR}/external/RTTBData") set(TEST_DATA_ROOT ${RTTBDATA_DIR}) #download RTTB data message(STATUS "RTTBdata will be automatically downloaded.") ExternalProject_Add( RTTBData SOURCE_DIR ${RTTBDATA_DIR} GIT_REPOSITORY "https://phabricator.mitk.org/source/rttb-data.git" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" ) #----------------------------------------------------------------------------- # Configure Testing branch #----------------------------------------------------------------------------- MAKE_DIRECTORY(${RTTBTesting_BINARY_DIR}/Temporary) OPTION(BUILD_Tester_All "All testing modules will be built" OFF) MESSAGE(STATUS "Process All Tests...") #----------------------------------------------------------------------------- # Include sub directories #----------------------------------------------------------------------------- OPTION(BUILD_Tester_Core "build project on/off" OFF) OPTION(BUILD_Tester_Examples "build project on/off" OFF) OPTION(BUILD_Tester_Algorithms "build project on/off" OFF) OPTION(BUILD_Tester_Models "build project on/off" OFF) OPTION(BUILD_Tester_IO "build project on/off" OFF) OPTION(BUILD_Tester_Masks "build project on/off" OFF) OPTION(BUILD_Tester_Interpolation "build project on/off" OFF) OPTION(BUILD_Tester_Apps "build project on/off" OFF) OPTION(BUILD_Tester_Validation "build project on/off" OFF) IF(BUILD_Tester_All OR BUILD_Tester_Core) ADD_SUBDIRECTORY(core) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Examples) ADD_SUBDIRECTORY(examples) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Algorithms) ADD_SUBDIRECTORY(algorithms) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Models) ADD_SUBDIRECTORY(models) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_IO) ADD_SUBDIRECTORY(io) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Masks) ADD_SUBDIRECTORY(masks) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Interpolation) ADD_SUBDIRECTORY(interpolation) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Validation) ADD_SUBDIRECTORY(validation) ENDIF() IF(BUILD_Tester_All OR BUILD_Tester_Apps) ADD_SUBDIRECTORY(apps) ENDIF() diff --git a/utilities/Litmus/Litmus.tar.gz b/utilities/Litmus/Litmus.tar.gz index d660516..7dd342d 100644 Binary files a/utilities/Litmus/Litmus.tar.gz and b/utilities/Litmus/Litmus.tar.gz differ