diff --git a/CMakeLists.txt b/CMakeLists.txt index f792e08..2a692f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,310 +1,320 @@ #----------------------------------------------------------------------------- # 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/rttbFunctionCreateModule.cmake) +include(cmake/rttbFunctionCheckModuleDependencies.cmake) +include(cmake/rttbFunctionUseModules.cmake) include(cmake/rttbFunctionOrganizeSources.cmake) +include(cmake/rttbMacroCreateTestModule.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 #----------------------------------------------------------------------------- +SET(RTTOOLBOX_INSTALL_VERSION_PATH "RTTB-${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}") + 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") + SET(RTTOOLBOX_INSTALL_INCLUDE_DIR "include/${RTTOOLBOX_INSTALL_VERSION_PATH}") ENDIF(NOT RTTOOLBOX_INSTALL_INCLUDE_DIR) +IF(NOT RTTOOLBOX_INSTALL_PACKAGE_DIR) + SET(RTTOOLBOX_INSTALL_PACKAGE_DIR "${RTTOOLBOX_INSTALL_LIB_DIR}/cmake/${RTTOOLBOX_INSTALL_VERSION_PATH}") +ENDIF(NOT RTTOOLBOX_INSTALL_PACKAGE_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) +# ---------------- Export targets ----------------- +SET(RTToolbox_TARGETS_FILE "${RTToolbox_BINARY_DIR}/RTToolboxTargets.cmake") +FILE(WRITE ${RTToolbox_TARGETS_FILE} "# Generated by CMake, do not edit!") + +set(targets_to_export) +get_property(module_targets GLOBAL PROPERTY RTTB_MODULE_TARGETS) +if(module_targets) + list(APPEND targets_to_export ${module_targets}) +endif() + +export(TARGETS ${targets_to_export} APPEND + FILE ${RTToolbox_TARGETS_FILE}) + # Create the RTToolboxConfig.cmake file containing the RTToolbox configuration. INCLUDE (${RTToolbox_SOURCE_DIR}/rttbGenerateRTToolboxConfig.cmake) -IF(NOT RTToolbox_INSTALL_NO_DEVELOPMENT) +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) +ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) diff --git a/README.md b/README.md index e1db17e..538ff38 100644 --- a/README.md +++ b/README.md @@ -1,271 +1,208 @@ # 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 +* [DCMTK](http://dicom.offis.de/dcmtk.php.en ) 3.6.5 or higher * [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` 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` +`b2 -j12 --with-filesystem --with-system --with-thread --with-program_options --with-date_time --with-atomic --with-chrono toolset= 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` +`b2 -j12 --with-filesystem --with-system --with-thread --with-program_options --with-date_time --with-atomic --with-chrono toolset= address-model=64 variant=release threading=multi link=shared` +Set the in the commands above accordingly. 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) -``` +To compile DCMTK with `/MD` flags (standard for all other libs), you need to set DCMTK_COMPILE_WIN32_MULTITHREADED_DLL to "ON". `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 * `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 * `DoseIndex tests`: (`testing/indices`): Computation of different dose indices (e.g. Conformation Number, Conformal Index, Conformity index) ## 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/apps/BioModelCalc/CMakeLists.txt b/apps/BioModelCalc/CMakeLists.txt index 4f9a488..2acdb58 100644 --- a/apps/BioModelCalc/CMakeLists.txt +++ b/apps/BioModelCalc/CMakeLists.txt @@ -1,5 +1,5 @@ MESSAGE (STATUS "generating app: BioModelCalc - calculating the radiobiological effect based on dose") SET(RTTB_Boost_ADDITIONAL_COMPONENT program_options) -RTTB_CREATE_APPLICATION(RTTBBioModelCalc DEPENDS RTTBCore RTTBModels RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib BoostBinaries) +RTTB_CREATE_APPLICATION(RTTBBioModelCalc DEPENDS RTTBCore RTTBModels RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib Boost) SET_TARGET_PROPERTIES(RTTBBioModelCalc PROPERTIES OUTPUT_NAME "BioModelCalc") diff --git a/apps/DoseAcc/CMakeLists.txt b/apps/DoseAcc/CMakeLists.txt index 5503fcf..ee22142 100644 --- a/apps/DoseAcc/CMakeLists.txt +++ b/apps/DoseAcc/CMakeLists.txt @@ -1,4 +1,4 @@ MESSAGE (STATUS "generating app: DoseAcc - simple dose accumulation tool") SET(RTTB_Boost_ADDITIONAL_COMPONENT program_options) -RTTB_CREATE_APPLICATION(RTTBDoseAcc DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib MatchPoint ITK BoostBinaries) +RTTB_CREATE_APPLICATION(RTTBDoseAcc DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib MatchPoint ITK Boost) SET_TARGET_PROPERTIES(RTTBDoseAcc PROPERTIES OUTPUT_NAME "DoseAcc") diff --git a/apps/DoseMap/CMakeLists.txt b/apps/DoseMap/CMakeLists.txt index 1fcb9f4..29bfdbb 100644 --- a/apps/DoseMap/CMakeLists.txt +++ b/apps/DoseMap/CMakeLists.txt @@ -1,4 +1,4 @@ MESSAGE (STATUS "generating app: DoseMap - simple dose mapping tool") SET(RTTB_Boost_ADDITIONAL_COMPONENT program_options) -RTTB_CREATE_APPLICATION(RTTBDoseMap DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBUtilsIO PACKAGE_DEPENDS MatchPoint ITK ArgumentParsingLib BoostBinaries) +RTTB_CREATE_APPLICATION(RTTBDoseMap DEPENDS RTTBCore RTTBAlgorithms RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBUtilsIO PACKAGE_DEPENDS MatchPoint ITK ArgumentParsingLib Boost) SET_TARGET_PROPERTIES(RTTBDoseMap PROPERTIES OUTPUT_NAME "DoseMap") diff --git a/apps/DoseTool/CMakeLists.txt b/apps/DoseTool/CMakeLists.txt index c1af0e1..459f5e3 100644 --- a/apps/DoseTool/CMakeLists.txt +++ b/apps/DoseTool/CMakeLists.txt @@ -1,5 +1,5 @@ MESSAGE (STATUS "generating app: DoseTool - calculating dose statistics and DVH") SET(RTTB_Boost_ADDITIONAL_COMPONENT program_options) -RTTB_CREATE_APPLICATION(RTTBDoseTool DEPENDS RTTBCore RTTBMask RTTBOtherIO RTTBAlgorithms RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib BoostBinaries) +RTTB_CREATE_APPLICATION(RTTBDoseTool DEPENDS RTTBCore RTTBMask RTTBOtherIO RTTBAlgorithms RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib Boost) SET_TARGET_PROPERTIES(RTTBDoseTool PROPERTIES OUTPUT_NAME "DoseTool") diff --git a/apps/VoxelizerTool/CMakeLists.txt b/apps/VoxelizerTool/CMakeLists.txt index 8d832d1..082e1de 100644 --- a/apps/VoxelizerTool/CMakeLists.txt +++ b/apps/VoxelizerTool/CMakeLists.txt @@ -1,4 +1,4 @@ MESSAGE (STATUS "generating app: VoxelizerTool - voxelize DICOM RTSTRUCT files") SET(RTTB_Boost_ADDITIONAL_COMPONENT program_options) -RTTB_CREATE_APPLICATION(RTTBVoxelizerTool DEPENDS RTTBMask RTTBCore RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib ITK BoostBinaries) +RTTB_CREATE_APPLICATION(RTTBVoxelizerTool DEPENDS RTTBMask RTTBCore RTTBUtilsIO PACKAGE_DEPENDS ArgumentParsingLib ITK Boost) SET_TARGET_PROPERTIES(RTTBVoxelizerTool PROPERTIES OUTPUT_NAME "VoxelizerTool") diff --git a/cmake/MacroParseArguments.cmake b/cmake/MacroParseArguments.cmake deleted file mode 100644 index c7cfc53..0000000 --- a/cmake/MacroParseArguments.cmake +++ /dev/null @@ -1,79 +0,0 @@ -# MACRO (MACRO_PARSE_ARGUMENTS prefix arg_names option_names) -# -# From http://www.cmake.org/Wiki/CMakeMacroParseArguments: -# -# The MACRO_PARSE_ARGUMENTS macro will take the arguments of another macro and -# define several variables: -# -# 1) The first argument to is a prefix to put on all variables it creates. -# 2) The second argument is a quoted list of names, -# 3) and the third argument is a quoted list of options. -# -# The rest of MACRO_PARSE_ARGUMENTS are arguments from another macro to be -# parsed. -# -# MACRO_PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...) -# -# For each item in options, MACRO_PARSE_ARGUMENTS will create a variable -# with that name, prefixed with prefix_. So, for example, if prefix is -# MY_MACRO and options is OPTION1;OPTION2, then PARSE_ARGUMENTS will create -# the variables MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These variables will -# be set to true if the option exists in the command line or false otherwise. -# -# For each item in arg_names, MACRO_PARSE_ARGUMENTS will create a variable -# with that name, prefixed with prefix_. Each variable will be filled with the -# arguments that occur after the given arg_name is encountered up to the next -# arg_name or the end of the arguments. All options are removed from these -# lists. -# -# MACRO_PARSE_ARGUMENTS also creates a prefix_DEFAULT_ARGS variable containing -# the list of all arguments up to the first arg_name encountered. - -IF(NOT COMMAND MACRO_PARSE_ARGUMENTS) - -MACRO (MACRO_PARSE_ARGUMENTS prefix arg_names option_names) - - SET(DEFAULT_ARGS) - - FOREACH (arg_name ${arg_names}) - SET(${prefix}_${arg_name}) - ENDFOREACH (arg_name) - - FOREACH (option ${option_names}) - SET(${prefix}_${option} FALSE) - ENDFOREACH (option) - - SET(current_arg_name DEFAULT_ARGS) - SET(current_arg_list) - - FOREACH (arg ${ARGN}) - - SET(larg_names ${arg_names}) - LIST(FIND larg_names "${arg}" is_arg_name) - - IF (is_arg_name GREATER -1) - - SET(${prefix}_${current_arg_name} ${current_arg_list}) - SET(current_arg_name "${arg}") - SET(current_arg_list) - - ELSE (is_arg_name GREATER -1) - - SET(loption_names ${option_names}) - LIST(FIND loption_names "${arg}" is_option) - - IF (is_option GREATER -1) - SET(${prefix}_${arg} TRUE) - ELSE (is_option GREATER -1) - SET(current_arg_list ${current_arg_list} "${arg}") - ENDIF (is_option GREATER -1) - - ENDIF (is_arg_name GREATER -1) - - ENDFOREACH (arg ${ARGN}) - - SET(${prefix}_${current_arg_name} ${current_arg_list}) - -ENDMACRO (MACRO_PARSE_ARGUMENTS) - -ENDIF(NOT COMMAND MACRO_PARSE_ARGUMENTS) diff --git a/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake b/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake index 77765d3..d9344bc 100644 --- a/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake +++ b/cmake/PackageDepends/RTTB_ArgumentParsingLib_Config.cmake @@ -1,14 +1,13 @@ #----------------------------------------------------------------------------- # ArgumentParsingLib is built automatically. Just set include dir and link directories #----------------------------------------------------------------------------- set(ArgumentParsingLib_INCLUDE_DIR ${ArgumentParsingLib_SOURCE_DIR}/main) set(ArgumentParsingLib_LIBRARY_DIR ${ArgumentParsingLib_BUILD_DIR}/main) set(ArgumentParsingLib_Boost_INCLUDE_DIR ${Boost_INCLUDE_DIRS}) set(ArgumentParsingLib_Boost_LIBRARY_DIR ${Boost_LIBRARYDIR}) set(ArgumentParsingLib_Boost_LIBRARIES ${Boost_LIBRARIES}) LIST(APPEND ALL_INCLUDE_DIRECTORIES ${ArgumentParsingLib_INCLUDE_DIR} ${ArgumentParsingLib_Boost_INCLUDE_DIR}) LIST(APPEND ALL_LIBRARIES "${CMAKE_STATIC_LIBRARY_PREFIX}ArgumentParsingLib${CMAKE_STATIC_LIBRARY_SUFFIX}") - -LINK_DIRECTORIES(${ArgumentParsingLib_LIBRARY_DIR} ${ArgumentParsingLib_Boost_LIBRARY_DIR}) +LIST(APPEND ALL_LINK_DIRECTORIES ${ArgumentParsingLib_LIBRARY_DIR} ${ArgumentParsingLib_Boost_LIBRARY_DIR}) diff --git a/cmake/PackageDepends/RTTB_BoostBinaries_Config.cmake b/cmake/PackageDepends/RTTB_BoostBinaries_Config.cmake deleted file mode 100644 index dc73c72..0000000 --- a/cmake/PackageDepends/RTTB_BoostBinaries_Config.cmake +++ /dev/null @@ -1,19 +0,0 @@ - IF(NOT DEFINED RTTB_USE_MITK_BOOST) - OPTION(RTTB_USE_MITK_BOOST "RTTB should use a boost which is available in the MITK superbuild external projects structure." OFF) - MARK_AS_ADVANCED(RTTB_USE_MITK_BOOST) - ENDIF(NOT DEFINED RTTB_USE_MITK_BOOST) - - IF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) - SET(Boost_USE_STATIC_LIBS OFF) - ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) - ELSE(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) - SET(Boost_USE_STATIC_LIBS ON) - ENDIF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) - - SET(BOOST_MIN_VERSION "1.64.0") - FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system ${RTTB_Boost_ADDITIONAL_COMPONENT} QUIET) - if(Boost_LIBRARIES) - LIST(APPEND ALL_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) - LIST(APPEND ALL_LIBRARIES ${Boost_LIBRARIES}) - link_directories(${Boost_LIBRARY_DIRS}) - endif() diff --git a/cmake/PackageDepends/RTTB_Boost_Config.cmake b/cmake/PackageDepends/RTTB_Boost_Config.cmake index 3670d99..02a5f49 100644 --- a/cmake/PackageDepends/RTTB_Boost_Config.cmake +++ b/cmake/PackageDepends/RTTB_Boost_Config.cmake @@ -1,5 +1,31 @@ - SET(BOOST_MIN_VERSION "1.64.0") - FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED QUIET) +IF(NOT DEFINED RTTB_USE_MITK_BOOST) + OPTION(RTTB_USE_MITK_BOOST "RTTB should use a boost which is available in the MITK superbuild external projects structure." OFF) + MARK_AS_ADVANCED(RTTB_USE_MITK_BOOST) +ENDIF(NOT DEFINED RTTB_USE_MITK_BOOST) - LIST(APPEND ALL_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIRS}) +IF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) + SET(Boost_USE_STATIC_LIBS OFF) + ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK) +ELSE(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) + SET(Boost_USE_STATIC_LIBS ON) +ENDIF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) +SET(BOOST_MIN_VERSION "1.64.0") + +SET(_RTTB_Boost_REQUIRED_COMPONENTS_BY_MODULE ${Boost_REQUIRED_COMPONENTS_BY_MODULE} ${RTTB_Boost_ADDITIONAL_COMPONENT}) + +SET(_RTTB_Boost_FIND_COMPONENTS ${_RTTB_Boost_REQUIRED_COMPONENTS_BY_MODULE}) +LIST(REMOVE_ITEM _RTTB_Boost_FIND_COMPONENTS "headers") +FIND_PACKAGE(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS ${_RTTB_Boost_FIND_COMPONENTS} QUIET) + +if(_RTTB_Boost_REQUIRED_COMPONENTS_BY_MODULE) + foreach(boost_component ${_RTTB_Boost_REQUIRED_COMPONENTS_BY_MODULE}) + list(APPEND ALL_LIBRARIES "Boost::${boost_component}") + endforeach() +endif() + +IF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) + IF(MSVC) + list(APPEND ALL_LIBRARIES "Boost::dynamic_linking" "bcrypt") + ENDIF(MSVC) +ENDIF(BUILD_SHARED_LIBS OR RTTB_USE_MITK_BOOST) diff --git a/cmake/PackageDepends/RTTB_DCMTK_Config.cmake b/cmake/PackageDepends/RTTB_DCMTK_Config.cmake index 91297ab..821a2f5 100644 --- a/cmake/PackageDepends/RTTB_DCMTK_Config.cmake +++ b/cmake/PackageDepends/RTTB_DCMTK_Config.cmake @@ -1,236 +1,10 @@ -#----------------------------------------------------------------------------- -# Find DCMTK -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# This part is based on the findDCMTK of CMake 2.8.8 -# it was patched because: -# 1. the find_library statement had an incomplete set -# of search paths. If building DCMTK with Visual -# Studio the libs are to be found in /lib/release -# or /lib/debug -# 2. the module DCMRT was not included (but needed by RTToolbox) -# -IF(DEFINED DCMTK_DIR) - IF(NOT IS_ABSOLUTE ${DCMTK_DIR}) - SET(DCMTK_DIR "${RTToolbox_BINARY_DIR}/${DCMTK_DIR}") - ENDIF(NOT IS_ABSOLUTE ${DCMTK_DIR}) -ENDIF(DEFINED DCMTK_DIR) - -if(NOT DCMTK_FOUND AND NOT DCMTK_DIR) - IF (NOT WIN32) - set(DCMTK_DIR "/usr/include/dcmtk/") - ENDIF(NOT WIN32) +if(NOT WIN32 AND NOT APPLE) + set(MISSING_LIBS_REQUIRED_BY_DCMTK tiff z) endif() -#ensure that we always have the variable as cache, independent from -#setting it via gui or command line -set(DCMTK_DIR ${DCMTK_DIR} CACHE PATH "Root of DCMTK tree.") - -IF(DEFINED DCMTK_SOURCE_DIR) - IF(NOT IS_ABSOLUTE ${DCMTK_SOURCE_DIR}) - SET(DCMTK_SOURCE_DIR "${RTToolbox_BINARY_DIR}/${DCMTK_SOURCE_DIR}") - ENDIF(NOT IS_ABSOLUTE ${DCMTK_SOURCE_DIR}) -ENDIF(DEFINED DCMTK_SOURCE_DIR) - -if(NOT DCMTK_FOUND AND NOT DCMTK_SOURCE_DIR) - set(DCMTK_SOURCE_DIR ${DCMTK_DIR}) -endif() - -#ensure that we always have the variable as cache, independent from -#setting it via gui or command line -set(DCMTK_SOURCE_DIR ${DCMTK_SOURCE_DIR} CACHE PATH "Root of DCMTK tree.") - -IF(NOT DEFINED RTTB_USE_MITK_DCMTK) - OPTION(RTTB_USE_MITK_DCMTK "RTTB should use a DCMTK which is available in the MITK superbuild external projects structure." OFF) - MARK_AS_ADVANCED(RTTB_USE_MITK_DCMTK) -ENDIF(NOT DEFINED RTTB_USE_MITK_DCMTK) - -OPTION(RTTB_USE_ML_DCMTK "RTTB should use a DCMTK which is available in the MeVisLab package structure." OFF) -MARK_AS_ADVANCED(RTTB_USE_ML_DCMTK) - - if(NOT DCMTK_FOUND) - set(DCMTK_FOUND True) - - set(DCMTK_DEBUG_LIB_SEARCH_PATH - ${DCMTK_DIR}/${lib}/libsrc/Debug - ${DCMTK_DIR}/${lib}/Debug - ${DCMTK_DIR}/lib/Debug - ${DCMTK_DIR}/Debug - ) - - set(DCMTK_LIB_SEARCH_PATH - ${DCMTK_DIR}/${lib}/libsrc - ${DCMTK_DIR}/${lib}/libsrc/Release - ${DCMTK_DIR}/${lib}/Release - ${DCMTK_DIR}/lib/Release - ${DCMTK_DIR}/lib - ${DCMTK_DIR} - ) - - set(DCMTK_LIB_SEARCH_NAMES - dcmdata - dcmimage - dcmimgle - dcmjpeg - dcmnet - dcmpstat - dcmqrdb - dcmdsig - dcmsr - dcmtls - dcmrt - ijg12 - ijg16 - ijg8 - ofstd - oflog - ) - - if(${RTTB_USE_ML_DCMTK}) - set(DCMTK_DEBUG_LIB_SEARCH_PATH ${DCMTK_DIR}/lib ) - set(DCMTK_LIB_SEARCH_PATH ${DCMTK_DIR}/lib ) - set(DCMTK_LIB_SEARCH_NAMES ${DCMTK_LIB_SEARCH_NAMES} zlib) - endif(${RTTB_USE_ML_DCMTK}) - - - -foreach(lib ${DCMTK_LIB_SEARCH_NAMES}) - - set(debuglib ${lib}) - - if(${RTTB_USE_MITK_DCMTK}) - set(debuglib ${lib}d) - elseif(${RTTB_USE_ML_DCMTK}) - set(debuglib ${lib}_d) - endif(${RTTB_USE_MITK_DCMTK}) - - find_library(DCMTK_${lib}_DEBUG_LIBRARY - ${debuglib} - PATHS ${DCMTK_DEBUG_LIB_SEARCH_PATH}) - - find_library(DCMTK_${lib}_LIBRARY - ${lib} - PATHS ${DCMTK_LIB_SEARCH_PATH}) - - if((${UNIX}) AND (NOT DCMTK_${lib}_DEBUG_LIBRARY)) - set(DCMTK_${lib}_DEBUG_LIBRARY ${DCMTK_${lib}_LIBRARY} CACHE PATH "Path to a library" FORCE) - endif((${UNIX}) AND (NOT DCMTK_${lib}_DEBUG_LIBRARY)) - - mark_as_advanced(DCMTK_${lib}_LIBRARY) - mark_as_advanced(DCMTK_${lib}_DEBUG_LIBRARY) - -# add_library(${lib} STATIC IMPORTED) -# set_target_properties(${lib} PROPERTIES IMPORTED_LOCATION ${DCMTK_${lib}_LIBRARY} IMPORTED_LOCATION_DEBUG ${DCMTK_${lib}_DEBUG_LIBRARY}) - - if(DCMTK_${lib}_LIBRARY ) - list(APPEND DCMTK_LIBRARIES optimized ${DCMTK_${lib}_LIBRARY}) - endif() - - if(DCMTK_${lib}_DEBUG_LIBRARY) - list(APPEND DCMTK_LIBRARIES debug ${DCMTK_${lib}_DEBUG_LIBRARY}) - endif() - - if(NOT DCMTK_${lib}_LIBRARY) - message(STATUS "Cannot find library DCMTK_${lib}_LIBRARY") - endif() - - if(NOT DCMTK_${lib}_DEBUG_LIBRARY) - message(STATUS "Cannot find library DCMTK_${lib}_DEBUG_LIBRARY") - endif() - - endforeach() - - -set(DCMTK_config_TEST_HEADER osconfig.h) -set(DCMTK_dcmdata_TEST_HEADER dctypes.h) -set(DCMTK_dcmimage_TEST_HEADER dicoimg.h) -set(DCMTK_dcmimgle_TEST_HEADER dcmimage.h) -set(DCMTK_dcmjpeg_TEST_HEADER djdecode.h) -set(DCMTK_dcmnet_TEST_HEADER assoc.h) -set(DCMTK_dcmpstat_TEST_HEADER dcmpstat.h) -set(DCMTK_dcmqrdb_TEST_HEADER dcmqrdba.h) -set(DCMTK_dcmrt_TEST_HEADER drmdose.h) -set(DCMTK_dcmsign_TEST_HEADER sicert.h) -set(DCMTK_dcmsr_TEST_HEADER dsrtree.h) -set(DCMTK_dcmtls_TEST_HEADER tlslayer.h) -set(DCMTK_ofstd_TEST_HEADER ofstdinc.h) -set(DCMTK_oflog_TEST_HEADER oflog.h) - -foreach(dir - config - dcmdata - dcmimage - dcmimgle - dcmjpeg - dcmnet - dcmpstat - dcmqrdb - dcmrt - dcmsign - dcmsr - dcmtls - ofstd - oflog) - find_path(DCMTK_${dir}_INCLUDE_DIR - ${DCMTK_${dir}_TEST_HEADER} - PATHS - ${DCMTK_DIR}/${dir}/include - ${DCMTK_DIR}/${dir} - ${DCMTK_DIR}/include/${dir} - ${DCMTK_DIR}/include/dcmtk/${dir} - ${DCMTK_DIR}/${dir}/include/dcmtk/${dir} - ${DCMTK_SOURCE_DIR}/${dir}/include - ${DCMTK_SOURCE_DIR}/${dir} - ${DCMTK_SOURCE_DIR}/dcmtk/${dir} - ${DCMTK_SOURCE_DIR}/include/${dir} - ${DCMTK_SOURCE_DIR}/include/dcmtk/${dir} - ${DCMTK_SOURCE_DIR}/${dir}/include/dcmtk/${dir} - ) - mark_as_advanced(DCMTK_${dir}_INCLUDE_DIR) - - if(DCMTK_${dir}_INCLUDE_DIR) - list(APPEND - DCMTK_INCLUDE_DIRS - ${DCMTK_${dir}_INCLUDE_DIR} ${DCMTK_SOURCE_DIR}/${dir}/include ${DCMTK_DIR}/${dir}/include) - endif() -endforeach() - -if(WIN32) - list(APPEND DCMTK_LIBRARIES iphlpapi netapi32 wsock32 ws2_32) -endif() - -if(UNIX) - list(APPEND DCMTK_LIBRARIES pthread) + find_package(DCMTK NO_MODULE REQUIRED) endif() - -if(DCMTK_ofstd_INCLUDE_DIR) - get_filename_component(DCMTK_dcmtk_INCLUDE_DIR - ${DCMTK_ofstd_INCLUDE_DIR} - PATH - CACHE) - list(APPEND DCMTK_INCLUDE_DIRS ${DCMTK_dcmtk_INCLUDE_DIR}) - mark_as_advanced(DCMTK_dcmtk_INCLUDE_DIR) -endif() - -endif() - -#----------------------------------------------------------------------------- -# RTTB part to use the found DCMTK -# -IF(NOT DCMTK_FOUND) - MESSAGE(SEND_ERROR "DCMTK development files not found.\n Please check variables (e.g. DCMTK_DIR) for include directories and libraries.\nYou may set environment variable DCMTK_DIR before pressing 'configure'") -ENDIF(NOT DCMTK_FOUND) - -IF( NOT WIN32 ) - SET(MISSING_LIBS_REQUIRED_BY_DCMTK wrap tiff) -ENDIF( NOT WIN32 ) - -LIST(APPEND ALL_INCLUDE_DIRECTORIES ${DCMTK_INCLUDE_DIRS} ${DCMTK_DIR}/include) -IF(DEFINED RTTB_USE_MITK_DCMTK) - LIST(APPEND ALL_INCLUDE_DIRECTORIES ${DCMTK_SOURCE_DIR}) -ENDIF(DEFINED RTTB_USE_MITK_DCMTK) - -LIST(APPEND ALL_LIBRARIES ${DCMTK_LIBRARIES} ${MISSING_LIBS_REQUIRED_BY_DCMTK}) +list(APPEND ALL_INCLUDE_DIRECTORIES ${DCMTK_INCLUDE_DIRS}) +list(APPEND ALL_LIBRARIES ${DCMTK_LIBRARIES} ${MISSING_LIBS_REQUIRED_BY_DCMTK}) \ No newline at end of file diff --git a/cmake/PackageDepends/RTTB_Litmus_Config.cmake b/cmake/PackageDepends/RTTB_Litmus_Config.cmake index f5d2607..f44533a 100644 --- a/cmake/PackageDepends/RTTB_Litmus_Config.cmake +++ b/cmake/PackageDepends/RTTB_Litmus_Config.cmake @@ -1,16 +1,15 @@ #----------------------------------------------------------------------------- # Litmus is built automatically. Just set include dir and link directories #----------------------------------------------------------------------------- set(Litmus_INCLUDE_DIRS "${LITMUS_SOURCE_DIR}/code/common;${LITMUS_SOURCE_DIR}/code/itk;${LITMUS_BUILD_DIR}") set(Litmus_LIBRARY_DIRS "${LITMUS_BUILD_DIR}/bin") #these test modules need LitmusITK. ITK is available as it is needed by all submodules IF (BUILD_Tester_All OR (BUILD_Tester_IO AND BUILD_IO_ITK) OR (BUILD_Tester_Interpolation AND BUILD_InterpolationMatchPointTransformation)) SET(Litmus_ITK "LitmusITK") ENDIF() LIST(APPEND ALL_INCLUDE_DIRECTORIES ${Litmus_INCLUDE_DIRS}) LIST(APPEND ALL_LIBRARIES LitmusCommon ${Litmus_ITK}) - -LINK_DIRECTORIES(${Litmus_LIBRARY_DIRS}) +LIST(APPEND ALL_LINK_DIRECTORIES ${Litmus_LIBRARY_DIRS}) diff --git a/cmake/PackageDepends/RTTB_RTTBData_Config.cmake b/cmake/PackageDepends/RTTB_RTTBData_Config.cmake new file mode 100644 index 0000000..95b23a0 --- /dev/null +++ b/cmake/PackageDepends/RTTB_RTTBData_Config.cmake @@ -0,0 +1,3 @@ +#----------------------------------------------------------------------------- +# RTTBData is automatically fetched. Just set include dir and link directories +#----------------------------------------------------------------------------- diff --git a/cmake/moduleExports.h.in b/cmake/moduleExports.h.in index 0e79d53..ca7df50 100644 --- a/cmake/moduleExports.h.in +++ b/cmake/moduleExports.h.in @@ -1,36 +1,36 @@ // ----------------------------------------------------------------------- // 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 "RTToolboxConfigure.h" #ifndef @MODULE_NAME@_EXPORTS_H #define @MODULE_NAME@_EXPORTS_H #if defined(WIN32) && !defined(RTTB_STATIC) - #ifdef @MODULE_PROVIDES@_EXPORTS - #define @MODULE_EXPORT_DEFINE@ __declspec(dllexport) + #ifdef @MODULE_NAME@_EXPORTS + #define @MODULE_EXPORT_DEFINE@ __declspec(dllexport) #else - #define @MODULE_EXPORT_DEFINE@ __declspec(dllimport) + #define @MODULE_EXPORT_DEFINE@ __declspec(dllimport) #endif #else #define @MODULE_EXPORT_DEFINE@ #endif #ifndef _CMAKE_MODULENAME - #ifdef @MODULE_PROVIDES@_EXPORTS + #ifdef @MODULE_NAME@_EXPORTS #define _CMAKE_MODULENAME "@MODULE_NAME@" #endif #endif #endif diff --git a/cmake/rttbFunctionCheckModuleDependencies.cmake b/cmake/rttbFunctionCheckModuleDependencies.cmake new file mode 100644 index 0000000..fd5108e --- /dev/null +++ b/cmake/rttbFunctionCheckModuleDependencies.cmake @@ -0,0 +1,69 @@ +#! Checks if all required modules and packages exist and stores missing +#! dependencies in . +#! +#! Usage: +#! +#! rttb_check_module_dependencies( +#! MODULES +#! PACKAGES +#! MISSING_DEPENDENCIES_VAR +#! MODULE_DEPENDENCIES_VAR +#! PACKAGE_DEPENDENCIES_VAR ) +#! +function(rttb_check_module_dependencies) + + set(_macro_params + MISSING_DEPENDENCIES_VAR # variable for storing missing dependencies + MODULE_DEPENDENCIES_VAR # variable for storing all module dependencies + PACKAGE_DEPENDENCIES_VAR # variable for storing all package dependencies + ) + + set(_macro_multiparams + MODULES # MITK modules which the given TARGET uses + PACKAGES # MITK packages which the given TARGET uses + ) + + set(_macro_options ) + + cmake_parse_arguments(CHECK "" "${_macro_params}" "${_macro_multiparams}" ${ARGN}) + + set(missing_deps ) + set(depends ${CHECK_MODULES}) + set(package_depends ${CHECK_PACKAGES}) + set(module_names ) + set(package_names ) + + foreach(dep ${depends}) + if(NOT dep STREQUAL "PUBLIC" AND NOT dep STREQUAL "PRIVATE" AND NOT dep STREQUAL "INTERFACE") + if(NOT TARGET ${dep}) + list(APPEND missing_deps ${dep}) + endif() + list(APPEND module_names ${dep}) + endif() + endforeach() + + set(package_names) + if(package_depends) + _rttb_parse_package_args(${package_depends}) + set(package_names ${PUBLIC_PACKAGE_NAMES} ${PRIVATE_PACKAGE_NAMES} ${INTERFACE_PACKAGE_NAMES}) + list(REMOVE_DUPLICATES package_names) + foreach(_package ${package_names}) + if((DEFINED MITK_USE_${_package}) AND NOT (${MITK_USE_${_package}})) + list(APPEND missing_deps ${_package}) + endif() + endforeach() + endif() + + if(missing_deps) + list(REMOVE_DUPLICATES missing_deps) + if(CHECK_MISSING_DEPENDENCIES_VAR) + set(${CHECK_MISSING_DEPENDENCIES_VAR} ${missing_deps} PARENT_SCOPE) + endif() + endif() + if(CHECK_MODULE_DEPENDENCIES_VAR) + set(${CHECK_MODULE_DEPENDENCIES_VAR} ${module_names} PARENT_SCOPE) + endif() + if(CHECK_PACKAGE_DEPENDENCIES_VAR) + set(${CHECK_PACKAGE_DEPENDENCIES_VAR} ${package_names} PARENT_SCOPE) + endif() +endfunction() diff --git a/cmake/rttbFunctionCreateModule.cmake b/cmake/rttbFunctionCreateModule.cmake new file mode 100644 index 0000000..0eb28fc --- /dev/null +++ b/cmake/rttbFunctionCreateModule.cmake @@ -0,0 +1,254 @@ +################################################################## +# +# RTTB_CREATE_MODULE +# +#! Creates a module for the automatic module dependency system within RTTB. +#! +#! Example: +#! +#! \code +#! RTTB_CREATE_MODULE2( NewModule +#! DEPENDS PUBLIC RTTBCore +#! PACKAGE_DEPENDS +#! PRIVATE Boost|System +#! PUBLIC ITK|IO +#! \endcode +#! +#! A modules source files are specified in a separate CMake file usually +#! called files.cmake, located in the module root directory. The +#! RTTB_CREATE_MODULE2() macro evaluates the following CMake variables +#! from the files.cmake file: +#! +#! - CPP_FILES A list of .cpp files +#! - H_FILES A list of .h files without a corresponding .cpp file +#! - TXX_FILES A list of .txx files +#! - DOX_FILES A list of .dox Doxygen files +#! +#! List of variables available after the function is called: +#! - MODULE_NAME +#! - MODULE_TARGET +#! - MODULE_IS_ENABLED +#! +#! Parameters (mandatory): +#! \param The module name (also used as target name) +#! +#! Parameters (all optional): +#! +#! \param DEPRECATED_SINCE Marks this modules as deprecated since +#! \param DESCRIPTION A description for this module +#! +#! Multi-value Parameters (all optional): +#! +#! \param INCLUDE_DIRS Include directories for this module: +#! \verbatim +#! [[PUBLIC|PRIVATE|INTERFACE] ...]... +#! \endverbatim +#! The default scope for include directories is PUBLIC. +#! \param DEPENDS List of module dependencies: +#! \verbatim +#! [[PUBLIC|PRIVATE|INTERFACE] ...]... +#! \endverbatim +#! The default scope for module dependencies is PUBLIC. +#! \param PACKAGE_DEPENDS List of public packages dependencies (e.g. Qt, VTK, etc.). +#! Package dependencies have the following syntax: +#! \verbatim +#! [PUBLIC|PRIVATE|INTERFACE] PACKAGE[|COMPONENT1[+COMPONENT2]...] +#! \endverbatim +#! The default scope for package dependencies is PRIVATE. +#! +################################################################## +function(RTTB_CREATE_MODULE) + + set(_macro_params + DEPRECATED_SINCE # marks this modules as deprecated + DESCRIPTION # a description for this module + ) + + set(_macro_multiparams + INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE] + DEPENDS # list of modules this module depends on: [PUBLIC|PRIVATE|INTERFACE] + PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.): [PUBLIC|PRIVATE|INTERFACE] + TARGET_DEPENDS # list of CMake targets this module should depend on: [PUBLIC|PRIVATE|INTERFACE] + ) + + set(_macro_options + FORCE_STATIC # force building this module as a static library + HEADERS_ONLY # this module is a headers-only library + C_MODULE # compile all source files as C sources + CXX_MODULE # compile all source files as C++ sources + ) + + cmake_parse_arguments(MODULE "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN}) + + set(MODULE_NAME ${MODULE_UNPARSED_ARGUMENTS}) + + # ----------------------------------------------------------------- + # Sanity checks + + if(NOT MODULE_NAME) + message(SEND_ERROR "The module name must not be empty") + endif() + + set(_Module_type Module) + + set(MODULE_FILES_CMAKE files.cmake) + + # ----------------------------------------------------------------- + # Check if module should be build + + set(MODULE_TARGET ${MODULE_NAME}) + + # assume worst case + set(MODULE_IS_ENABLED 0) + # first we check if we have an explicit module build list + if(RTTB_MODULES_TO_BUILD) + list(FIND RTTB_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX) + if(_MOD_INDEX EQUAL -1) + set(MODULE_IS_EXCLUDED 1) + endif() + endif() + + if(NOT MODULE_IS_EXCLUDED) + message(STATUS "configuring Module ${MODULE_NAME}...") + # first of all we check for the dependencies + _rttb_parse_package_args(${MODULE_PACKAGE_DEPENDS}) + rttb_check_module_dependencies(MODULES ${MODULE_DEPENDS} + PACKAGES ${PACKAGE_NAMES} + MISSING_DEPENDENCIES_VAR _MISSING_DEP + PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES) + + if(_MISSING_DEP) + message("${_Module_type} ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") + set(MODULE_IS_ENABLED 0) + else() + set(MODULE_IS_ENABLED 1) + # now check for every package if it is enabled. This overlaps a bit with + # RTTB_CHECK_MODULE ... + foreach(_package ${PACKAGE_NAMES}) + if((DEFINED RTTB_USE_${_package}) AND NOT (RTTB_USE_${_package})) + message("${_Module_type} ${MODULE_NAME} won't be built. Turn on RTTB_USE_${_package} if you want to use it.") + set(MODULE_IS_ENABLED 0) + break() + endif() + endforeach() + endif() + endif() + + # ----------------------------------------------------------------- + # Start creating the module + + if(MODULE_IS_ENABLED) + + # clear variables defined in files.cmake + set(CPP_FILES ) + set(H_FILES ) + set(TXX_FILES ) + set(DOX_FILES ) + + set(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT) + + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE}") + include(${MODULE_FILES_CMAKE}) + endif() + + if(CPP_FILES) + set(MODULE_HEADERS_ONLY 0) + else() + set(MODULE_HEADERS_ONLY 1) + endif() + + if(MODULE_FORCE_STATIC) + set(_STATIC ${RTTB_WIN32_FORCE_STATIC) + else() + set(_STATIC ) + endif(MODULE_FORCE_STATIC) + + ORGANIZE_SOURCES( + SOURCE ${CPP_FILES} + HEADER ${H_FILES} + TXX ${TXX_FILES} + DOC ${DOX_FILES} + ) + + set(coverage_sources + ${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES}) + + # --------------------------------------------------------------- + # Create the actual module target + + if(MODULE_HEADERS_ONLY) + add_library(${MODULE_TARGET} INTERFACE) + else() + add_library(${MODULE_TARGET} ${_STATIC} + ${coverage_sources} ${CPP_FILES_GENERATED} + ${DOX_FILES}) + set_property(TARGET ${MODULE_TARGET} PROPERTY FOLDER "${RTTB_ROOT_FOLDER}/Modules") + + # add the target name to a global property which is used in the top-level + # CMakeLists.txt file to export the target + set_property(GLOBAL APPEND PROPERTY RTTB_MODULE_TARGETS ${MODULE_TARGET}) + + if(MODULE_DEPRECATED_SINCE) + set_property(TARGET ${MODULE_TARGET} PROPERTY RTTB_MODULE_DEPRECATED_SINCE ${MODULE_DEPRECATED_SINCE}) + endif() + + # create export macros + CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/moduleExports.h.in ${RTTB_MODULES_CONF_DIR}/${MODULE_NAME}Exports.h @ONLY) + + target_include_directories(${MODULE_TARGET} PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${RTTB_MODULES_CONF_DIR}) + + INSTALL(TARGETS ${MODULE_TARGET} EXPORT RTToolboxExport + RUNTIME DESTINATION ${RTTOOLBOX_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries + LIBRARY DESTINATION ${RTTOOLBOX_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries + ARCHIVE DESTINATION ${RTTOOLBOX_INSTALL_LIB_DIR} COMPONENT Development) + + endif() + + # --------------------------------------------------------------- + # Properties for both header-only and compiled modules + + if(MODULE_HEADERS_ONLY) + set(_module_property_type INTERFACE) + else() + set(_module_property_type PUBLIC) + endif() + + if(MODULE_TARGET_DEPENDS) + target_link_libraries(${MODULE_TARGET} ${MODULE_TARGET_DEPENDS}) + endif() + + set(DEPENDS "${MODULE_DEPENDS}") + if(DEPENDS OR MODULE_PACKAGE_DEPENDS) + rttb_use_modules(TARGET ${MODULE_TARGET} + MODULES ${DEPENDS} + PACKAGES ${MODULE_PACKAGE_DEPENDS} + ) + endif() + + # add include directories + target_include_directories(${MODULE_TARGET} ${_module_property_type} .) + target_include_directories(${MODULE_TARGET} ${_module_property_type} ${MODULE_INCLUDE_DIRS}) + + IF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) + INSTALL(FILES ${H_FILES} ${TXX_FILES} + DESTINATION ${RTTOOLBOX_INSTALL_INCLUDE_DIR} COMPONENT Development) + ENDIF(NOT RTTOOLBOX_INSTALL_NO_DEVELOPMENT) + + endif() + + # ----------------------------------------------------------------- + # Record missing dependency information + + if(_MISSING_DEP) + if(MODULE_DESCRIPTION) + set(MODULE_DESCRIPTION "${MODULE_DESCRIPTION} (missing dependencies: ${_MISSING_DEP})") + else() + set(MODULE_DESCRIPTION "(missing dependencies: ${_MISSING_DEP})") + endif() + endif() + + set(MODULE_NAME ${MODULE_NAME} PARENT_SCOPE) + set(MODULE_TARGET ${MODULE_TARGET} PARENT_SCOPE) + set(MODULE_IS_ENABLED ${MODULE_IS_ENABLED} PARENT_SCOPE) + +endfunction() diff --git a/cmake/rttbFunctionOrganizeSources.cmake b/cmake/rttbFunctionOrganizeSources.cmake index c60ecda..c6e96f2 100644 --- a/cmake/rttbFunctionOrganizeSources.cmake +++ b/cmake/rttbFunctionOrganizeSources.cmake @@ -1,51 +1,53 @@ FUNCTION(ORGANIZE_SOURCES) # this functions gets a filelist as input and looks # for corresponding h-files to add them to the project. # additionally files are grouped in source-groups. # No parameters explicitly declared here, because # we want to allow for variable argument lists, which # are later access by the keyword FOREACH(MYFILE ${ARGV}) # output: after calling the macro, files that were found # correspondigly to the given files are stored in the # variable: # ${CORRESPONDING_H_FILES} # ${CORRESPONDING_TXX_FILES} # Globbed can be found in the variables # ${GLOBBED_TXX_FILES} (CURRENTLY COMMENTED OUT) # ${GLOBBED_DOX_FILES} - MACRO_PARSE_ARGUMENTS(_ORG "HEADER;SOURCE;TXX;DOC" "" ${ARGN}) + cmake_parse_arguments(_ORG "" "" "HEADER;SOURCE;TXX;DOC" ${ARGN}) SET(CORRESPONDING__H_FILES "" ) SET(GLOBBED__H_FILES "" ) IF(_ORG_HEADER) FOREACH(_file ${_ORG_SOURCE}) STRING(REGEX REPLACE "(.*)\\.(txx|tpp|cpp|c|cxx)$" "\\1.h" H_FILE ${_file}) IF(EXISTS ${H_FILE}) LIST(APPEND CORRESPONDING__H_FILES "${H_FILE}") ENDIF() ENDFOREACH() ELSE() FILE(GLOB_RECURSE GLOBBED__H_FILES *.h) ENDIF() - - + + set(CORRESPONDING__H_FILES ${CORRESPONDING__H_FILES} PARENT_SCOPE) + set(GLOBBED__H_FILES ${GLOBBED__H_FILES} PARENT_SCOPE) + #_MACRO_APPEND_TO_LIST(_ORG_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/") SOURCE_GROUP("Source Files" FILES ${_ORG_SOURCE}) #_MACRO_APPEND_TO_LIST(_ORG_TXX "${CMAKE_CURRENT_SOURCE_DIR}/") SOURCE_GROUP("Template Files" FILES ${_ORG_TXX}) #_MACRO_APPEND_TO_LIST(_ORG_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/") SOURCE_GROUP("Header Files" FILES ${_ORG_HEADER} ${CORRESPONDING__H_FILES} ${GLOBBED__H_FILES}) #_MACRO_APPEND_TO_LIST(_ORG_DOC "${CMAKE_CURRENT_SOURCE_DIR}/") SOURCE_GROUP("Doxygen Files" FILES ${_ORG_DOC}) ENDFUNCTION(ORGANIZE_SOURCES) diff --git a/cmake/rttbFunctionUseModules.cmake b/cmake/rttbFunctionUseModules.cmake new file mode 100644 index 0000000..e286195 --- /dev/null +++ b/cmake/rttbFunctionUseModules.cmake @@ -0,0 +1,169 @@ +function(_rttb_parse_package_args) + set(package_list ${ARGN}) + + set(PUBLIC_PACKAGE_NAMES ) + set(PRIVATE_PACKAGE_NAMES ) + set(INTERFACE_PACKAGE_NAMES ) + + set(_package_visibility PRIVATE) + foreach(_package ${package_list}) + if(_package STREQUAL "PUBLIC" OR _package STREQUAL "PRIVATE" OR _package STREQUAL "INTERFACE") + set(_package_visibility ${_package}) + else() + list(APPEND packages ${_package}) + set(_package_name ) + set(_package_components_list ) + string(REPLACE "|" ";" _package_list ${_package}) + if("${_package_list}" STREQUAL "${_package}") + set(_package_name ${_package}) + else() + list(GET _package_list 0 _package_name) + list(GET _package_list 1 _package_components) + string(REPLACE "+" ";" _package_components_list "${_package_components}") + if(NOT _package_name OR NOT _package_components) + message(SEND_ERROR "PACKAGE argument syntax wrong. ${_package} is not of the form PACKAGE[|COMPONENT1[+COMPONENT2]...]") + endif() + endif() + list(APPEND ${_package_visibility}_PACKAGE_NAMES ${_package_name}) + list(APPEND ${_package_visibility}_${_package_name}_REQUIRED_COMPONENTS ${_package_components_list}) + endif() + endforeach() + + # remove duplicates and set package components in parent scope + foreach(_package_visibility PUBLIC PRIVATE INTERFACE) + foreach(_package_name ${${_package_visibility}_PACKAGE_NAMES}) + if(${_package_visibility}_${_package_name}_REQUIRED_COMPONENTS) + list(REMOVE_DUPLICATES ${_package_visibility}_${_package_name}_REQUIRED_COMPONENTS) + endif() + set(${_package_visibility}_${_package_name}_REQUIRED_COMPONENTS ${${_package_visibility}_${_package_name}_REQUIRED_COMPONENTS} PARENT_SCOPE) + endforeach() + endforeach() + + set(PUBLIC_PACKAGE_NAMES ${PUBLIC_PACKAGE_NAMES} PARENT_SCOPE) + set(PRIVATE_PACKAGE_NAMES ${PRIVATE_PACKAGE_NAMES} PARENT_SCOPE) + set(INTERFACE_PACKAGE_NAMES ${INTERFACE_PACKAGE_NAMES} PARENT_SCOPE) + set(PACKAGE_NAMES ${PUBLIC_PACKAGE_NAMES} ${PRIVATE_PACKAGE_NAMES} ${INTERFACE_PACKAGE_NAMES} PARENT_SCOPE) +endfunction() + +function(_include_package_config pkg_config_file) + # wrap the inclusion of the RTTB__Config.cmake file in a + # function to create a scope for its variables; this allows + # multiple inclusions of the file in the parent scope + include(${pkg_config_file}) + set(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} PARENT_SCOPE) + set(ALL_LINK_DIRECTORIES ${ALL_LINK_DIRECTORIES} PARENT_SCOPE) + set(ALL_LIBRARIES ${ALL_LIBRARIES} PARENT_SCOPE) + set(ALL_COMPILE_DEFINITIONS ${ALL_COMPILE_DEFINITIONS} PARENT_SCOPE) + set(ALL_COMPILE_OPTIONS ${ALL_COMPILE_OPTIONS} PARENT_SCOPE) +endfunction() + +#! This CMake function sets up the necessary include directories, +#! linker dependencies, and compile flags for a given target which +#! depends on a set of RTTB modules or packages. +#! +#! A package argument is of the form +#! +#! [PUBLIC|PRIVATE|INTERFACE] PACKAGE[|COMPONENT1[+COMPONENT2]...] +#! +#! where PACKAGE is the package name (e.g. VTK) and components are +#! the names of required package components or libraries. +#! +#! If a dependency is not available, an error is thrown. +function(rttb_use_modules) + + set(_macro_params + TARGET # The target name (required) + ) + + set(_macro_multiparams + MODULES # MITK modules which the given TARGET uses + PACKAGES # MITK packages which the given TARGET uses + ) + + set(_macro_options ) + + cmake_parse_arguments(USE "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN}) + + # Sanity checks + if(NOT USE_TARGET) + message(SEND_ERROR "Required TARGET argument missing.") + elseif(NOT TARGET ${USE_TARGET}) + message(SEND_ERROR "The given TARGET argument ${USE_TARGET} is not a valid target") + endif() + + set(depends ${USE_MODULES}) + set(package_depends ${USE_PACKAGES}) + + if(depends) + # Iterate over all module dependencies + foreach(dependency ${depends}) + if(TARGET ${dependency} AND NOT MODULE_IS_DEPRECATED) + get_target_property(_is_interface_lib ${dependency} TYPE) + if(NOT _is_interface_lib) + get_target_property(_dependency_deprecated_since ${dependency} RTTB_MODULE_DEPRECATED_SINCE) + if(_dependency_deprecated_since) + message(WARNING "Module ${dependency} is deprecated since ${_dependency_deprecated_since}") + endif() + endif() + endif() + endforeach() + target_link_libraries(${USE_TARGET} PUBLIC ${depends}) + endif() + + # Parse package dependencies + if(package_depends) + _rttb_parse_package_args(${package_depends}) + + # Some package config files rely on a + # properly set "MODULE_NAME" variable for the current target. + set(MODULE_NAME ${USE_TARGET}) + # Read all package information + foreach(_package_visibility INTERFACE PUBLIC PRIVATE) + foreach(_package ${${_package_visibility}_PACKAGE_NAMES}) + set(ALL_INCLUDE_DIRECTORIES) + set(ALL_LINK_DIRECTORIES) + set(ALL_LIBRARIES) + set(ALL_COMPILE_DEFINITIONS) + set(ALL_COMPILE_OPTIONS) + + set(${_package}_REQUIRED_COMPONENTS_BY_MODULE ${${_package_visibility}_${_package}_REQUIRED_COMPONENTS}) + set(_package_found 0) + foreach(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) + if((NOT DEFINED RTTB_USE_${_package} OR RTTB_USE_${_package}) AND EXISTS "${dir}/RTTB_${_package}_Config.cmake") + _include_package_config("${dir}/RTTB_${_package}_Config.cmake") + set(_package_found 1) + break() + endif() + endforeach() + if(_package_found) + if(ALL_INCLUDE_DIRECTORIES) + list(REMOVE_DUPLICATES ALL_INCLUDE_DIRECTORIES) + target_include_directories(${USE_TARGET} SYSTEM ${_package_visibility} ${ALL_INCLUDE_DIRECTORIES}) + endif() + if(ALL_LINK_DIRECTORIES) + list(REMOVE_DUPLICATES ALL_LINK_DIRECTORIES) + target_link_directories(${USE_TARGET} ${_package_visibility} ${ALL_LINK_DIRECTORIES}) + endif() + if(ALL_LIBRARIES) + # Don't remove "duplicats" because ALL_LIBRARIES may be of the form: + # "general;bla;debug;blad;general;foo;debug;food" + target_link_libraries(${USE_TARGET} ${_package_visibility} ${ALL_LIBRARIES}) + endif() + if(ALL_COMPILE_DEFINITIONS) + list(REMOVE_DUPLICATES ALL_COMPILE_DEFINITIONS) + # Compile definitions are always added "PRIVATE" to avoid multiple definitions + # on the command line due to transitive and direct dependencies adding the + # same definitions. + target_compile_definitions(${USE_TARGET} PRIVATE ${ALL_COMPILE_DEFINITIONS}) + endif() + if(ALL_COMPILE_OPTIONS) + list(REMOVE_DUPLICATES ALL_COMPILE_OPTIONS) + target_compile_options(${USE_TARGET} ${_package_visibility} ${ALL_COMPILE_OPTIONS}) + endif() + else() + message(SEND_ERROR "Missing package: ${_package}") + endif() + endforeach() + endforeach() + endif() +endfunction() diff --git a/cmake/rttbMacroCheckModule.cmake b/cmake/rttbMacroCheckModule.cmake deleted file mode 100644 index 5b47e3d..0000000 --- a/cmake/rttbMacroCheckModule.cmake +++ /dev/null @@ -1,73 +0,0 @@ -# Usage: RTTB_CHECK_MODULE(RESULT_VAR [dependencies ...] ) -# check if all required modules exist and stores missing module names in RESULT_VAR. -MACRO(RTTB_CHECK_MODULE RESULT_VAR) - SET(${RESULT_VAR} "") - SET(DEPENDS "") - SET(DEPENDS_BEFORE "not initialized") - SET(PACKAGE_DEPENDS "") - - - # check for each parameter if it is a package (3rd party) - FOREACH(package ${ARGN}) - SET(is_package) - FOREACH(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) - IF(EXISTS "${dir}/RTTB_${package}_Config.cmake") - LIST(APPEND PACKAGE_DEPENDS ${package}) - SET(is_package 1) - BREAK() - ENDIF() - ENDFOREACH() - IF(NOT is_package) - LIST(APPEND DEPENDS ${package}) - ENDIF() - ENDFOREACH(package) - - # create a list of all lowercase module names - FILE(GLOB _ALL_MODULES RELATIVE ${RTTB_MODULES_CONF_DIR} ${RTTB_MODULES_CONF_DIR}/*Config.cmake) - SET(_ALL_MODULES_LOWERCASE "") - FOREACH(_module ${_ALL_MODULES}) - STRING(TOLOWER ${_module} _lowermodule) - LIST(APPEND _ALL_MODULES_LOWERCASE ${_lowermodule}) - ENDFOREACH(_module ${_ALL_MODULES}) - - WHILE(NOT "${DEPENDS}" STREQUAL "${DEPENDS_BEFORE}") - SET(DEPENDS_BEFORE ${DEPENDS}) - FOREACH(dependency ${DEPENDS}) - - SET(_dependency_file_name ${dependency}Config.cmake) - LIST(FIND _ALL_MODULES ${_dependency_file_name} _index) - IF(NOT _index EQUAL -1) - INCLUDE(${RTTB_MODULES_CONF_DIR}/${dependency}Config.cmake) - IF(${dependency}_IS_ENABLED) - LIST(APPEND DEPENDS ${${dependency}_DEPENDS}) - LIST(APPEND PACKAGE_DEPENDS ${${dependency}_PACKAGE_DEPENDS}) - ELSE(${dependency}_IS_ENABLED) - LIST(APPEND ${RESULT_VAR} ${dependency}) - LIST(REMOVE_DUPLICATES ${RESULT_VAR}) - ENDIF(${dependency}_IS_ENABLED) - ELSE(NOT _index EQUAL -1) - STRING(TOLOWER ${_dependency_file_name} _lowercase_dependency_file_name) - LIST(FIND _ALL_MODULES_LOWERCASE ${_lowercase_dependency_file_name} _index_lower) - IF(NOT _index_lower EQUAL -1) - LIST(GET _ALL_MODULES ${_index_lower} _real_module_name) - STRING(REPLACE "Config.cmake" "" _real_module_name ${_real_module_name}) - MESSAGE("Warning: case mismatch for module name ${dependency}, did you mean ${_real_module_name} ?") - ENDIF(NOT _index_lower EQUAL -1) - LIST(APPEND ${RESULT_VAR} ${dependency}) - LIST(REMOVE_DUPLICATES ${RESULT_VAR}) - ENDIF(NOT _index EQUAL -1) - - ENDFOREACH(dependency) - LIST(REMOVE_DUPLICATES DEPENDS) - LIST(REMOVE_DUPLICATES PACKAGE_DEPENDS) - LIST(SORT DEPENDS) - LIST(SORT PACKAGE_DEPENDS) - ENDWHILE() - - FOREACH(_package PACKAGE_DEPENDS) - IF((DEFINED RTTB_USE_${_package}) AND NOT (${RTTB_USE_${_package}})) - LIST(APPEND ${RESULT_VAR} ${_package}) - ENDIF() - ENDFOREACH() - -ENDMACRO(RTTB_CHECK_MODULE) diff --git a/cmake/rttbMacroCreateApplication.cmake b/cmake/rttbMacroCreateApplication.cmake index 65fbff5..b554910 100644 --- a/cmake/rttbMacroCreateApplication.cmake +++ b/cmake/rttbMacroCreateApplication.cmake @@ -1,82 +1,106 @@ ################################################################## # # RTTB_CREATE_APPLICATION # #! Creates a application using the automatic module dependency system within RTTB. #! Configurations are generated in the moduleConf directory. #! #! USAGE: #! #! \code #! MAP_CREATE_APPLICATION( #! [INCLUDE_DIRS ] #! [DEPENDS ] #! [PACKAGE_DEPENDS ] #! \endcode #! #! \param APP_NAME_IN The name for the new application # ################################################################## MACRO(RTTB_CREATE_APPLICATION APP_NAME_IN) - MACRO_PARSE_ARGUMENTS(APP - "INCLUDE_DIRS;DEPENDS;PACKAGE_DEPENDS" - "FORCE_STATIC;HEADERS_ONLY" - ${ARGN}) + + set(_macro_params) + + set(_macro_multiparams + INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE] + DEPENDS # list of modules this module depends on: [PUBLIC|PRIVATE|INTERFACE] + PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.): [PUBLIC|PRIVATE|INTERFACE] + ) + + set(_macro_options) + + cmake_parse_arguments(APP "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN}) SET(APP_NAME ${APP_NAME_IN}) SET(WAIT_FOR_DEPENDENCY_LIBS "ArgumentParsingLib") #each application depends on ArgumentParsingLib + set(MODULE_FILES_CMAKE files.cmake) + # assume worst case + SET(APP_IS_ENABLED 0) MESSAGE(STATUS "configuring Application ${APP_NAME}...") # first of all we check for the dependencies - RTTB_CHECK_MODULE(_MISSING_DEP ${APP_DEPENDS}) - IF(_MISSING_DEP) + + + _rttb_parse_package_args(${APP_DEPENDS}) + rttb_check_module_dependencies(MODULES ${MODULE_DEPENDS} + PACKAGES ${PACKAGE_NAMES} + MISSING_DEPENDENCIES_VAR _MISSING_DEP + PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES) + + if(_MISSING_DEP) MESSAGE("Application ${APP_NAME} won't be built, missing dependency: ${_MISSING_DEP}") SET(APP_IS_ENABLED 0) - ELSE(_MISSING_DEP) + else() SET(APP_IS_ENABLED 1) # now check for every package if it is enabled. This overlaps a bit with # RTTB_CHECK_MODULE ... - FOREACH(_package ${APP_PACKAGE_DEPENDS}) - IF((DEFINED RTTB_USE_${_package}) AND NOT (RTTB_USE_${_package})) - MESSAGE("Application ${APP_NAME} won't be built. Turn on RTTB_USE_${_package} if you want to use it.") - SET(APP_IS_ENABLED 0) - ENDIF() - ENDFOREACH() + foreach(_package ${PACKAGE_NAMES}) + if((DEFINED RTTB_USE_${_package}) AND NOT (RTTB_USE_${_package})) + message("Application ${APP_NAME} won't be built. Turn on RTTB_USE_${_package} if you want to use it.") + set(MODULE_IS_ENABLED 0) + break() + endif() + endforeach() + endif() - IF(APP_IS_ENABLED) - SET(DEPENDS "${APP_DEPENDS}") - SET(DEPENDS_BEFORE "not initialized") - SET(PACKAGE_DEPENDS "${APP_PACKAGE_DEPENDS}") - RTTB_USE_MODULE("${APP_DEPENDS}") - IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/source) - SET(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} ${CMAKE_CURRENT_SOURCE_DIR}/source) - ENDIF() + IF(APP_IS_ENABLED) - IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include) - SET(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} ${CMAKE_CURRENT_SOURCE_DIR}/include) - ENDIF() + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE}") + include(${MODULE_FILES_CMAKE}) + endif() - INCLUDE_DIRECTORIES(. ${ALL_INCLUDE_DIRECTORIES}) - INCLUDE(files.cmake) + ORGANIZE_SOURCES(SOURCE ${CPP_FILES} + HEADER ${H_FILES} + TPP ${TPP_FILES} + DOC ${DOX_FILES} + ) - ORGANIZE_SOURCES(SOURCE ${CPP_FILES} - HEADER ${H_FILES} - TPP ${TPP_FILES} - DOC ${DOX_FILES} - ) + SET(coverage_sources ${CPP_FILES} ${H_FILES} ${TXX_FILES}) - LINK_DIRECTORIES(${ALL_LIBRARY_DIRS}) + ADD_EXECUTABLE(${APP_NAME} ${coverage_sources}) - SET(coverage_sources ${CPP_FILES} ${H_FILES} ${TXX_FILES}) + SET(DEPENDS "${APP_DEPENDS}") + SET(DEPENDS_BEFORE "not initialized") + rttb_use_modules(TARGET ${APP_NAME} + MODULES ${DEPENDS} + PACKAGES ${APP_PACKAGE_DEPENDS} + ) - ADD_EXECUTABLE(${APP_NAME} ${coverage_sources}) + set (_app_include_dirs . ${APP_INCLUDE_DIRS}) + IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/source) + SET(_app_include_dirs ${_app_include_dirs} ${CMAKE_CURRENT_SOURCE_DIR}/source) + ENDIF() + IF (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include) + SET(_app_include_dirs ${_app_include_dirs} ${CMAKE_CURRENT_SOURCE_DIR}/include) + ENDIF() + target_include_directories(${APP_NAME} PUBLIC ${_app_include_dirs}) - TARGET_LINK_LIBRARIES(${APP_NAME} ${ALL_LIBRARIES}) - # Necessary so the build waits for libs to build - ADD_DEPENDENCIES(${APP_NAME} ${WAIT_FOR_DEPENDENCY_LIBS}) - ENDIF(APP_IS_ENABLED) + INSTALL(TARGETS ${APP_NAME} EXPORT RTToolboxExport + RUNTIME DESTINATION ${RTTOOLBOX_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries + LIBRARY DESTINATION ${RTTOOLBOX_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries + ARCHIVE DESTINATION ${RTTOOLBOX_INSTALL_LIB_DIR} COMPONENT Development) - ENDIF(_MISSING_DEP) + ENDIF(APP_IS_ENABLED) ENDMACRO(RTTB_CREATE_APPLICATION) diff --git a/cmake/rttbMacroCreateModule.cmake b/cmake/rttbMacroCreateModule.cmake deleted file mode 100644 index 7ca3219..0000000 --- a/cmake/rttbMacroCreateModule.cmake +++ /dev/null @@ -1,118 +0,0 @@ -################################################################## -# -# RTTB_CREATE_MODULE -# -#! Creates a module for the automatic module dependency system within RTTB. -#! Configurations are generated in the moduleConf directory. -#! -#! USAGE: -#! -#! \code -#! RTTB_CREATE_MODULE( -#! [INCLUDE_DIRS ] -#! [INTERNAL_INCLUDE_DIRS ] -#! [DEPENDS ] -#! [PROVIDES ] -#! [PACKAGE_DEPENDS ] -#! [EXPORT_DEFINE ] -#! \endcode -#! -#! \param MODULE_NAME_IN The name for the new module -# -################################################################## -MACRO(RTTB_CREATE_MODULE MODULE_NAME_IN) - MACRO_PARSE_ARGUMENTS(MODULE - "INCLUDE_DIRS;INTERNAL_INCLUDE_DIRS;DEPENDS;DEPENDS_INTERNAL;PROVIDES;PACKAGE_DEPENDS;EXPORT_DEFINE;ADDITIONAL_LIBS" - "FORCE_STATIC;HEADERS_ONLY" - ${ARGN}) - - SET(MODULE_NAME ${MODULE_NAME_IN}) - - # assume worst case - SET(MODULE_IS_ENABLED 0) - # first we check if we have an explicit module build list - IF(RTTB_MODULES_TO_BUILD) - LIST(FIND RTTB_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX) - IF(_MOD_INDEX EQUAL -1) - SET(MODULE_IS_EXCLUDED 1) - ENDIF() - ENDIF() - - IF(NOT MODULE_IS_EXCLUDED) - MESSAGE(STATUS "configuring Module ${MODULE_NAME}...") - # first of all we check for the dependencies - RTTB_CHECK_MODULE(_MISSING_DEP ${MODULE_DEPENDS}) - IF(_MISSING_DEP) - MESSAGE("Module ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") - SET(MODULE_IS_ENABLED 0) - ELSE(_MISSING_DEP) - SET(MODULE_IS_ENABLED 1) - # now check for every package if it is enabled. This overlaps a bit with - # RTTB_CHECK_MODULE ... - FOREACH(_package ${MODULE_PACKAGE_DEPENDS}) - IF((DEFINED RTTB_USE_${_package}) AND NOT (RTTB_USE_${_package})) - MESSAGE("Module ${MODULE_NAME} won't be built. Turn on RTTB_USE_${_package} if you want to use it.") - SET(MODULE_IS_ENABLED 0) - ENDIF() - ENDFOREACH() - - IF(MODULE_IS_ENABLED) - SET(MODULE_IS_ENABLED 1) - _RTTB_CREATE_MODULE_CONF() - IF(NOT MODULE_EXPORT_DEFINE) - SET(MODULE_EXPORT_DEFINE ${MODULE_NAME}_EXPORT) - ENDIF(NOT MODULE_EXPORT_DEFINE) - - CONFIGURE_FILE(${RTToolbox_SOURCE_DIR}/cmake/moduleExports.h.in ${RTTB_MODULES_CONF_DIR}/${MODULE_NAME}Exports.h @ONLY) - - SET(DEPENDS "${MODULE_DEPENDS}") - SET(DEPENDS_BEFORE "not initialized") - SET(PACKAGE_DEPENDS "${MODULE_PACKAGE_DEPENDS}") - RTTB_USE_MODULE("${MODULE_DEPENDS}") - - # ok, now create the module itself - INCLUDE_DIRECTORIES(. ${ALL_INCLUDE_DIRECTORIES}) - INCLUDE(files.cmake) - - ORGANIZE_SOURCES(SOURCE ${CPP_FILES} - HEADER ${H_FILES} - TXX ${TXX_FILES} - DOC ${DOX_FILES} - ) - - IF(MODULE_FORCE_STATIC) - SET(_STATIC ${RTTB_WIN32_FORCE_STATIC}) - ENDIF(MODULE_FORCE_STATIC) - - IF(NOT MODULE_HEADERS_ONLY) - IF(ALL_LIBRARY_DIRS) - # LINK_DIRECTORIES applies only to targets which are added after the call to LINK_DIRECTORIES - LINK_DIRECTORIES(${ALL_LIBRARY_DIRS}) - ENDIF(ALL_LIBRARY_DIRS) - - SET(coverage_sources ${CPP_FILES} ${H_FILES} ${TXX_FILES}) - SET_PROPERTY(SOURCE ${coverage_sources} APPEND PROPERTY LABELS ${MODULE_SUBPROJECTS}) - - ADD_LIBRARY(${MODULE_PROVIDES} ${_STATIC} ${coverage_sources} ${CPP_FILES_GENERATED}) - - SET_TARGET_PROPERTIES(${MODULE_PROVIDES} PROPERTIES ${RTToolbox_LIBRARY_PROPERTIES} OUTPUT_NAME ${MODULE_PROVIDES}-${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR} OUTPUT_NAME_DEBUG ${MODULE_PROVIDES}-D-${RTToolbox_VERSION_MAJOR}.${RTToolbox_VERSION_MINOR}) - EXPORT(TARGETS ${MODULE_PROVIDES} APPEND FILE ${RTToolbox_TARGETS_FILE}) - - INSTALL(TARGETS ${MODULE_PROVIDES} EXPORT RTToolboxExport - RUNTIME DESTINATION ${RTTOOLBOX_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries - LIBRARY DESTINATION ${RTTOOLBOX_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries - ARCHIVE DESTINATION ${RTTOOLBOX_INSTALL_LIB_DIR} COMPONENT Development) - - IF(ALL_LIBRARIES) - TARGET_LINK_LIBRARIES(${MODULE_PROVIDES} ${ALL_LIBRARIES}) - ENDIF(ALL_LIBRARIES) - ENDIF() - - ENDIF(MODULE_IS_ENABLED) - ENDIF(_MISSING_DEP) - ENDIF(NOT MODULE_IS_EXCLUDED) - - IF(NOT MODULE_IS_ENABLED) - _RTTB_CREATE_MODULE_CONF() - ENDIF(NOT MODULE_IS_ENABLED) -ENDMACRO(RTTB_CREATE_MODULE) diff --git a/cmake/rttbMacroCreateTestModule.cmake b/cmake/rttbMacroCreateTestModule.cmake index 9c03e26..61799b6 100644 --- a/cmake/rttbMacroCreateTestModule.cmake +++ b/cmake/rttbMacroCreateTestModule.cmake @@ -1,175 +1,213 @@ ################################################################## # -# RTTB_CREATE_MODULE +# RTTB_CREATE_TEST_MODULE # #! Creates a module for the automatic module dependency system within RTTB. #! Configurations are generated in the moduleConf directory. #! #! USAGE: #! #! \code -#! RTTB_CREATE_MODULE( +#! RTTB_CREATE_TEST_MODULE( #! [INCLUDE_DIRS ] -#! [INTERNAL_INCLUDE_DIRS ] #! [DEPENDS ] -#! [PROVIDES ] #! [PACKAGE_DEPENDS ] #! [HEADER_TEST] #! \endcode #! #! \param MODULE_NAME_IN The name for the new module # ################################################################## MACRO(RTTB_CREATE_TEST_MODULE MODULE_NAME_IN) - MACRO_PARSE_ARGUMENTS(MODULE - "INCLUDE_DIRS;INTERNAL_INCLUDE_DIRS;DEPENDS;DEPENDS_INTERNAL;PROVIDES;PACKAGE_DEPENDS;ADDITIONAL_LIBS" - "HEADER_TESTS" - ${ARGN}) - - SET(MODULE_NAME "${RTToolbox_PREFIX}${MODULE_NAME_IN}Tests") - SET(WAIT_FOR_DEPENDENCY_LIBS "Litmus") #each test depends on Litmus - - # assume worst case - SET(MODULE_IS_ENABLED 0) - # first we check if we have an explicit module build list - IF(RTTB_MODULES_TO_BUILD) - LIST(FIND RTTB_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX) - IF(_MOD_INDEX EQUAL -1) - SET(MODULE_IS_EXCLUDED 1) - ENDIF() - ENDIF() - - IF(NOT MODULE_IS_EXCLUDED) - MESSAGE(STATUS "configuring Tests ${MODULE_NAME}...") - # first of all we check for the dependencies - RTTB_CHECK_MODULE(_MISSING_DEP ${MODULE_DEPENDS}) - IF(_MISSING_DEP) - MESSAGE("Module ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") - SET(MODULE_IS_ENABLED 0) - ELSE(_MISSING_DEP) - SET(MODULE_IS_ENABLED 1) - # now check for every package if it is enabled. This overlaps a bit with - # RTTB_CHECK_MODULE ... - FOREACH(_package ${MODULE_PACKAGE_DEPENDS}) - IF((DEFINED RTTB_USE_${_package}) AND NOT (RTTB_USE_${_package})) - MESSAGE("Module ${MODULE_NAME} won't be built. Turn on RTTB_USE_${_package} if you want to use it.") - SET(MODULE_IS_ENABLED 0) - ENDIF() - ENDFOREACH() - - IF(NOT MODULE_PROVIDES) - SET(MODULE_PROVIDES ${MODULE_NAME}) - ENDIF(NOT MODULE_PROVIDES) - - SET(DEPENDS "${MODULE_DEPENDS}") - SET(DEPENDS_BEFORE "not initialized") - SET(PACKAGE_DEPENDS "${MODULE_PACKAGE_DEPENDS}") - RTTB_USE_MODULE("${MODULE_DEPENDS}") - - # ok, now create the module itself - INCLUDE_DIRECTORIES(. ${ALL_INCLUDE_DIRECTORIES}) - INCLUDE(files.cmake) - - ORGANIZE_SOURCES(SOURCE ${CPP_FILES} - HEADER ${H_FILES} - TXX ${TXX_FILES} - DOC ${DOX_FILES} - ) - - IF(ALL_LIBRARY_DIRS) - # LINK_DIRECTORIES applies only to targets which are added after the call to LINK_DIRECTORIES - LINK_DIRECTORIES(${ALL_LIBRARY_DIRS}) - ENDIF(ALL_LIBRARY_DIRS) - - SET(coverage_sources ${CPP_FILES} ${H_FILES} ${TXX_FILES}) - - ADD_EXECUTABLE(${MODULE_PROVIDES} ${coverage_sources} ${CPP_FILES_GENERATED}) - - IF(ALL_LIBRARIES) - TARGET_LINK_LIBRARIES(${MODULE_PROVIDES} ${ALL_LIBRARIES}) - ENDIF(ALL_LIBRARIES) - - IF(MODULE_HEADER_TESTS) - MESSAGE(STATUS "generating header tests ${MODULE_NAME}...") - SET(HEADER_TEST_CPP "${CMAKE_CURRENT_BINARY_DIR}/${RTToolbox_PREFIX}${MODULE_NAME_IN}HeaderTest.cpp") - MESSAGE(STATUS "generating header tests ${HEADER_TEST_CPP}") - - FILE(WRITE ${HEADER_TEST_CPP} ${RTTB_HEADER_TESTS_HEADER}) - FOREACH(_h_file ${H_FILES}) - FILE(APPEND ${HEADER_TEST_CPP} "#include <${_h_file}>\n") - ENDFOREACH() - FILE(APPEND ${HEADER_TEST_CPP} ${RTTB_HEADER_TESTS_FOOTER}) - - ADD_EXECUTABLE(${RTToolbox_PREFIX}${MODULE_NAME_IN}HeaderTest ${HEADER_TEST_CPP}) - - IF(ALL_LIBRARIES) - TARGET_LINK_LIBRARIES(${RTToolbox_PREFIX}${MODULE_NAME_IN}HeaderTest ${ALL_LIBRARIES}) - ENDIF(ALL_LIBRARIES) - - ENDIF(MODULE_HEADER_TESTS) - - # Necessary so the build waits for libs to build - ADD_DEPENDENCIES(${MODULE_NAME} ${WAIT_FOR_DEPENDENCY_LIBS}) - - #----------------------------------------------------------------------------- - - IF(RTToolbox_BINARY_DIR) - SET(RTToolbox_SYSTEM_INFORMATION_DIR ${RTToolbox_BINARY_DIR}) - ELSE(RTToolbox_BINARY_DIR) - SET(RTToolbox_SYSTEM_INFORMATION_DIR ${RTTBTesting_BINARY_DIR}) - ENDIF(RTToolbox_BINARY_DIR) - - WRITE_FILE( - "${RTToolbox_SYSTEM_INFORMATION_DIR}/testing/HTML/TestingResults/Sites/${SITE}/${BUILDNAME}/BuildNameNotes.xml" - - "\n" - "\n" - "\n" - "\n" - "Wed Oct 24 1:00:00 EST\n" - "\n" - "Here is some basic information:\n" - "RTToolbox_SOURCE_DIR = ${RTToolbox_SOURCE_DIR}\n" - "RTToolbox_BINARY_DIR = ${RTToolbox_BINARY_DIR}\n" - "RTTBTesting_SOURCE_DIR = ${RTTBTesting_SOURCE_DIR}\n" - "RTTBTesting_BINARY_DIR = ${RTTBTesting_BINARY_DIR}\n" - "CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}\n" - "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}\n" - "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}\n" - "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}\n" - "CMAKE_SYSTEM = ${CMAKE_SYSTEM}\n" - "CMAKE_MAKE_PROGRAM = ${CMAKE_MAKE_PROGRAM}\n" - "\n" - "\n" - "\n" - "\n" - ) - - ENDIF(_MISSING_DEP) - ENDIF(NOT MODULE_IS_EXCLUDED) + + set(_macro_params) + + set(_macro_multiparams + INCLUDE_DIRS # include directories: [PUBLIC|PRIVATE|INTERFACE] + DEPENDS # list of modules this module depends on: [PUBLIC|PRIVATE|INTERFACE] + PACKAGE_DEPENDS # list of "packages this module depends on (e.g. Qt, VTK, etc.): [PUBLIC|PRIVATE|INTERFACE] + ) + + set(_macro_options + HEADER_TESTS + ) + + cmake_parse_arguments(MODULE "${_macro_options}" "${_macro_params}" "${_macro_multiparams}" ${ARGN}) + + SET(MODULE_NAME "${RTToolbox_PREFIX}${MODULE_NAME_IN}Tests") + SET(WAIT_FOR_DEPENDENCY_LIBS "Litmus") #each test depends on Litmus + set(MODULE_FILES_CMAKE files.cmake) + + # ----------------------------------------------------------------- + # Check if module should be build + + set(MODULE_TARGET ${MODULE_NAME}) + + # assume worst case + SET(MODULE_IS_ENABLED 0) + # first we check if we have an explicit module build list + IF(RTTB_MODULES_TO_BUILD) + LIST(FIND RTTB_MODULES_TO_BUILD ${MODULE_NAME} _MOD_INDEX) + IF(_MOD_INDEX EQUAL -1) + SET(MODULE_IS_EXCLUDED 1) + ENDIF() + ENDIF() + + IF(NOT MODULE_IS_EXCLUDED) + MESSAGE(STATUS "configuring Tests ${MODULE_NAME}...") + # first of all we check for the dependencies + _rttb_parse_package_args(${MODULE_PACKAGE_DEPENDS}) + rttb_check_module_dependencies(MODULES ${MODULE_DEPENDS} + PACKAGES ${PACKAGE_NAMES} + MISSING_DEPENDENCIES_VAR _MISSING_DEP + PACKAGE_DEPENDENCIES_VAR PACKAGE_NAMES) + + if(_MISSING_DEP) + message("${_Module_type} ${MODULE_NAME} won't be built, missing dependency: ${_MISSING_DEP}") + set(MODULE_IS_ENABLED 0) + else() + set(MODULE_IS_ENABLED 1) + # now check for every package if it is enabled. This overlaps a bit with + # RTTB_CHECK_MODULE ... + foreach(_package ${PACKAGE_NAMES}) + if((DEFINED RTTB_USE_${_package}) AND NOT (RTTB_USE_${_package})) + message("${_Module_type} ${MODULE_NAME} won't be built. Turn on RTTB_USE_${_package} if you want to use it.") + set(MODULE_IS_ENABLED 0) + break() + endif() + endforeach() + endif() + endif() + + # ----------------------------------------------------------------- + # Start creating the module + + if(MODULE_IS_ENABLED) + + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FILES_CMAKE}") + include(${MODULE_FILES_CMAKE}) + endif() + + if(CPP_FILES) + set(MODULE_HEADERS_ONLY 0) + else() + set(MODULE_HEADERS_ONLY 1) + endif() + + if(MODULE_FORCE_STATIC) + set(_STATIC ${RTTB_WIN32_FORCE_STATIC) + else() + set(_STATIC ) + endif(MODULE_FORCE_STATIC) + + ORGANIZE_SOURCES( + SOURCE ${CPP_FILES} + HEADER ${H_FILES} + TXX ${TXX_FILES} + DOC ${DOX_FILES} + ) + + set(coverage_sources + ${CPP_FILES} ${H_FILES} ${GLOBBED__H_FILES} ${CORRESPONDING__H_FILES} ${TXX_FILES}) + + ADD_EXECUTABLE(${MODULE_TARGET} ${coverage_sources} ${CPP_FILES_GENERATED}) + + SET(DEPENDS "${MODULE_DEPENDS}") + SET(DEPENDS_BEFORE "not initialized") + + rttb_use_modules(TARGET ${MODULE_TARGET} + MODULES ${DEPENDS} + PACKAGES ${MODULE_PACKAGE_DEPENDS} + ) + + # add include directories + target_include_directories(${MODULE_TARGET} PUBLIC .) + target_include_directories(${MODULE_TARGET} PUBLIC ${MODULE_INCLUDE_DIRS}) + + IF(MODULE_HEADER_TESTS) + MESSAGE(STATUS "generating header tests ${MODULE_NAME}...") + SET(HEADER_TEST_CPP "${CMAKE_CURRENT_BINARY_DIR}/${RTToolbox_PREFIX}${MODULE_NAME_IN}HeaderTest.cpp") + MESSAGE(STATUS "generating header tests ${HEADER_TEST_CPP}") + + FILE(WRITE ${HEADER_TEST_CPP} ${RTTB_HEADER_TESTS_HEADER}) + FOREACH(_h_file ${H_FILES}) + FILE(APPEND ${HEADER_TEST_CPP} "#include <${_h_file}>\n") + ENDFOREACH() + FILE(APPEND ${HEADER_TEST_CPP} ${RTTB_HEADER_TESTS_FOOTER}) + + ADD_EXECUTABLE(${RTToolbox_PREFIX}${MODULE_NAME_IN}HeaderTest ${HEADER_TEST_CPP}) + + SET(DEPENDS "${MODULE_DEPENDS}") + SET(DEPENDS_BEFORE "not initialized") + + rttb_use_modules(TARGET ${RTToolbox_PREFIX}${MODULE_NAME_IN}HeaderTest + MODULES ${DEPENDS} + PACKAGES ${MODULE_PACKAGE_DEPENDS} + ) + + ENDIF(MODULE_HEADER_TESTS) + + # Necessary so the build waits for libs to build + ADD_DEPENDENCIES(${MODULE_NAME} ${WAIT_FOR_DEPENDENCY_LIBS}) + + #----------------------------------------------------------------------------- + + IF(RTToolbox_BINARY_DIR) + SET(RTToolbox_SYSTEM_INFORMATION_DIR ${RTToolbox_BINARY_DIR}) + ELSE(RTToolbox_BINARY_DIR) + SET(RTToolbox_SYSTEM_INFORMATION_DIR ${RTTBTesting_BINARY_DIR}) + ENDIF(RTToolbox_BINARY_DIR) + + WRITE_FILE( + "${RTToolbox_SYSTEM_INFORMATION_DIR}/testing/HTML/TestingResults/Sites/${SITE}/${BUILDNAME}/BuildNameNotes.xml" + + "\n" + "\n" + "\n" + "\n" + "Wed Oct 24 1:00:00 EST\n" + "\n" + "Here is some basic information:\n" + "RTToolbox_SOURCE_DIR = ${RTToolbox_SOURCE_DIR}\n" + "RTToolbox_BINARY_DIR = ${RTToolbox_BINARY_DIR}\n" + "RTTBTesting_SOURCE_DIR = ${RTTBTesting_SOURCE_DIR}\n" + "RTTBTesting_BINARY_DIR = ${RTTBTesting_BINARY_DIR}\n" + "CMAKE_C_COMPILER = ${CMAKE_C_COMPILER}\n" + "CMAKE_C_FLAGS = ${CMAKE_C_FLAGS}\n" + "CMAKE_CXX_COMPILER = ${CMAKE_CXX_COMPILER}\n" + "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}\n" + "CMAKE_SYSTEM = ${CMAKE_SYSTEM}\n" + "CMAKE_MAKE_PROGRAM = ${CMAKE_MAKE_PROGRAM}\n" + "\n" + "\n" + "\n" + "\n" + ) + + endif() ENDMACRO(RTTB_CREATE_TEST_MODULE) SET(RTTB_HEADER_TESTS_HEADER "// -----------------------------------------------------------------------\n" "// RTToolbox - DKFZ radiotherapy quantitative evaluation library\n" "//\n" "// (c) Copyright 2007, DKFZ, Heidelberg, Germany\n" "// ALL RIGHTS RESERVED\n" "//\n" "// THIS FILE CONTAINS CONFIDENTIAL AND PROPRIETARY INFORMATION OF DKFZ.\n" "// ANY DUPLICATION, MODIFICATION, DISTRIBUTION, OR\n" "// DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY PROHIBITED\n" "// WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF DKFZ.\n" "//\n" "//------------------------------------------------------------------------\n" "// Automatically generated header test file \n" "#if defined(_MSC_VER)\n" "#pragma warning ( disable : 4786 )\n" "#endif\n" "#include \n") SET(RTTB_HEADER_TESTS_FOOTER "\nint main ( int , char* )\n" "{\n" " return EXIT_SUCCESS;\n" "}\n") diff --git a/cmake/rttbMacroUseModule.cmake b/cmake/rttbMacroUseModule.cmake deleted file mode 100644 index 6c43016..0000000 --- a/cmake/rttbMacroUseModule.cmake +++ /dev/null @@ -1,65 +0,0 @@ -# Usage: RTTB_USE_MODULE([dependencies ...] ) -# loads module config files of all dependencies specified. -MACRO(RTTB_USE_MODULE) - SET(DEPENDS "") - SET(DEPENDS_BEFORE "not initialized") - - # check for each parameter if it is a package (3rd party) - FOREACH(package ${ARGN}) - SET(is_package) - FOREACH(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) - IF(EXISTS "${dir}/RTTB_${package}_Config.cmake") - LIST(APPEND PACKAGE_DEPENDS ${package}) - SET(is_package 1) - BREAK() - ENDIF() - ENDFOREACH() - IF(NOT is_package) - LIST(APPEND DEPENDS ${package}) - ENDIF() - ENDFOREACH(package) - - # go through all module dependencies and get there dependencies for modules and packages - WHILE(NOT "${DEPENDS}" STREQUAL "${DEPENDS_BEFORE}") - SET(DEPENDS_BEFORE ${DEPENDS}) - FOREACH(dependency ${DEPENDS}) - INCLUDE(${RTTB_MODULES_CONF_DIR}/${dependency}Config.cmake) - LIST(APPEND DEPENDS ${${dependency}_DEPENDS}) - LIST(APPEND PACKAGE_DEPENDS ${${dependency}_PACKAGE_DEPENDS}) - ENDFOREACH(dependency) - IF(DEPENDS) - LIST(REMOVE_DUPLICATES DEPENDS) - LIST(SORT DEPENDS) - ENDIF(DEPENDS) - IF(PACKAGE_DEPENDS) - LIST(REMOVE_DUPLICATES PACKAGE_DEPENDS) - LIST(SORT PACKAGE_DEPENDS) - ENDIF(PACKAGE_DEPENDS) - ENDWHILE() - - # now go through all module dependencies and get dirs and libraries - FOREACH(dependency ${DEPENDS} ${MODULE_DEPENDS_INTERNAL}) - INCLUDE(${RTTB_MODULES_CONF_DIR}/${dependency}Config.cmake) - SET(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} ${${dependency}_INCLUDE_DIRS}) - SET(ALL_LIBRARIES ${ALL_LIBRARIES} ${${dependency}_PROVIDES}) - SET(ALL_LIBRARY_DIRS ${ALL_LIBRARY_DIRS} ${${dependency}_LIBRARY_DIRS}) - ENDFOREACH(dependency) - - # now go through all package dependencies and include there config file - FOREACH(package ${PACKAGE_DEPENDS}) - FOREACH(dir ${MODULES_PACKAGE_DEPENDS_DIRS}) - IF(EXISTS "${dir}/RTTB_${package}_Config.cmake") - INCLUDE("${dir}/RTTB_${package}_Config.cmake") - BREAK() - ENDIF() - ENDFOREACH() - ENDFOREACH(package) - - SET(ALL_LIBRARIES ${ALL_LIBRARIES} ${MODULE_ADDITIONAL_LIBS}) - SET(ALL_INCLUDE_DIRECTORIES ${ALL_INCLUDE_DIRECTORIES} ${MODULE_INCLUDE_DIRS} ${MODULE_INTERNAL_INCLUDE_DIRS} ${RTTB_MODULES_CONF_DIR}) - - IF(ALL_LIBRARY_DIRS) - LIST(REMOVE_DUPLICATES ALL_LIBRARY_DIRS) - ENDIF(ALL_LIBRARY_DIRS) - -ENDMACRO(RTTB_USE_MODULE) diff --git a/code/algorithms/CMakeLists.txt b/code/algorithms/CMakeLists.txt index 6178418..9cda14e 100644 --- a/code/algorithms/CMakeLists.txt +++ b/code/algorithms/CMakeLists.txt @@ -1,2 +1,2 @@ -RTTB_CREATE_MODULE(RTTBAlgorithms DEPENDS RTTBCore PACKAGE_DEPENDS Boost) - +RTTB_CREATE_MODULE(RTTBAlgorithms + DEPENDS PUBLIC RTTBCore) diff --git a/code/algorithms/rttbDoseToVolumeMeasureCollection.h b/code/algorithms/rttbDoseToVolumeMeasureCollection.h index c335296..ba462a9 100644 --- a/code/algorithms/rttbDoseToVolumeMeasureCollection.h +++ b/code/algorithms/rttbDoseToVolumeMeasureCollection.h @@ -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. // //------------------------------------------------------------------------ #ifndef __DOSE_TO_VOLUME_MEASURE_COLLECTION_H #define __DOSE_TO_VOLUME_MEASURE_COLLECTION_H #include "rttbMeasureCollection.h" #include #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace algorithms { /*! @class DoseToVolumeMeasureCollection @brief This class handels the access to the DoseToVolumeMeasureCollection elements for a specific complex statistic @note _referenceDose has to be set to use getValueRelative() otherwise an exception is thrown */ class RTTBAlgorithms_EXPORT DoseToVolumeMeasureCollection : public MeasureCollection { public: rttbClassMacro(DoseToVolumeMeasureCollection, MeasureCollection) typedef std::map DoseToVolumeFunctionType; private: complexStatistics _name; DoseTypeGy _referenceDose; DoseToVolumeFunctionType _values; public: DoseToVolumeMeasureCollection(complexStatistics name, DoseTypeGy referenceDose = -1); /*! @brief This has to be set >=0 to use getValueRelative() */ void setReferenceDose(DoseTypeGy referenceDose); void insertValue(DoseTypeGy dose, VolumeType volume); /*! @brief Gets the volume irradiated with a dose >= x, depending on the complexStatistics name. @return Return absolute volume in absolute cm^3. @exception InvalidDoseException if the vector values is empty or _referenceDose is -1 @exception NoDataException if the requested Dose is not in the vector */ VolumeType getValue(DoseTypeGy xVolumeAbsolute) const; VolumeType getValue(DoseTypeGy xVolumeAbsolute, bool findNearestValue, DoseTypeGy& nearestXDose) const; VolumeType getValueRelative(DoseTypeGy xDoseRelative) const; VolumeType getValueRelative(DoseTypeGy xDoseRelative, bool findNearestValue, DoseTypeGy& nearestXDose) const; DoseToVolumeFunctionType getAllValues() const; - - friend bool operator==(const DoseToVolumeMeasureCollection& volumeToDoseMesureCollection, const DoseToVolumeMeasureCollection& otherVolumeToDoseMesureCollection); }; + + RTTBAlgorithms_EXPORT bool operator==(const DoseToVolumeMeasureCollection& volumeToDoseMesureCollection, const DoseToVolumeMeasureCollection& otherVolumeToDoseMesureCollection); } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/algorithms/rttbVolumeToDoseMeasureCollection.h b/code/algorithms/rttbVolumeToDoseMeasureCollection.h index c9e4f71..9602e93 100644 --- a/code/algorithms/rttbVolumeToDoseMeasureCollection.h +++ b/code/algorithms/rttbVolumeToDoseMeasureCollection.h @@ -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. // //------------------------------------------------------------------------ #ifndef __VOLUME_TO_DOSE_MEASURE_COLLECTION_H #define __VOLUME_TO_DOSE_MEASURE_COLLECTION_H #include "rttbMeasureCollection.h" #include #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace algorithms { /*! @class VolumeToDoseMeasureCollection @brief This class handels the access to the VolumeToDoseMeasureCollection elements for a specific complex statistic @note _volume has to be set to use getValueRelative() otherwise an exception is thrown */ class RTTBAlgorithms_EXPORT VolumeToDoseMeasureCollection : public MeasureCollection { public: rttbClassMacro(VolumeToDoseMeasureCollection, MeasureCollection) typedef std::map VolumeToDoseFunctionType; private: complexStatistics _name; VolumeType _volume; VolumeToDoseFunctionType _values; public: VolumeToDoseMeasureCollection(complexStatistics name, VolumeType volume = -1); /*! @brief This has to be set >=0 to use getValueRelative() */ void setVolume(VolumeType volume); void insertValue(VolumeType volume, DoseTypeGy dose); /*! @brief Gets the x of the current volume, depending on the complexStatistics name. @return Return dose value in Gy. @exception InvalidDoseException if the vector values is empty @exception DataNotAvailableException if _volume is not set */ DoseTypeGy getValue(VolumeType xVolumeAbsolute) const; DoseTypeGy getValue(VolumeType xVolumeAbsolute, bool findNearestValue, VolumeType& nearestXDose) const; DoseTypeGy getValueRelative(VolumeType xDoseRelative) const; DoseTypeGy getValueRelative(VolumeType xDoseRelative, bool findNearestValue, VolumeType& nearestXDose) const; VolumeToDoseFunctionType getAllValues() const; - - friend bool operator==(const VolumeToDoseMeasureCollection& volumeToDoseMesureCollection, const VolumeToDoseMeasureCollection& otherVolumeToDoseMesureCollection); }; + + RTTBAlgorithms_EXPORT bool operator==(const VolumeToDoseMeasureCollection& volumeToDoseMesureCollection, const VolumeToDoseMeasureCollection& otherVolumeToDoseMesureCollection); } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/core/CMakeLists.txt b/code/core/CMakeLists.txt index eb85b02..e240faf 100644 --- a/code/core/CMakeLists.txt +++ b/code/core/CMakeLists.txt @@ -1,2 +1,4 @@ -RTTB_CREATE_MODULE(RTTBCore PACKAGE_DEPENDS BoostBinaries) - +RTTB_CREATE_MODULE(RTTBCore + PACKAGE_DEPENDS + PUBLIC Boost|headers + PRIVATE Boost|filesystem) diff --git a/code/core/files.cmake b/code/core/files.cmake index 5f2cbff..3180ba9 100644 --- a/code/core/files.cmake +++ b/code/core/files.cmake @@ -1,58 +1,59 @@ SET(CPP_FILES rttbAccessorWithGeoInfoBase.cpp rttbDoseIteratorInterface.cpp rttbDVH.cpp rttbDVHCalculator.cpp rttbDVHSet.cpp rttbGenericDoseIterator.cpp rttbGenericMaskedDoseIterator.cpp rttbGeometricInfo.cpp rttbMaskedDoseIteratorInterface.cpp rttbMaskVoxel.cpp rttbStructure.cpp rttbStructureSet.cpp rttbStrVectorStructureSetGenerator.cpp rttbUtils.cpp + rttbMutableMaskAccessorInterface.cpp ) SET(H_FILES rttbAccessorInterface.h rttbAccessorWithGeoInfoBase.h rttbBaseType.h rttbDataNotAvailableException.h rttbDoseAccessorInterface.h rttbDoseIteratorInterface.h rttbDoseAccessorGeneratorBase.h rttbDoseAccessorGeneratorInterface.h rttbDVH.h rttbDVHCalculator.h rttbDVHGeneratorInterface.h rttbDVHSet.h rttbException.h rttbExceptionMacros.h rttbGenericDoseIterator.h rttbGenericMaskedDoseIterator.h rttbGeometricInfo.h rttbIndexConversionInterface.h rttbIndexOutOfBoundsException.h rttbInvalidDoseException.h rttbInvalidParameterException.h rttbMappingOutsideOfImageException.h rttbMaskAccessorGeneratorBase.h rttbMaskAccessorGeneratorInterface.h rttbMaskAccessorInterface.h rttbMaskAccessorProcessorBase.h rttbMaskAccessorProcessorInterface.h rttbMaskedDoseIteratorInterface.h rttbMaskVoxel.h rttbMutableDoseAccessorInterface.h rttbMutableMaskAccessorInterface.h rttbNullPointerException.h rttbPaddingException.h rttbStructure.h rttbStructureSet.h rttbStructureSetGeneratorInterface.h rttbStrVectorStructureSetGenerator.h rttbUtils.h rttbCommon.h ) diff --git a/code/core/rttbDVH.h b/code/core/rttbDVH.h index 59e75f3..6db285c 100644 --- a/code/core/rttbDVH.h +++ b/code/core/rttbDVH.h @@ -1,213 +1,213 @@ // ----------------------------------------------------------------------- // 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 __DVH_H #define __DVH_H #include #include #include #include "boost/shared_ptr.hpp" #include "rttbBaseType.h" #include "rttbCommon.h" #include "RTTBCoreExports.h" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace core { /*! @class DVH @brief This is a class representing a dose volume histogram (DVH) */ class RTTBCore_EXPORT DVH { public: using DataDifferentialType = std::deque; rttbClassMacroNoParent(DVH); private: /*! @brief Differential dvh data index is the dose bin, value is the voxel number (sub voxel accuracy) of the dose bin */ DataDifferentialType _dataDifferential; /*! @brief Absolute dose value of a dose-bin in Gy */ DoseTypeGy _deltaD; /*! @brief Volume of a voxel in cm3 */ DoseVoxelVolumeType _deltaV; IDType _structureID; IDType _doseID; IDType _voxelizationID; StructureLabel _label; DoseStatisticType _maximum; DoseStatisticType _minimum; DoseStatisticType _mean; DoseStatisticType _modal; DVHVoxelNumber _numberOfVoxels; DoseStatisticType _median; DoseStatisticType _stdDeviation; DoseStatisticType _variance; DataDifferentialType _dataCumulative; /*! @brief DVH initialization The DVH is initialized and all statistical values are calculated. @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ void init(); /*! @brief Calculate the cumulative data of dvh */ void calcCumulativeDVH(); public: ~DVH(); /*! @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ DVH(const DataDifferentialType& aDataDifferential, const DoseTypeGy& aDeltaD, const DoseVoxelVolumeType& aDeltaV, const IDType& aStructureID, const IDType& aDoseID); /*! @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ DVH(const DataDifferentialType& aDataDifferential, DoseTypeGy aDeltaD, DoseVoxelVolumeType aDeltaV, const IDType& aStructureID, const IDType& aDoseID, const IDType& aVoxelizationID); DVH(const DVH& copy); /*! @throw if _deltaV or _deltaD are zero @throw is _data differential is empty */ DVH& operator=(const DVH& copy); - /*! equality operator - DVHs are considered equal if the following are equal (let alone double inconsistencies): - - structureID - - doseID - - voxelizationID - - number of voxels - - Histogram entries. - */ - bool friend operator==(const DVH& aDVH, const DVH& otherDVH); - - friend std::ostream& operator<<(std::ostream& s, const DVH& aDVH); - void setLabel(StructureLabel aLabel); StructureLabel getLabel() const; /*! @param relativeVolume default false-> Value is the voxel number of the dose bin; if true-> value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @return Return differential data of the dvh (relative or absolute depending on the input parameter). */ DataDifferentialType getDataDifferential() const; /*! @param relativeVolume default false-> Value is the voxel number of the dose bin; if true-> value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @return Return cumulative data of the dvh */ DataDifferentialType getDataCumulative() const; DoseVoxelVolumeType getDeltaV() const; DoseTypeGy getDeltaD() const; IDType getStructureID() const; IDType getDoseID() const; IDType getVoxelizationID() const; void setDoseID(IDType aDoseID); void setStructureID(IDType aStrID); /*! @brief Calculate number of the voxels (with sub voxel accuracy) @return Return -1 if not initialized */ DVHVoxelNumber getNumberOfVoxels() const; /*! @brief Get the maximum dose in Gy from dvh @return Return the maximum dose in Gy (i+0.5)*deltaD, i-the maximal dose-bin with volume>0 Return -1 if not initialized */ DoseStatisticType getMaximum() const; /*! @brief Get the minimum dose in Gy from dvh @return Return the minimum dose (i+0.5)*deltaD, i-the minimal dose-bin with volume>0 Return -1 if not initialized */ DoseStatisticType getMinimum() const; DoseStatisticType getMean() const; DoseStatisticType getMedian() const; DoseStatisticType getModal() const; DoseStatisticType getStdDeviation() const; DoseStatisticType getVariance() const; /*! @brief Get Vx the volume irradiated to >= x @return Return absolute Volume in absolute cm3 Return -1 if not initialized */ VolumeType getVx(DoseTypeGy xDoseAbsolute) const; /*! @brief Get Dx the minimal dose delivered to x @return Return absolute dose value in Gy Return -1 if not initialized */ DoseTypeGy getDx(VolumeType xVolumeAbsolute) const; /*! @brief Calculate the absolute volume in cm3 @param relativePercent 0~100, the percent of the whole volume */ VolumeType getAbsoluteVolume(int relativePercent) const; /*! @brief Convert absolute values relative to the total number of voxels */ DataDifferentialType convertAbsoluteToRelative(bool isCumulative = true) const; /* @brief Multiplies each values with its Delta value. Values depend on DVHType. @param The DVHType that is being used DVHType::Cumulative or DVHType::Differential */ std::map getNormalizedDVH(DVHType dvhType = { DVHType::Cumulative }) const; }; + + /*! equality operator + DVHs are considered equal if the following are equal (let alone double inconsistencies): + - structureID + - doseID + - voxelizationID + - number of voxels + - Histogram entries. + */ + RTTBCore_EXPORT bool operator==(const DVH& aDVH, const DVH& otherDVH); + + RTTBCore_EXPORT std::ostream& operator<<(std::ostream& s, const DVH& aDVH); } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/core/rttbDVHSet.h b/code/core/rttbDVHSet.h index 62b4e1f..887754d 100644 --- a/code/core/rttbDVHSet.h +++ b/code/core/rttbDVHSet.h @@ -1,146 +1,140 @@ // ----------------------------------------------------------------------- // 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 __DVH_SET_H #define __DVH_SET_H #include #include #include #include "rttbCommon.h" #include "rttbBaseType.h" #include "rttbDVH.h" #include "RTTBCoreExports.h" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace core { /*! @class DVHSet @brief This is a class representing a RT DVHSet including Target Volume and Organ at Risk. @details A DVHSet consists of three subsets: one for the target volume (_dvhTVSet), one for healthy tissue (_dvhHTSet), and one for the whole volume (_dvhWVSet). */ class RTTBCore_EXPORT DVHSet { public: rttbClassMacroNoParent(DVHSet) using DVHSetType = std::vector; using IndexType = DVHSetType::size_type; private: IDType _structureSetID; IDType _doseID; DVHSetType _dvhTVSet; DVHSetType _dvhHTSet; DVHSetType _dvhWVSet; public: DVHSet(IDType aStructureSetID = "", IDType aDoseID = ""); DVHSet(DVHSetType aDVHTVSet, DVHSetType aDVHHTSet, IDType aStructureSetID = "", IDType aDoseID = ""); DVHSet(DVHSetType aDVHTVSet, DVHSetType aDVHHTSet, DVHSetType aDVHWVSet, IDType aStructureSetID = "", IDType aDoseID = ""); /*! @brief Get the size of the DVHSet, that is the sum of the numbers of DVHs in all sub-sets. */ std::size_t size() const; void setStrSetID(IDType aStrSetID); void setDoseID(IDType aDoseID); IDType getStrSetID() const; IDType getDoseID() const; /*! @brief Get the DVH according to the structure ID @return Return nullptr if not found */ DVH* getDVH(IDType aStructureID); /*! @brief Insert a DVH object. @brief param aDVHType "TV" for target volume or "HT" for healthy tissue or "WV" for whole volume @exception InvalidParameterException Thrown if no valid DVHRole was given. */ void insert(DVH& aDvh, DVHRole aDVHRole); /*! @brief Get DVH subset for target volume */ const DVHSetType& getTargetVolumeSet() const { return _dvhTVSet; }; /*! @brief Get DVH subset for healthy tissue */ const DVHSetType& getHealthyTissueSet() const { return _dvhHTSet; }; /*! @brief Get DVH subset for whole volume */ const DVHSetType& getWholeVolumeSet() const { return _dvhWVSet; }; /*! @brief Get the whole volume irradiated to >= aDoseAbsolute */ VolumeType getWholeVolume(DoseTypeGy aDoseAbsolute) const; /*! @brief Get the healthy tissue volume irradiated to >= aDoseAbsolute @return Return -1 if DVH of _dvhHTSet init() failed */ VolumeType getHealthyTissueVolume(DoseTypeGy aDoseAbsolute) const; /*! @brief Get the target volume irradiated to >= aDoseAbsolute @return Return -1 if DVH of _dvhTVSet init() failed */ VolumeType getTargetVolume(DoseTypeGy aDoseAbsolute) const; - - /*! DVHSets are considered equal if they have the same structureSet, dose and voxelization ID - and the number of DVHs are equal. - */ - bool friend operator==(const DVHSet& aDVHSet, const DVHSet& otherDVHSet); - - friend std::ostream& operator<<(std::ostream& s, const DVHSet& aDVHSet); - - friend std::ostream& operator<<(std::ostream& s, const DVHSetType& aDVHSet); }; - bool operator==(const DVHSet& aDVHSet, const DVHSet& otherDVHSet); + /*! DVHSets are considered equal if they have the same structureSet, dose and voxelization ID + and the number of DVHs are equal. + */ + RTTBCore_EXPORT bool operator==(const DVHSet& aDVHSet, const DVHSet& otherDVHSet); - std::ostream& operator<<(std::ostream& s, const DVHSet& aDVHSet); + RTTBCore_EXPORT std::ostream& operator<<(std::ostream& s, const DVHSet& aDVHSet); - std::ostream& operator<<(std::ostream& s, const DVHSet::DVHSetType& aDVHSet); + RTTBCore_EXPORT std::ostream& operator<<(std::ostream& s, const DVHSet::DVHSetType& aDVHSet); } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/core/rttbGeometricInfo.h b/code/core/rttbGeometricInfo.h index 28d5828..c7ce3b2 100644 --- a/code/core/rttbGeometricInfo.h +++ b/code/core/rttbGeometricInfo.h @@ -1,192 +1,192 @@ // ----------------------------------------------------------------------- // 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 __GEOMETRIC_INFO_NEW_H #define __GEOMETRIC_INFO_NEW_H #include #include #include "rttbBaseType.h" #include #include "rttbCommon.h" #include "RTTBCoreExports.h" #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace core { /*! @brief GeometricInfo objects contain all the information required for transformations between voxel grid coordinates and world coordinates. Corresponding converter functions are also available. @note ITK Pixel Indexing used (http://www.itk.org/Doxygen45/html/classitk_1_1Image.html): The Index type reverses the order so that with Index[0] = col, Index[1] = row, Index[2] = slice. */ class RTTBCore_EXPORT GeometricInfo { public: rttbClassMacroNoParent(GeometricInfo) private: WorldCoordinate3D _imagePositionPatient{ 0 }; OrientationMatrix _orientationMatrix{ 0 }; OrientationMatrix _invertedOrientationMatrix{ 0 }; SpacingVectorType3D _spacing{ 0 }; VoxelGridDimensionType _numberOfColumns{0}; VoxelGridDimensionType _numberOfRows{0}; VoxelGridDimensionType _numberOfFrames{0}; /* @brief Matrix inversion routine. Uses lu_factorize and lu_substitute in uBLAS to invert a matrix http://savingyoutime.wordpress.com/2009/09/21/c-matrix-inversion-boostublas/ */ bool computeInvertOrientation(); public: /*! @brief Constructor, initializes orientation matrix, spacing vector and patient position with zeros. */ GeometricInfo() = default; GeometricInfo(const GeometricInfo& source) = default; /**Returns a clone of the current instance*/ GeometricInfo::Pointer clone() const; void setSpacing(const SpacingVectorType3D& aSpacingVector); const SpacingVectorType3D& getSpacing() const; void setImagePositionPatient(const WorldCoordinate3D& aImagePositionPatient); const WorldCoordinate3D& getImagePositionPatient() const; void setOrientationMatrix(const OrientationMatrix& anOrientationMatrix); const OrientationMatrix getOrientationMatrix() const { return _orientationMatrix; }; void setImageSize(const ImageSize& aSize); const ImageSize getImageSize() const; void setNumColumns(const VoxelGridDimensionType aValue); const VoxelGridDimensionType getNumColumns() const; void setNumRows(const VoxelGridDimensionType aValue); const VoxelGridDimensionType getNumRows() const; void setNumSlices(const VoxelGridDimensionType aValue); const VoxelGridDimensionType getNumSlices() const; /*! @brief determines equality of two GeometricInfo objects. */ friend bool RTTBCore_EXPORT operator == (const GeometricInfo& gInfo, const GeometricInfo& gInfo1); bool equalsAlmost(const GeometricInfo& another, double errorConstantGI = 1e-5) const; /*! @brief converts world coordinates to voxel grid index. @details the voxels world coordinates are defined by spacing, orientation and imagePositionPatient. (-0.5/-0.5/-0.5) --> (0/0/0) and (0.4999/0.4999/0.4999) --> (0/0/0) define the outer coordinates of a voxel with spacing=1, orientation= x y z (identity matrix) and imagePositionPatient=(0/0/0). @sa WorldCoordinate3D VoxelGridIndex3D @note The conversion of values is done even if the target index is not inside the given voxel grid. @returns false if aWorldCoordinate is outside the voxel grid, true otherwise. */ bool worldCoordinateToIndex(const WorldCoordinate3D& aWorldCoordinate, VoxelGridIndex3D& aIndex) const; /*! @brief converts world coordinates to double geometry coordinate. @details This is needed because of a double precision voxel coordinate system for voxelization. The world coordinate of the image position patient is the center of the first voxel (0.0/0.0/0.0). (-0.5/-0.5/-0.5) --> (-0.5/-0.5/-0.5) and (0.4999/0.4999/0.4999) --> (0.4999/0.4999/0.4999) with spacing=1, orientation= x y z (identity matrix) and imagePositionPatient=(0/0/0). @sa WorldCoordinate3D, ContinuousVoxelGridIndex3D @note The conversion of values is done even if the target index is not inside the given voxel grid. @returns false if aWorldCoordinate is outside the voxel grid, true otherwise. */ bool worldCoordinateToContinuousIndex(const WorldCoordinate3D& aWorldCoordinate, ContinuousVoxelGridIndex3D& aIndex) const; /*! @brief converts double geometry coordinate to world coordinates. @details This is needed because of a double precision voxel coordinate system for voxelization. The world coordinate of the image position patient is the center of the first voxel (0.0/0.0/0.0). (-0.5/-0.5/-0.5) --> (-0.5/-0.5/-0.5) and (5.5/3.2/1.0) --> (5.5/3.2/1.0) with spacing=1, orientation= x y z (identity matrix) and imagePositionPatient=(0/0/0). @sa ContinuousVoxelGridIndex3D, WorldCoordinate3D @note The conversion of values is done even if the target index is not inside the given voxel grid. @returns false if aWorldCoordinate is outside the voxel grid, true otherwise. */ bool continuousIndexToWorldCoordinate(const ContinuousVoxelGridIndex3D& aIndex, WorldCoordinate3D& aWorldCoordinate) const; /*! @brief convert voxel grid index to world coordinates @details The world coordinate of the image position patient (center of the first voxel) is the center of the first voxel (0.0/0.0/0.0) (0/0/0) --> (0.0/0.0/0.0) and (1/1/2) --> (1.0/1.0/2.0) with spacing=1, orientation= x y z (identity matrix) and imagePositionPatient=(0/0/0). Thus, the center of the voxel is taken and converted. @sa VoxelGridIndex3D, WorldCoordinate3D @note The conversion of values is done even if the target index is not inside the given voxel grid. @returns false if aWorldCoordinate is outside the voxel grid, true otherwise. */ bool indexToWorldCoordinate(const VoxelGridIndex3D& aIndex, WorldCoordinate3D& aWorldCoordinate) const; /*! @brief check if a given voxel grid index is inside the given voxel grid.*/ bool isInside(const VoxelGridIndex3D& aIndex) const; /*! @brief check if a given world coordinate is inside the given voxel grid.*/ bool isInside(const WorldCoordinate3D& aWorldCoordinate) const; const GridSizeType getNumberOfVoxels() const; bool convert(const VoxelGridID& gridID, VoxelGridIndex3D& gridIndex) const; bool convert(const VoxelGridIndex3D& gridIndex, VoxelGridID& gridID) const; /*! @brief test if given ID is inside current dose grid */ bool validID(const VoxelGridID aID) const; /*! @brief test if given index is inside current dose grid */ bool validIndex(const VoxelGridIndex3D& aIndex) const; - - /*!@ brief generates string stream representation of the GeometricInfo object. */ - friend std::ostream& operator << (std::ostream& s, const GeometricInfo& anGeometricInfo); }; + + /*!@ brief generates string stream representation of the GeometricInfo object. */ + RTTBCore_EXPORT std::ostream& operator << (std::ostream& s, const GeometricInfo& anGeometricInfo); } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/core/rttbIndexConversionInterface.h b/code/core/rttbIndexConversionInterface.h index 36c7bc6..66ee3d8 100644 --- a/code/core/rttbIndexConversionInterface.h +++ b/code/core/rttbIndexConversionInterface.h @@ -1,55 +1,57 @@ // ----------------------------------------------------------------------- // 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 __INDEX_CONVERSION_INTERFACE_NEW_H #define __INDEX_CONVERSION_INTERFACE_NEW_H #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif + #include +#include "RTTBCoreExports.h" namespace rttb { namespace core { /*! @class IndexConversionInterface @brief This class represents the conversion of 3D grid indices to 1D grid IDs. */ - class IndexConversionInterface + class RTTBCore_EXPORT IndexConversionInterface { public: rttbClassMacroNoParent(IndexConversionInterface); private: IndexConversionInterface(const IndexConversionInterface&) = delete; //not implemented on purpose -> non-copyable IndexConversionInterface& operator=(const IndexConversionInterface&) = delete;//not implemented on purpose -> non-copyable - public: + protected: IndexConversionInterface() = default; virtual ~IndexConversionInterface() = default; }; } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/core/rttbMaskAccessorInterface.h b/code/core/rttbMaskAccessorInterface.h index 0b532d6..14374c2 100644 --- a/code/core/rttbMaskAccessorInterface.h +++ b/code/core/rttbMaskAccessorInterface.h @@ -1,106 +1,109 @@ // ----------------------------------------------------------------------- // 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 __MASK_ACCESSOR_INTERFACE_NEW_H #define __MASK_ACCESSOR_INTERFACE_NEW_H #include "rttbCommon.h" #include "rttbBaseType.h" #include "rttbMaskVoxel.h" #include "rttbIndexConversionInterface.h" +#include "RTTBCoreExports.h" + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace core { class GeometricInfo; /*! @class MaskAccessorInterface @brief This class triggers the voxelization and gives acess to the masked voxels. */ - class MaskAccessorInterface: public IndexConversionInterface + class RTTBCore_EXPORT MaskAccessorInterface: public IndexConversionInterface { public: rttbClassMacro(MaskAccessorInterface, IndexConversionInterface); using MaskVoxelList = std::vector; using MaskVoxelListPointer = boost::shared_ptr; private: MaskAccessorInterface(const MaskAccessorInterface&) = delete; //not implemented on purpose -> non-copyable MaskAccessorInterface& operator=(const MaskAccessorInterface&) = delete;//not implemented on purpose -> non-copyable - - public: + protected: MaskAccessorInterface() = default; ~MaskAccessorInterface() override = default; + public: /*! @brief Start generation of mask @post mask is valid and acessible */ virtual void updateMask() = 0; virtual const GeometricInfo& getGeometricInfo() const = 0; /*! @brief Get vector containing all relevant voxels that are inside the given structure. */ virtual MaskVoxelListPointer getRelevantVoxelVector() = 0; /*! @brief get vector containing all relevant voxels that have a relevant volume above the given threshold and are inside the given structure @pre updateMask should have been called (at least once, to ensure a valid mask). */ virtual MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold) = 0; /*! @brief Get masked voxel value corresponding to a given VoxelGridID. @post after a valid call voxel contains the mask information corresponding to aID. If aID is not valid, voxel values are undefined. @return Indicates if a MaskVoxel for the given ID exists and therefore if parameter voxel containes valid values. @pre updateMask should have been called (at least once, to ensure a valid mask). */ virtual bool getMaskAt(const VoxelGridID aID, MaskVoxel& voxel) const = 0; /*! @brief Get masked voxel value corresponding to a given VoxelGridIndex. @post after a valid call voxel contains the mask information corresponding to gridIndex. If gridIndex is not valid, voxel values are undefined. @return Indicates if a MaskVoxel for the given index exists and therefore if parameter voxel containes valid values. @pre updateMask should have been called (at least once, to ensure a valid mask). */ virtual bool getMaskAt(const VoxelGridIndex3D& gridIndex, MaskVoxel& voxel) const = 0; /* @brief Is true if dose is on a homogeneous grid. @note Inhomogeneous grids are not supported at the moment, but if they will be supported in the future the interface does not need to change. */ virtual bool isGridHomogeneous() const { return true; } virtual IDType getMaskUID() const = 0; }; } + } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/core/rttbMutableDoseAccessorInterface.h b/code/core/rttbMutableDoseAccessorInterface.h index c491e90..af4b37c 100644 --- a/code/core/rttbMutableDoseAccessorInterface.h +++ b/code/core/rttbMutableDoseAccessorInterface.h @@ -1,54 +1,64 @@ // ----------------------------------------------------------------------- // 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 __MUTABLE_DOSE_ACCESSOR_INTERFACE_NEW_H #define __MUTABLE_DOSE_ACCESSOR_INTERFACE_NEW_H #include "rttbDoseAccessorInterface.h" #include "rttbBaseType.h" #include "rttbCommon.h" +#include "RTTBCoreExports.h" + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace core { /*! @class MutableDoseAccessorInterface @brief Extends the DoseAccessorInterface to provide writing access to the data. */ - class MutableDoseAccessorInterface: public DoseAccessorInterface + class RTTBCore_EXPORT MutableDoseAccessorInterface: public DoseAccessorInterface { public: rttbClassMacro(MutableDoseAccessorInterface, DoseAccessorInterface) virtual void setDoseAt(const VoxelGridID aID, DoseTypeGy value) = 0; virtual void setDoseAt(const VoxelGridIndex3D& aIndex, DoseTypeGy value) = 0; + protected: + MutableDoseAccessorInterface() = default; + ~MutableDoseAccessorInterface() override = default; + + private: + MutableDoseAccessorInterface(const MutableDoseAccessorInterface&) = delete; //not implemented on purpose -> non-copyable + MutableDoseAccessorInterface& operator=(const + MutableDoseAccessorInterface&) = delete;//not implemented on purpose -> non-copyable }; } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/io/dicom/rttbDcmrtException.h b/code/core/rttbMutableMaskAccessorInterface.cpp similarity index 57% copy from code/io/dicom/rttbDcmrtException.h copy to code/core/rttbMutableMaskAccessorInterface.cpp index 135f684..fad0e6c 100644 --- a/code/io/dicom/rttbDcmrtException.h +++ b/code/core/rttbMutableMaskAccessorInterface.cpp @@ -1,43 +1,21 @@ -// ----------------------------------------------------------------------- -// 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 __DCMRT_EXCEPTION_H -#define __DCMRT_EXCEPTION_H - -#include - -#include "rttbException.h" - -namespace rttb -{ - namespace io - { - namespace dicom - { - - /*! @class DcmrtException - @brief This class represents a DcmrtException. Any dcmrt error will throw this exception. - */ - class DcmrtException: public core::Exception - { - public: - explicit DcmrtException(const std::string& aWhat): Exception(aWhat) {} - }; - } - } - -} - -#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. +// +//------------------------------------------------------------------------ + + +#include "rttbMutableMaskAccessorInterface.h" + +//This file was added, because on windows some compiler +//do not export the class symbols correctly if only the +//header is specified. diff --git a/code/core/rttbMutableMaskAccessorInterface.h b/code/core/rttbMutableMaskAccessorInterface.h index 6601102..282735b 100644 --- a/code/core/rttbMutableMaskAccessorInterface.h +++ b/code/core/rttbMutableMaskAccessorInterface.h @@ -1,60 +1,77 @@ // ----------------------------------------------------------------------- // 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 __MUTABLE_MASK_ACCESSOR_INTERFACE_H #define __MUTABLE_MASK_ACCESSOR_INTERFACE_H #include "rttbCommon.h" #include "rttbMaskAccessorInterface.h" #include "rttbBaseType.h" +#include "RTTBCoreExports.h" + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace core { class MaskVoxel; /*! @class MutableMaskAccessorInterface @brief Extends the MaskAccessorInterface to provide writing access to the data. @details This interface is created for external manipulation of generated masks. For example to store the results of arithmetic operations on other masks. */ - class MutableMaskAccessorInterface: public MaskAccessorInterface + class RTTBCore_EXPORT MutableMaskAccessorInterface: public MaskAccessorInterface { public: rttbClassMacro(MutableMaskAccessorInterface, MaskAccessorInterface) using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; virtual void setRelevantVoxelVector(MaskVoxelListPointer aVoxelListPointer) = 0; virtual void setMaskAt(VoxelGridID aID, const MaskVoxel& voxel) = 0; virtual void setMaskAt(const VoxelGridIndex3D& gridIndex, const MaskVoxel& voxel) = 0; + virtual bool isGridHomogeneous() const + { + return false; + } + + protected: + MutableMaskAccessorInterface() = default; + ~MutableMaskAccessorInterface() override = default; + + private: + MutableMaskAccessorInterface(const MutableMaskAccessorInterface&) = delete; //not implemented on purpose -> non-copyable + MutableMaskAccessorInterface& operator=(const + MutableMaskAccessorInterface&) = delete;//not implemented on purpose -> non-copyable + }; } + } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/indices/CMakeLists.txt b/code/indices/CMakeLists.txt index a14e257..9c5f241 100644 --- a/code/indices/CMakeLists.txt +++ b/code/indices/CMakeLists.txt @@ -1 +1,2 @@ -RTTB_CREATE_MODULE(RTTBIndices DEPENDS RTTBCore RTTBInterpolation PACKAGE_DEPENDS Boost) \ No newline at end of file +RTTB_CREATE_MODULE(RTTBIndices + DEPENDS PUBLIC RTTBCore) diff --git a/code/interpolation/CMakeLists.txt b/code/interpolation/CMakeLists.txt index bd08f77..9db8a69 100644 --- a/code/interpolation/CMakeLists.txt +++ b/code/interpolation/CMakeLists.txt @@ -1,11 +1,11 @@ -RTTB_CREATE_MODULE(RTTBInterpolation DEPENDS RTTBCore PACKAGE_DEPENDS Boost) +RTTB_CREATE_MODULE(RTTBInterpolation DEPENDS PUBLIC RTTBCore) ADD_SUBDIRECTORY(ITKTransformation) OPTION(BUILD_InterpolationMatchPointTransformation "Determine if the MatchPoint transformation for dose interpolation classes will be generated." OFF) IF(BUILD_All_Modules OR BUILD_InterpolationMatchPointTransformation) ADD_SUBDIRECTORY(MatchPointTransformation) SET(BUILD_InterpolationMatchPointTransformation ON CACHE BOOL ON FORCE) ENDIF() diff --git a/code/interpolation/ITKTransformation/CMakeLists.txt b/code/interpolation/ITKTransformation/CMakeLists.txt index 1a2fbb4..ca64739 100644 --- a/code/interpolation/ITKTransformation/CMakeLists.txt +++ b/code/interpolation/ITKTransformation/CMakeLists.txt @@ -1 +1,2 @@ -RTTB_CREATE_MODULE(RTTBInterpolationITKTransformation DEPENDS RTTBCore RTTBInterpolation RTTBITKIO PACKAGE_DEPENDS Boost ITK) \ No newline at end of file +RTTB_CREATE_MODULE(RTTBInterpolationITKTransformation + DEPENDS PUBLIC RTTBCore RTTBInterpolation RTTBITKIO PACKAGE_DEPENDS PUBLIC ITK) \ No newline at end of file diff --git a/code/interpolation/MatchPointTransformation/CMakeLists.txt b/code/interpolation/MatchPointTransformation/CMakeLists.txt index efe5fd1..b2956f5 100644 --- a/code/interpolation/MatchPointTransformation/CMakeLists.txt +++ b/code/interpolation/MatchPointTransformation/CMakeLists.txt @@ -1,2 +1,2 @@ -RTTB_CREATE_MODULE(RTTBInterpolationMatchPointTransformation DEPENDS RTTBCore RTTBInterpolation PACKAGE_DEPENDS Boost MatchPoint ITK) +RTTB_CREATE_MODULE(RTTBInterpolationMatchPointTransformation DEPENDS PUBLIC RTTBCore RTTBInterpolation PACKAGE_DEPENDS PUBLIC MatchPoint ITK) diff --git a/code/interpolation/rttbRosuMappableDoseAccessor.h b/code/interpolation/rttbRosuMappableDoseAccessor.h index a7ea314..ef3f14d 100644 --- a/code/interpolation/rttbRosuMappableDoseAccessor.h +++ b/code/interpolation/rttbRosuMappableDoseAccessor.h @@ -1,75 +1,77 @@ // ----------------------------------------------------------------------- // 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 __ROSU_MAPPABLE_DOSE_ACCESSOR_H #define __ROSU_MAPPABLE_DOSE_ACCESSOR_H #include #include "rttbBaseType.h" #include "rttbInterpolationBase.h" #include "rttbMappableDoseAccessorInterface.h" +#include "RTTBInterpolationExports.h" + namespace rttb { namespace interpolation { class TransformationInterface; /*! @class RosuMappableDoseAccessor @brief Class for dose mapping based on interpolation described in the Rosu2005 paper @details implementation of the following paper: Rosu, M., Chetty, I. J., Balter, J. M., Kessler, M. L., McShan, D. L., & Ten Haken, R. K. (2005). Dose reconstruction in deforming lung anatomy: Dose grid size effects and clinical implications. Medical Physics, 32(8), 2487. @ingroup interpolation */ - class RosuMappableDoseAccessor: public MappableDoseAccessorInterface + class RTTBInterpolation_EXPORT RosuMappableDoseAccessor: public MappableDoseAccessorInterface { private: InterpolationBase::Pointer _spInterpolation; public: /*! @brief Constructor. Just hands values over to base class constructor. @note no interpolation as parameter since linear interpolation is fixed. @sa MappableDoseAccessorBase */ RosuMappableDoseAccessor(const core::GeometricInfo& geoInfoTargetImage, core::DoseAccessorInterface::ConstPointer doseMovingImage, const TransformationInterface::Pointer aTransformation, bool acceptPadding = true, DoseTypeGy defaultOutsideValue = 0.0); /*! @brief Virtual destructor. */ ~RosuMappableDoseAccessor() override = default; GenericValueType getValueAt(const VoxelGridID aID) const override; /*! @brief Returns the dose for a given voxel grid index. The computation of the octant around the voxel is done and the interpolation is performed. @details Boundary treatment: if more than 6 subvoxels are outside: return _defaultOutsideValue. Otherwise: ignore the outside values. @return the dose or if (isOutside==true && _acceptPadding==true) then _defaultValue @exception core::MappingOutsideOfImageException if the point is mapped outside and if _acceptPadding==false, possibly returning _defaultValue) */ GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; private: /*! @brief returns the octant coordinates around a coordinate. @details i.e. coordinate is the center of a virtual voxel. Then, each side is divided into equal parts. The centers of the new subvoxels are then returned. @return a vector of the octant coordinates. */ std::vector getOctants(const WorldCoordinate3D& aCoordinate) const; }; } } #endif diff --git a/code/io/dicom/CMakeLists.txt b/code/io/dicom/CMakeLists.txt index 58e76b5..ca7dd15 100644 --- a/code/io/dicom/CMakeLists.txt +++ b/code/io/dicom/CMakeLists.txt @@ -1,2 +1 @@ -RTTB_CREATE_MODULE(RTTBDicomIO DEPENDS RTTBCore RTTBAlgorithms PACKAGE_DEPENDS BoostBinaries DCMTK) - +RTTB_CREATE_MODULE(RTTBDicomIO DEPENDS PUBLIC RTTBCore RTTBAlgorithms PACKAGE_DEPENDS PUBLIC DCMTK PRIVATE Boost|filesystem) diff --git a/code/io/dicom/rttbDVHDicomFileReader.h b/code/io/dicom/rttbDVHDicomFileReader.h index c8f68b6..74ebfbe 100644 --- a/code/io/dicom/rttbDVHDicomFileReader.h +++ b/code/io/dicom/rttbDVHDicomFileReader.h @@ -1,53 +1,55 @@ // ----------------------------------------------------------------------- // 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 __DVH_DICOM_FILE_READER_H #define __DVH_DICOM_FILE_READER_H #include "rttbBaseType.h" #include "rttbDVHGeneratorInterface.h" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { /*! @class DVHDicomFileReader @brief Read DVH data from a dicom file and create corresponding DVH object. */ - class DVHDicomFileReader: public core::DVHGeneratorInterface + class RTTBDicomIO_EXPORT DVHDicomFileReader: public core::DVHGeneratorInterface { private: FileNameString _fileName; void createDVH(); public: /*! @brief DVHDicomFileReader Constructor @param aFileName the dicom dvh file name */ explicit DVHDicomFileReader(FileNameString aFileName); /*! @brief Set the dicom dvh file name (triggers data import) @param aFileName the dicom dvh file name */ void setFileName(FileNameString aFileName); }; } } } #endif diff --git a/code/io/dicom/rttbDcmrtException.h b/code/io/dicom/rttbDcmrtException.h index 135f684..ed87178 100644 --- a/code/io/dicom/rttbDcmrtException.h +++ b/code/io/dicom/rttbDcmrtException.h @@ -1,43 +1,45 @@ // ----------------------------------------------------------------------- // 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 __DCMRT_EXCEPTION_H #define __DCMRT_EXCEPTION_H #include #include "rttbException.h" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { /*! @class DcmrtException @brief This class represents a DcmrtException. Any dcmrt error will throw this exception. */ - class DcmrtException: public core::Exception + class RTTBDicomIO_EXPORT DcmrtException: public core::Exception { public: explicit DcmrtException(const std::string& aWhat): Exception(aWhat) {} }; } } } #endif diff --git a/code/io/dicom/rttbDicomDoseAccessor.cpp b/code/io/dicom/rttbDicomDoseAccessor.cpp index a018e77..e4d5ba5 100644 --- a/code/io/dicom/rttbDicomDoseAccessor.cpp +++ b/code/io/dicom/rttbDicomDoseAccessor.cpp @@ -1,285 +1,285 @@ // ----------------------------------------------------------------------- // 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 "drtdose.h" +#include #include #include #include "rttbDicomDoseAccessor.h" #include "rttbNullPointerException.h" #include "rttbInvalidDoseException.h" #include "rttbDcmrtException.h" #include "rttbIndexOutOfBoundsException.h" namespace rttb { namespace io { namespace dicom { DicomDoseAccessor::~DicomDoseAccessor() = default; DicomDoseAccessor::DicomDoseAccessor(DRTDoseIODPtr aDRTDoseIODP, DcmItemPtr aDcmDataset) { _dose = aDRTDoseIODP; _dataSet = aDcmDataset; OFString uid; _dose->getSeriesInstanceUID(uid); _doseUID = uid.c_str(); this->begin(); } bool DicomDoseAccessor::begin() { assembleGeometricInfo(); doseData.clear(); OFString doseGridScalingStr; this->_dose->getDoseGridScaling(doseGridScalingStr); try { _doseGridScaling = boost::lexical_cast(doseGridScalingStr.c_str()); } catch (boost::bad_lexical_cast&) { throw core::InvalidDoseException("Dose grid scaling not readable or = 0!") ; } OFCondition status; unsigned long count; const Uint16* pixelData; status = _dataSet->findAndGetUint16Array(DcmTagKey(0x7fe0, 0x0010), pixelData, &count); if (status.good()) { for (unsigned int i = 0; i < static_cast(this->_geoInfo.getNumberOfVoxels()); i++) { this->doseData.push_back(pixelData[i]); } return true; } else { throw io::dicom::DcmrtException("Read Pixel Data (7FE0,0010) failed!"); } } void DicomDoseAccessor::assembleGeometricInfo() { Uint16 temp = 0; this->_dose->getColumns(temp); _geoInfo.setNumColumns(temp); temp = 0; this->_dose->getRows(temp); _geoInfo.setNumRows(temp); if (_geoInfo.getNumColumns() == 0 || _geoInfo.getNumRows() == 0) { throw core::InvalidDoseException("Empty dicom dose!") ; } OFString numberOfFramesStr; OFString imageOrientationRowX, imageOrientationRowY, imageOrientationRowZ; OFString imageOrientationColumnX, imageOrientationColumnY, imageOrientationColumnZ; WorldCoordinate3D imageOrientationRow; WorldCoordinate3D imageOrientationColumn; try { this->_dose->getNumberOfFrames(numberOfFramesStr); _geoInfo.setNumSlices(boost::lexical_cast(numberOfFramesStr.c_str())); _dose->getImageOrientationPatient(imageOrientationRowX, 0); _dose->getImageOrientationPatient(imageOrientationRowY, 1); _dose->getImageOrientationPatient(imageOrientationRowZ, 2); _dose->getImageOrientationPatient(imageOrientationColumnX, 3); _dose->getImageOrientationPatient(imageOrientationColumnY, 4); _dose->getImageOrientationPatient(imageOrientationColumnZ, 5); imageOrientationRow(0) = boost::lexical_cast(imageOrientationRowX.c_str()); imageOrientationRow(1) = boost::lexical_cast(imageOrientationRowY.c_str()); imageOrientationRow(2) = boost::lexical_cast(imageOrientationRowZ.c_str()); imageOrientationColumn(0) = boost::lexical_cast(imageOrientationColumnX.c_str()); imageOrientationColumn(1) = boost::lexical_cast(imageOrientationColumnY.c_str()); imageOrientationColumn(2) = boost::lexical_cast(imageOrientationColumnZ.c_str()); } catch (boost::bad_lexical_cast&) { throw core::InvalidDoseException("boost::lexical_cast failed! Empty dicom dose!") ; } /*Get orientation*/ OrientationMatrix orientation; orientation(0, 0) = imageOrientationRow.x(); orientation(1, 0) = imageOrientationRow.y(); orientation(2, 0) = imageOrientationRow.z(); orientation(0, 1) = imageOrientationColumn.x(); orientation(1, 1) = imageOrientationColumn.y(); orientation(2, 1) = imageOrientationColumn.z(); WorldCoordinate3D perpendicular = imageOrientationRow.cross(imageOrientationColumn); orientation(0, 2) = perpendicular.x(); orientation(1, 2) = perpendicular.y(); orientation(2, 2) = perpendicular.z(); _geoInfo.setOrientationMatrix(orientation); OFString imagePositionX, imagePositionY, imagePositionZ; _dose->getImagePositionPatient(imagePositionX, 0); _dose->getImagePositionPatient(imagePositionY, 1); _dose->getImagePositionPatient(imagePositionZ, 2); WorldCoordinate3D imagePositionPatient; try { imagePositionPatient(0) = boost::lexical_cast(imagePositionX.c_str()); imagePositionPatient(1) = boost::lexical_cast(imagePositionY.c_str()); imagePositionPatient(2) = boost::lexical_cast(imagePositionZ.c_str()); } catch (boost::bad_lexical_cast&) { throw core::InvalidDoseException("Can not read image position X/Y/Z!") ; } _geoInfo.setImagePositionPatient(imagePositionPatient); /*Get spacing*/ SpacingVectorType3D spacingVector; OFString pixelSpacingRowStr, pixelSpacingColumnStr, sliceThicknessStr; _dose->getPixelSpacing(pixelSpacingRowStr, 0); _dose->getPixelSpacing(pixelSpacingColumnStr, 1); try { spacingVector(1) = boost::lexical_cast(pixelSpacingRowStr.c_str()); spacingVector(0) = boost::lexical_cast(pixelSpacingColumnStr.c_str()); } catch (boost::bad_lexical_cast&) { throw core::InvalidDoseException("Can not read Pixel Spacing Row/Column!") ; } _geoInfo.setSpacing(spacingVector); if (_geoInfo.getSpacing()(0) == 0 || _geoInfo.getSpacing()(1) == 0) { throw core::InvalidDoseException("Pixel spacing is 0!"); } _dose->getSliceThickness(sliceThicknessStr); try { spacingVector(2) = boost::lexical_cast(sliceThicknessStr.c_str()); } catch (boost::bad_lexical_cast&) { spacingVector(2) = 0 ; } if (spacingVector(2) == 0) { OFVector gridFrameOffsetVector; _dose->getGridFrameOffsetVector(gridFrameOffsetVector); if (gridFrameOffsetVector.size() >= 2) { spacingVector(2) = gridFrameOffsetVector.at(1) - gridFrameOffsetVector.at( 0); //read slice thickness from GridFrameOffsetVector (3004,000c) } if (spacingVector(2) == 0) { OFCondition status; DcmItem doseitem; OFString pixelSpacingBetweenSlices; status = _dose->write(doseitem); if (status.good()) { status = doseitem.findAndGetOFString(DcmTagKey(0x0018, 0x0088), pixelSpacingBetweenSlices); try { spacingVector(2) = boost::lexical_cast (pixelSpacingBetweenSlices.c_str());//read slice thickness from PixelSpacingBetweenSlices (0018,0088) } catch (boost::bad_lexical_cast&) { spacingVector(2) = 0 ; } } //if no useful tags to compute slicing -> set slice thickness to spacingVector(0) if (spacingVector(2) == 0) { std::cerr << "sliceThickness == 0! It wird be replaced with pixelSpacingRow=" << _geoInfo.getSpacing()(0) << "!" << std::endl; spacingVector(2) = spacingVector(0); } } } _geoInfo.setSpacing(spacingVector); } GenericValueType DicomDoseAccessor::getValueAt(const VoxelGridID aID) const { return doseData.at(aID) * _doseGridScaling; } GenericValueType DicomDoseAccessor::getValueAt(const VoxelGridIndex3D& aIndex) const { VoxelGridID aVoxelGridID; if (_geoInfo.convert(aIndex, aVoxelGridID)) { return getValueAt(aVoxelGridID); } else { return -1; } } } } } diff --git a/code/io/dicom/rttbDicomDoseAccessor.h b/code/io/dicom/rttbDicomDoseAccessor.h index 5e54f62..d4ba869 100644 --- a/code/io/dicom/rttbDicomDoseAccessor.h +++ b/code/io/dicom/rttbDicomDoseAccessor.h @@ -1,93 +1,95 @@ // ----------------------------------------------------------------------- // 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 __DICOM_DOSE_ACCESSOR_H #define __DICOM_DOSE_ACCESSOR_H -#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include /* make sure OS specific configuration is included first */ +#include #include #include #include #include "rttbAccessorWithGeoInfoBase.h" #include "rttbBaseType.h" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { /*! @class DicomDoseAccessor @brief This class gives access to dose information from DRTDoseIOD and DcmItem */ - class DicomDoseAccessor: public core::AccessorWithGeoInfoBase + class RTTBDicomIO_EXPORT DicomDoseAccessor: public core::AccessorWithGeoInfoBase { public: using DRTDoseIODPtr = boost::shared_ptr; using DcmItemPtr = boost::shared_ptr; private: DRTDoseIODPtr _dose; DcmItemPtr _dataSet; /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ std::vector doseData; double _doseGridScaling; IDType _doseUID; DicomDoseAccessor() = delete; protected: /*! @brief Initialize dose data @exception InvalidDoseException Thrown if _dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ bool begin(); /*! @brief get all required data from dicom information contained in _dose @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ void assembleGeometricInfo() override; public: ~DicomDoseAccessor() override; /*! @brief Constructor. Initialisation with a boost::shared_ptr of DRTDoseIOD and of DcmItem to get the pixel data @exception DcmrtException Throw if dcmrt error */ DicomDoseAccessor(DRTDoseIODPtr aDRTDoseIODP, DcmItemPtr aDcmDataset); GenericValueType getValueAt(const VoxelGridID aID) const override; GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; const IDType getUID() const override { return _doseUID; }; }; } } } #endif diff --git a/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h b/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h index 50f581f..61527a4 100644 --- a/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h +++ b/code/io/dicom/rttbDicomFileDoseAccessorGenerator.h @@ -1,71 +1,73 @@ // ----------------------------------------------------------------------- // 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 __DICOM_FILE_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_FILE_DOSE_ACCESSOR_GENERATOR_H -#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include /* make sure OS specific configuration is included first */ +#include #include "rttbDoseAccessorGeneratorBase.h" #include "rttbBaseType.h" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { /*! @class DicomFileDoseAccessorGenerator @brief Load dose data from dicom file and generate DicomDoseAccessor. */ - class DicomFileDoseAccessorGenerator: public core::DoseAccessorGeneratorBase + class RTTBDicomIO_EXPORT DicomFileDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: using DRTDoseIODPtr = boost::shared_ptr; using DcmItemPtr = boost::shared_ptr; private: FileNameType _dicomDoseFileName; DicomFileDoseAccessorGenerator() = delete; protected: public: ~DicomFileDoseAccessorGenerator() override; /*! @brief Constructor. Initialization with a DICOM-RT dose file or a directory name @param aDICOMRTDoseFileName a DICOM-RT dose file name or a directory name @exception InvalidParameterException thrown if the file does not exist or the directory has no dicom dose file @exception DcmrtException thrown if load and read file failed */ explicit DicomFileDoseAccessorGenerator(FileNameType aDICOMRTDoseFileName); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if the loaded dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/dicom/rttbDicomFileDoseAccessorWriter.h b/code/io/dicom/rttbDicomFileDoseAccessorWriter.h index db43ac5..2301706 100644 --- a/code/io/dicom/rttbDicomFileDoseAccessorWriter.h +++ b/code/io/dicom/rttbDicomFileDoseAccessorWriter.h @@ -1,77 +1,79 @@ // ----------------------------------------------------------------------- // 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 __DICOM_FILE_DOSE_ACCESSOR_WRITER_H #define __DICOM_FILE_DOSE_ACCESSOR_WRITER_H #include "../itk/rttbDoseAccessorProcessorBase.h" #include "../itk/rttbDoseAccessorConversionSettingInterface.h" #include "rttbDicomDoseAccessor.h" +#include "RTTBDicomIOExports.h" + //pixel data max value UINT16_MAX #define PixelDataMaxValue 0xffff namespace rttb { namespace io { namespace dicom { /*! @class DicomFileDoseAccessorWriter @brief Class converts/dumps the processed accessor into an dicom file @remark DoseAccessorConversionInterface defines how the converter should react on non valid dose values. */ - class DicomFileDoseAccessorWriter: public core::DoseAccessorProcessorBase, + class RTTBDicomIO_EXPORT DicomFileDoseAccessorWriter: public core::DoseAccessorProcessorBase, public core::DoseAccessorConversionSettingInterface { public: using DoseAccessorPointer = core::DoseAccessorInterface::Pointer; using DRTDoseIODPointer = DicomDoseAccessor::DRTDoseIODPtr; /*! @brief Standard Constructor. */ DicomFileDoseAccessorWriter(); ~DicomFileDoseAccessorWriter() override = default; /*! Set a file name to write the dose @param aFileName a file name to write the dose */ void setFileName(DICOMRTFileNameString aFileName); /*! @brief Convert the accessor into dicom dataset and write dicom dataset to a file @exception InvalidDoseException thrown if put and insert pixel data into dicom dataset failed */ bool process() override; private: DicomFileDoseAccessorWriter(const DicomFileDoseAccessorWriter&) = delete; //not implemented on purpose -> non-copyable DicomFileDoseAccessorWriter& operator=(const DicomFileDoseAccessorWriter&) = delete;//not implemented on purpose -> non-copyable DRTDoseIODPointer _doseIOD; DICOMRTFileNameString _fileName; DcmFileFormat _fileformat; DcmDataset* _dataset; }; } } } #endif diff --git a/code/io/dicom/rttbDicomFileReaderHelper.h b/code/io/dicom/rttbDicomFileReaderHelper.h index 739d4ca..2e6a3cd 100644 --- a/code/io/dicom/rttbDicomFileReaderHelper.h +++ b/code/io/dicom/rttbDicomFileReaderHelper.h @@ -1,74 +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. // //------------------------------------------------------------------------ #ifndef __DICOM_FILE_READER_HELPER_H #define __DICOM_FILE_READER_HELPER_H #include -#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include /* make sure OS specific configuration is included first */ +#include #include "rttbBaseType.h" #include "boost/shared_ptr.hpp" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { struct Modality { enum Type { RTDOSE = 1, RTSTRUCT = 2, RTPLAN = 3, UserDefined = 128 } Type; }; using DRTDoseIODPtr = boost::shared_ptr; using DcmDataSetPtr = boost::shared_ptr; /*! Return the vector of all files with the same UID in the given directory, the UID is defined by the first file with the modality. @exception InvalidParameterException thrown if the file/directory does not exist or the modality is invalid @exception DcmrtException thrown if load/read file failed */ - std::vector getFileNamesWithSameUID(FileNameType aDirName, Modality aModality); + RTTBDicomIO_EXPORT std::vector getFileNamesWithSameUID(FileNameType aDirName, Modality aModality); /*! Return the vector of all files with the same UID in the directory of the given file @exception InvalidParameterException thrown if the file does not exist @exception DcmrtException thrown if load/read file failed */ - std::vector getFileNames(FileNameType aFileName); + RTTBDicomIO_EXPORT std::vector getFileNames(FileNameType aFileName); /*! Return modality DcmTagKey(0x0008, 0x0060) @exception DcmrtException thrown if reading modality failed*/ - OFString getModality(DcmDataSetPtr aDcmDataSet); + RTTBDicomIO_EXPORT OFString getModality(DcmDataSetPtr aDcmDataSet); /*! Return uid DcmTagKey(0x0020, 0x000e) @exception DcmrtException thrown if reading uid failed*/ - OFString getUID(DcmDataSetPtr aDcmDataSet); + RTTBDicomIO_EXPORT OFString getUID(DcmDataSetPtr aDcmDataSet); }; } } #endif diff --git a/code/io/dicom/rttbDicomFileStructureSetGenerator.h b/code/io/dicom/rttbDicomFileStructureSetGenerator.h index 082a1a6..3e8c1b5 100644 --- a/code/io/dicom/rttbDicomFileStructureSetGenerator.h +++ b/code/io/dicom/rttbDicomFileStructureSetGenerator.h @@ -1,89 +1,91 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /* Changes in Architecture: The DICOM specific classes will be removed and transfered to the corresponding IO classes. This class should only provide general structure functionality. */ #ifndef __DICOM_FILE_STRUCTURE_SET_GENERATOR_H #define __DICOM_FILE_STRUCTURE_SET_GENERATOR_H #include #include -#include "drtstrct.h" +#include #include "rttbBaseType.h" #include "rttbStrVectorStructureSetGenerator.h" +#include "RTTBDicomIOExports.h" + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable: 4251) #endif namespace rttb { namespace io { namespace dicom { /*! @class DicomFileStructureSetGenerator @brief Generate a structure set from a corresponding dicomRT file. */ - class DicomFileStructureSetGenerator: public core::StrVectorStructureSetGenerator + class RTTBDicomIO_EXPORT DicomFileStructureSetGenerator: public core::StrVectorStructureSetGenerator { public: using StructTypePointer = core::Structure::Pointer; using StructureSetPointer = core::StructureSet::Pointer; using DRTStrSetIODPtr = boost::shared_ptr; private: IDType _UID; DICOMRTFileNameString _fileName; DicomFileStructureSetGenerator() = default; public: /*! @brief Constructor @param aDICOMRTStrSetFileName a DICOM-RT Structure set file name or a directory name @exception InvalidParameterException thrown if the file does not exist or the directory has no dicom structure file @exception DcmrtException thrown if load and read file failed */ explicit DicomFileStructureSetGenerator(DICOMRTFileNameString aDICOMRTStrSetFileName); /*! @brief Destructor */ ~DicomFileStructureSetGenerator() override; /*! @brief generate structure set @return return shared pointer of StructureSet @exception DcmrtException Thrown if loadFile and read failed @exception InvalidParameterException throw if the imported header tags are not numerical. */ StructureSetPointer generateStructureSet() override; }; } } } #ifdef _MSC_VER #pragma warning(pop) #endif #endif diff --git a/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h b/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h index 95de522..e3896ed 100644 --- a/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h +++ b/code/io/dicom/rttbDicomIODDoseAccessorGenerator.h @@ -1,69 +1,71 @@ // ----------------------------------------------------------------------- // 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 __DICOM_IOD_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_IOD_DOSE_ACCESSOR_GENERATOR_H -#include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include /* make sure OS specific configuration is included first */ +#include #include "rttbDoseAccessorGeneratorBase.h" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { /*! @class DicomIODDoseAccessorGenerator @brief Generate DicomDoseAccessor with a DRTDoseIOD. */ - class DicomIODDoseAccessorGenerator: public core::DoseAccessorGeneratorBase + class RTTBDicomIO_EXPORT DicomIODDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: using DRTDoseIODPtr = boost::shared_ptr; using DcmItemPtr = boost::shared_ptr; protected: private: DRTDoseIODPtr _doseIODPtr; DicomIODDoseAccessorGenerator() = delete; public: ~DicomIODDoseAccessorGenerator() override; /*! @brief Constructor. Initialization with a boost shared pointer of DRTDoseIOD */ explicit DicomIODDoseAccessorGenerator(DRTDoseIODPtr aDRTDoseIODP); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if aDRTDoseIODP is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/dicom/rttbDicomIODStructureSetGenerator.h b/code/io/dicom/rttbDicomIODStructureSetGenerator.h index 4b5c3f6..e01573e 100644 --- a/code/io/dicom/rttbDicomIODStructureSetGenerator.h +++ b/code/io/dicom/rttbDicomIODStructureSetGenerator.h @@ -1,84 +1,86 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ /* Changes in Architecture: The DICOM specific classes will be removed and transfered to the corresponding IO classes. This class should only provide general structure functionality. */ #ifndef __DICOM_IOD_STRUCTURE_SET_GENERATOR_H #define __DICOM_IOD_STRUCTURE_SET_GENERATOR_H #include -#include "drtstrct.h" +#include #include "rttbBaseType.h" #include "rttbStrVectorStructureSetGenerator.h" +#include "RTTBDicomIOExports.h" + namespace rttb { namespace io { namespace dicom { /*! @class DicomIODStructureSetGenerator @brief Generate a structure set from a DRTStructureSetIOD pointer. */ - class DicomIODStructureSetGenerator: public core::StrVectorStructureSetGenerator + class RTTBDicomIO_EXPORT DicomIODStructureSetGenerator: public core::StrVectorStructureSetGenerator { public: using StructTypePointer = core::Structure::Pointer; using StructureSetPointer = core::StructureSet::Pointer; using DRTStrSetIODPtr = boost::shared_ptr; private: DRTStrSetIODPtr _drtStrSetIOD; IDType _UID; /*! Import Structure data from file. @exception InvalidParameterException Thrown if the imported header tags are not numerical. */ void readStrSet(); /*! Replaces the character 'á' ((int)-96) to ' ' ((int)32) in a string. */ void correctSpacesInROIName(std::string& roiName); public: /*! @brief Structure Constructor Get the vector of structures from DRTStructureSetIOD object @exception NullPointerException Thrown if structureSet is nullptr */ explicit DicomIODStructureSetGenerator(DRTStrSetIODPtr aDRTStructureSetIOD); /*! @brief Destructor */ ~DicomIODStructureSetGenerator() override; /*! @brief generate structure set @return return shared pointer of StructureSet @exception InvalidParameterException throw if the imported header tags are not numerical. */ StructureSetPointer generateStructureSet() override; }; } } } #endif diff --git a/code/io/helax/CMakeLists.txt b/code/io/helax/CMakeLists.txt index cc0cd7e..7dff56a 100644 --- a/code/io/helax/CMakeLists.txt +++ b/code/io/helax/CMakeLists.txt @@ -1 +1 @@ -RTTB_CREATE_MODULE(RTTBHelaxIO DEPENDS RTTBCore RTTBDicomIO PACKAGE_DEPENDS BoostBinaries DCMTK) \ No newline at end of file +RTTB_CREATE_MODULE(RTTBHelaxIO DEPENDS RTTBCore RTTBDicomIO PACKAGE_DEPENDS PRIVATE Boost|filesystem DCMTK) \ No newline at end of file diff --git a/code/io/helax/rttbDicomHelaxDoseAccessor.h b/code/io/helax/rttbDicomHelaxDoseAccessor.h index 6edce97..98d8b69 100644 --- a/code/io/helax/rttbDicomHelaxDoseAccessor.h +++ b/code/io/helax/rttbDicomHelaxDoseAccessor.h @@ -1,94 +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. // //------------------------------------------------------------------------ #ifndef __DICOM_HELAX_DOSE_ACCESSOR_H #define __DICOM_HELAX_DOSE_ACCESSOR_H #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include "dcmtk/dcmrt/drtdose.h" #include "rttbBaseType.h" #include "rttbAccessorWithGeoInfoBase.h" namespace rttb { namespace io { namespace helax { /*! @class DicomHelaxDoseAccessor @brief Load dose data from a directory containing dicom dose files, each file describes the helax dose in one slice. */ class DicomHelaxDoseAccessor: public core::AccessorWithGeoInfoBase { public: using DRTDoseIODPtr = boost::shared_ptr; private: /*! vector of DRTDoseIOD shared pointers, each DRTDoseIOD pointer presents the dose in one slice*/ std::vector _doseVector; /*! vector of dose data(absolute Gy dose/doseGridScaling)*/ std::vector _doseData; double _doseGridScaling; IDType _doseUID; DicomHelaxDoseAccessor() = delete; protected: /*! @brief Initialize dose data @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ bool begin(); /*! @brief get all required data from dicom information contained in _dose @exception boost/bad_lexical_cast Thrown if the imported header tags are not numerical. */ void assembleGeometricInfo() override; public: ~DicomHelaxDoseAccessor() override; /*! @brief Constructor. Initialisation with a vector of DRTDoseIOD pointers @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ explicit DicomHelaxDoseAccessor(std::vector aDICOMRTDoseVector); GenericValueType getValueAt(const VoxelGridID aID) const override; GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; const IDType getUID() const override { return _doseUID; }; }; } } } #endif diff --git a/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h b/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h index 65d686f..283b21c 100644 --- a/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h +++ b/code/io/helax/rttbDicomHelaxFileDoseAccessorGenerator.h @@ -1,73 +1,73 @@ // ----------------------------------------------------------------------- // 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 __DICOM_HELAX_FILE_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_HELAX_FILE_DOSE_ACCESSOR_GENERATOR_H #include #include #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include "dcmtk/dcmrt/drtdose.h" #include "rttbDoseAccessorGeneratorBase.h" #include "rttbBaseType.h" namespace rttb { namespace io { namespace helax { /*! @class DicomHelaxFileDoseAccessorGenerator @brief Load dose data from dicom helax files and generate DoseAccessor */ class DicomHelaxFileDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: using DRTDoseIODPtr = boost::shared_ptr; protected: private: FileNameType _doseDirName; DicomHelaxFileDoseAccessorGenerator() = delete; public: ~DicomHelaxFileDoseAccessorGenerator() override; /*! @brief Constructor. Initialisation with a directory name */ explicit DicomHelaxFileDoseAccessorGenerator(FileNameType aDICOMRTDoseDirName); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidParameterException Thrown if aDICOMRTDoseDirName is not found @exception InvalidDoseException Thrown if any loaded dose is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h b/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h index f3f55c7..5ed9498 100644 --- a/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h +++ b/code/io/helax/rttbDicomHelaxIODVecDoseAccessorGenerator.h @@ -1,68 +1,68 @@ // ----------------------------------------------------------------------- // 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 __DICOM_HELAX_IOD_VEC_DOSE_ACCESSOR_GENERATOR_H #define __DICOM_HELAX_IOD_VEC_DOSE_ACCESSOR_GENERATOR_H #include #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ -#include "drtdose.h" +#include "dcmtk/dcmrt/drtdose.h" #include "rttbDoseAccessorGeneratorBase.h" namespace rttb { namespace io { namespace helax { /*! @class DicomHelaxIODVecDoseAccessorGenerator @brief Generate DoseAccessor with a vector of DRTDoseIOD. */ class DicomHelaxIODVecDoseAccessorGenerator: public core::DoseAccessorGeneratorBase { public: using DRTDoseIODPtr = boost::shared_ptr; protected: private: std::vector _dosePtrVector; DicomHelaxIODVecDoseAccessorGenerator() = delete; public: ~DicomHelaxIODVecDoseAccessorGenerator() override; /*! @brief Constructor. Initialisation with a vector of DRTDoseIOD pointers */ explicit DicomHelaxIODVecDoseAccessorGenerator(std::vector& aDICOMRTDoseVector); /*! @brief Generate DoseAccessor @return Return shared pointer of DoseAccessor. @exception InvalidDoseException Thrown if any DRTDoseIOD pointer of _doseVector is invalid: one of column/row/numberOfFrames/doseGridScaling/pixelSpacing=0 @exception DcmrtException Throw if dcmrt error */ DoseAccessorPointer generateDoseAccessor() override ; }; } } } #endif diff --git a/code/io/itk/CMakeLists.txt b/code/io/itk/CMakeLists.txt index 5a01901..5b27e61 100644 --- a/code/io/itk/CMakeLists.txt +++ b/code/io/itk/CMakeLists.txt @@ -1,9 +1,9 @@ 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) + RTTB_CREATE_MODULE(RTTBITKIO INCLUDE_DIRS PRIVATE ITK5 DEPENDS PUBLIC RTTBCore PACKAGE_DEPENDS PUBLIC 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) + RTTB_CREATE_MODULE(RTTBITKIO INCLUDE_DIRS PRIVATE ITK4 DEPENDS PUBLIC RTTBCore PACKAGE_DEPENDS PUBLIC ITK) ENDIF() \ No newline at end of file diff --git a/code/io/models/CMakeLists.txt b/code/io/models/CMakeLists.txt index 3f6de7d..03dfcf9 100644 --- a/code/io/models/CMakeLists.txt +++ b/code/io/models/CMakeLists.txt @@ -1,2 +1,2 @@ -RTTB_CREATE_MODULE(RTTBModelsIO DEPENDS RTTBCore RTTBModels RTTBOtherIO RTTBAlgorithms PACKAGE_DEPENDS Boost) +RTTB_CREATE_MODULE(RTTBModelsIO DEPENDS RTTBCore RTTBModels RTTBOtherIO RTTBAlgorithms PACKAGE_DEPENDS PRIVATE Boost|filesystem) diff --git a/code/io/models/rttbModelXMLWriter.h b/code/io/models/rttbModelXMLWriter.h index 7a1e779..4ea4343 100644 --- a/code/io/models/rttbModelXMLWriter.h +++ b/code/io/models/rttbModelXMLWriter.h @@ -1,57 +1,59 @@ // ----------------------------------------------------------------------- // 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 __MODELS_XML_WRITER_H #define __MODELS_XML_WRITER_H #include "rttbBioModel.h" +#include "RTTBModelsIOExports.h" + namespace rttb { namespace io { namespace models { /*! @class ModelXMLWriter @brief Writes a model (TCP, NTCP, ...) to an xml file */ - class ModelXMLWriter + class RTTBModelsIO_EXPORT ModelXMLWriter { private: std::string _filename; rttb::models::BioModel::Pointer _model; bool _printDVH; public: ModelXMLWriter(const std::string& filename, rttb::models::BioModel::Pointer model, bool printDVH = true); void setFilename(std::string filename); std::string getFilename() const; void setModel(rttb::models::BioModel::Pointer model); rttb::models::BioModel::Pointer getModel() const; void setPrintDVH(bool printDVH); bool getPrintDVH() const; void writeModel(); }; } } } #endif diff --git a/code/io/other/rttbDVHXMLFileReader.h b/code/io/other/rttbDVHXMLFileReader.h index 01e8e60..8822af0 100644 --- a/code/io/other/rttbDVHXMLFileReader.h +++ b/code/io/other/rttbDVHXMLFileReader.h @@ -1,64 +1,66 @@ // ----------------------------------------------------------------------- // 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 __DVH_XML_FILE_READER_H #define __DVH_XML_FILE_READER_H #include "rttbBaseType.h" #include "rttbDVHGeneratorInterface.h" +#include "RTTBOtherIOExports.h" + namespace rttb { namespace io { namespace other { /*! @class DVHXMLFileReader @brief Reads DVH data from xml files. */ - class DVHXMLFileReader: public core::DVHGeneratorInterface + class RTTBOtherIO_EXPORT DVHXMLFileReader: public core::DVHGeneratorInterface { private: FileNameString _fileName; bool _resetFile; /*! @brief Create new DVH object using the info from dvh txt file @exception InvalidParameterException Thrown if _fileName invalid */ void createDVH(); public: /*! @brief Constructor. */ explicit DVHXMLFileReader(FileNameString aFileName); ~DVHXMLFileReader(); /*! @brief Change file name. */ void resetFileName(FileNameString aFileName); /*! @brief Generate DVH, createDVH() will be called @return Return new shared pointer of DVH. @exception InvalidParameterException Thrown if _fileName invalid */ core::DVH::Pointer generateDVH() override; }; } } } #endif diff --git a/code/io/other/rttbDoseStatisticsXMLReader.h b/code/io/other/rttbDoseStatisticsXMLReader.h index 73bf445..abb806d 100644 --- a/code/io/other/rttbDoseStatisticsXMLReader.h +++ b/code/io/other/rttbDoseStatisticsXMLReader.h @@ -1,58 +1,60 @@ // ----------------------------------------------------------------------- // 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 __DOSE_STATISTICS_XML_READER_H #define __DOSE_STATISTICS_XML_READER_H #include "rttbDoseStatistics.h" +#include "RTTBOtherIOExports.h" + namespace rttb { namespace io { namespace other { /*! @class DoseStatisticsXMLReader @brief Reads a dose statistics XML into a DoseStatistics object */ - class DoseStatisticsXMLReader{ + class RTTBOtherIO_EXPORT DoseStatisticsXMLReader{ public: explicit DoseStatisticsXMLReader(const std::string& filename); ~DoseStatisticsXMLReader(); void setFilename(const std::string& filename); /*! @brief Generate a Model, createModel() will be called @return Return new shared pointer of a Model. @exception InvalidParameterException Thrown if _filename invalid */ algorithms::DoseStatistics::Pointer generateDoseStatistic(); private: std::string _filename; bool _newFile; algorithms::DoseStatistics::Pointer _doseStatistic; /*! @brief Create new Model object using the info from model xml file @exception InvalidParameterException Thrown if _filename invalid */ void createDoseStatistic(); }; } } } #endif diff --git a/code/masks/CMakeLists.txt b/code/masks/CMakeLists.txt index a107409..544aec1 100644 --- a/code/masks/CMakeLists.txt +++ b/code/masks/CMakeLists.txt @@ -1,7 +1,5 @@ -MESSAGE (STATUS "processing RTToolbox boost mask") - -RTTB_CREATE_MODULE(RTTBMask DEPENDS RTTBCore PACKAGE_DEPENDS BoostBinaries) +RTTB_CREATE_MODULE(RTTBMask DEPENDS PUBLIC RTTBCore) IF (CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") ENDIF() diff --git a/code/masks/rttbBoostMask.h b/code/masks/rttbBoostMask.h index 18b009c..e37d886 100644 --- a/code/masks/rttbBoostMask.h +++ b/code/masks/rttbBoostMask.h @@ -1,195 +1,197 @@ // ----------------------------------------------------------------------- // 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 __BOOST_MASK_R_H #define __BOOST_MASK_R_H #include "rttbBaseType.h" #include "rttbStructure.h" #include "rttbGeometricInfo.h" #include "rttbMaskAccessorInterface.h" #include #include #include #include +#include "RTTBMaskExports.h" + namespace rttb { namespace masks { namespace boost { /*! @class BoostMask * @brief Implementation of voxelization using boost::geometry. * @attention If "strict" is set to true, an exception will be thrown when the given structure has self intersection. * (A structure without self intersection means all contours of the structure have no self intersection, and * the polygons on the same slice have no intersection between each other, unless the case of a donut. A donut is accepted.) * If "strict" is set to false, debug information will be displayed when the given structure has self intersection. Self intersections will be ignored * and the mask will be calculated, however, it may cause errors in the mask results. */ - class BoostMask + class RTTBMask_EXPORT BoostMask { public: using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; /*! @brief Constructor * @exception rttb::core::NullPointerException thrown if aDoseGeoInfo or aStructure is nullptr * @param aDoseGeoInfo the GeometricInfo * @param aStructure the structure set * @param strict indicates whether to allow self intersection in the structure. If it is set to true, an exception will be thrown when the given structure has self intersection. * @param numberOfThreads number of threads used for voxelization. default value 0 means automatic detection, using the number of Hardware thread/cores * @exception InvalidParameterException thrown if strict is true and the structure has self intersections */ BoostMask(core::GeometricInfo::Pointer aDoseGeoInfo, core::Structure::Pointer aStructure, bool strict = true, unsigned int numberOfThreads = 0); /*! @brief Generate mask and return the voxels in the mask * @exception rttb::core::InvalidParameterException thrown if the structure has self intersections */ MaskVoxelListPointer getRelevantVoxelVector(); private: using BoostPoint2D = ::boost::geometry::model::d2::point_xy; using BoostPolygon2D = ::boost::geometry::model::polygon< ::boost::geometry::model::d2::point_xy >; using BoostRing2D = ::boost::geometry::model::ring< ::boost::geometry::model::d2::point_xy >; using BoostRingVector = std::vector;//polygon without holes using BoostPolygonVector = std::vector;//polygon with or without holes using VoxelIndexVector = std::vector; typedef std::map BoostPolygonMap;//map of the z index with the vector of boost 2d polygon typedef std::map BoostRingMap;//map of the z index with the vector of boost 2d ring typedef ::boost::multi_array BoostArray2D; using BoostArray2DPointer = ::boost::shared_ptr; typedef ::boost::shared_ptr > BoostArrayMapPointer; core::GeometricInfo::Pointer _geometricInfo; core::Structure::Pointer _structure; bool _strict; /*! @brief The number of threads */ unsigned int _numberOfThreads; //@brief The thickness of the voxelization plane (the contour plane), in double dose grid index //@details for example, the first contour has the double grid index 0.1, the second 0.3, the third 0.5, then the thickness is 0.2 double _voxelizationThickness; //@brief vector of the MaskVoxel inside the structure MaskVoxelListPointer _voxelInStructure; /*! @brief The map of z index and a vector of boost ring 2d (without holes) * @details Key: the double z grid index * Value: the vector of boost ring 2d (without holes) */ BoostRingMap _ringMap; /*! @brief The min and max index of the global bounding box. * @details The first index has the minimum for x/y/z of the global bounding box. * The second index has the maximum for x/y/z of the global bounding index. */ VoxelIndexVector _globalBoundingBox; /*! @brief The voxelization map * @details key: the converted double z grid index of a contour plane * value: the 2d mask, array[i][j] = the mask value of the position (i,j) in the global bounding box, * i: 0 - (_globalBoundingBoxSize0-1), j: 0 - (_globalBoundingBoxSize1-1) */ BoostArrayMapPointer _voxelizationMap; /*! @brief If the mask is up to date */ bool _isUpToDate; /*! @brief Voxelization and generate mask */ void calcMask(); /*! @brief The preprocessing step, wich consists of the following logic and Sub setps: * @details For all contours in a struct: * 1) Transfer the contour polygons into boost::geometry structures * 1a) Convert the contur points from world coordinates into geometry coordinates. * 1b) get min and max for x/y/z of a contour * 2) Tilt check: if difference of z_min and z_max is larger then a tolerance value -> there is a tilt. Throw rttb::TiltedMaskPlaneException. * 3) Get struct-bounding-box: get x_min_struct, y_min_struct, x_max_struct, y_max_struct to define the bounding box that containes all contours of a struct in x-y-dimensions. */ void preprocessing(); /*! @brief The voxelization step, which computes the voxelization planes (in x/y) for all contours of an struct. * @details For each contour (that is in the z-Range of the reference geometry) of the struct: * 1) Allocate result array (voxelization plane) based on the bounding box (see Preprocessing Step 3) * 2) Generate voxelization plane for the contour (based on the x-y-raster of the reference geometry). * 3) Add result Array (key is the z-Value of the contour) */ void voxelization(); /*! @brief mask voxel Generation step which transfers the voxelization planes into the (z-)geometry of the reference geometry. * @details It consists of following Sub steps : * For all "slices" in the reference geometry : * 1) generate weight vector for all voxelization planes for a given z - value of a slice * Iterate over the bounding box of a struct.For each voxel : * 2) Compute weighted sum of all voxelization planes(use weight vector, step 1) * 2a) If sum > 0 : Add mask voxel for the current x / y(inner Loop) and z value(outer Loop). * 3) return mask voxel list. */ void generateMaskVoxelList(); /*! @brief Convert the rttb polygon with world coordinate to the rttb polygon with double geometry coordinate, calculate the current min/max * and check if the polygon is planar * @param minimum the current global minimum * @param maximum the current global maximum * @return Return true if the polygon is planar, which means that the minimal and maximal z-coordinate of the polygon is not larger than a error constant */ bool preprocessingPolygon(const rttb::PolygonType& aRTTBPolygon, rttb::PolygonType& geometryCoordinatePolygon, rttb::ContinuousVoxelGridIndex3D& minimum, rttb::ContinuousVoxelGridIndex3D& maximum, double aErrorConstant) const; /*! @brief Convert a rttb 3d polygon to a 2d boost ring*/ BoostRing2D convertRTTBPolygonToBoostRing(const rttb::PolygonType& aRTTBPolygon) const; /*! @brief Convert a rttb 3d polygon to a map of z index with a vector of boost 2d ring, because of tilt check use the first z index of the polygon as the map key*/ BoostRingMap convertRTTBPolygonSequenceToBoostRingMap(const rttb::PolygonSequenceType& aRTTBPolygonVector) const; /*! @brief Find the key with error constant to aIndex * @pre aBoostRingMap should not be empty * @return Return aBoostRingMap.end() if the key is not found */ BoostMask::BoostRingMap::iterator findNearestKey(BoostMask::BoostRingMap& aBoostRingMap, double aIndex, double aErrorConstant) const; /*! @brief If 2 rings in the vector build a donut, convert the 2 rings to a donut polygon, other rings unchanged*/ BoostPolygonVector checkDonutAndConvert(const BoostRingVector& aRingVector) const; /*! @brief Calculate the voxelization thickness. Return false, if the voxelization plane is not homogeneous */ bool calcVoxelizationThickness(double& aThickness) const; }; } } } #endif diff --git a/code/masks/rttbBoostMaskAccessor.h b/code/masks/rttbBoostMaskAccessor.h index d615ba7..362f160 100644 --- a/code/masks/rttbBoostMaskAccessor.h +++ b/code/masks/rttbBoostMaskAccessor.h @@ -1,116 +1,116 @@ // ----------------------------------------------------------------------- // 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 __BOOST_MASK_R_ACCESSOR__H #define __BOOST_MASK_R_ACCESSOR__H #include "rttbBaseType.h" #include "rttbGeometricInfo.h" #include "rttbMaskAccessorInterface.h" #include "rttbStructure.h" #include "RTTBMaskExports.h" namespace rttb { namespace masks { namespace boost { /*! @class BoostMaskAccessor * @brief Using the voxelization based on boost::geometry and generate the mask accessor. * @attention If "strict" is set to true, an exception will be thrown when the given structure has self intersection. * (A structure without self intersection means all contours of the structure have no self intersection, and * the polygons on the same slice have no intersection between each other, unless the case of a donut. A donut is accepted.) * If "strict" is set to false, debug information will be displayed when the given structure has self intersection. Self intersections will be ignored * and the mask will be calculated, however, it may cause errors in the mask results. */ - class RTTBMask_EXPORT BoostMaskAccessor : public core::MaskAccessorInterface + class RTTBMask_EXPORT BoostMaskAccessor : public core::MaskAccessorInterface { public: using MaskVoxelList = core::MaskAccessorInterface::MaskVoxelList; using MaskVoxelListPointer = core::MaskAccessorInterface::MaskVoxelListPointer; using StructTypePointer = core::Structure::Pointer; private: StructTypePointer _spStructure; core::GeometricInfo _geoInfo; bool _strict; /*! vector containing list of mask voxels*/ MaskVoxelListPointer _spRelevantVoxelVector; IDType _maskUID; public: /*! @brief Constructor with a structure pointer and a geometric info pointer * @param aStructurePointer smart pointer of the structure * @param aGeometricInfo smart pointer of the geometricInfo of the dose * @param strict indicates whether to allow self intersection in the structure. If it is set to true, an exception will be thrown when the given structure has self intersection. * @exception InvalidParameterException thrown if strict is true and the structure has self intersections */ BoostMaskAccessor(StructTypePointer aStructurePointer, const core::GeometricInfo& aGeometricInfo, bool strict = true); /*! @brief destructor*/ ~BoostMaskAccessor() override; /*! @brief voxelization of the given structures using boost algorithms*/ void updateMask() override; /*! @brief get vector containing all relevant voxels that are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector() override; /*! @brief get vector containing all relevant voxels that have a relevant volume above the given threshold and are inside the given structure*/ MaskVoxelListPointer getRelevantVoxelVector(float lowerThreshold) override; /*!@brief determine how a given voxel on the dose grid is masked * @param aID ID of the voxel in grid. * @param voxel Reference to the voxel. * @post after a valid call voxel containes the information of the specified grid voxel. If aID is not valid, voxel values are undefined. * The relevant volume fraction will be set to zero. * @return Indicates of the voxel exists and therefore if parameter voxel containes valid values.*/ bool getMaskAt(const VoxelGridID aID, core::MaskVoxel& voxel) const override; /*!@brief determine how a given voxel on the dose grid is masked * @param aIndex 3d index of the voxel in grid. * @param voxel Reference to the voxel. * @return Indicates of the voxel exists and therefore if parameter voxel containes valid values.*/ bool getMaskAt(const VoxelGridIndex3D& aIndex, core::MaskVoxel& voxel) const override; /*! @brief give access to GeometricInfo*/ const core::GeometricInfo& getGeometricInfo() const override; /* @ brief is true if dose is on a homogeneous grid * @remark Inhomogeneous grids are not supported at the moment, but if they will be supported in the future the interface does not need to change.*/ bool isGridHomogeneous() const override { return true; }; IDType getMaskUID() const override { return _maskUID; }; }; } } } #endif diff --git a/code/models/CMakeLists.txt b/code/models/CMakeLists.txt index b7cc625..4479756 100644 --- a/code/models/CMakeLists.txt +++ b/code/models/CMakeLists.txt @@ -1,2 +1,2 @@ -RTTB_CREATE_MODULE(RTTBModels DEPENDS RTTBCore PACKAGE_DEPENDS Boost) +RTTB_CREATE_MODULE(RTTBModels DEPENDS PUBLIC RTTBCore) diff --git a/code/models/rttbBioModelCurve.h b/code/models/rttbBioModelCurve.h index 7e4e44d..46dd759 100644 --- a/code/models/rttbBioModelCurve.h +++ b/code/models/rttbBioModelCurve.h @@ -1,49 +1,51 @@ // ----------------------------------------------------------------------- // 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 __MODEL_CURVE_H #define __MODEL_CURVE_H +#include "RTTBModelsExports.h" + namespace rttb { namespace models { class BioModel; class NTCPLKBModel; //map of dose value and model value typedef std::map CurveDataType; //pair of dose value and model value typedef std::pair CurvePointType; /*! @brief Get the curve TCP/NTCP Value vs normalisationDose, normalisationDose variant between minDose and maxDose. @param aBin the size of the map @param minDose min value for x axis @param maxDose max value for x axis @param normalisationDose prescribed dose of the current _dvh or mean/maximum. */ - CurveDataType getCurveDoseVSBioModel(BioModel& aModel, double normalisationDose, int aBin = 201, + RTTBModels_EXPORT CurveDataType getCurveDoseVSBioModel(BioModel& aModel, double normalisationDose, int aBin = 201, double minDose = 0.1, double maxDose = 150); /*! @brief Get the curve NTCP Value vs EUD, dvh variant between minFactor*deltaD and maxFactor*deltaD. @param aBin the size of the map @param minFactor min factor for dvh deltaD @param maxFactor max factor for dvh deltaD */ - CurveDataType getCurveEUDVSBioModel(NTCPLKBModel& aModel, DoseCalcType maxFactor = 10, + RTTBModels_EXPORT CurveDataType getCurveEUDVSBioModel(NTCPLKBModel& aModel, DoseCalcType maxFactor = 10, DoseCalcType minFactor = 0.1, int aBin = 201); } } #endif \ No newline at end of file diff --git a/code/models/rttbBioModelScatterPlots.h b/code/models/rttbBioModelScatterPlots.h index 9268b63..980a87d 100644 --- a/code/models/rttbBioModelScatterPlots.h +++ b/code/models/rttbBioModelScatterPlots.h @@ -1,90 +1,92 @@ // ----------------------------------------------------------------------- // 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 __MODEL_SCATTER_H #define __MODEL_SCATTER_H #include "rttbBaseType.h" #include "rttbBaseTypeModels.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { class BioModel; // maps dose to a pair of model value and probability typedef std::multimap > ScatterPlotType; using ParamVectorType = std::vector; /*! @brief Get the points (TCP/NTCP Value, probability of the value) if 1 parameter vary from a normal- distribution with mean=aMean, variance=aVariance. @param aModel biological model for which the scatter plot will be generated @param aParamId ID of the parameter to be varied to generate the scatter plot @param aMean mean value for the distribution of the varied parameter @param aVariance variance of the varied parameter. The variance may not be exactly zero. If so, it is set to 1e-30 to avoid numerical instability. @param aNormalisationDose prescribed dose of the current _dvh @param numberOfPoints the size of the map, number of points to be calculated @param aMinDose dose will be randomly selected from [aMinDose] (uniform distribution). They will define the minvalue for x axis @param aMaxDose dose will be randomly selected from [aMaxDose] (uniform distribution). They will define the max value for x axis @return Map of scattered values. If all parameters are valid, this map contains numberOfPoints valid scatter values. If aMaxDose<=aMinDose, the scatter plot cannot be generated. The map will therefore be empty. @warning This method is slow, do not use with too many points. Because the scatter plot map must contain numberOfPoints the scatter plot generation may run more often (producing invalid values). In tests the generation process runs on average approximately 20% more often. @exception InvalidParameterException Thrown if aNormalisationDose<=0 or aMinDose<=aMaxiDose */ - ScatterPlotType getScatterPlotVary1Parameter(BioModel& aModel, int aParamId, + RTTBModels_EXPORT ScatterPlotType getScatterPlotVary1Parameter(BioModel& aModel, int aParamId, BioModelParamType aMean, BioModelParamType aVariance, DoseTypeGy aNormalisationDose, int numberOfPoints = 100, DoseTypeGy aMinDose = 0, DoseTypeGy aMaxDose = 150); /*! @brief Get the points (TCP/NTCP Value, probability of the value) if >=1 parameter vary from a normal- distribution with mean of parameter aParamIdVec.at(i)=aMeanVec.at(i), variance of parameter aParamIdVec.at(i)= aVarianceVec.at(i). @param aModel biological model for which the scatter plot will be generated @param aParamIdVec a vector containing the IDs of the parameters to be varied to generate the scatter plot @param aMeanVec a vector of mean values for the distribution of individually the varied parameters @param aVarianceVec a vector of variance values of the individually varied parameter. The variance may not be exactly zero for any parameter. If so, it is set to 1e-30 to avoid numerical instability. @param aNormalisationDose prescribed dose of the current _dvh @param numberOfPoints the size of the map, number of points to be calculated @param aMinDose dose will be randomly selected from [aMinDose] (uniform distribution). They will define the min value for x axis @param aMaxDose dose will be randomly selected from [aMaxDose] (uniform distribution). They will define the max value for x axis @throw InvalidParameterException is thrown if the parameter vectors do not have the same size. @return Map of scattered values. If all parameters are valid, this map contains numberOfPoints valid scatter values. If aMaxDose<=aMinDose, the scatter plot cannot be generated. The map will therefore be empty. @warning This method is very slow do not use with too many points. Because the scatter plot map must contain numberOfPoints the scatter plot generation may run more often (producing invalid values). In tests the generation process runs on average approximately 20% more often. @exception InvalidParameterException Thrown if aNormalisationDose<=0 or aMinDose<=aMaxiDose */ - ScatterPlotType getScatterPlotVaryParameters(BioModel& aModel, std::vector aParamIdVec, + RTTBModels_EXPORT ScatterPlotType getScatterPlotVaryParameters(BioModel& aModel, std::vector aParamIdVec, ParamVectorType aMeanVec, ParamVectorType aVarianceVec, DoseTypeGy aNormalisationDose, int numberOfPoints = 50, DoseTypeGy aMinDose = 0, DoseTypeGy aMaxDose = 150); /*! Compute normal probability density function for zero mean at aValue with aVariance. */ - double normal_pdf(double aValue, double aVariance); + RTTBModels_EXPORT double normal_pdf(double aValue, double aVariance); } } -#endif \ No newline at end of file +#endif diff --git a/code/models/rttbDoseBasedModels.h b/code/models/rttbDoseBasedModels.h index 0101de3..d83591d 100644 --- a/code/models/rttbDoseBasedModels.h +++ b/code/models/rttbDoseBasedModels.h @@ -1,37 +1,39 @@ // ----------------------------------------------------------------------- // 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 "rttbBaseTypeModels.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { /*! @brief Calculate biological LinearQuadratic Model of a dose @details \f$LQ = exp(-\frac{alpha*d+beta*d^2}{nFractions})\f$ @param dose @param alpha @param beta @param nFractions the number of fractions @pre dose>=0 @pre alpha>=0 @pre beta>=0 @return The LQ value @exception rttb::core::InvalidParameterException Thrown if parameters were not set correctly. */ - BioModelValueType calcLQ(DoseTypeGy dose, DoseCalcType alpha, + RTTBModels_EXPORT BioModelValueType calcLQ(DoseTypeGy dose, DoseCalcType alpha, DoseCalcType beta, unsigned int nFractions=1); } } \ No newline at end of file diff --git a/code/models/rttbDvhBasedModels.h b/code/models/rttbDvhBasedModels.h index 7d5334e..b87cd89 100644 --- a/code/models/rttbDvhBasedModels.h +++ b/code/models/rttbDvhBasedModels.h @@ -1,65 +1,67 @@ // ----------------------------------------------------------------------- // 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 #include "rttbDVH.h" #include "rttbBaseType.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { using DataDifferentialType = core::DVH::DataDifferentialType; typedef std::map BEDDVHType; typedef std::map LQEDDVHType; /*! @brief Get Equivalent Uniform Dose (EUD) @pre dvh data differential is not empty, @pre aA is not zero, @return Return calculated EUD value, @exception InvalidParameterException Thrown if parameters were not set correctly. */ - DoseStatisticType getEUD(core::DVH::ConstPointer dvh, const DoseCalcType aA); + RTTBModels_EXPORT DoseStatisticType getEUD(core::DVH::ConstPointer dvh, const DoseCalcType aA); /*! @brief Calculate Biological Effective/Equivalent Dose (BED) of dvh @param relativeVolume default false-> the corresponding volume value is the voxel number of the dose bin; if true-> the corresponding volume value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @pre dvh should be an accumulated dvh of all fractions, not a single fraction dvh @pre dvh data differential is not empty @pre alpha_beta > 0 @pre numberOfFractions > 1 @return Return map: keys are BEDi in Gy, values are the volume of the dose bin @exception InvalidParameterException Thrown if parameters were not set correctly. */ - BEDDVHType calcBEDDVH(core::DVH::ConstPointer dvh, const int numberOfFractions, + RTTBModels_EXPORT BEDDVHType calcBEDDVH(core::DVH::ConstPointer dvh, const int numberOfFractions, const DoseCalcType alpha_beta, const bool relativeVolume = false); /*! @brief Calculate Linear-quadratic equivalent dose for 2-Gy (LQED2) of dvh @param relativeVolume default false-> the corresponding volume value is the voxel number of the dose bin; if true-> the corresponding volume value is the relative volume % between 0 and 1, (the voxel number of this dose bin)/(number of voxels) @pre dvh should be an accumulated dvh of all fractions, not a single fraction dvh @pre dvh data differential is not empty @pre alpha_beta > 0 @pre numberOfFractions > 1 @return Return map: keys are LQED2 in Gy, values are the volume of the dose bin; return empty map if not initialized @exception InvalidParameterException Thrown if parameters were not set correctly. */ - LQEDDVHType calcLQED2DVH(core::DVH::ConstPointer dvh, const int numberOfFractions, + RTTBModels_EXPORT LQEDDVHType calcLQED2DVH(core::DVH::ConstPointer dvh, const int numberOfFractions, const DoseCalcType alpha_beta, const bool relativeVolume = false); } } \ No newline at end of file diff --git a/code/models/rttbLQModelAccessor.h b/code/models/rttbLQModelAccessor.h index c97ba08..9442af9 100644 --- a/code/models/rttbLQModelAccessor.h +++ b/code/models/rttbLQModelAccessor.h @@ -1,87 +1,89 @@ // ----------------------------------------------------------------------- // 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 __LQ_MODEL_ACCESSOR_H #define __LQ_MODEL_ACCESSOR_H #include "rttbAccessorWithGeoInfoBase.h" #include "rttbDoseAccessorInterface.h" #include "rttbBaseTypeModels.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { /*! @class LQModelAccessor @brief This class gives access to the LQ Model information in an image */ - class LQModelAccessor: public core::AccessorWithGeoInfoBase + class RTTBModels_EXPORT LQModelAccessor: public core::AccessorWithGeoInfoBase { public: using DoseAccessorPointer = core::DoseAccessorInterface::Pointer; private: DoseAccessorPointer _dose; BioModelParamType _alpha; BioModelParamType _beta; unsigned int _nFractions; DoseAccessorPointer _alphaMap; DoseAccessorPointer _betaMap; double _doseScaling; bool _withAlphaBetaMaps; IDType _bioModelUID; LQModelAccessor() = delete; /*! @brief get all required data from the dose geometric info */ void assembleGeometricInfo() override; public: ~LQModelAccessor() override; /*! @brief Constructor. @pre dose must be a valid instance (and != nullptr) @exception InvalidDoseException if _dose is nullptr */ LQModelAccessor(DoseAccessorPointer dose, BioModelParamType alpha, BioModelParamType beta, unsigned int nFractions=1, double doseScaling = 1.0); /*! @brief Constructor. @pre dose must be a valid instance (and != nullptr) @exception InvalidDoseException if dose is nullptr, if alphaMap is nullptr or if betaMap is nullptr */ LQModelAccessor(DoseAccessorPointer dose, DoseAccessorPointer alphaMap, DoseAccessorPointer betaMap, unsigned int nFractions = 1, double doseScaling = 1.0); /*! @brief returns the LQ Model value for an id */ GenericValueType getValueAt(const VoxelGridID aID) const override; /*! @brief returns the LQ Model value for an index */ GenericValueType getValueAt(const VoxelGridIndex3D& aIndex) const override; const IDType getUID() const override { return _bioModelUID; }; }; } } #endif diff --git a/code/models/rttbNTCPLKBModel.h b/code/models/rttbNTCPLKBModel.h index 56b8690..e0b8332 100644 --- a/code/models/rttbNTCPLKBModel.h +++ b/code/models/rttbNTCPLKBModel.h @@ -1,97 +1,97 @@ // ----------------------------------------------------------------------- // 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 __NTCP_LKB_MODEL_H #define __NTCP_LKB_MODEL_H #include #include "rttbNTCPModel.h" #include "rttbBaseTypeModels.h" namespace rttb { namespace models { /*! @class NTCPLKBModel @brief This class represents a NTCP(Normal Tissue Complication Probability) LKB model (Lyman 1985, Kutcher and Burman 1989) @see NTCPModel */ - class NTCPLKBModel: public NTCPModel + class RTTBModels_EXPORT NTCPLKBModel: public NTCPModel { public: using ParamVectorType = NTCPModel::ParamVectorType; private: /*! The steepness of the dose-response curve. Must not be zero on model evaluation. */ BioModelParamType _m{0}; /*! Tumor or normal tissue-specific parameter that describes the dose-volume effect, e.g. -10 for prostate (Wu 2002). Must not be zero on model evaluation, because EUD calculation will fail. */ BioModelParamType _a{0}; protected: /*! @brief Calculate the model value * @param doseFactor: scaling factor for the dose. The model calculation will use the dvh with each di=old di*doseFactor. * @throw if either _a or _m is zero for the model calculation */ BioModelValueType calcModel(const double doseFactor = 1) override; public: NTCPLKBModel(); NTCPLKBModel(core::DVH::Pointer aDvh, BioModelParamType aD50, BioModelParamType aM, BioModelParamType aA); void setM(const BioModelParamType aM); const BioModelParamType getM(); void setA(const BioModelParamType aA); const BioModelParamType getA(); /*! @brief Set parameter with ID. "d50":0,"m":1,"a":2 @exception InvalidParameterException Thrown if aParamId is not 0 or 1 or 2. */ void setParameterByID(const int aParamId, const BioModelParamType aValue) override; /*! @brief Set parameter vector, where index of vector is the parameter ID. "d50":0,"m":1,"a":2 @exception InvalidParameterException Thrown if aParamterVector.size()!=3. */ void setParameterVector(const ParamVectorType& aParameterVector) override; /*! @brief Get parameter ID. "d50":0,"m":1,"a":2 @return 0 for "d50", 1 for "m", 2 for "a" @exception InvalidParameterException Thrown if aParamName is not d50 or m or a. */ const int getParameterID(const std::string& aParamName) const override; std::map getParameterMap() const override; void fillParameterMap() override; std::string getModelType() const override; }; } } #endif diff --git a/code/models/rttbNTCPModel.h b/code/models/rttbNTCPModel.h index 6416c9f..dfc5f59 100644 --- a/code/models/rttbNTCPModel.h +++ b/code/models/rttbNTCPModel.h @@ -1,57 +1,59 @@ // ----------------------------------------------------------------------- // 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 __NTCP_MODEL_H #define __NTCP_MODEL_H #include "rttbBioModel.h" #include "rttbBaseTypeModels.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { /*! @class NTCPModel @brief This is the interface class for NTCP(Normal Tissue Complication Probability) models */ - class NTCPModel: public BioModel + class RTTBModels_EXPORT NTCPModel: public BioModel { public: using ParamVectorType = BioModel::ParamVectorType; protected: BioModelParamType _d50{0}; public: NTCPModel(): BioModel() {} explicit NTCPModel(const BioModelParamType aD50): BioModel(), _d50(aD50) {} NTCPModel(core::DVH::Pointer aDvh, const BioModelParamType aD50): BioModel(aDvh), _d50(aD50) {} const BioModelParamType getD50() { return _d50; } void setD50(const BioModelParamType aD50) { _d50 = aD50; } }; }//end namespace models }//end namespace rttb #endif diff --git a/code/models/rttbNTCPRSModel.h b/code/models/rttbNTCPRSModel.h index 387871b..f93f1c7 100644 --- a/code/models/rttbNTCPRSModel.h +++ b/code/models/rttbNTCPRSModel.h @@ -1,104 +1,106 @@ // ----------------------------------------------------------------------- // 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 __NTCP_RS_MODEL_H #define __NTCP_RS_MODEL_H #include #include "rttbNTCPModel.h" #include "rttbBaseTypeModels.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { /*! @class NTCPRSModel @brief This class represents a NTCP(Normal Tissue Complication Probability) relative seriality model (Kaellman 1992) @see NTCPModel */ - class NTCPRSModel: public NTCPModel + class RTTBModels_EXPORT NTCPRSModel: public NTCPModel { public: using ParamVectorType = NTCPModel::ParamVectorType; using DVHPointer = NTCPModel::DVHPointer; private: /*! _gamma The normalised dose-response gradient, values between 1.7 and 2.0 are typical for human tumours. (Kaellman 1992) */ BioModelParamType _gamma{0}; /*! _s The relative seriality factor, e.g. s=3.4 for the esophagus (highly serial structure) and s=0.0061 for the lung(highly parallel structure). Must not be zero on model evaluation. */ BioModelParamType _s{0}; const double poissonModel(const double dose); protected: /*! @brief Calculate the model value @param doseFactor scaling factor for the dose. The model calculation will use the dvh with each di=old di*doseFactor. @throw if either _s or _d50 is zero for the model calculation. */ BioModelValueType calcModel(const double doseFactor = 1) override; public: NTCPRSModel(); /*!@brief Constructor initializing all member variables with given parameters. */ NTCPRSModel(DVHPointer aDvh, BioModelParamType aD50, BioModelParamType aGamma, BioModelParamType aS); void setGamma(const BioModelParamType aGamma); const BioModelParamType getGamma(); void setS(const BioModelParamType aS); const BioModelParamType getS(); /*! @brief Set parameter with ID. "d50":0,"gamma":1,"s":2 @exception InvalidParameterException Thrown if aParamId is not 0 or 1 or 2. */ void setParameterByID(const int aParamId, const BioModelParamType aValue) override; /*! @brief Set parameter vector, where index of vector is the parameter Id. "d50":0,"gamma":1,"s":2 @exception InvalidParameterException Thrown if aParamterVector.size()!=3. */ void setParameterVector(const ParamVectorType& aParameterVector) override; /*! @brief Get parameter ID. "d50":0,"gamma":1,"s":2 @return 0 for "d50", 1 for "gamma", 2 for "s" @exception InvalidParameterException Thrown if aParamName is not d50 or gamma or s. */ const int getParameterID(const std::string& aParamName) const override; std::map getParameterMap() const override; void fillParameterMap() override; std::string getModelType() const override; }; } } #endif diff --git a/code/models/rttbTCPLQModel.h b/code/models/rttbTCPLQModel.h index 9b7eba2..a975437 100644 --- a/code/models/rttbTCPLQModel.h +++ b/code/models/rttbTCPLQModel.h @@ -1,163 +1,165 @@ // ----------------------------------------------------------------------- // 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 __TCP_LQ_MODEL_H #define __TCP_LQ_MODEL_H #include #include #include "rttbTCPModel.h" #include "rttbBaseTypeModels.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { /*! @class TCPLQModel @brief This class represents a TCP(Tumor Control Probability) LQ model (Nahum and Sanchez-Nieto 2001, Hall and Giaccia 2006) @see TCPModel */ - class TCPLQModel: public TCPModel + class RTTBModels_EXPORT TCPLQModel: public TCPModel { public: using ParamVectorType = TCPModel::ParamVectorType; using DVHPointer = core::DVH::Pointer; private: /*! @brief Calculate intermediate tcp using alpha constant. This is a helper function for calcTCP() @see calcTCP */ long double calcTCPi(BioModelParamType aRho, BioModelParamType aAlphaMean, double vj, double bedj); /*! @brief Calculate tcp using alpha constant. */ long double calcTCP(std::map aBEDDVH, BioModelParamType aRho, BioModelParamType aAlphaMean, double aDeltaV); /*! @brief Calculate tcp using a normal distribution for alpha. */ long double calcTCPAlphaNormalDistribution(std::map aBEDDVH, BioModelParamType aRho, BioModelParamType aAlphaMean, BioModelParamType aAlphaVariance, double aDeltaV); protected: BioModelParamType _alphaMean{0}; BioModelParamType _alphaVariance{0}; BioModelParamType _alpha_beta{0}; /*! Roh is the initial clonogenic cell density */ BioModelParamType _rho{0}; /*! @brief Calculate the model value @param doseFactor scaling factor for prescribed dose. The model calculation will use the dvh with each di=old di*doseFactor. @pre _alphaMean >0 @pre _alphaVariance >= 0 @pre _alpha_beta > 0 @pre _rho > 0 @pre _numberOfFractions > 1 @exception InvalidParameterException Thrown if parameters were not set correctly. */ BioModelValueType calcModel(const double doseFactor = 1) override; public: TCPLQModel(); /*! @brief Constructor initializes member variables with given parameters. @pre aAlphaMean >0 @pre aBeta > 0 @pre aRho > 0 @pre aNumberOfFractions > 1 */ TCPLQModel(DVHPointer aDVH, BioModelParamType aAlphaMean, BioModelParamType aBeta, BioModelParamType aRho, int aNumberOfFractions); /*! @brief Constructor for alpha distribution initializes member variables with given parameters. @pre aAlphaMean >0 @pre aAlphaVariance >0 @pre aAlpha_Beta > 0 @pre aRho > 0 @pre aNumberOfFractions > 1 */ TCPLQModel(DVHPointer aDVH, BioModelParamType aRho, int aNumberOfFractions, BioModelParamType aAlpha_Beta, BioModelParamType aAlphaMean, BioModelParamType aAlphaVariance); const BioModelParamType getRho(); void setRho(const BioModelParamType aRho); const BioModelParamType getAlphaMean(); const BioModelParamType getAlphaVariance(); /*! @brief The distribution of the parameter alpha, which is characteristic for a population of cells, is described by the its mean and variance. If alpha is constant the variance is 0. @param aAlphaVariance The variance of alpha can be given, the default value is 0 resulting in constant alpha. */ void setAlpha(const BioModelParamType aAlphaMean, const BioModelParamType aAlphaVariance = 0); const BioModelParamType getAlphaBeta(); void setAlphaBeta(const BioModelParamType aAlpha_Beta); /*! @brief Set parameters for the TCP model. _value will be reset to 0. @param aAlpha_Beta alpha/beta constant . @param aAlphaMean mean of alpha distribution. @param aAlphaVariance variance of alpha distribution. */ void setParameters(const BioModelParamType aAlphaMean, const BioModelParamType aAlpha_Beta, const BioModelParamType aRho, const BioModelParamType aAlphaVariance = 0); /*! @brief Set parameter with ID. "alphaMean":0,"alphaVariance":1,"alpha_beta":2, "rho":3 @exception InvalidParameterException Thrown if aParamId is not 0 or 1 or 2 or 3. */ void setParameterByID(const int aParamId, const BioModelParamType aValue) override; /*! @brief Set parameter vector, where index of vector is the parameter id. "alphaMean":0,"alphaVariance":1,"alpha_beta":2, "rho":3 @exception InvalidParameterException Thrown if aParamterVector.size()!=4. */ void setParameterVector(const ParamVectorType& aParameterVector) override; /*! @brief Get parameter id. "alphaMean":0,"alphaVariance":1,"alpha_beta":2, "rho":3 @return 0 for "alphaMean", 1 for "alphaVariance", 2 for "alpha_beta", 3 for "rho" @exception InvalidParameterException Thrown if aParamName is not alphaMean or alphaVariance or alpha_beta or rho. */ const int getParameterID(const std::string& aParamName) const override; std::map getParameterMap() const override; void fillParameterMap() override; std::string getModelType() const override; }; }//end algorithms }//end rttb #endif diff --git a/code/models/rttbTCPModel.h b/code/models/rttbTCPModel.h index 03169a4..2f22235 100644 --- a/code/models/rttbTCPModel.h +++ b/code/models/rttbTCPModel.h @@ -1,56 +1,58 @@ // ----------------------------------------------------------------------- // 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 __TCP_MODEL_H #define __TCP_MODEL_H #include "rttbBioModel.h" +#include "RTTBModelsExports.h" + namespace rttb { namespace models { /*! @class TCPModel @brief This is the interface class for TCP(Tumor Control Probability) models */ - class TCPModel: public BioModel + class RTTBModels_EXPORT TCPModel: public BioModel { public: using ParamVectorType = BioModel::ParamVectorType; protected: int _numberOfFractions{0}; public: TCPModel(): BioModel() {}; explicit TCPModel(int aNum): BioModel(), _numberOfFractions(aNum) {}; TCPModel(core::DVH::Pointer aDvh, int aNum): BioModel(aDvh), _numberOfFractions(aNum) {}; void setNumberOfFractions(const int aNumberOfFractions); const int getNumberOfFractions(); }; }//end namespace models }//end namespace rttb #endif diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index ec2a5cc..cf1b7fa 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -1,118 +1,119 @@ 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=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 + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} ${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_Indices "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_Indices) ADD_SUBDIRECTORY(indices) 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/testing/examples/rttbTestExamples.cpp b/testing/examples/rttbTestExamples.cpp index 5fb25de..c1fd14d 100644 --- a/testing/examples/rttbTestExamples.cpp +++ b/testing/examples/rttbTestExamples.cpp @@ -1,61 +1,60 @@ // ----------------------------------------------------------------------- // 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. // //------------------------------------------------------------------------ // this file defines the rttbCoreTests for the test driver // and all it expects is that you have a function called RegisterTests #if defined(_MSC_VER) #pragma warning ( disable : 4786 ) #endif #include "litMultiTestsMain.h" #include "RTToolboxConfigure.h" namespace rttb { namespace testing { void registerTests() { LIT_REGISTER_TEST(RTBioModelExampleTest); LIT_REGISTER_TEST(RTDVHTest); - LIT_REGISTER_TEST(RTDoseIndexTest); LIT_REGISTER_TEST(RTDoseStatisticsDicomTest); LIT_REGISTER_TEST(RTBioModelScatterPlotExampleTest); } } } int main(int argc, char* argv[]) { int result = 0; rttb::testing::registerTests(); try { result = lit::multiTestsMain(argc, argv); } catch (const std::exception& /*e*/) { result = -1; } catch (...) { result = -1; } return result; } diff --git a/testing/interpolation/InterpolationMatchPointTransformation/CMakeLists.txt b/testing/interpolation/InterpolationMatchPointTransformation/CMakeLists.txt index dd0e0a7..a047d44 100644 --- a/testing/interpolation/InterpolationMatchPointTransformation/CMakeLists.txt +++ b/testing/interpolation/InterpolationMatchPointTransformation/CMakeLists.txt @@ -1,14 +1,14 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(INTERPOLATION_MP_TRANSFORMATION_TESTS ${EXECUTABLE_OUTPUT_PATH}/${RTToolbox_PREFIX}InterpolationMPTransformationTests) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(SimpleMappableDoseAccessorWithMatchPointTest ${INTERPOLATION_MP_TRANSFORMATION_TESTS} SimpleMappableDoseAccessorWithMatchPointTest "${TEST_DATA_ROOT}/Dose/DICOM/ConstantTwo.dcm" "${TEST_DATA_ROOT}/Dose/DICOM/LinearIncreaseX.dcm") -RTTB_CREATE_TEST_MODULE(InterpolationMPTransformation DEPENDS RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBDicomIO PACKAGE_DEPENDS Litmus MatchPoint RTTBData) +RTTB_CREATE_TEST_MODULE(InterpolationMPTransformation DEPENDS RTTBInterpolation RTTBInterpolationMatchPointTransformation RTTBDicomIO PACKAGE_DEPENDS Litmus MatchPoint RTTBData ITK) diff --git a/testing/io/helax/CMakeLists.txt b/testing/io/helax/CMakeLists.txt index 8c09b8b..f23d9f8 100644 --- a/testing/io/helax/CMakeLists.txt +++ b/testing/io/helax/CMakeLists.txt @@ -1,23 +1,23 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(HelaxIO_TEST ${EXECUTABLE_OUTPUT_PATH}/${RTToolbox_PREFIX}HelaxIOTests) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(DicomHelaxDoseAccessorGeneratorTest ${HelaxIO_TEST} DicomHelaxDoseAccessorGeneratorTest "${TEST_DATA_ROOT}/Dose/DICOM/Helax/" "${TEST_DATA_ROOT}/Dose/DICOM/ConstantTwo.dcm" "${TEST_DATA_ROOT}/Dose/DICOM/ConstantFifty.dcm" "${TEST_DATA_ROOT}/Dose/DICOM/LinearIncrease3D.dcm" ) ADD_TEST(DicomHelaxIOTest ${HelaxIO_TEST} DicomHelaxIOTest "${TEST_DATA_ROOT}/Dose/DICOM/Helax/" ) -RTTB_CREATE_TEST_MODULE(HelaxIO DEPENDS RTTBHelaxIO RTTBDicomIO PACKAGE_DEPENDS BoostBinaries Litmus RTTBData DCMTK) +RTTB_CREATE_TEST_MODULE(HelaxIO DEPENDS RTTBHelaxIO RTTBDicomIO PACKAGE_DEPENDS Boost Litmus RTTBData DCMTK) diff --git a/testing/io/models/CMakeLists.txt b/testing/io/models/CMakeLists.txt index ab4adad..094b6d3 100644 --- a/testing/io/models/CMakeLists.txt +++ b/testing/io/models/CMakeLists.txt @@ -1,16 +1,16 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(MODELSIO_TEST ${EXECUTABLE_OUTPUT_PATH}/${RTToolbox_PREFIX}ModelsIOTests) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(ModelsIOTest ${MODELSIO_TEST} ModelsIOTest "${TEST_DATA_ROOT}/BioModel/XML/referenceBioModeltcpleqIOTest.xml" "${TEST_DATA_ROOT}/BioModel/XML/referenceBioModelntcplkIOTest.xml" ) -RTTB_CREATE_TEST_MODULE(ModelsIO DEPENDS RTTBModelsIO RTTBModels PACKAGE_DEPENDS Boost Litmus RTTBData) +RTTB_CREATE_TEST_MODULE(ModelsIO DEPENDS RTTBModelsIO RTTBModels PACKAGE_DEPENDS Boost|filesystem Litmus RTTBData) diff --git a/testing/io/other/CMakeLists.txt b/testing/io/other/CMakeLists.txt index 24e6cf3..3c651d3 100644 --- a/testing/io/other/CMakeLists.txt +++ b/testing/io/other/CMakeLists.txt @@ -1,17 +1,17 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(OTHERIO_TEST ${EXECUTABLE_OUTPUT_PATH}/${RTToolbox_PREFIX}OtherIOTests) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(DoseStatisticsIOTest ${OTHERIO_TEST} DoseStatisticsIOTest) ADD_TEST(DVHXMLIOTest ${OTHERIO_TEST} DVHXMLIOTest) -RTTB_CREATE_TEST_MODULE(OtherIO DEPENDS RTTBOtherIO RTTBTestHelper PACKAGE_DEPENDS Boost Litmus RTTBData) +RTTB_CREATE_TEST_MODULE(OtherIO DEPENDS RTTBOtherIO PACKAGE_DEPENDS Boost|filesystem Litmus RTTBData) diff --git a/testing/masks/CMakeLists.txt b/testing/masks/CMakeLists.txt index cb65197..c92918b 100644 --- a/testing/masks/CMakeLists.txt +++ b/testing/masks/CMakeLists.txt @@ -1,20 +1,20 @@ #----------------------------------------------------------------------------- # Setup the system information test. Write out some basic failsafe # information in case the test doesn't run. #----------------------------------------------------------------------------- SET(Boost_Mask_TESTS ${EXECUTABLE_OUTPUT_PATH}/${RTToolbox_PREFIX}MaskTests) SET(TEMP ${RTTBTesting_BINARY_DIR}/temporary) #----------------------------------------------------------------------------- ADD_TEST(BoostMaskTest ${Boost_Mask_TESTS} BoostMaskTest) -RTTB_CREATE_TEST_MODULE(Mask DEPENDS RTTBDicomIO RTTBMask RTTBTestHelper PACKAGE_DEPENDS BoostBinaries Litmus DCMTK) +RTTB_CREATE_TEST_MODULE(Mask DEPENDS RTTBDicomIO RTTBMask PACKAGE_DEPENDS PRIVATE Boost|filesystem Litmus DCMTK) IF (CMAKE_COMPILER_IS_GNUCC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals") ENDIF() \ No newline at end of file