diff --git a/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake b/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake index 749f5a71e2..ac6ab42f11 100644 --- a/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake +++ b/Applications/PluginGenerator/ProjectTemplate/CMakeExternals/MITK.cmake @@ -1,215 +1,213 @@ #----------------------------------------------------------------------------- # MITK #----------------------------------------------------------------------------- set(MITK_DEPENDS) set(proj_DEPENDENCIES) set(proj MITK) if(NOT MITK_DIR) #----------------------------------------------------------------------------- # Create CMake options to customize the MITK build #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Use superbuild for MITK" ON) option(MITK_USE_BLUEBERRY "Build the BlueBerry platform in MITK" ON) option(MITK_BUILD_EXAMPLES "Build the MITK examples" OFF) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) option(MITK_BUILD_TESTING "Build the MITK unit tests" OFF) option(MITK_USE_ACVD "Use Approximated Centroidal Voronoi Diagrams" OFF) option(MITK_USE_CTK "Use CTK in MITK" ${MITK_USE_BLUEBERRY}) option(MITK_USE_DCMTK "Use DCMTK in MITK" ON) option(MITK_USE_Qt5 "Use Qt 5 library in MITK" ON) option(MITK_USE_DCMQI "Use dcmqi in MITK" OFF) option(MITK_USE_OpenCV "Use Intel's OpenCV library" OFF) - option(MITK_USE_SOFA "Use Simulation Open Framework Architecture" OFF) option(MITK_USE_VMTK "Use the Vascular Modeling Toolkit in MITK" OFF) option(MITK_USE_Python "Enable Python wrapping in MITK" OFF) if(MITK_USE_BLUEBERRY AND NOT MITK_USE_CTK) message("Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() if(MITK_USE_CTK AND NOT MITK_USE_Qt5) message("Forcing MITK_USE_Qt5 to ON because of MITK_USE_CTK") set(MITK_USE_Qt5 ON CACHE BOOL "Use Qt 5 library in MITK" FORCE) endif() set(MITK_USE_CableSwig ${MITK_USE_Python}) set(MITK_USE_GDCM 1) set(MITK_USE_ITK 1) set(MITK_USE_VTK 1) mark_as_advanced(MITK_USE_SUPERBUILD MITK_BUILD_ALL_PLUGINS MITK_BUILD_TESTING ) set(mitk_cmake_boolean_args MITK_USE_SUPERBUILD MITK_USE_BLUEBERRY MITK_BUILD_EXAMPLES MITK_BUILD_ALL_PLUGINS MITK_USE_ACVD MITK_USE_CTK MITK_USE_DCMTK MITK_USE_Qt5 MITK_USE_DCMQI MITK_USE_OpenCV - MITK_USE_SOFA MITK_USE_VMTK MITK_USE_Python ) if(MITK_USE_Qt5) # Look for Qt at the superbuild level, to catch missing Qt libs early find_package(Qt5Widgets REQUIRED) endif() set(additional_mitk_cmakevars ) # Configure the set of default pixel types set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") foreach(_arg MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES MITK_ACCESSBYITK_DIMENSIONS) mark_as_advanced(${_arg}) list(APPEND additional_mitk_cmakevars "-D${_arg}:STRING=${${_arg}}") endforeach() #----------------------------------------------------------------------------- # Create options to inject pre-build dependencies #----------------------------------------------------------------------------- - foreach(proj CTK DCMTK DCMQI GDCM VTK ACVD ITK OpenCV SOFA VMTK CableSwig) + foreach(proj CTK DCMTK DCMQI GDCM VTK ACVD ITK OpenCV VMTK CableSwig) if(MITK_USE_${proj}) set(MITK_${proj}_DIR "${${proj}_DIR}" CACHE PATH "Path to ${proj} build directory") mark_as_advanced(MITK_${proj}_DIR) if(MITK_${proj}_DIR) list(APPEND additional_mitk_cmakevars "-D${proj}_DIR:PATH=${MITK_${proj}_DIR}") endif() endif() endforeach() set(MITK_BOOST_ROOT "${BOOST_ROOT}" CACHE PATH "Path to Boost directory") mark_as_advanced(MITK_BOOST_ROOT) if(MITK_BOOST_ROOT) list(APPEND additional_mitk_cmakevars "-DBOOST_ROOT:PATH=${MITK_BOOST_ROOT}") endif() set(MITK_SOURCE_DIR "" CACHE PATH "MITK source code location. If empty, MITK will be cloned from MITK_GIT_REPOSITORY") set(MITK_GIT_REPOSITORY "https://phabricator.mitk.org/diffusion/MITK/mitk.git" CACHE STRING "The git repository for cloning MITK") set(MITK_GIT_TAG "origin/release/2016-11" CACHE STRING "The git tag/hash to be used when cloning from MITK_GIT_REPOSITORY") mark_as_advanced(MITK_SOURCE_DIR MITK_GIT_REPOSITORY MITK_GIT_TAG) #----------------------------------------------------------------------------- # Create the final variable containing superbuild boolean args #----------------------------------------------------------------------------- set(mitk_boolean_args) foreach(mitk_cmake_arg ${mitk_cmake_boolean_args}) list(APPEND mitk_boolean_args -D${mitk_cmake_arg}:BOOL=${${mitk_cmake_arg}}) endforeach() #----------------------------------------------------------------------------- # Additional MITK CMake variables #----------------------------------------------------------------------------- if(MITK_USE_Qt5) list(APPEND additional_mitk_cmakevars "-DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}") endif() if(MITK_USE_CTK) list(APPEND additional_mitk_cmakevars "-DGIT_EXECUTABLE:FILEPATH=${GIT_EXECUTABLE}") endif() if(MITK_INITIAL_CACHE_FILE) list(APPEND additional_mitk_cmakevars "-DMITK_INITIAL_CACHE_FILE:INTERNAL=${MITK_INITIAL_CACHE_FILE}") endif() if(MITK_USE_SUPERBUILD) set(MITK_BINARY_DIR ${proj}-superbuild) else() set(MITK_BINARY_DIR ${proj}-build) endif() set(proj_DEPENDENCIES) set(MITK_DEPENDS ${proj}) # Configure the MITK souce code location if(NOT MITK_SOURCE_DIR) set(mitk_source_location SOURCE_DIR ${CMAKE_BINARY_DIR}/${proj} GIT_REPOSITORY ${MITK_GIT_REPOSITORY} GIT_TAG ${MITK_GIT_TAG} ) else() set(mitk_source_location SOURCE_DIR ${MITK_SOURCE_DIR} ) endif() ExternalProject_Add(${proj} ${mitk_source_location} BINARY_DIR ${MITK_BINARY_DIR} PREFIX ${proj}${ep_suffix} INSTALL_COMMAND "" CMAKE_GENERATOR ${gen} CMAKE_ARGS ${ep_common_args} ${mitk_boolean_args} ${additional_mitk_cmakevars} -DBUILD_SHARED_LIBS:BOOL=ON -DBUILD_TESTING:BOOL=${MITK_BUILD_TESTING} CMAKE_CACHE_ARGS ${ep_common_cache_args} CMAKE_CACHE_DEFAULT_ARGS ${ep_common_cache_default_args} DEPENDS ${proj_DEPENDENCIES} ) if(MITK_USE_SUPERBUILD) set(MITK_DIR "${CMAKE_CURRENT_BINARY_DIR}/${MITK_BINARY_DIR}/MITK-build") else() set(MITK_DIR "${CMAKE_CURRENT_BINARY_DIR}/${MITK_BINARY_DIR}") endif() else() # The project is provided using MITK_DIR, nevertheless since other # projects may depend on MITK, let's add an 'empty' one MacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") # Further, do some sanity checks in the case of a pre-built MITK set(my_itk_dir ${ITK_DIR}) set(my_vtk_dir ${VTK_DIR}) find_package(MITK REQUIRED) if(my_itk_dir AND NOT my_itk_dir STREQUAL ${ITK_DIR}) message(FATAL_ERROR "ITK packages do not match:\n ${MY_PROJECT_NAME}: ${my_itk_dir}\n MITK: ${ITK_DIR}") endif() if(my_vtk_dir AND NOT my_vtk_dir STREQUAL ${VTK_DIR}) message(FATAL_ERROR "VTK packages do not match:\n ${MY_PROJECT_NAME}: ${my_vtk_dir}\n MITK: ${VTK_DIR}") endif() endif() diff --git a/CMake/BuildConfigurations/All.cmake b/CMake/BuildConfigurations/All.cmake index 44485e6a27..3fb1ead7fb 100644 --- a/CMake/BuildConfigurations/All.cmake +++ b/CMake/BuildConfigurations/All.cmake @@ -1,81 +1,73 @@ set(MITK_CONFIG_PACKAGES ) set(_apple_package_excludes) -if(APPLE) - set(_apple_package_excludes - SOFA - ) -endif() - set(_python_excludes ) if(NOT (CMAKE_SIZEOF_VOID_P EQUAL 8) ) set(_python_excludes Python Numpy ) endif() set(_package_excludes ${_apple_package_excludes} ${_python_excludes} Gflags Caffe Caffe2 OpenCL SYSTEM_Boost Boost_LIBRARIES SYSTEM_PYTHON - SOFA_PLUGINS - SOFA_PLUGINS_DIR SUPERBUILD BiophotonicsHardware_SpectroCam POLHEMUS_TRACKER US_DiPhAS_SDK GALIL_HARDWARE OPHIR_PRYO_HARDWARE KWSTYLE MICROBIRD_TRACKER MICROBIRD_TRACKER_INCLUDE_DIR MICROBIRD_TRACKER_LIB MICRON_TRACKER OPTITRACK_TRACKER SPACENAVIGATOR TOF_KINECT TOF_KINECTV2 TOF_MESASR4000 TOF_PMDCAMBOARD TOF_PMDCAMCUBE TOF_PMDO3 US_TELEMED_SDK videoInput WIIMOTE ) get_cmake_property(_cache_vars CACHE_VARIABLES) foreach(_cache_var ${_cache_vars}) string(REGEX REPLACE "MITK_USE_(.+)" "\\1" _package "${_cache_var}") if(_package AND NOT _package STREQUAL _cache_var) list(FIND _package_excludes ${_package} _index) if(_index EQUAL -1) list(APPEND MITK_CONFIG_PACKAGES ${_package}) endif() endif() endforeach() set(MITK_BUILD_ALL_APPS ON CACHE BOOL "Build all MITK applications" FORCE) set(MITK_BUILD_ALL_PLUGINS ON CACHE BOOL "Build all MITK plugins" FORCE) set(MITK_BUILD_EXAMPLES ON CACHE BOOL "Build the MITK examples" FORCE) set(BLUEBERRY_BUILD_ALL_PLUGINS ON CACHE BOOL "Build all BlueBerry plugins" FORCE) set(BUILD_DiffusionCoreCmdApps ON CACHE BOOL "Build commandline tools for diffusion" FORCE) set(BUILD_DiffusionFiberProcessingCmdApps ON CACHE BOOL "Build commandline tools for diffusion fiber processing" FORCE) set(BUILD_DiffusionFiberfoxCmdApps ON CACHE BOOL "Build commandline tools for diffusion data simulation (Fiberfox)" FORCE) set(BUILD_DiffusionMiscCmdApps ON CACHE BOOL "Build miscellaneous commandline tools for diffusion" FORCE) set(BUILD_DiffusionQuantificationCmdApps ON CACHE BOOL "Build commandline tools for diffusion quantification (IVIM, ADC, ...)" FORCE) set(BUILD_DiffusionTractographyCmdApps ON CACHE BOOL "Build commandline tools for diffusion fiber tractography" FORCE) set(BUILD_DiffusionTractographyEvaluationCmdApps ON CACHE BOOL "Build commandline tools for diffusion fiber tractography evaluation" FORCE) set(BUILD_DiffusionConnectomicsCmdApps ON CACHE BOOL "Build commandline tools for diffusion connectomics" FORCE) diff --git a/CMake/MITKDashboardSetup.cmake b/CMake/MITKDashboardSetup.cmake index 34a2f05048..4e6f4c48ce 100644 --- a/CMake/MITKDashboardSetup.cmake +++ b/CMake/MITKDashboardSetup.cmake @@ -1,161 +1,160 @@ # This file is intended to be included at the end of a custom MITKDashboardScript.TEMPLATE.cmake file list(APPEND CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") # # Automatically determined properties # set(MY_OPERATING_SYSTEM ) if(UNIX) # Download a utility script if(IS_PHABRICATOR_URL) set(url "https://phabricator.mitk.org/source/mitk/browse/${GIT_BRANCH}/CMake/mitkDetectOS.sh?view=raw") else() set(url "https://raw.githubusercontent.com/MITK/MITK/master/CMake/mitkDetectOS.sh") endif() set(dest "${CTEST_SCRIPT_DIRECTORY}/mitkDetectOS.sh") downloadFile("${url}" "${dest}") execute_process(COMMAND sh "${dest}" RESULT_VARIABLE _result OUTPUT_VARIABLE _out OUTPUT_STRIP_TRAILING_WHITESPACE) if(NOT _result) set(MY_OPERATING_SYSTEM "${_out}") endif() endif() if(NOT MY_OPERATING_SYSTEM) set(MY_OPERATING_SYSTEM "${CMAKE_HOST_SYSTEM}") # Windows 7, Linux-2.6.32, Darwin... endif() site_name(CTEST_SITE) if(NOT DEFINED MITK_USE_Qt5) set(MITK_USE_Qt5 1) endif() if(MITK_USE_Qt5) if(NOT QT_QMAKE_EXECUTABLE) find_program(QT_QMAKE_EXECUTABLE NAMES qmake qmake-qt5 HINTS ${QT_BINARY_DIR}) endif() execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} --version OUTPUT_VARIABLE MY_QT_VERSION RESULT_VARIABLE qmake_error) if(qmake_error) message(FATAL_ERROR "Error when executing ${QT_QMAKE_EXECUTABLE} --version\n${qmake_error}") endif() string(REGEX REPLACE ".*Qt version ([0-9.]+) .*" "\\1" MY_QT_VERSION ${MY_QT_VERSION}) endif() # # Project specific properties # if(NOT CTEST_BUILD_NAME) if(MITK_USE_Qt5) set(CTEST_BUILD_NAME "${MY_OPERATING_SYSTEM} ${MY_COMPILER} Qt${MY_QT_VERSION} ${CTEST_BUILD_CONFIGURATION}") else() set(CTEST_BUILD_NAME "${MY_OPERATING_SYSTEM} ${MY_COMPILER} ${CTEST_BUILD_CONFIGURATION}") endif() set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}${CTEST_BUILD_NAME_SUFFIX}") endif() set(PROJECT_BUILD_DIR "MITK-build") set(CTEST_PATH "$ENV{PATH}") if(WIN32) if("${CTEST_CMAKE_GENERATOR}" MATCHES ".*Win64") set(CMAKE_LIBRARY_ARCHITECTURE x64) else() set(CMAKE_LIBRARY_ARCHITECTURE x86) endif() string(SUBSTRING "${MY_COMPILER}" 2 2 vc_version) set(OPENCV_BIN_DIR "${CTEST_BINARY_DIRECTORY}/ep/${CMAKE_LIBRARY_ARCHITECTURE}/vc${vc_version}/bin") - set(SOFA_BINARY_DIR "${CTEST_BINARY_DIRECTORY}/ep/src/SOFA-build/bin/${CTEST_BUILD_CONFIGURATION}") set(BLUEBERRY_RUNTIME_DIR "${CTEST_BINARY_DIRECTORY}/MITK-build/bin/plugins/${CTEST_BUILD_CONFIGURATION}") set(PYTHON_BINARY_DIRS "${CTEST_BINARY_DIRECTORY}/ep/src/CTK-build/CMakeExternals/Install/bin") list(APPEND PYTHON_BINARY_DIRS "${CTEST_BINARY_DIRECTORY}/ep/lib/python2.7/bin") - set(CTEST_PATH "${CTEST_PATH};${CTEST_BINARY_DIRECTORY}/ep/bin;${QT_BINARY_DIR};${SOFA_BINARY_DIR};${BLUEBERRY_RUNTIME_DIR};${OPENCV_BIN_DIR};${PYTHON_BINARY_DIRS}") + set(CTEST_PATH "${CTEST_PATH};${CTEST_BINARY_DIRECTORY}/ep/bin;${QT_BINARY_DIR};${BLUEBERRY_RUNTIME_DIR};${OPENCV_BIN_DIR};${PYTHON_BINARY_DIRS}") endif() set(ENV{PATH} "${CTEST_PATH}") # If the dashscript doesn't define a GIT_REPOSITORY variable, let's define it here. if(NOT DEFINED GIT_REPOSITORY OR GIT_REPOSITORY STREQUAL "") set(GIT_REPOSITORY "https://phabricator.mitk.org/source/mitk.git") endif() # # Display build info # message("Site name: ${CTEST_SITE}") message("Build name: ${CTEST_BUILD_NAME}") message("Script Mode: ${SCRIPT_MODE}") message("Coverage: ${WITH_COVERAGE}, MemCheck: ${WITH_MEMCHECK}") # # Set initial cache options # if(CTEST_CMAKE_GENERATOR MATCHES ".*Makefiles.*") set(CTEST_USE_LAUNCHERS 1) else() set(CTEST_USE_LAUNCHERS 0) endif() set(ENV{CTEST_USE_LAUNCHERS_DEFAULT} ${CTEST_USE_LAUNCHERS}) # Remove this if block after all dartclients work if(DEFINED ADDITIONNAL_CMAKECACHE_OPTION) message(WARNING "Rename ADDITIONNAL to ADDITIONAL in your dartlclient script: ${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}") set(ADDITIONAL_CMAKECACHE_OPTION ${ADDITIONNAL_CMAKECACHE_OPTION}) endif() if(NOT DEFINED MITK_BUILD_CONFIGURATION) set(MITK_BUILD_CONFIGURATION "All") endif() if(NOT DEFINED MITK_VTK_DEBUG_LEAKS) set(MITK_VTK_DEBUG_LEAKS 1) endif() set(INITIAL_CMAKECACHE_OPTIONS " SUPERBUILD_EXCLUDE_MITKBUILD_TARGET:BOOL=TRUE MITK_BUILD_CONFIGURATION:STRING=${MITK_BUILD_CONFIGURATION} MITK_VTK_DEBUG_LEAKS:BOOL=${MITK_VTK_DEBUG_LEAKS} ${ADDITIONAL_CMAKECACHE_OPTION} ") if(MITK_USE_Qt5) set(INITIAL_CMAKECACHE_OPTIONS "${INITIAL_CMAKECACHE_OPTIONS} QT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}") endif() # Write a cache file for populating the MITK initial cache (not the superbuild cache). # This can be used to provide variables which are not passed through the # superbuild process to the MITK configure step) if(MITK_INITIAL_CACHE) set(mitk_cache_file "${CTEST_SCRIPT_DIRECTORY}/mitk_initial_cache.txt") file(WRITE "${mitk_cache_file}" "${MITK_INITIAL_CACHE}") set(INITIAL_CMAKECACHE_OPTIONS "${INITIAL_CMAKECACHE_OPTIONS} MITK_INITIAL_CACHE_FILE:INTERNAL=${mitk_cache_file} ") endif() # # Download and include dashboard driver script # if(IS_PHABRICATOR_URL) set(url "https://phabricator.mitk.org/source/mitk/browse/${GIT_BRANCH}/CMake/MITKDashboardDriverScript.cmake?view=raw") else() set(url "https://raw.githubusercontent.com/MITK/MITK/master/CMake/MITKDashboardDriverScript.cmake") endif() set(dest ${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}.driver) downloadFile("${url}" "${dest}") include(${dest}) diff --git a/CMake/PackageDepends/MITK_SOFA_Config.cmake b/CMake/PackageDepends/MITK_SOFA_Config.cmake deleted file mode 100644 index 96c12a5bd2..0000000000 --- a/CMake/PackageDepends/MITK_SOFA_Config.cmake +++ /dev/null @@ -1,2 +0,0 @@ -list(APPEND ALL_INCLUDE_DIRECTORIES ${SOFA_INCLUDE_DIRS}) -list(APPEND ALL_LIBRARIES ${SOFA_LIBRARIES}) diff --git a/CMake/mitkFunctionGetLibrarySearchPaths.cmake b/CMake/mitkFunctionGetLibrarySearchPaths.cmake index f172bce679..54b5f12c83 100644 --- a/CMake/mitkFunctionGetLibrarySearchPaths.cmake +++ b/CMake/mitkFunctionGetLibrarySearchPaths.cmake @@ -1,168 +1,161 @@ function(mitkFunctionGetLibrarySearchPaths search_path intermediate_dir) set(_dir_candidates "${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "${MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins" "${MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY}" "${MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugins" ) if(MITK_EXTERNAL_PROJECT_PREFIX) list(APPEND _dir_candidates "${MITK_EXTERNAL_PROJECT_PREFIX}/bin" "${MITK_EXTERNAL_PROJECT_PREFIX}/lib" ) endif() # Determine the Qt5 library installation prefix set(_qmake_location ) if(MITK_USE_Qt5 AND TARGET ${Qt5Core_QMAKE_EXECUTABLE}) get_property(_qmake_location TARGET ${Qt5Core_QMAKE_EXECUTABLE} PROPERTY IMPORT_LOCATION) endif() if(_qmake_location) if(NOT _qt_install_libs) if(WIN32) execute_process(COMMAND ${_qmake_location} -query QT_INSTALL_BINS OUTPUT_VARIABLE _qt_install_libs OUTPUT_STRIP_TRAILING_WHITESPACE) else() execute_process(COMMAND ${_qmake_location} -query QT_INSTALL_LIBS OUTPUT_VARIABLE _qt_install_libs OUTPUT_STRIP_TRAILING_WHITESPACE) endif() file(TO_CMAKE_PATH "${_qt_install_libs}" _qt_install_libs) set(_qt_install_libs ${_qt_install_libs} CACHE INTERNAL "Qt library installation prefix" FORCE) endif() if(_qt_install_libs) list(APPEND _dir_candidates ${_qt_install_libs}) endif() elseif(MITK_USE_Qt5) message(WARNING "The qmake executable could not be found.") endif() get_property(_additional_paths GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) if(MITK_USE_HDF5) FIND_PACKAGE(HDF5 COMPONENTS C HL NO_MODULE REQUIRED shared) get_target_property(_location hdf5-shared LOCATION) get_filename_component(_location ${_location} PATH) list(APPEND _additional_paths ${_location}) # This is a work-around. The hdf5-config.cmake file is not robust enough # to be included several times via find_pakcage calls. set(HDF5_LIBRARIES ${HDF5_LIBRARIES} PARENT_SCOPE) endif() if(MITK_USE_Vigra) # we cannot use _find_package(Vigra) here because the vigra-config.cmake file # always includes the target-exports files without using an include guard. This # would lead to errors when another find_package(Vigra) call is processed. The # (bad) assumption here is that for the time being, only the Classification module # is using Vigra. if(UNIX) list(APPEND _additional_paths ${Vigra_DIR}/lib) else() list(APPEND _additional_paths ${Vigra_DIR}/bin) endif() endif() if(_additional_paths) list(APPEND _dir_candidates ${_additional_paths}) endif() # The code below is sub-optimal. It makes assumptions about # the structure of the build directories, pointed to by # the *_DIR variables. Instead, we should rely on package # specific "LIBRARY_DIRS" variables, if they exist. if(WIN32) - if(SOFA_DIR) - list(APPEND _dir_candidates "${SOFA_DIR}/bin") - endif() list(APPEND _dir_candidates "${ITK_DIR}/bin") - else() - if(SOFA_DIR) - list(APPEND _dir_candidates "${SOFA_DIR}/lib") - endif() endif() if(MITK_USE_MatchPoint) if(WIN32) list(APPEND _dir_candidates "${MatchPoint_DIR}/bin") else() list(APPEND _dir_candidates "${MatchPoint_DIR}/lib") endif() endif() if(OpenCV_DIR) set(_opencv_link_directories "${OpenCV_LIB_DIR_DBG}" "${OpenCV_LIB_DIR_OPT}" "${OpenCV_3RDPARTY_LIB_DIR_DBG}" "${OpenCV_3RDPARTY_LIB_DIR_OPT}") list(REMOVE_DUPLICATES _opencv_link_directories) if(WIN32) foreach(_opencv_link_directory ${_opencv_link_directories}) list(APPEND _dir_candidates "${_opencv_link_directory}/../bin") endforeach() else() list(APPEND _dir_candidates ${_opencv_link_directories}) endif() endif() if(MITK_USE_Python) list(APPEND _dir_candidates "${CTK_DIR}/CMakeExternals/Install/bin") list(APPEND _dir_candidates "${MITK_EXTERNAL_PROJECT_PREFIX}/lib/python2.7/bin") endif() if(MITK_USE_TOF_PMDO3 OR MITK_USE_TOF_PMDCAMCUBE OR MITK_USE_TOF_PMDCAMBOARD) list(APPEND _dir_candidates "${MITK_PMD_SDK_DIR}/plugins" "${MITK_PMD_SDK_DIR}/bin") endif() if(MITK_USE_CTK) list(APPEND _dir_candidates "${CTK_LIBRARY_DIRS}") foreach(_ctk_library ${CTK_LIBRARIES}) if(${_ctk_library}_LIBRARY_DIRS) list(APPEND _dir_candidates "${${_ctk_library}_LIBRARY_DIRS}") endif() endforeach() endif() if(MITK_USE_BLUEBERRY) if(DEFINED CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY) if(IS_ABSOLUTE "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") list(APPEND _dir_candidates "${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") else() list(APPEND _dir_candidates "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CTK_PLUGIN_RUNTIME_OUTPUT_DIRECTORY}") endif() endif() endif() if(MITK_LIBRARY_DIRS) list(APPEND _dir_candidates ${MITK_LIBRARY_DIRS}) endif() list(REMOVE_DUPLICATES _dir_candidates) set(_search_dirs ) foreach(_dir ${_dir_candidates}) if(EXISTS "${_dir}/${intermediate_dir}") list(APPEND _search_dirs "${_dir}/${intermediate_dir}") else() list(APPEND _search_dirs "${_dir}") endif() endforeach() # Special handling for "internal" search dirs. The intermediate directory # might not have been created yet, so we can't check for its existence. # Hence we just add it for Windows without checking. set(_internal_search_dirs "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/plugins") if(WIN32) foreach(_dir ${_internal_search_dirs}) set(_search_dirs "${_dir}/${intermediate_dir}" ${_search_dirs}) endforeach() else() set(_search_dirs ${_internal_search_dirs} ${_search_dirs}) endif() list(REMOVE_DUPLICATES _search_dirs) set(${search_path} ${_search_dirs} PARENT_SCOPE) endfunction() diff --git a/CMakeExternals/PatchSOFA-386a3a7+7568b4.cmake b/CMakeExternals/PatchSOFA-386a3a7+7568b4.cmake deleted file mode 100644 index 65b801ef9d..0000000000 --- a/CMakeExternals/PatchSOFA-386a3a7+7568b4.cmake +++ /dev/null @@ -1,231 +0,0 @@ -# Changes of cmake/dependencies.cmake are commented separately below - -set(path "cmake/dependencies.cmake") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) - -# Comment out add_subdirectory() commands that reference the SOFA applications -# directory - -string(REPLACE "add_subdirectory(\"\${SOFA_A" "#add_subdirectory(\"\${SOFA_A" CONTENTS ${CONTENTS}) - -# Rename tinyxml to SofaTinyXml since MITK has its own version of tinyxml and -# the same name lead to linker or runtime errors in the past - -string(REPLACE "\"tinyxml\"" "\"SofaTinyXml\"" CONTENTS ${CONTENTS}) - -# Use MITK's version of Eigen -string(REPLACE "RegisterProjects(\"eigen\" PATH \"\${SOFA-EXTERNAL_EIGEN_PATH}\" COMPILE_DEFINITIONS SOFA_HAVE_EIGEN2)" "add_library(eigen INTERFACE IMPORTED GLOBAL)\nset_property(TARGET eigen APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES \${SOFA-EXTERNAL_EIGEN_PATH})\nset(GLOBAL_PROJECT_DEPENDENCIES_COMPLETE_eigen 1 CACHE INTERNAL \"\" FORCE)\nlist(APPEND GLOBAL_INCLUDE_DIRECTORIES \"\${SOFA-EXTERNAL_EIGEN_PATH}\")" CONTENTS ${CONTENTS}) - -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Adjust tinyxml references (see above) - -set(path "framework/sofa/helper/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "modules/sofa/component/SofaBaseVisual/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "modules/sofa/component/SofaLoader/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "modules/sofa/simulation/common/CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "tinyxml" "SofaTinyXml" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Changes of cmake/environment.cmake are commented separately below - -set(path "cmake/environment.cmake") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) - -# Allow setting SOFA_APPLICATIONS_PLUGINS_DIR from outside - -string(REPLACE "S_DIR}/plugins\" CACHE INTERNAL" "S_DIR}/plugins\" CACHE PATH" CONTENTS ${CONTENTS}) - -# Place binaries and libraries in different subfolders according to the build -# configuration - -string(REPLACE "DEBUG \"\${directory}" "DEBUG \"\${directory}/Debug" CONTENTS ${CONTENTS}) -string(REPLACE "RELEASE \"\${directory}" "RELEASE \"\${directory}/Release" CONTENTS ${CONTENTS}) -string(REPLACE "RELWITHDEBINFO \"\${directory}" "RELWITHDEBINFO \"\${directory}/RelWithDebInfo" CONTENTS ${CONTENTS}) -string(REPLACE "MINSIZEREL \"\${directory}" "MINSIZEREL \"\${directory}/MinSizeRel" CONTENTS ${CONTENTS}) - -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Binary directories in add_subdirectory() regarding external plugins have to be explicitly specified - -set(path "cmake/functions.cmake") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "add_subdirectory(\"\${GLOBAL_PROJECT_PATH_\${projectName}}\")" -"if(\${GLOBAL_PROJECT_PATH_\${projectName}} MATCHES ^\${CMAKE_SOURCE_DIR}.*) - add_subdirectory(\"\${GLOBAL_PROJECT_PATH_\${projectName}}\") - else() - string(LENGTH \"\${SOFA_APPLICATIONS_PLUGINS_DIR}\" begin) - string(SUBSTRING \"\${GLOBAL_PROJECT_PATH_\${projectName}}\" \${begin} -1 subdir) - add_subdirectory(\"\${GLOBAL_PROJECT_PATH_\${projectName}}\" \"\${CMAKE_BINARY_DIR}/applications/plugins\${subdir}\") - endif()" -CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Remove SOFA's FindGLEW.cmake since we need the official FindGLEW.cmake to -# inject the MITK superbuild version of GLEW into SOFA - -file(REMOVE "cmake/Modules/FindGLEW.cmake") - -# Changes of cmake/externals.cmake are commented separately below - -set(path "cmake/externals.cmake") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) - -# Enhance GLUT and GLEW finding routine to regard externally injected GLUT and -# GLEW libraries - -string(REPLACE "set(GLUT_LIBRARIES \"freeglut\")" "find_package(GLUT REQUIRED)" CONTENTS ${CONTENTS}) -string(REPLACE "set(GLEW_LIBRARIES \"glew32\")" "find_package(GLEW REQUIRED)" CONTENTS ${CONTENTS}) -string(REPLACE "else()\n set(O" " list(APPEND GLOBAL_INCLUDE_DIRECTORIES \"\${GLUT_INCLUDE_DIRS}\" \"\${GLEW_INCLUDE_DIRS}\")\nelse()\n set(O" CONTENTS ${CONTENTS}) -string(REPLACE "GLUT REQUIRED" "GLUT REQUIRED CONFIG" CONTENTS ${CONTENTS}) -string(REPLACE "GLEW REQUIRED" "GLEW REQUIRED CONFIG" CONTENTS ${CONTENTS}) - -# Remove Boost binary graph dependency because it is not straight forward to -# compile on all plattforms and its header-only part is enough - -string(REPLACE "graph " "" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Changes of CMakeLists.txt are commented separately below - -set(path "CMakeLists.txt") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) - -# Set CMake policies to prevent configure warnings - -string(REPLACE "set(SOLUTION_NAME" "if(POLICY CMP0039) - cmake_policy(SET CMP0039 OLD) -endif() - -if(POLICY CMP0043) - cmake_policy(SET CMP0043 OLD) - endif() - -if(POLICY CMP0054) - cmake_policy(SET CMP0054 OLD) -endif() - -set(SOLUTION_NAME" -CONTENTS ${CONTENTS}) - -# Use configure file (see below) - -string(REPLACE "\nendif()" "\nendif()\n\nconfigure_file(SOFAConfig.cmake.in SOFAConfig.cmake @ONLY)" CONTENTS ${CONTENTS}) - -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Do not define snprintf starting with Visual Studio 2015. - -set(path "framework/sofa/helper/system/config.h") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "#define snprintf _snprintf" "#if (_MSC_VER < 1900)\n#define snprintf _snprintf\n#endif" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "extlibs/miniFlowVR/src/ftlm/type.cpp") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "#define snprintf _snprintf" "#if (_MSC_VER < 1900)\n#define snprintf _snprintf\n#endif" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Include Eigen/Core in RigidMapping.inl. - -set(path "modules/sofa/component/mapping/RigidMapping.inl") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "#include " "#include \n#include " CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Use unordered_map instead of hash_map. - -set(path "modules/sofa/component/container/SpatialGridContainer.h") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "hash_map" "unordered_map" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -set(path "modules/sofa/component/container/SpatialGridContainer.h") -file(STRINGS ${path} CONTENTS NEWLINE_CONSUME) -string(REPLACE "stdext" "std" CONTENTS ${CONTENTS}) -configure_file(${TEMPLATE_FILE} ${path} @ONLY) - -# Create SOFAConfig.cmake.in file to make SOFA findable through the config mode -# of find_package() - -file(WRITE "SOFAConfig.cmake.in" -"add_definitions(-DSOFA_XML_PARSER_TINYXML;-DTIXML_USE_STL;-DMINI_FLOWVR;-DSOFA_HAVE_BOOST;-DSOFA_HAVE_CSPARSE;-DSOFA_HAVE_DAG;-DSOFA_HAVE_EIGEN2;-DSOFA_HAVE_FREEGLUT;-DSOFA_HAVE_GLEW;-DSOFA_HAVE_METIS) - -set(SOFA_INCLUDE_DIRS \"@SOFA_EXTLIBS_DIR@/csparse;@SOFA_EXTLIBS_DIR@/eigen-3.2.1;@SOFA_EXTLIBS_DIR@/metis-5.1.0/include;@SOFA_EXTLIBS_DIR@/miniFlowVR/include;@SOFA_EXTLIBS_DIR@/newmat;@SOFA_EXTLIBS_DIR@/tinyxml;@SOFA_SRC_DIR@/framework;@SOFA_SRC_DIR@/modules\") - -if(WIN32) - set(SOFA_LIBRARY_DIRS \"@SOFA_LIB_DIR@\") - set(version \"_1_0\") -else() - set(SOFA_LIBRARY_DIRS \"@SOFA_LIB_DIR@/@CMAKE_BUILD_TYPE@\") - set(version \"\") -endif() - -set(SOFA_LIBRARIES - debug SofaBaseAnimationLoop\${version}d optimized SofaBaseAnimationLoop\${version} - debug SofaBaseCollision\${version}d optimized SofaBaseCollision\${version} - debug SofaBaseLinearSolver\${version}d optimized SofaBaseLinearSolver\${version} - debug SofaBaseMechanics\${version}d optimized SofaBaseMechanics\${version} - debug SofaBaseTopology\${version}d optimized SofaBaseTopology\${version} - debug SofaBaseVisual\${version}d optimized SofaBaseVisual\${version} - debug SofaBoundaryCondition\${version}d optimized SofaBoundaryCondition\${version} - debug SofaComponentAdvanced\${version}d optimized SofaComponentAdvanced\${version} - debug SofaComponentBase\${version}d optimized SofaComponentBase\${version} - debug SofaComponentCommon\${version}d optimized SofaComponentCommon\${version} - debug SofaComponentGeneral\${version}d optimized SofaComponentGeneral\${version} - debug SofaComponentMain\${version}d optimized SofaComponentMain\${version} - debug SofaComponentMisc\${version}d optimized SofaComponentMisc\${version} - debug SofaConstraint\${version}d optimized SofaConstraint\${version} - debug SofaCore\${version}d optimized SofaCore\${version} - debug SofaDefaultType\${version}d optimized SofaDefaultType\${version} - debug SofaDeformable\${version}d optimized SofaDeformable\${version} - debug SofaDenseSolver\${version}d optimized SofaDenseSolver\${version} - debug SofaEigen2Solver\${version}d optimized SofaEigen2Solver\${version} - debug SofaEngine\${version}d optimized SofaEngine\${version} - debug SofaEulerianFluid\${version}d optimized SofaEulerianFluid\${version} - debug SofaExplicitOdeSolver\${version}d optimized SofaExplicitOdeSolver\${version} - debug SofaExporter\${version}d optimized SofaExporter\${version} - debug SofaGraphComponent\${version}d optimized SofaGraphComponent\${version} - debug SofaHaptics\${version}d optimized SofaHaptics\${version} - debug SofaHelper\${version}d optimized SofaHelper\${version} - debug SofaImplicitOdeSolver\${version}d optimized SofaImplicitOdeSolver\${version} - debug SofaLoader\${version}d optimized SofaLoader\${version} - debug SofaMeshCollision\${version}d optimized SofaMeshCollision\${version} - debug SofaMisc\${version}d optimized SofaMisc\${version} - debug SofaMiscCollision\${version}d optimized SofaMiscCollision\${version} - debug SofaMiscEngine\${version}d optimized SofaMiscEngine\${version} - debug SofaMiscFem\${version}d optimized SofaMiscFem\${version} - debug SofaMiscForceField\${version}d optimized SofaMiscForceField\${version} - debug SofaMiscMapping\${version}d optimized SofaMiscMapping\${version} - debug SofaMiscSolver\${version}d optimized SofaMiscSolver\${version} - debug SofaMiscTopology\${version}d optimized SofaMiscTopology\${version} - debug SofaNonUniformFem\${version}d optimized SofaNonUniformFem\${version} - debug SofaObjectInteraction\${version}d optimized SofaObjectInteraction\${version} - debug SofaOpenglVisual\${version}d optimized SofaOpenglVisual\${version} - debug SofaPreconditioner\${version}d optimized SofaPreconditioner\${version} - debug SofaRigid\${version}d optimized SofaRigid\${version} - debug SofaSimpleFem\${version}d optimized SofaSimpleFem\${version} - debug SofaSimulationCommon\${version}d optimized SofaSimulationCommon\${version} - debug SofaSimulationGraph\${version}d optimized SofaSimulationGraph\${version} - debug SofaSimulationTree\${version}d optimized SofaSimulationTree\${version} - debug SofaSparseSolver\${version}d optimized SofaSparseSolver\${version} - debug SofaSphFluid\${version}d optimized SofaSphFluid\${version} - debug SofaTopologyMapping\${version}d optimized SofaTopologyMapping\${version} - debug SofaUserInteraction\${version}d optimized SofaUserInteraction\${version} - debug SofaValidation\${version}d optimized SofaValidation\${version} - debug SofaVolumetricData\${version}d optimized SofaVolumetricData\${version} - debug SofaTinyXml\${version}d optimized SofaTinyXml\${version} -)") diff --git a/CMakeExternals/SOFA.cmake b/CMakeExternals/SOFA.cmake deleted file mode 100644 index 870944f1f8..0000000000 --- a/CMakeExternals/SOFA.cmake +++ /dev/null @@ -1,114 +0,0 @@ -#----------------------------------------------------------------------------- -# SOFA -#----------------------------------------------------------------------------- - -if(MITK_USE_SOFA) - # Sanity checks - if(DEFINED SOFA_DIR AND NOT EXISTS ${SOFA_DIR}) - message(FATAL_ERROR "SOFA_DIR variable is defined but corresponds to non-existing directory") - endif() - - set(proj SOFA) - set(proj_DEPENDENCIES Boost Eigen GLEW) - set(SOFA_DEPENDS ${proj}) - - set(preconfigure_cmake_args - -DGLEW_DIR:PATH=${GLEW_DIR} - -DSOFA-APPLICATION_GENERATERIGID:BOOL=OFF - -DSOFA-APPLICATION_MODELER:BOOL=OFF - -DSOFA-APPLICATION_RUNSOFA:BOOL=OFF - -DSOFA-EXTERNAL_BOOST:BOOL=ON - -DSOFA-EXTERNAL_BOOST_PATH:PATH=${BOOST_LIBRARYDIR} - -DSOFA-EXTERNAL_CSPARSE:BOOL=ON - -DSOFA-EXTERNAL_EIGEN_PATH:PATH=${ep_prefix}/include/eigen3 - -DSOFA-EXTERNAL_GLEW:BOOL=ON - -DSOFA-EXTERNAL_PNG:BOOL=OFF - -DSOFA-EXTERNAL_ZLIB:BOOL=OFF - -DSOFA-LIB_COMPONENT_SPARSE_SOLVER:BOOL=ON - -DSOFA-LIB_GUI_GLUT:BOOL=OFF - -DSOFA-LIB_GUI_QT:BOOL=OFF - -DSOFA-LIB_GUI_QTVIEWER:BOOL=OFF - -DSOFA-TUTORIAL_COMPOSITE_OBJECT:BOOL=OFF - -DSOFA-TUTORIAL_MIXED_PENDULUM:BOOL=OFF - -DSOFA-TUTORIAL_ONE_PARTICLE:BOOL=OFF - -DSOFA-TUTORIAL_ONE_TETRAHEDRON:BOOL=OFF - ) - - if(NOT APPLE) - list(APPEND proj_DEPENDENCIES GLUT) - - list(APPEND preconfigure_cmake_args - -DSOFA-EXTERNAL_FREEGLUT:BOOL=ON - -DGLUT_DIR:PATH=${GLUT_DIR} - ) - endif() - - if(NOT MITK_USE_SYSTEM_Boost) - list(APPEND preconfigure_cmake_args - -DBoost_NO_SYSTEM_PATHS:BOOL=ON - -DBOOST_ROOT:PATH=${BOOST_ROOT} - -DBOOST_LIBRARYDIR:PATH=${BOOST_LIBRARYDIR} - -DBoost_ADDITIONAL_VERSIONS:STRING=1.64${sep}1.64.0 - ) - endif() - - if(MITK_USE_SOFA_PLUGINS_DIR) - list(APPEND preconfigure_cmake_args - -DSOFA_APPLICATIONS_PLUGINS_DIR:PATH=${MITK_USE_SOFA_PLUGINS_DIR} - ) - - foreach(plugin ${MITK_USE_SOFA_PLUGINS}) - string(TOUPPER ${plugin} plugin) - list(APPEND preconfigure_cmake_args - -DSOFA-PLUGIN_${plugin}:BOOL=ON - ) - endforeach() - endif() - - set(additional_cmake_args ) - if(CTEST_USE_LAUNCHERS) - list(APPEND additional_cmake_args - "-DCMAKE_PROJECT_${proj}_INCLUDE:FILEPATH=${CMAKE_ROOT}/Modules/CTestUseLaunchers.cmake" - ) - endif() - - set(rev "386a3a7+7568b4") - - set(SOFA_PATCH_COMMAND ${CMAKE_COMMAND} -DTEMPLATE_FILE:FILEPATH=${MITK_SOURCE_DIR}/CMakeExternals/EmptyFileForPatching.dummy -P ${MITK_SOURCE_DIR}/CMakeExternals/PatchSOFA-${rev}.cmake) - set(SOFA_PRECONFIGURE_COMMAND ${CMAKE_COMMAND} -G${gen} ${ep_common_args} ${preconfigure_cmake_args} ${boost_cmake_args} ) - - if(NOT DEFINED SOFA_DIR) - ExternalProject_Add(${proj} - LIST_SEPARATOR ${sep} - URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/SOFA-${rev}.tar.gz - URL_MD5 45ba5a931855f06e30405a60229938ca - PATCH_COMMAND ${SOFA_PATCH_COMMAND} - INSTALL_COMMAND "" - CMAKE_GENERATOR ${gen} - CMAKE_ARGS - ${ep_common_args} - ${additional_cmake_args} - CMAKE_CACHE_ARGS - ${ep_common_cache_args} - CMAKE_CACHE_DEFAULT_ARGS - ${ep_common_cache_default_args} - DEPENDS ${proj_DEPENDENCIES} - ) - - ExternalProject_Add_Step(${proj} preconfigure - COMMAND ${SOFA_PRECONFIGURE_COMMAND} - WORKING_DIRECTORY - DEPENDEES patch - DEPENDERS configure - LOG 1 - ) - - # SOFA does not support "make install" yet - # set(SOFA_DIR ${ep_prefix} - ExternalProject_Get_Property(${proj} binary_dir) - set(SOFA_DIR ${binary_dir}) - - else() - mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") - endif() -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f470d2880..d1b7dc6252 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,1397 +1,1360 @@ set(MITK_CMAKE_MINIMUM_REQUIRED_VERSION 3.5) cmake_minimum_required(VERSION ${MITK_CMAKE_MINIMUM_REQUIRED_VERSION}) #----------------------------------------------------------------------------- # See http://www.cmake.org/cmake/help/v3.5/manual/cmake-policies.7.html for details #----------------------------------------------------------------------------- set(project_policies ) foreach(policy ${project_policies}) if(POLICY ${policy}) cmake_policy(SET ${policy} NEW) endif() endforeach() #----------------------------------------------------------------------------- # Superbuild Option - Enabled by default #----------------------------------------------------------------------------- option(MITK_USE_SUPERBUILD "Build MITK and the projects it depends on via SuperBuild.cmake." ON) if(MITK_USE_SUPERBUILD) project(MITK-superbuild) set(MITK_SOURCE_DIR ${PROJECT_SOURCE_DIR}) set(MITK_BINARY_DIR ${PROJECT_BINARY_DIR}) else() project(MITK VERSION 2016.11.99) endif() #----------------------------------------------------------------------------- # Update CMake module path #------------------------------------------------------------------------------ set(MITK_CMAKE_DIR ${MITK_SOURCE_DIR}/CMake) set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- # Standard CMake macros include(FeatureSummary) include(CTestUseLaunchers) include(CMakeParseArguments) include(FindPackageHandleStandardArgs) # MITK macros include(mitkFunctionGetGccVersion) include(mitkFunctionCheckCompilerFlags) include(mitkFunctionSuppressWarnings) # includes several functions include(mitkMacroEmptyExternalProject) include(mitkFunctionGenerateProjectXml) include(mitkFunctionEnableBuildConfiguration) include(mitkFunctionWhitelists) include(mitkFunctionAddExternalProject) SUPPRESS_VC_DEPRECATED_WARNINGS() #----------------------------------------------------------------------------- # Set a default build type if none was specified #----------------------------------------------------------------------------- if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) message(STATUS "Setting build type to 'Debug' as none was specified.") set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE) # Set the possible values of build type for cmake-gui set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() #----------------------------------------------------------------------------- # Check miminum Mac OS X version #----------------------------------------------------------------------------- # The minimum supported Mac OS X version is 10.9. If you use a version less than 10.9, there is no guarantee that the build still works. if(APPLE) exec_program(sw_vers ARGS -productVersion OUTPUT_VARIABLE osx_version) if (osx_version VERSION_LESS "10.9") message(WARNING "Detected OS X version \"${osx_version}\" is not supported anymore. Minimum required OS X version is 10.9 or greater.") endif() if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.9) message(WARNING "Detected OS X deployment target \"${CMAKE_OSX_DEPLOYMENT_TARGET}\" is not supported anymore. Minimum required OS X version is 10.9 or greater.") endif() endif() #----------------------------------------------------------------------------- # Check miminum compiler versions #----------------------------------------------------------------------------- if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # require at least gcc 4.9 as provided by ppa:ubuntu-toolchain-r/test for Ubuntu 14.04 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) message(FATAL_ERROR "GCC version must be at least 4.9 If you are using Ubuntu 14.04, you can easily install gcc and g++ 4.9 (or any later version available) in addition to your version ${CMAKE_CXX_COMPILER_VERSION}: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-4.9 g++-4.9 Make sure to explicitly specify these compilers when configuring MITK: CMAKE_C_COMPILER:FILEPATH=/usr/bin/gcc-4.9 CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/g++-4.9 For more information on the proposed PPA see the Toolchain Updates section of https://wiki.ubuntu.com/ToolChain.") endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # require at least clang 3.4 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4) message(FATAL_ERROR "Clang version must be at least 3.4") endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") # require at least clang 5.0 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) message(FATAL_ERROR "Apple Clang version must be at least 5.0") endif() elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # require at least Visual Studio 2013 if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0.40629.0) message(FATAL_ERROR "Microsoft Visual Studio 2013 Update 5 or newer required (MSVC 18.0.40629.0)") endif() else() message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang (Linux or Apple), GCC and MSVC.") endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION) else() set(GCC_VERSION 0) endif() set(MITK_CXX_STANDARD 14) set(CMAKE_CXX_EXTENSIONS 0) set(CMAKE_CXX_STANDARD ${MITK_CXX_STANDARD}) set(CMAKE_CXX_STANDARD_REQUIRED 1) # This is necessary to avoid problems with compile feature checks. # CMAKE_CXX_STANDARD seems to only set the -std=c++14 flag for targets. # However, compile flag checks also need to be done with -std=c++14. # The MITK_CXX14_FLAG variable is also used for external projects # build during the MITK super-build. mitkFunctionCheckCompilerFlags("-std=c++14" MITK_CXX14_FLAG) #----------------------------------------------------------------------------- # Warn if source or build path is too long #----------------------------------------------------------------------------- if(WIN32) set(_src_dir_length_max 50) set(_bin_dir_length_max 50) if(MITK_USE_SUPERBUILD) set(_src_dir_length_max 34) # _src_dir_length_max - strlen(ep/src/ITK-build) set(_bin_dir_length_max 40) # _bin_dir_length_max - strlen(MITK-build) endif() string(LENGTH "${MITK_SOURCE_DIR}" _src_n) string(LENGTH "${MITK_BINARY_DIR}" _bin_n) # The warnings should be converted to errors if(_src_n GREATER _src_dir_length_max) message(WARNING "MITK source code directory path length is too long (${_src_n} > ${_src_dir_length_max})." "Please move the MITK source code directory to a directory with a shorter path." ) endif() if(_bin_n GREATER _bin_dir_length_max) message(WARNING "MITK build directory path length is too long (${_bin_n} > ${_bin_dir_length_max})." "Please move the MITK build directory to a directory with a shorter path." ) endif() endif() #----------------------------------------------------------------------------- # Additional MITK Options (also shown during superbuild) #----------------------------------------------------------------------------- macro(env_option name doc value) set(_value $ENV{${name}}) if("${_value}" STREQUAL "") set(_value ${value}) endif() option(${name} "${doc}" ${_value}) endmacro() # ----------------------------------------- # General build options option(BUILD_SHARED_LIBS "Build MITK with shared libraries" ON) option(WITH_COVERAGE "Enable/Disable coverage" OFF) option(BUILD_TESTING "Test the project" ON) env_option(MITK_BUILD_ALL_APPS "Build all MITK applications" OFF) env_option(MITK_BUILD_EXAMPLES "Build the MITK Examples" OFF) option(MITK_ENABLE_PIC_READER "Enable support for reading the DKFZ pic file format." ON) mark_as_advanced(MITK_BUILD_ALL_APPS MITK_ENABLE_PIC_READER ) # ----------------------------------------- # Qt version related variables env_option(MITK_USE_Qt5 "Use Qt 5 library" ON) env_option(MITK_USE_Qt5_WebEngine "Use Qt 5 WebEngine library" ON) if(MITK_USE_Qt5) set(MITK_QT5_MINIMUM_VERSION 5.6.0) set(MITK_QT5_COMPONENTS Concurrent OpenGL PrintSupport Script Sql Svg Widgets Xml XmlPatterns UiTools Help LinguistTools) if(MITK_USE_Qt5_WebEngine) set(MITK_QT5_COMPONENTS ${MITK_QT5_COMPONENTS} WebEngineWidgets) endif() if(APPLE) set(MITK_QT5_COMPONENTS ${MITK_QT5_COMPONENTS} DBus) endif() find_package(Qt5 ${MITK_QT5_MINIMUM_VERSION} COMPONENTS ${MITK_QT5_COMPONENTS} REQUIRED) if(Qt5_DIR) get_filename_component(_Qt5_DIR "${Qt5_DIR}/../../../" ABSOLUTE) list(FIND CMAKE_PREFIX_PATH "${_Qt5_DIR}" _result) if(_result LESS 0) set(CMAKE_PREFIX_PATH "${_Qt5_DIR};${CMAKE_PREFIX_PATH}" CACHE PATH "" FORCE) endif() endif() elseif(MITK_USE_Qt5_WebEngine) set(MITK_USE_Qt5_WebEngine OFF) endif() # ------------------------------------------------------------------------ # Register external projects which can be build with the MITK superbuild # system. Each mitkFunctionAddExternalProject() call registers an external # project for which a CMakeExternals/.cmake file must exist. The # call also creates a MITK_USE_ variable (appearing in the CMake # UI if the NO_CACHE option is *not* given). # ----------------------------------------- # Optional external projects with no # inter-dependencies set_property(GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS "") mitkFunctionAddExternalProject(NAME Poco ON COMPONENTS Foundation Net Util XML Zip) mitkFunctionAddExternalProject(NAME DCMTK ON DOC "EXPERIMENTAL, superbuild only: Use DCMTK in MITK") mitkFunctionAddExternalProject(NAME OpenIGTLink OFF) mitkFunctionAddExternalProject(NAME tinyxml ON ADVANCED) mitkFunctionAddExternalProject(NAME GDCM ON ADVANCED) mitkFunctionAddExternalProject(NAME GLUT OFF ADVANCED) mitkFunctionAddExternalProject(NAME Raptor2 OFF ADVANCED) mitkFunctionAddExternalProject(NAME Eigen ON ADVANCED DOC "Use the Eigen library") mitkFunctionAddExternalProject(NAME GLEW ON ADVANCED DOC "Use the GLEW library") mitkFunctionAddExternalProject(NAME ANN ON ADVANCED DOC "Use Approximate Nearest Neighbor Library") mitkFunctionAddExternalProject(NAME CppUnit ON ADVANCED DOC "Use CppUnit for unit tests") mitkFunctionAddExternalProject(NAME PCRE OFF ADVANCED NO_PACKAGE) mitkFunctionAddExternalProject(NAME ZLIB OFF ADVANCED NO_PACKAGE NO_CACHE) mitkFunctionAddExternalProject(NAME HDF5 ON ADVANCED) # ----------------------------------------- # The following external projects must be # ordered according to their # inter-dependencies mitkFunctionAddExternalProject(NAME SWIG OFF ADVANCED NO_PACKAGE DEPENDS PCRE) mitkFunctionAddExternalProject(NAME Python OFF NO_PACKAGE DEPENDS SWIG DOC "Use Python wrapping in MITK") mitkFunctionAddExternalProject(NAME Numpy OFF ADVANCED NO_PACKAGE) mitkFunctionAddExternalProject(NAME OpenCV OFF) mitkFunctionAddExternalProject(NAME Vigra OFF DEPENDS HDF5) # These are "hard" dependencies and always set to ON mitkFunctionAddExternalProject(NAME ITK ON NO_CACHE DEPENDS HDF5) mitkFunctionAddExternalProject(NAME VTK ON NO_CACHE) mitkFunctionAddExternalProject(NAME Boost ON NO_CACHE) mitkFunctionAddExternalProject(NAME SimpleITK OFF DEPENDS ITK GDCM SWIG) mitkFunctionAddExternalProject(NAME ACVD OFF DOC "Use Approximated Centroidal Voronoi Diagrams") mitkFunctionAddExternalProject(NAME CTK ON DEPENDS Qt5 DCMTK DOC "Use CTK in MITK") mitkFunctionAddExternalProject(NAME Rasqal OFF DEPENDS Raptor2 PCRE ADVANCED) mitkFunctionAddExternalProject(NAME Redland OFF DEPENDS Rasqal DOC "Use the Redland RDF library") -mitkFunctionAddExternalProject(NAME SOFA OFF DEPENDS GLUT Eigen Boost DOC "Use Simulation Open Framework Architecture") mitkFunctionAddExternalProject(NAME VMTK OFF DEPENDS ITK VTK) mitkFunctionAddExternalProject(NAME DCMQI OFF DEPENDS DCMTK ITK DOC "Use dcmqi in MITK") mitkFunctionAddExternalProject(NAME MatchPoint OFF ADVANCED DEPENDS ITK DOC "Use the MatchPoint translation image registration library") if(MITK_USE_Qt5) mitkFunctionAddExternalProject(NAME Qwt ON ADVANCED DEPENDS Qt5) endif() if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") mitkFunctionAddExternalProject(NAME Gflags OFF ADVANCED DOC "Experimental. Only available on Linux systems. Needed for Caffe.") mitkFunctionAddExternalProject(NAME Caffe OFF ADVANCED DEPENDS HDF5 OpenCV Gflags DOC "Experimental. Only available on Linux systems.") mitkFunctionAddExternalProject(NAME Caffe2 OFF ADVANCED DOC "Experimental. Only available on Linux systems.") endif() # ----------------------------------------- # Other MITK_USE_* options not related to # external projects build via the # MITK superbuild env_option(MITK_USE_BLUEBERRY "Build the BlueBerry platform" ON) env_option(MITK_USE_OpenCL "Use OpenCL GPU-Computing library" OFF) #----------------------------------------------------------------------------- # Build configurations #----------------------------------------------------------------------------- set(_buildConfigs "Custom") file(GLOB _buildConfigFiles CMake/BuildConfigurations/*.cmake) foreach(_buildConfigFile ${_buildConfigFiles}) get_filename_component(_buildConfigFile ${_buildConfigFile} NAME_WE) list(APPEND _buildConfigs ${_buildConfigFile}) endforeach() set(MITK_BUILD_CONFIGURATION "Custom" CACHE STRING "Use pre-defined MITK configurations") set_property(CACHE MITK_BUILD_CONFIGURATION PROPERTY STRINGS ${_buildConfigs}) mitkFunctionEnableBuildConfiguration() mitkFunctionCreateWhitelistPaths(MITK) mitkFunctionFindWhitelists(MITK) # ----------------------------------------- # Custom dependency logic option(MITK_USE_SYSTEM_Boost "Use the system Boost" OFF) set(MITK_USE_Boost_LIBRARIES "" CACHE STRING "A semi-colon separated list of required Boost libraries") -if(MITK_USE_SOFA) - # SOFA requires boost system library - list(FIND MITK_USE_Boost_LIBRARIES system _result) - if(_result LESS 0) - message("> Adding 'system' to MITK_USE_Boost_LIBRARIES.") - list(APPEND MITK_USE_Boost_LIBRARIES system) - endif() - # SOFA requires boost thread library - list(FIND MITK_USE_Boost_LIBRARIES thread _result) - if(_result LESS 0) - message("> Adding 'thread' to MITK_USE_Boost_LIBRARIES.") - list(APPEND MITK_USE_Boost_LIBRARIES thread) - endif() - # Simulation plugin requires boost chrono library - list(FIND MITK_USE_Boost_LIBRARIES chrono _result) - if(_result LESS 0) - message("> Adding 'chrono' to MITK_USE_Boost_LIBRARIES.") - list(APPEND MITK_USE_Boost_LIBRARIES chrono) - endif() - set(MITK_USE_Boost_LIBRARIES ${MITK_USE_Boost_LIBRARIES} CACHE STRING "" FORCE) - # Allow setting external SOFA plugins directory and SOFA plugins - set(MITK_USE_SOFA_PLUGINS_DIR ${MITK_USE_SOFA_PLUGINS_DIR} CACHE PATH "External SOFA plugins directory" FORCE) - set(MITK_USE_SOFA_PLUGINS ${MITK_USE_SOFA_PLUGINS} CACHE PATH "List of semicolon-separated plugin names" FORCE) -endif() - # only windows can't build python in debug mode if(MITK_USE_Python AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND WIN32) message(WARNING "Disabling Python support. Building MITK Python in debug mode on Windowsis not supported!") set(MITK_USE_Python OFF CACHE BOOL "Use python wrapping in MITK" FORCE) set(MITK_USE_Numpy OFF CACHE BOOL "Use Numpy" FORCE) set(MITK_USE_SimpleITK OFF CACHE BOOL "Use SimpleITK" FORCE) elseif(MITK_USE_Python) set(MITK_USE_ZLIB ON) if(NOT MITK_USE_Numpy) message("> Forcing MITK_USE_Numpy to ON because of MITK_USE_Python") set(MITK_USE_Numpy ON CACHE BOOL "Use Numpy" FORCE) endif() if(NOT MITK_USE_SimpleITK) message("> Forcing MITK_USE_SimpleITK to ON because of MITK_USE_Python") set(MITK_USE_SimpleITK ON CACHE BOOL "Use SimpleITK" FORCE) endif() option(MITK_USE_SYSTEM_PYTHON "Use the system python runtime" OFF) if(MITK_USE_SYSTEM_PYTHON) find_package(PythonLibs REQUIRED) find_package(PythonInterp REQUIRED) endif() elseif(MITK_USE_Python AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND WIN32) message(WARNING "Disabling Python support. Building MITK Python in debug mode on Windowsis not supported!") set(MITK_USE_Python OFF CACHE BOOL "Use python wrapping in MITK" FORCE) endif() if(BUILD_TESTING AND NOT MITK_USE_CppUnit) message("> Forcing MITK_USE_CppUnit to ON because BUILD_TESTING=ON") set(MITK_USE_CppUnit ON CACHE BOOL "Use CppUnit for unit tests" FORCE) endif() if(MITK_USE_BLUEBERRY) option(MITK_BUILD_ALL_PLUGINS "Build all MITK plugins" OFF) mark_as_advanced(MITK_BUILD_ALL_PLUGINS) if(NOT MITK_USE_CTK) message("> Forcing MITK_USE_CTK to ON because of MITK_USE_BLUEBERRY") set(MITK_USE_CTK ON CACHE BOOL "Use CTK in MITK" FORCE) endif() endif() #----------------------------------------------------------------------------- # Pixel type multiplexing #----------------------------------------------------------------------------- # Customize the default pixel types for multiplex macros set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros") set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") mark_as_advanced(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES MITK_ACCESSBYITK_DIMENSIONS ) # consistency checks if(NOT MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES) set(MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES "int, unsigned int, short, unsigned short, char, unsigned char" CACHE STRING "List of integral pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES) set(MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES "double, float" CACHE STRING "List of floating pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES) set(MITK_ACCESSBYITK_COMPOSITE_PIXEL_TYPES "itk::RGBPixel, itk::RGBAPixel" CACHE STRING "List of composite pixel types used in AccessByItk and InstantiateAccessFunction macros" FORCE) endif() if(NOT MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES) string(REPLACE "," ";" _integral_types ${MITK_ACCESSBYITK_INTEGRAL_PIXEL_TYPES}) string(REPLACE "," ";" _floating_types ${MITK_ACCESSBYITK_FLOATING_PIXEL_TYPES}) foreach(_scalar_type ${_integral_types} ${_floating_types}) set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}itk::VariableLengthVector<${_scalar_type}>,") endforeach() string(LENGTH "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" _length) math(EXPR _length "${_length} - 1") string(SUBSTRING "${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES}" 0 ${_length} MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES) set(MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES ${MITK_ACCESSBYITK_VECTOR_PIXEL_TYPES} CACHE STRING "List of vector pixel types used in AccessByItk and InstantiateAccessFunction macros for itk::VectorImage types" FORCE) endif() if(NOT MITK_ACCESSBYITK_DIMENSIONS) set(MITK_ACCESSBYITK_DIMENSIONS "2,3" CACHE STRING "List of dimensions used in AccessByItk and InstantiateAccessFunction macros") endif() #----------------------------------------------------------------------------- # Project.xml #----------------------------------------------------------------------------- # A list of topologically ordered targets set(CTEST_PROJECT_SUBPROJECTS) list(APPEND CTEST_PROJECT_SUBPROJECTS MITK-Core MITK-CoreUI MITK-IGT MITK-ToF MITK-DTI MITK-Modules # all modules not contained in a specific subproject MITK-Plugins # all plugins not contained in a specific subproject MITK-Examples Unlabeled # special "subproject" catching all unlabeled targets and tests ) # Configure CTestConfigSubProject.cmake that could be used by CTest scripts configure_file(${MITK_SOURCE_DIR}/CTestConfigSubProject.cmake.in ${MITK_BINARY_DIR}/CTestConfigSubProject.cmake) if(CTEST_PROJECT_ADDITIONAL_TARGETS) # those targets will be executed at the end of the ctest driver script # and they also get their own subproject label set(subproject_list "${CTEST_PROJECT_SUBPROJECTS};${CTEST_PROJECT_ADDITIONAL_TARGETS}") else() set(subproject_list "${CTEST_PROJECT_SUBPROJECTS}") endif() # Generate Project.xml file expected by the CTest driver script mitkFunctionGenerateProjectXml(${MITK_BINARY_DIR} MITK "${subproject_list}" ${MITK_USE_SUPERBUILD}) #----------------------------------------------------------------------------- # Superbuild script #----------------------------------------------------------------------------- if(MITK_USE_SUPERBUILD) include("${CMAKE_CURRENT_SOURCE_DIR}/SuperBuild.cmake") # Print configuration summary message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL) return() endif() #***************************************************************************** #**************************** END OF SUPERBUILD **************************** #***************************************************************************** #----------------------------------------------------------------------------- # CMake function(s) and macro(s) #----------------------------------------------------------------------------- include(WriteBasicConfigVersionFile) include(CheckCXXSourceCompiles) include(GenerateExportHeader) include(mitkFunctionAddCustomModuleTest) include(mitkFunctionCheckModuleDependencies) include(mitkFunctionCompileSnippets) include(mitkFunctionConfigureVisualStudioUserProjectFile) include(mitkFunctionConvertXPSchema) include(mitkFunctionCreateBlueBerryApplication) include(mitkFunctionCreateCommandLineApp) include(mitkFunctionCreateModule) include(mitkFunctionCreatePlugin) include(mitkFunctionCreateProvisioningFile) include(mitkFunctionGetLibrarySearchPaths) include(mitkFunctionGetVersion) include(mitkFunctionGetVersionDescription) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionInstallCTKPlugin) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallThirdPartyCTKPlugins) include(mitkFunctionOrganizeSources) include(mitkFunctionTestPlugin) include(mitkFunctionUseModules) if( ${MITK_USE_MatchPoint} ) include(mitkFunctionCreateMatchPointDeployedAlgorithm) endif() include(mitkMacroConfigureItkPixelTypes) include(mitkMacroCreateExecutable) include(mitkMacroCreateModuleTests) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetLinuxDistribution) include(mitkMacroGetPMDPlatformString) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroMultiplexPicType) # Deprecated include(mitkMacroCreateCTKPlugin) #----------------------------------------------------------------------------- # Global CMake variables #----------------------------------------------------------------------------- # Required and enabled C++14 features for all MITK code. # These are added as PUBLIC compile features to all MITK modules. set(MITK_CXX_FEATURES cxx_auto_type cxx_decltype cxx_enum_forward_declarations cxx_extended_friend_declarations cxx_extern_templates cxx_final cxx_lambdas cxx_local_type_template_args cxx_long_long_type cxx_nullptr cxx_override cxx_range_for cxx_right_angle_brackets cxx_rvalue_references cxx_static_assert cxx_strong_enums cxx_template_template_parameters cxx_trailing_return_types cxx_variadic_macros ) if(NOT DEFINED CMAKE_DEBUG_POSTFIX) # We can't do this yet because the CTK Plugin Framework # cannot cope with a postfix yet. #set(CMAKE_DEBUG_POSTFIX d) endif() #----------------------------------------------------------------------------- # Output directories. #----------------------------------------------------------------------------- set(_default_LIBRARY_output_dir lib) set(_default_RUNTIME_output_dir bin) set(_default_ARCHIVE_output_dir lib) foreach(type LIBRARY RUNTIME ARCHIVE) # Make sure the directory exists if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY AND NOT EXISTS ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) message("Creating directory MITK_CMAKE_${type}_OUTPUT_DIRECTORY: ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") file(MAKE_DIRECTORY "${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}") endif() if(MITK_CMAKE_${type}_OUTPUT_DIRECTORY) set(CMAKE_${type}_OUTPUT_DIRECTORY ${MITK_CMAKE_${type}_OUTPUT_DIRECTORY}) else() set(CMAKE_${type}_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/${_default_${type}_output_dir}) set(MITK_CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY}) endif() set(CMAKE_${type}_OUTPUT_DIRECTORY ${CMAKE_${type}_OUTPUT_DIRECTORY} CACHE INTERNAL "Output directory for ${type} files.") mark_as_advanced(CMAKE_${type}_OUTPUT_DIRECTORY) endforeach() #----------------------------------------------------------------------------- # Set MITK specific options and variables (NOT available during superbuild) #----------------------------------------------------------------------------- # Look for optional Doxygen package find_package(Doxygen) option(BLUEBERRY_DEBUG_SMARTPOINTER "Enable code for debugging smart pointers" OFF) mark_as_advanced(BLUEBERRY_DEBUG_SMARTPOINTER) # ASK THE USER TO SHOW THE CONSOLE WINDOW FOR CoreApp and mitkWorkbench option(MITK_SHOW_CONSOLE_WINDOW "Use this to enable or disable the console window when starting MITK GUI Applications" ON) mark_as_advanced(MITK_SHOW_CONSOLE_WINDOW) # TODO: check if necessary option(USE_ITKZLIB "Use the ITK zlib for pic compression." ON) mark_as_advanced(USE_ITKZLIB) if(NOT MITK_FAST_TESTING) if(DEFINED MITK_CTEST_SCRIPT_MODE AND (MITK_CTEST_SCRIPT_MODE STREQUAL "continuous" OR MITK_CTEST_SCRIPT_MODE STREQUAL "experimental") ) set(MITK_FAST_TESTING 1) endif() endif() if(NOT UNIX AND NOT MINGW) set(MITK_WIN32_FORCE_STATIC "STATIC" CACHE INTERNAL "Use this variable to always build static libraries on non-unix platforms") endif() if(MITK_BUILD_ALL_PLUGINS) set(MITK_BUILD_ALL_PLUGINS_OPTION "FORCE_BUILD_ALL") endif() # Configure pixel types used for ITK image access multiplexing mitkMacroConfigureItkPixelTypes() # Configure module naming conventions set(MITK_MODULE_NAME_REGEX_MATCH "^[A-Z].*$") set(MITK_MODULE_NAME_REGEX_NOT_MATCH "^[Mm][Ii][Tt][Kk].*$") set(MITK_MODULE_NAME_PREFIX "Mitk") set(MITK_MODULE_NAME_DEFAULTS_TO_DIRECTORY_NAME 1) #----------------------------------------------------------------------------- # Get MITK version info #----------------------------------------------------------------------------- mitkFunctionGetVersion(${MITK_SOURCE_DIR} MITK) mitkFunctionGetVersionDescription(${MITK_SOURCE_DIR} MITK) # MITK_VERSION set(MITK_VERSION_STRING "${MITK_VERSION_MAJOR}.${MITK_VERSION_MINOR}.${MITK_VERSION_PATCH}") if(MITK_VERSION_PATCH STREQUAL "99") set(MITK_VERSION_STRING "${MITK_VERSION_STRING}-${MITK_REVISION_SHORTID}") endif() #----------------------------------------------------------------------------- # Installation preparation # # These should be set before any MITK install macros are used #----------------------------------------------------------------------------- # on Mac OSX all BlueBerry plugins get copied into every # application bundle (.app directory) specified here if(MITK_USE_BLUEBERRY AND APPLE) include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 1 option_name) list(GET target_info_list 0 app_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) set(MACOSX_BUNDLE_NAMES ${MACOSX_BUNDLE_NAMES} Mitk${app_name}) endif() endforeach() endif() #----------------------------------------------------------------------------- # Set coverage Flags #----------------------------------------------------------------------------- if(WITH_COVERAGE) if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O0 -DNDEBUG") set(COVERAGE_CXX_FLAGS ${coverage_flags}) set(COVERAGE_C_FLAGS ${coverage_flags}) endif() endif() #----------------------------------------------------------------------------- # MITK C/CXX Flags #----------------------------------------------------------------------------- set(MITK_C_FLAGS "${COVERAGE_C_FLAGS}") set(MITK_C_FLAGS_DEBUG ) set(MITK_C_FLAGS_RELEASE ) set(MITK_CXX_FLAGS "${COVERAGE_CXX_FLAGS} ${MITK_CXX14_FLAG}") set(MITK_CXX_FLAGS_DEBUG ) set(MITK_CXX_FLAGS_RELEASE ) set(MITK_EXE_LINKER_FLAGS ) set(MITK_SHARED_LINKER_FLAGS ) find_package(OpenMP) if (OPENMP_FOUND) set(MITK_C_FLAGS "${MITK_C_FLAGS} ${OpenMP_C_FLAGS}") set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") endif() if(WIN32) set(MITK_CXX_FLAGS "${MITK_CXX_FLAGS} -D_WIN32_WINNT=0x0501 -DPOCO_NO_UNWINDOWS -DWIN32_LEAN_AND_MEAN -DNOMINMAX") mitkFunctionCheckCompilerFlags("/wd4005" MITK_CXX_FLAGS) # warning C4005: macro redefinition mitkFunctionCheckCompilerFlags("/wd4231" MITK_CXX_FLAGS) # warning C4231: nonstandard extension used : 'extern' before template explicit instantiation # the following line should be removed after fixing bug 17637 mitkFunctionCheckCompilerFlags("/wd4316" MITK_CXX_FLAGS) # warning C4316: object alignment on heap mitkFunctionCheckCompilerFlags("/wd4180" MITK_CXX_FLAGS) # warning C4180: qualifier applied to function type has no meaning endif() if(NOT MSVC_VERSION) foreach(_flag -Wall -Wextra -Wpointer-arith -Winvalid-pch -Wcast-align -Wwrite-strings -Wno-error=gnu -Wno-error=unknown-pragmas # The strict-overflow warning is generated by ITK template code -Wno-error=strict-overflow -Woverloaded-virtual -Wstrict-null-sentinel #-Wold-style-cast #-Wsign-promo -Wno-array-bounds -fdiagnostics-show-option ) mitkFunctionCheckCAndCXXCompilerFlags(${_flag} MITK_C_FLAGS MITK_CXX_FLAGS) endforeach() endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) mitkFunctionCheckCompilerFlags("-Wl,--no-undefined" MITK_SHARED_LINKER_FLAGS) mitkFunctionCheckCompilerFlags("-Wl,--as-needed" MITK_SHARED_LINKER_FLAGS) endif() if(CMAKE_COMPILER_IS_GNUCXX) mitkFunctionCheckCAndCXXCompilerFlags("-fstack-protector-all" MITK_C_FLAGS MITK_CXX_FLAGS) if(MINGW) # suppress warnings about auto imported symbols set(MITK_SHARED_LINKER_FLAGS "-Wl,--enable-auto-import ${MITK_SHARED_LINKER_FLAGS}") endif() set(MITK_CXX_FLAGS_RELEASE "-U_FORTIFY_SOURCES -D_FORTIFY_SOURCE=2 ${MITK_CXX_FLAGS_RELEASE}") endif() set(MITK_MODULE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) set(MITK_EXE_LINKER_FLAGS ${MITK_SHARED_LINKER_FLAGS}) #----------------------------------------------------------------------------- # MITK Packages #----------------------------------------------------------------------------- set(MITK_MODULES_PACKAGE_DEPENDS_DIR ${MITK_SOURCE_DIR}/CMake/PackageDepends) set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) if(NOT MITK_USE_SYSTEM_Boost) set(Boost_NO_SYSTEM_PATHS 1) endif() set(Boost_USE_MULTITHREADED 1) set(Boost_USE_STATIC_LIBS 0) set(Boost_USE_STATIC_RUNTIME 0) set(Boost_ADDITIONAL_VERSIONS "1.64" "1.64.0") # We need this later for a DCMTK workaround set(_dcmtk_dir_orig ${DCMTK_DIR}) # This property is populated at the top half of this file get_property(MITK_EXTERNAL_PROJECTS GLOBAL PROPERTY MITK_EXTERNAL_PROJECTS) foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) if(MITK_USE_${ep} AND _package) if(_components) find_package(${_package} COMPONENTS ${_components} REQUIRED CONFIG) else() # Prefer config mode first because it finds external # Config.cmake files pointed at by _DIR variables. # Otherwise, existing Find.cmake files could fail. # (e.g. in the case of GLEW and the FindGLEW.cmake file shipped # with CMake). find_package(${_package} QUIET CONFIG) string(TOUPPER "${_package}" _package_uc) if(NOT (${_package}_FOUND OR ${_package_uc}_FOUND)) find_package(${_package} REQUIRED) endif() endif() endif() endforeach() # Ensure that the MITK CMake module path comes first set(CMAKE_MODULE_PATH ${MITK_CMAKE_DIR} ${CMAKE_MODULE_PATH} ) if(MITK_USE_DCMTK) # Due to the preferred CONFIG mode in find_package calls above, # the DCMTKConfig.cmake file is read, which does not provide useful # package information. We explictly need MODULE mode to find DCMTK. if(${_dcmtk_dir_orig} MATCHES "${MITK_EXTERNAL_PROJECT_PREFIX}.*") # Help our FindDCMTK.cmake script find our super-build DCMTK set(DCMTK_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) else() # Use the original value set(DCMTK_DIR ${_dcmtk_dir_orig}) endif() find_package(DCMTK REQUIRED MODULE) endif() if(MITK_USE_DCMQI) # Due to the preferred CONFIG mode in find_package calls above, # the DCMQIConfig.cmake file is read, which does not provide useful # package information. We explictly need MODULE mode to find DCMQI. # Help our FindDCMQI.cmake script find our super-build DCMQI set(DCMQI_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) find_package(DCMQI REQUIRED) endif() if(MITK_USE_Python) find_package(PythonLibs REQUIRED) find_package(PythonInterp REQUIRED) if(MITK_USE_Numpy) find_package(Numpy REQUIRED) endif() endif() -if(MITK_USE_SOFA) - # The SOFAConfig.cmake file does not provide exported targets or - # libraries with absolute paths, hence we need to make the link - # directories globally available until the SOFAConfig.cmake file - # supports a proper mechanism for handling targets. - # The same code is needed in MITKConfig.cmake. - link_directories(${SOFA_LIBRARY_DIRS}) -endif() - -# Same as SOFA above link_directories(${Boost_LIBRARY_DIRS}) if(MITK_USE_OpenIGTLink) - # Same as SOFA above link_directories(${OpenIGTLink_LIBRARY_DIRS}) endif() if(MITK_USE_SimpleITK) link_directories(${SimpleITK_LIBRARY_DIRS}) endif() if(MITK_USE_OpenCL) find_package(OpenCL REQUIRED) endif() # Qt support if(MITK_USE_Qt5) find_package(Qt5Core ${MITK_QT5_MINIMUM_VERSION} REQUIRED) # at least Core required get_target_property(_qmake_exec Qt5::qmake LOCATION) execute_process(COMMAND ${_qmake_exec} -query QT_INSTALL_BINS RESULT_VARIABLE _result OUTPUT_VARIABLE QT_BINARY_DIR ERROR_VARIABLE _error ) string(STRIP "${QT_BINARY_DIR}" QT_BINARY_DIR) if(_result OR NOT EXISTS "${QT_BINARY_DIR}") message(FATAL_ERROR "Could not determine Qt binary directory: ${_result} ${QT_BINARY_DIR} ${_error}") endif() find_program(QT_HELPGENERATOR_EXECUTABLE NAMES qhelpgenerator qhelpgenerator-qt5 qhelpgenerator5 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH ) find_program(QT_COLLECTIONGENERATOR_EXECUTABLE NAMES qcollectiongenerator qcollectiongenerator-qt5 qcollectiongenerator5 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH ) find_program(QT_ASSISTANT_EXECUTABLE NAMES assistant assistant-qt5 assistant5 PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH ) find_program(QT_XMLPATTERNS_EXECUTABLE NAMES xmlpatterns PATHS ${QT_BINARY_DIR} NO_DEFAULT_PATH ) mark_as_advanced(QT_HELPGENERATOR_EXECUTABLE QT_COLLECTIONGENERATOR_EXECUTABLE QT_ASSISTANT_EXECUTABLE QT_XMLPATTERNS_EXECUTABLE ) if(MITK_USE_BLUEBERRY) option(BLUEBERRY_USE_QT_HELP "Enable support for integrating plugin documentation into Qt Help" ${DOXYGEN_FOUND}) mark_as_advanced(BLUEBERRY_USE_QT_HELP) # Sanity checks for in-application BlueBerry plug-in help generation if(BLUEBERRY_USE_QT_HELP) set(_force_blueberry_use_qt_help_to_off 0) if(NOT DOXYGEN_FOUND) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen was not found.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(DOXYGEN_FOUND AND DOXYGEN_VERSION VERSION_LESS 1.8.7) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because Doxygen version 1.8.7 or newer not found.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT QT_HELPGENERATOR_EXECUTABLE) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because QT_HELPGENERATOR_EXECUTABLE is empty.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT MITK_USE_Qt5_WebEngine) message("> Forcing BLUEBERRY_USE_QT_HELP to OFF because MITK_USE_Qt5_WebEngine is OFF.") set(_force_blueberry_use_qt_help_to_off 1) endif() if(NOT QT_XMLPATTERNS_EXECUTABLE) message("You have enabled Qt Help support, but QT_XMLPATTERNS_EXECUTABLE is empty") set(_force_blueberry_use_qt_help_to_off 1) endif() if(_force_blueberry_use_qt_help_to_off) set(BLUEBERRY_USE_QT_HELP OFF CACHE BOOL "Enable support for integrating plugin documentation into Qt Help" FORCE) endif() endif() if(BLUEBERRY_QT_HELP_REQUIRED AND NOT BLUEBERRY_USE_QT_HELP) message(FATAL_ERROR "BLUEBERRY_USE_QT_HELP is required to be set to ON") endif() endif() endif() #----------------------------------------------------------------------------- # Testing #----------------------------------------------------------------------------- if(BUILD_TESTING) enable_testing() include(CTest) mark_as_advanced(TCL_TCLSH DART_ROOT) option(MITK_ENABLE_RENDERING_TESTING OFF "Enable the MITK rendering tests. Requires x-server in Linux.") #Rendering testing does not work for Linux nightlies, thus it is disabled per default #and activated for Mac and Windows. if(WIN32 OR APPLE) set(MITK_ENABLE_RENDERING_TESTING ON) endif() mark_as_advanced( MITK_ENABLE_RENDERING_TESTING ) # Setup file for setting custom ctest vars configure_file( CMake/CTestCustom.cmake.in ${MITK_BINARY_DIR}/CTestCustom.cmake @ONLY ) # Initial cache for ProjectTemplate and PluginGenerator tests configure_file( CMake/mitkTestInitialCache.txt.in ${MITK_BINARY_DIR}/mitkTestInitialCache.txt @ONLY ) # Configuration for the CMake-generated test driver set(CMAKE_TESTDRIVER_EXTRA_INCLUDES "#include ") set(CMAKE_TESTDRIVER_BEFORE_TESTMAIN " try {") set(CMAKE_TESTDRIVER_AFTER_TESTMAIN " } catch( std::exception & excp ) { fprintf(stderr,\"%s\\n\",excp.what()); return EXIT_FAILURE; } catch( ... ) { printf(\"Exception caught in the test driver\\n\"); return EXIT_FAILURE; } ") set(MITK_TEST_OUTPUT_DIR "${MITK_BINARY_DIR}/test_output") if(NOT EXISTS ${MITK_TEST_OUTPUT_DIR}) file(MAKE_DIRECTORY ${MITK_TEST_OUTPUT_DIR}) endif() # Test the external project template if(MITK_USE_BLUEBERRY) include(mitkTestProjectTemplate) endif() # Test the package target include(mitkPackageTest) endif() configure_file(mitkTestingConfig.h.in ${MITK_BINARY_DIR}/mitkTestingConfig.h) #----------------------------------------------------------------------------- # MITK_SUPERBUILD_BINARY_DIR #----------------------------------------------------------------------------- # If MITK_SUPERBUILD_BINARY_DIR isn't defined, it means MITK is *NOT* build using Superbuild. # In that specific case, MITK_SUPERBUILD_BINARY_DIR should default to MITK_BINARY_DIR if(NOT DEFINED MITK_SUPERBUILD_BINARY_DIR) set(MITK_SUPERBUILD_BINARY_DIR ${MITK_BINARY_DIR}) endif() #----------------------------------------------------------------------------- # Set C/CXX and linker flags for MITK code #----------------------------------------------------------------------------- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MITK_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MITK_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MITK_CXX_FLAGS_RELEASE}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MITK_C_FLAGS}") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MITK_C_FLAGS_DEBUG}") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MITK_C_FLAGS_RELEASE}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MITK_EXE_LINKER_FLAGS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MITK_SHARED_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${MITK_MODULE_LINKER_FLAGS}") #----------------------------------------------------------------------------- # Add custom targets representing CDash subprojects #----------------------------------------------------------------------------- foreach(subproject ${CTEST_PROJECT_SUBPROJECTS}) if(NOT TARGET ${subproject} AND NOT subproject MATCHES "Unlabeled") add_custom_target(${subproject}) endif() endforeach() #----------------------------------------------------------------------------- # Add subdirectories #----------------------------------------------------------------------------- add_subdirectory(Utilities) add_subdirectory(Modules) if(MITK_USE_BLUEBERRY) set(BLUEBERRY_XPDOC_OUTPUT_DIR ${MITK_DOXYGEN_OUTPUT_DIR}/html/extension-points/html/) set(MITK_DEFAULT_SUBPROJECTS MITK-Plugins) # Plug-in testing (needs some work to be enabled again) if(BUILD_TESTING) set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp") if(TARGET CoreApp) get_target_property(_is_macosx_bundle CoreApp MACOSX_BUNDLE) if(APPLE AND _is_macosx_bundle) set(BLUEBERRY_UI_TEST_APP "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/CoreApp.app/Contents/MacOS/CoreApp") endif() endif() set(BLUEBERRY_TEST_APP_ID "org.mitk.qt.coreapplication") endif() include("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/PluginList.cmake") mitkFunctionWhitelistPlugins(MITK MITK_PLUGINS) set(mitk_plugins_fullpath "") foreach(mitk_plugin ${MITK_PLUGINS}) list(APPEND mitk_plugins_fullpath Plugins/${mitk_plugin}) endforeach() if(EXISTS ${MITK_PRIVATE_MODULES}/PluginList.cmake) include(${MITK_PRIVATE_MODULES}/PluginList.cmake) foreach(mitk_plugin ${MITK_PRIVATE_PLUGINS}) list(APPEND mitk_plugins_fullpath ${MITK_PRIVATE_MODULES}/${mitk_plugin}) endforeach() endif() if(MITK_BUILD_EXAMPLES) include("${CMAKE_CURRENT_SOURCE_DIR}/Examples/Plugins/PluginList.cmake") set(mitk_example_plugins_fullpath ) foreach(mitk_example_plugin ${MITK_EXAMPLE_PLUGINS}) list(APPEND mitk_example_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) list(APPEND mitk_plugins_fullpath Examples/Plugins/${mitk_example_plugin}) endforeach() endif() # Specify which plug-ins belong to this project macro(GetMyTargetLibraries all_target_libraries varname) set(re_ctkplugin_mitk "^org_mitk_[a-zA-Z0-9_]+$") set(re_ctkplugin_bb "^org_blueberry_[a-zA-Z0-9_]+$") set(_tmp_list) list(APPEND _tmp_list ${all_target_libraries}) ctkMacroListFilter(_tmp_list re_ctkplugin_mitk re_ctkplugin_bb OUTPUT_VARIABLE ${varname}) endmacro() # Get infos about application directories and build options include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/AppList.cmake") set(mitk_apps_fullpath ) foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 directory_name) list(GET target_info_list 1 option_name) if(${option_name}) list(APPEND mitk_apps_fullpath "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${directory_name}^^${option_name}") endif() endforeach() if (mitk_plugins_fullpath) ctkMacroSetupPlugins(${mitk_plugins_fullpath} BUILD_OPTION_PREFIX MITK_BUILD_ APPS ${mitk_apps_fullpath} BUILD_ALL ${MITK_BUILD_ALL_PLUGINS} COMPACT_OPTIONS) endif() set(MITK_PLUGIN_USE_FILE "${MITK_BINARY_DIR}/MitkPluginUseFile.cmake") if(${PROJECT_NAME}_PLUGIN_LIBRARIES) ctkFunctionGeneratePluginUseFile(${MITK_PLUGIN_USE_FILE}) else() file(REMOVE ${MITK_PLUGIN_USE_FILE}) set(MITK_PLUGIN_USE_FILE ) endif() endif() #----------------------------------------------------------------------------- # Documentation #----------------------------------------------------------------------------- if(DOXYGEN_FOUND) add_subdirectory(Documentation) endif() #----------------------------------------------------------------------------- # Installation #----------------------------------------------------------------------------- # set MITK cpack variables # These are the default variables, which can be overwritten ( see below ) include(mitkSetupCPack) set(use_default_config ON) # MITK_APPS is set in Applications/AppList.cmake (included somewhere above # if MITK_USE_BLUEBERRY is set to ON). if(MITK_APPS) set(activated_apps_no 0) list(LENGTH MITK_APPS app_count) # Check how many apps have been enabled # If more than one app has been activated, the we use the # default CPack configuration. Otherwise that apps configuration # will be used, if present. foreach(mitk_app ${MITK_APPS}) # extract option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 1 option_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) MATH(EXPR activated_apps_no "${activated_apps_no} + 1") endif() endforeach() if(app_count EQUAL 1 AND (activated_apps_no EQUAL 1 OR MITK_BUILD_ALL_APPS)) # Corner case if there is only one app in total set(use_project_cpack ON) elseif(activated_apps_no EQUAL 1 AND NOT MITK_BUILD_ALL_APPS) # Only one app is enabled (no "build all" flag set) set(use_project_cpack ON) else() # Less or more then one app is enabled set(use_project_cpack OFF) endif() foreach(mitk_app ${MITK_APPS}) # extract target_dir and option_name string(REPLACE "^^" "\\;" target_info ${mitk_app}) set(target_info_list ${target_info}) list(GET target_info_list 0 target_dir) list(GET target_info_list 1 option_name) list(GET target_info_list 2 executable_name) # check if the application is enabled if(${option_name} OR MITK_BUILD_ALL_APPS) # check whether application specific configuration files will be used if(use_project_cpack) # use files if they exist if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake") include("${CMAKE_CURRENT_SOURCE_DIR}/Applications/${target_dir}/CPackOptions.cmake") endif() if(EXISTS "${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in") set(CPACK_PROJECT_CONFIG_FILE "${PROJECT_BINARY_DIR}/Applications/${target_dir}/CPackConfig.cmake") configure_file(${PROJECT_SOURCE_DIR}/Applications/${target_dir}/CPackConfig.cmake.in ${CPACK_PROJECT_CONFIG_FILE} @ONLY) set(use_default_config OFF) endif() endif() # add link to the list list(APPEND CPACK_CREATE_DESKTOP_LINKS "${executable_name}") endif() endforeach() endif() # if no application specific configuration file was used, use default if(use_default_config) configure_file(${MITK_SOURCE_DIR}/MITKCPackOptions.cmake.in ${MITK_BINARY_DIR}/MITKCPackOptions.cmake @ONLY) set(CPACK_PROJECT_CONFIG_FILE "${MITK_BINARY_DIR}/MITKCPackOptions.cmake") endif() # include CPack model once all variables are set include(CPack) # Additional installation rules include(mitkInstallRules) #----------------------------------------------------------------------------- # Last configuration steps #----------------------------------------------------------------------------- # ---------------- Export targets ----------------- set(MITK_EXPORTS_FILE "${MITK_BINARY_DIR}/MitkExports.cmake") file(REMOVE ${MITK_EXPORTS_FILE}) set(targets_to_export) get_property(module_targets GLOBAL PROPERTY MITK_MODULE_TARGETS) if(module_targets) list(APPEND targets_to_export ${module_targets}) endif() if(MITK_USE_BLUEBERRY) if(MITK_PLUGIN_LIBRARIES) list(APPEND targets_to_export ${MITK_PLUGIN_LIBRARIES}) endif() endif() export(TARGETS ${targets_to_export} APPEND FILE ${MITK_EXPORTS_FILE}) set(MITK_EXPORTED_TARGET_PROPERTIES ) foreach(target_to_export ${targets_to_export}) get_target_property(autoload_targets ${target_to_export} MITK_AUTOLOAD_TARGETS) if(autoload_targets) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_TARGETS \"${autoload_targets}\")") endif() get_target_property(autoload_dir ${target_to_export} MITK_AUTOLOAD_DIRECTORY) if(autoload_dir) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_AUTOLOAD_DIRECTORY \"${autoload_dir}\")") endif() get_target_property(deprecated_module ${target_to_export} MITK_MODULE_DEPRECATED_SINCE) if(deprecated_module) set(MITK_EXPORTED_TARGET_PROPERTIES "${MITK_EXPORTED_TARGET_PROPERTIES} set_target_properties(${target_to_export} PROPERTIES MITK_MODULE_DEPRECATED_SINCE \"${deprecated_module}\")") endif() endforeach() # ---------------- External projects ----------------- get_property(MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS_CONFIG GLOBAL PROPERTY MITK_ADDITIONAL_LIBRARY_SEARCH_PATHS) set(MITK_CONFIG_EXTERNAL_PROJECTS ) #string(REPLACE "^^" ";" _mitk_external_projects ${MITK_EXTERNAL_PROJECTS}) foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS} set(MITK_USE_${ep} ${MITK_USE_${ep}}) set(MITK_${ep}_DIR \"${${ep}_DIR}\") set(MITK_${ep}_COMPONENTS ${_components}) ") endforeach() foreach(ep ${MITK_EXTERNAL_PROJECTS}) get_property(_package GLOBAL PROPERTY MITK_${ep}_PACKAGE) get_property(_components GLOBAL PROPERTY MITK_${ep}_COMPONENTS) if(_components) set(_components_arg COMPONENTS \${_components}) else() set(_components_arg) endif() if(_package) set(MITK_CONFIG_EXTERNAL_PROJECTS "${MITK_CONFIG_EXTERNAL_PROJECTS} if(MITK_USE_${ep}) set(${ep}_DIR \${MITK_${ep}_DIR}) if(MITK_${ep}_COMPONENTS) mitkMacroFindDependency(${_package} COMPONENTS \${MITK_${ep}_COMPONENTS}) else() mitkMacroFindDependency(${_package}) endif() endif()") endif() endforeach() # ---------------- Tools ----------------- configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactory.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolExtensionITKFactoryLoader.cpp.in ${MITK_BINARY_DIR}/ToolExtensionITKFactoryLoader.cpp.in COPYONLY) configure_file(${MITK_SOURCE_DIR}/CMake/ToolGUIExtensionITKFactory.cpp.in ${MITK_BINARY_DIR}/ToolGUIExtensionITKFactory.cpp.in COPYONLY) # ---------------- Configure files ----------------- configure_file(mitkVersion.h.in ${MITK_BINARY_DIR}/mitkVersion.h) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) set(IPFUNC_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities/ipFunc) set(UTILITIES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Utilities) configure_file(mitkConfig.h.in ${MITK_BINARY_DIR}/mitkConfig.h) configure_file(MITKConfig.cmake.in ${MITK_BINARY_DIR}/MITKConfig.cmake @ONLY) write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${MITK_VERSION_STRING} COMPATIBILITY AnyNewerVersion) #----------------------------------------------------------------------------- # MITK Applications #----------------------------------------------------------------------------- # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Applications) #----------------------------------------------------------------------------- # MITK Examples #----------------------------------------------------------------------------- if(MITK_BUILD_EXAMPLES) # This must come after MITKConfig.h was generated, since applications # might do a find_package(MITK REQUIRED). add_subdirectory(Examples) endif() #----------------------------------------------------------------------------- # Print configuration summary #----------------------------------------------------------------------------- message("\n\n") feature_summary( DESCRIPTION "------- FEATURE SUMMARY FOR ${PROJECT_NAME} -------" WHAT ALL ) diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox index 3d47cc93d6..685d278bb9 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/BuildInstructions.dox @@ -1,219 +1,217 @@ /** \page BuildInstructionsPage Build Instructions \tableofcontents \section BuildInstructions_Introduction Introduction The CMake-based build system of MITK supports a "superbuild" process, meaning that it will download, configure, and build all required third-party libraries (except Qt) automatically. These instructions will show you how to use the MITK superbuild. \note This page explains explicitly how to build MITK itself. If you want to create your own project based on MITK, the process described below is completely automated. Please see \ref HowToNewProject. For more advanced users, the last sections explains how to inject custom build libraries into the superbuild process. \section BuildInstructions_Prerequisites Prerequisites You need: -# Git from http://git-scm.com (there are also numerous third-party graphical clients available). We recomment using Git, but see below for a way how to get the current source code without using it. -# CMake (version \minimumCMakeVersion or higher) -# Qt 5.6 or 5.7.1 if you plan to develop Qt-based applications -# If you are using Mac OS X you need an XCode installation as it provides the neccessary compilers and SDKs \section BuildInstructions_Qt A note about Qt As we do not provide Qt in the MITK superbuild you need to install Qt manually. Installing Qt dramatically improved since Qt 5, as The Qt Company provides sophisticated online installers for all supported platforms. \section BuildInstructions_Get_Source Get a source tree Since MITK is under active development we recommend to use Git to check out the latest stable release from the homepage. If you decide to use the most current nightly release, make sure to get a stable tree: Check the MITK dashboard before checking out. If the build tree is not clean, you can specify an older revision for the checkout or get a stable tar ball from www.mitk.org. To clone MITK's current Git repository do: \code git clone https://phabricator.mitk.org/source/mitk.git MITK \endcode \section BuildInstructions_Build_With_CMake Build MITK with CMake Create a new directory for the superbuild binary tree, change to it and call CMake: In the shell (assuming your current directory is the same as the one where you issued the git clone command): \code mkdir MITK-superbuild cd MITK-superbuild ccmake ../MITK \endcode If you use Windows or prefer to use the CMake GUI, start the CMake GUI and enter the location of the source tree and binary tree, choose a suitable generator and configure the project. CMake will present you a couple of options, these are the most important ones: - CMAKE_PREFIX_PATH The path to your Qt installation, e.g., C:/Qt/5.6/msvc2013_64 or /home/user/Qt/5.6/gcc_64 - MITK_USE_ACVD Build MITK code which depends on ACVD (this will download and build ACVD) - MITK_USE_BLUEBERRY Build the BlueBerry application framework - MITK_USE_Boost_LIBRARIES If you need binary Boost libraries, specify them here. - MITK_USE_OpenCV Build MITK code which depends on OpenCV (this will download and build OpenCV 2.4) - MITK_USE_Python Enables Python wrapping in MITK. This will also configure ITK, VTK, and OpenCV (if enabled) to build Python wrappers. - MITK_USE_Qt5 Build MITK code which depends on Qt 5 - - MITK_USE_SOFA Build MITK code which depends on SOFA (this will - download and build SOFA) If you are satisfied with the configuration of your MITK superbuild, generate the project files with CMake by pressing "Generate". Linux and Mac OS X users usually just enter "make" (optionally supplying the number threads to be used for a parallel build): \code make -j6 \endcode Windows users using Visual Studio can open the generated MITK-superbuild.sln solution file in the MITK-superbuild directory and start the build by building the BUILD_ALL project. \section BuildInstructions_Customize Customize your MITK superbuild The MITK superbuild configures MITK as well as all external libraries. The build directories of these libraries, and of MITK itself are located inside the MITK-superbuild directory. For example, the directory layout may look like: \code MITK-superbuild |- ep "external projects" |-bin |-lib |-include |-src |- MITK-build \endcode To change the configuration of the MITK build itself, choose the MITK-build directory as the binary directory in the CMake GUI (not the MITK-superbuild directory). After generating the project files, build the MITK project by either issuing "make" in the MITK-build directory (Linux, Mac OS X), or by opening MITK-build/MITK.sln (Windows). You may also change the configuration of any project configured via the superbuild process. Make sure to also build the changed project and also the projects which depend on it. \section BuildInstructions_Running Running Applications On Linux, just execute the application you want to run. MITK executables are located in MITK-superbuild/MITK-build/bin On Windows, the PATH environment variable must contain the directories containing the third-party libraries. This is automatically done from Visual Studio. For running the applications directly use the generated batch files in the MITK-superbuild/MITK-build/bin. \section BuildInstructions_Documentation Documentation If you have the Doxygen documentation tool installed, you get a new project (Visual Studio) or "make" target named "doc". You can build this to generate the HTML documentation of MITK in the Documentation/Doxygen directory of your MITK-build binary tree or in the MITK_DOXYGEN_OUTPUT_DIR CMake variable (if specified). \section BuildInstructions_Extending Extend MITK on your own (using the application framework BlueBerry) Please see \ref NewPluginPage \section BuildInstructions_As_Toolkit Use MITK in your own project (as a toolkit) To use MITK in your external project, add the CMake command find_package(MITK REQUIRED) to your CMakeLists.txt and make use of the CMake macros mitk_create_module() and mitk_create_executable() provided by MITK. Here is a very basic example CMakeLists.txt including MITK as a project: \code cmake_minimum_required(VERSION 3.5 FATAL_ERROR) project(MyProject) find_package(MITK 2016.11 REQUIRED) add_executable(MyApp main.cpp) target_link_libraries(MyApp MitkCore) \endcode with the main.ccp being \code #include #include int main() { MITK_INFO << "Hello world!"; return 0; } \endcode \section BuildInstructions_Advanced_Customization Superbuild customization You can inject pre-build third-party libraries into the MITK superbuild by setting certain CMake variables before the first configure step. MITK will then use these third-party libraries instead of downloading and building them by itself. Note that you must take care of configuring those libraries with all options MITK requires. The variables listed below are provided for injecting third-party libraries. Their occurrence in the CMake GUI or in ccmake may depend on specific MITK_USE_* options set to ON. You may also use the variable names below without the EXTERNAL_ prefix, for example when providing their values on a command line call to CMake. - EXTERNAL_BOOST_ROOT Set this variable to your custom Boost installation - EXTERNAL_CTK_DIR Set this variable to your CTK binary tree (the directory containing the CTKConfig.cmake file) - EXTERNAL_CableSwig_DIR Set this variable to your CableSwig binary tree for Python wrapping (the directory containing the CableSwigConfig.cmake file) - EXTERNAL_DCMTK_DIR Set this variable to your DCMTK binary tree (the directory containing the DCMTKConfig.cmake file) - EXTERNAL_GDCM_DIR Set this variable to your GDCM binary tree (the directory containing the GDCMConfig.cmake file) - EXTERNAL_ITK_DIR Set this variable to your ITK binary tree (the directory containing the ITKConfig.cmake file) - EXTERNAL_OpenCV_DIR Set this variable to your OpenCV binary tree (the directory containing the OpenCVConfig.cmake file) - EXTERNAL_VTK_DIR Set this variable to your VTK binary tree (the directory containing the VTKConfig.cmake file) To set CMake options before the first configure step is invoked, supply them on the command line, i.e. \code ccmake -DITK_DIR:PATH=/opt/ITK-release ../MITK \endcode */ diff --git a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox index 5c2f464af7..6f556ac4d5 100644 --- a/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox +++ b/Documentation/Doxygen/3-DeveloperManual/Starting/SettingUpMITK/ThirdPartyLibs.dox @@ -1,143 +1,139 @@ /** \page thirdpartylibs Third-party libraries The following third-party libraries can be used with MITK by default and can, in part, be automatically downloaded during superbuild. \par ACVD http://www.creatis.insa-lyon.fr/site/en/acvd \par ANN http://www.cs.umd.edu/~mount/ANN/ \par Boost http://www.boost.org/ \par CppUnit http://sourceforge.net/projects/cppunit/ \par CTK http://www.commontk.org/ \par DCMTK http://dicom.offis.de/dcmtk.php.en \par Eigen http://eigen.tuxfamily.org/index.php?title=Main_Page \par GDCM http://gdcm.sourceforge.net/ \par GLEW http://glew.sourceforge.net/ \par GLUT https://www.opengl.org/resources/libraries/glut/ \par HDF5 https://support.hdfgroup.org/HDF5/ \par ITK http://www.itk.org/ \par MatchPoint https://www.dkfz.de/en/sidt/projects/matchpoint/info.html \par NumPy http://www.numpy.org/ \par OpenCL https://www.khronos.org/opencl/ \par OpenCV http://opencv.willowgarage.com/wiki/Welcome \par OpenIGTLink http://openigtlink.org/ \par PCRE http://www.pcre.org/ \par POCO http://pocoproject.org \par Python https://www.python.org/ \par Qt http://www.qt.io/ \par Qwt http://qwt.sourceforge.net/ \par Rasqal http://librdf.org/rasqal/ \par Raptor2 http://librdf.org/raptor/ \par Redland http://librdf.org/ \par SimpleITK http://www.simpleitk.org/ -\par SOFA - -http://www.sofa-framework.org/ - \par SWIG http://swig.org/ \par tinyxml http://sourceforge.net/projects/tinyxml/ \par VIGRA http://ukoethe.github.io/vigra/ \par VMTK http://www.vmtk.org/ \par VTK http://www.vtk.org/ \par zlib https://github.com/commontk/zlib \par libSVM http://www.csie.ntu.edu.tw/~cjlin/libsvm/ For copyright information on any of the above toolkits see the corresponding home page or the corresponding source folder. */ diff --git a/MITKConfig.cmake.in b/MITKConfig.cmake.in index e26525b752..76ca77f3a0 100644 --- a/MITKConfig.cmake.in +++ b/MITKConfig.cmake.in @@ -1,338 +1,323 @@ if(CMAKE_VERSION VERSION_LESS @MITK_CMAKE_MINIMUM_REQUIRED_VERSION@) message(FATAL_ERROR "MITK requires at least CMake Version @MITK_CMAKE_MINIMUM_REQUIRED_VERSION@") endif() # The MITK version number set(MITK_VERSION_MAJOR "@MITK_VERSION_MAJOR@") set(MITK_VERSION_MINOR "@MITK_VERSION_MINOR@") set(MITK_VERSION_PATCH "@MITK_VERSION_PATCH@") set(MITK_VERSION_STRING "@MITK_VERSION_STRING@") #----------------------------------------------------------------------------- # C++ language standard #----------------------------------------------------------------------------- set(MITK_CXX_STANDARD @MITK_CXX_STANDARD@) #----------------------------------------------------------------------------- # Include required CMake scripts #----------------------------------------------------------------------------- # Update the CMake module path set(MITK_CMAKE_MODULE_PATH "@MITK_SOURCE_DIR@/CMake") list(APPEND CMAKE_MODULE_PATH ${MITK_CMAKE_MODULE_PATH}) # Standard CMake macros include(CMakeParseArguments) include(FeatureSummary) include(FindPackageHandleStandardArgs) include(GenerateExportHeader) # Include MITK macros include(MacroParseArguments) include(mitkFunctionAddCustomModuleTest) include(mitkFunctionCheckMitkCompatibility) include(mitkFunctionCheckModuleDependencies) include(mitkFunctionConfigureVisualStudioUserProjectFile) include(mitkFunctionCreateBlueBerryApplication) include(mitkFunctionCreateCommandLineApp) include(mitkFunctionCreateModule) include(mitkFunctionCreatePlugin) include(mitkFunctionCreateProvisioningFile) include(mitkFunctionCreateWindowsBatchScript) include(mitkFunctionGetLibrarySearchPaths) include(mitkFunctionInstallAutoLoadModules) include(mitkFunctionInstallCTKPlugin) include(mitkFunctionInstallProvisioningFiles) include(mitkFunctionInstallThirdPartyCTKPlugins) include(mitkFunctionOrganizeSources) include(mitkFunctionUseModules) include(mitkMacroCreateExecutable) include(mitkMacroCreateModuleTests) include(mitkMacroFindDependency) include(mitkMacroGenerateToolsLibrary) include(mitkMacroGetPMDPlatformString) include(mitkMacroInstall) include(mitkMacroInstallHelperApp) include(mitkMacroInstallTargets) include(mitkMacroMultiplexPicType) #----------------------------------------------------------------------------- # MITK flags and directories #----------------------------------------------------------------------------- # MITK compiler flags set(MITK_C_FLAGS "@MITK_C_FLAGS@") set(MTTK_C_FLAGS_DEBUG "@MITK_C_FLAGS_DEBUG@") set(MITK_C_FLAGS_RELEASE "@MITK_C_FLAGS_RELEASE@") set(MITK_CXX_FLAGS "@MITK_CXX_FLAGS@") set(MTTK_CXX_FLAGS_DEBUG "@MITK_CXX_FLAGS_DEBUG@") set(MITK_CXX_FLAGS_RELEASE "@MITK_CXX_FLAGS_RELEASE@") # MITK linker flags set(MITK_EXE_LINKER_FLAGS "@MITK_EXE_LINKER_FLAGS@") set(MITK_SHARED_LINKER_FLAGS "@MITK_SHARED_LINKER_FLAGS@") set(MITK_MODULE_LINKER_FLAGS "@MITK_MODULE_LINKER_FLAGS@") # MITK specific directories set(MITK_SOURCE_DIR "@MITK_SOURCE_DIR@") set(MITK_BINARY_DIR "@MITK_BINARY_DIR@") set(MITK_CMAKE_DIR "@MITK_CMAKE_DIR@") # MITK output directories set(MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY "@MITK_CMAKE_RUNTIME_OUTPUT_DIRECTORY@") set(MITK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY "@MITK_CMAKE_ARCHIVE_OUTPUT_DIRECTORY@") set(MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY "@MITK_CMAKE_LIBRARY_OUTPUT_DIRECTORY@") #----------------------------------------------------------------------------- # Miscellaneous variables #----------------------------------------------------------------------------- # Internal version numbers, used for approximate compatibility checks # of a MITK development version (non-release). set(MITK_VERSION_PLUGIN_SYSTEM 2) # dropped legacy BlueBerry plug-in CMake support set(MITK_DATA_DIR "@MITK_DATA_DIR@") set(UTILITIES_DIR "@UTILITIES_DIR@") set(REGISTER_QFUNCTIONALITY_CPP_IN "@REGISTER_QFUNCTIONALITY_CPP_IN@") set(MITK_DOXYGEN_TAGFILE_NAME "@MITK_DOXYGEN_TAGFILE_NAME@") set(MITK_LEGACY_EXPORT_MACRO_NAME 1) set(DCMTK_CMAKE_DEBUG_POSTFIX @DCMTK_CMAKE_DEBUG_POSTFIX@) # Get the canonical name of the directory to avoid potential case mismatch, # e.g. in the drive letter on Windows. get_filename_component(CMAKE_CURRENT_LIST_DIR_REALPATH ${CMAKE_CURRENT_LIST_DIR} REALPATH) if(CMAKE_CURRENT_LIST_DIR_REALPATH STREQUAL MITK_BINARY_DIR) set(MITK_EXTERNAL_PROJECT_PREFIX @MITK_EXTERNAL_PROJECT_PREFIX@) endif() set(MITK_MODULES_PACKAGE_DEPENDS_DIR "@MITK_MODULES_PACKAGE_DEPENDS_DIR@") if(MODULES_PACKAGE_DEPENDS_DIRS) list(APPEND MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) list(REMOVE_DUPLICATES MODULES_PACKAGE_DEPENDS_DIRS) else() set(MODULES_PACKAGE_DEPENDS_DIRS ${MITK_MODULES_PACKAGE_DEPENDS_DIR}) endif() #----------------------------------------------------------------------------- # External dependencies #----------------------------------------------------------------------------- list(APPEND CMAKE_PREFIX_PATH "@MITK_EXTERNAL_PROJECT_PREFIX@") # ----------------------------------------- # Qt variables and dependencies set(MITK_USE_Qt5 @MITK_USE_Qt5@) set(MITK_USE_Qt5_WebEngine @MITK_USE_Qt5_WebEngine@) if(MITK_USE_Qt5) set(MITK_QT5_MINIMUM_VERSION @MITK_QT5_MINIMUM_VERSION@) set(MITK_QT5_COMPONENTS @MITK_QT5_COMPONENTS@) mitkMacroFindDependency(Qt5 ${MITK_QT5_MINIMUM_VERSION} COMPONENTS ${MITK_QT5_COMPONENTS}) endif() # ----------------------------------------- # Special Python variables set(MITK_USE_Python @MITK_USE_Python@) set(MITK_USE_SYSTEM_PYTHON @MITK_USE_SYSTEM_PYTHON@) if(MITK_USE_Python) set(PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@" CACHE FILEPATH "") set(PYTHON_INCLUDE_DIR "@PYTHON_INCLUDE_DIR@" CACHE PATH "") set(PYTHON_LIBRARY "@PYTHON_LIBRARY@" CACHE FILEPATH "") set(PYTHON_INCLUDE_DIR2 "@PYTHON_INCLUDE_DIR2@" CACHE PATH "") mitkMacroFindDependency(PythonLibs) mitkMacroFindDependency(PythonInterp) endif() # ----------------------------------------- # Special Boost variables set(MITK_USE_Boost_LIBRARIES @MITK_USE_Boost_LIBRARIES@) set(MITK_USE_SYSTEM_Boost @MITK_USE_SYSTEM_Boost@) set(BOOST_ROOT "@BOOST_ROOT@" CACHE PATH "") set(BOOST_LIBRARYDIR "@BOOST_LIBRARYDIR@" CACHE PATH "") set(Boost_ADDITIONAL_VERSIONS "1.64" "1.64.0") # We need this later for a DCMTK workaround set(_dcmtk_dir_orig "@DCMTK_DIR@") # ----------------------------------------- # External dependencies from the superbuild # or injected from somewhere else via # _DIR variables. @MITK_CONFIG_EXTERNAL_PROJECTS@ # Ensure the MITK module path comes first set(CMAKE_MODULE_PATH ${MITK_CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH}) # ----------------------------------------- # Special handling for DCMTK if(MITK_USE_DCMTK) # Due to the preferred CONFIG mode in find_package calls above, # the DCMTKConfig.cmake file is read, which does not provide useful # package information. We explictly need MODULE mode to find DCMTK. if(${_dcmtk_dir_orig} MATCHES "${MITK_EXTERNAL_PROJECT_PREFIX}.*") # Help our FindDCMTK.cmake script find our super-build DCMTK set(DCMTK_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) else() # Use the original value set(DCMTK_DIR ${_dcmtk_dir_orig}) endif() find_package(DCMTK REQUIRED MODULE) endif() # ----------------------------------------- # Special handling for DCMQI if(MITK_USE_DCMQI) # Due to the preferred CONFIG mode in find_package calls above, # the DCMQIConfig.cmake file is read, which does not provide useful # package information. We explictly need MODULE mode to find DCMQI. # Help our FindDCMQI.cmake script find our super-build DCMQI set(DCMQI_DIR ${MITK_EXTERNAL_PROJECT_PREFIX}) find_package(DCMQI REQUIRED) endif() -# ----------------------------------------- -# Special handling for SOFA - -if(MITK_USE_SOFA) - # The SOFAConfig.cmake file does not provide exported targets or - # libraries with absolute paths, hence we need to make the link - # directories globally available until the SOFAConfig.cmake file - # supports a proper mechanism for handling targets. -# find_package(SOFA PATHS ${SOFA_DIR} CONFIG REQUIRED) - link_directories(${SOFA_LIBRARY_DIRS}) -endif() - # ----------------------------------------- # Special handling for VMTK if(MITK_USE_VMTK) - # Same as SOFA above link_directories(${VMTK_LIBRARY_DIRS}) endif() # ----------------------------------------- # Special handling for Boost if(MITK_USE_Boost) - # Same as SOFA above link_directories(${Boost_LIBRARY_DIRS}) endif() # ----------------------------------------- # Special handling for OpenIGTLink if(MITK_USE_OpenIGTLink) - # Same as SOFA above link_directories(${OpenIGTLink_LIBRARY_DIRS}) endif() # ----------------------------------------- # Internal project dependencies set(CppMicroServices_DIR "@CppMicroServices_DIR@") mitkMacroFindDependency(CppMicroServices) set(MITK_USE_BLUEBERRY @MITK_USE_BLUEBERRY@) if(MITK_USE_BLUEBERRY) set(MITK_PLUGIN_USE_FILE "@MITK_PLUGIN_USE_FILE@") if(MITK_PLUGIN_USE_FILE) if(EXISTS "${MITK_PLUGIN_USE_FILE}") include("${MITK_PLUGIN_USE_FILE}") endif() endif() set(MITK_PLUGIN_PROVISIONING_FILE "@MITK_EXTAPP_PROVISIONING_FILE@") set(MITK_PROVISIONING_FILES "${BLUEBERRY_PLUGIN_PROVISIONING_FILE}" "${MITK_PLUGIN_PROVISIONING_FILE}") endif() set(BLUEBERRY_USE_QT_HELP @BLUEBERRY_USE_QT_HELP@) if(BLUEBERRY_USE_QT_HELP AND DOXYGEN_VERSION VERSION_LESS "1.8.7") message("Setting BLUEBERRY_USE_QT_HELP to OFF because Doxygen version 1.8.7 or newer not found.") set(BLUEBERRY_USE_QT_HELP OFF) endif() set(BLUEBERRY_QTPLUGIN_PATH "@BLUEBERRY_QTPLUGIN_PATH@") set(QT_HELPGENERATOR_EXECUTABLE "@QT_HELPGENERATOR_EXECUTABLE@") set(QT_COLLECTIONGENERATOR_EXECUTABLE "@QT_COLLECTIONGENERATOR_EXECUTABLE@") set(QT_ASSISTANT_EXECUTABLE "@QT_ASSISTANT_EXECUTABLE@") set(QT_XMLPATTERNS_EXECUTABLE "@QT_XMLPATTERNS_EXECUTABLE@") #----------------------------------------------------------------------------- # MITK sub-project variables #----------------------------------------------------------------------------- # External SDK directories set(MITK_PMD_SDK_DIR @MITK_PMD_SDK_DIR@) # MITK ToF use variables set(MITK_TOF_PMDCAMCUBE_AVAILABLE @MITK_USE_TOF_PMDCAMCUBE@) if(MITK_TOF_PMDCAMCUBE_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_PMDCAMCUBE "Enable support for PMD Cam Cube" @MITK_USE_TOF_PMDCAMCUBE@) mark_as_advanced(MITK_USE_TOF_PMDCAMCUBE) endif() set(MITK_TOF_PMDCAMBOARD_AVAILABLE @MITK_USE_TOF_PMDCAMBOARD@) if(MITK_TOF_PMDCAMBOARD_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_PMDCAMBOARD "Enable support for PMD Cam Board" @MITK_USE_TOF_PMDCAMBOARD@) mark_as_advanced(MITK_USE_TOF_PMDCAMBOARD) endif() set(MITK_TOF_PMDO3_AVAILABLE @MITK_USE_TOF_PMDO3@) if(MITK_TOF_PMDO3_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_PMDO3 "Enable support for PMD =3" @MITK_USE_TOF_PMDO3@) mark_as_advanced(MITK_USE_TOF_PMDO3) endif() set(MITK_TOF_KINECT_AVAILABLE @MITK_USE_TOF_KINECT@) if(MITK_TOF_KINECT_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_KINECT "Enable support for Kinect" @MITK_USE_TOF_KINECT@) mark_as_advanced(MITK_USE_TOF_KINECT) endif() set(MITK_TOF_MESASR4000_AVAILABLE @MITK_USE_TOF_MESASR4000@) if(MITK_TOF_MESASR4000_AVAILABLE AND NOT ${PROJECT_NAME} STREQUAL "MITK") option(MITK_USE_TOF_MESASR4000 "Enable support for MESA SR4000" @MITK_USE_TOF_MESASR4000@) mark_as_advanced(MITK_USE_TOF_MESASR4000) endif() if(MITK_USE_IGT) #include("${MITK_DIR}/mitkIGTConfig.cmake") endif() #----------------------------------------------------------------------------- # Import MITK targets and set custom properties #----------------------------------------------------------------------------- if(NOT MITK_EXPORTS_FILE_INCLUDED) if(EXISTS "@MITK_EXPORTS_FILE@") set(MITK_EXPORTS_FILE_INCLUDED 1) include("@MITK_EXPORTS_FILE@") endif() endif() # Set properties on exported targets @MITK_EXPORTED_TARGET_PROPERTIES@ #----------------------------------------------------------------------------- # Install rules #----------------------------------------------------------------------------- # Install rules for ToF libraries loaded at runtime if(EXISTS "@MITK_BINARY_DIR@/mitkToFHardwareInstallRules.cmake") include("@MITK_BINARY_DIR@/mitkToFHardwareInstallRules.cmake") endif() diff --git a/Modules/ModuleList.cmake b/Modules/ModuleList.cmake index c17b7b596c..36a97fe6a3 100644 --- a/Modules/ModuleList.cmake +++ b/Modules/ModuleList.cmake @@ -1,81 +1,80 @@ # The entries in the mitk_modules list must be # ordered according to their dependencies. set(mitk_modules Core CommandLine AppUtil DCMTesting RDF LegacyIO DataTypesExt Annotation LegacyGL AlgorithmsExt MapperExt DICOMReader DICOMReaderServices DICOMTesting SceneSerializationBase PlanarFigure ImageDenoising ImageExtraction SceneSerialization Gizmo GraphAlgorithms Multilabel ImageStatistics ContourModel SurfaceInterpolation Segmentation PlanarFigureSegmentation OpenViewCore QtWidgets QtWidgetsExt Chart QmlItems SegmentationUI Classification DiffusionImaging GPGPU OpenIGTLink IGTBase IGT CameraCalibration OpenCL OpenCVVideoSupport QtOverlays ToFHardware ToFProcessing ToFUI PhotoacousticsHardware PhotoacousticsAlgorithms US USUI DicomUI - Simulation Remeshing Python QtPython Persistence OpenIGTLinkUI IGTUI DicomRT RTUI IOExt XNAT TubeGraph BiophotonicsHardware TumorInvasionAnalysis MatchPointRegistration MatchPointRegistrationUI BoundingShape RenderWindowManager RenderWindowManagerUI CEST DICOMQI ) if(MITK_ENABLE_PIC_READER) list(APPEND mitk_modules IpPicSupportIO) endif() diff --git a/Modules/Simulation/CMakeLists.txt b/Modules/Simulation/CMakeLists.txt deleted file mode 100644 index b3ef1affb1..0000000000 --- a/Modules/Simulation/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -MITK_CREATE_MODULE( - DEPENDS MitkSceneSerializationBase - PACKAGE_DEPENDS - PUBLIC SOFA - PRIVATE GLUT GLEW -) - -if(TARGET ${MODULE_TARGET}) - target_compile_options(${MODULE_TARGET} PUBLIC "$<$:/wd4068;/wd4250;/wd4251;/wd4267;/wd4275>") -endif() diff --git a/Modules/Simulation/Resources/Interactions/Simulation.xml b/Modules/Simulation/Resources/Interactions/Simulation.xml deleted file mode 100644 index c0bad251b8..0000000000 --- a/Modules/Simulation/Resources/Interactions/Simulation.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Modules/Simulation/Resources/Interactions/SimulationConfig.xml b/Modules/Simulation/Resources/Interactions/SimulationConfig.xml deleted file mode 100644 index 224f082a55..0000000000 --- a/Modules/Simulation/Resources/Interactions/SimulationConfig.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Modules/Simulation/files.cmake b/Modules/Simulation/files.cmake deleted file mode 100644 index 321bbc9ab1..0000000000 --- a/Modules/Simulation/files.cmake +++ /dev/null @@ -1,30 +0,0 @@ -set(CPP_FILES - mitkGetSimulationService.cpp - mitkExportMitkVisitor.cpp - mitkIndexROI.cpp - mitkISimulationService.cpp - mitkPlaneIntersectionVisitor.cpp - mitkRoundRobinSchedulingAlgorithm.cpp - mitkSetVtkRendererVisitor.cpp - mitkSchedulableProcess.cpp - mitkScheduler.cpp - mitkSchedulingAlgorithmBase.cpp - mitkSimulation.cpp - mitkSimulationActivator.cpp - mitkSimulationInteractor.cpp - mitkSimulationIO.cpp - mitkSimulationObjectFactory.cpp - mitkSimulationSerializer.cpp - mitkSimulationService.cpp - mitkSimulationVtkMapper2D.cpp - mitkSimulationVtkMapper3D.cpp - mitkVtkModel.cpp - mitkVtkSimulationPolyDataMapper2D.cpp - mitkVtkSimulationPolyDataMapper3D.cpp - mitkWeightedRoundRobinSchedulingAlgorithm.cpp -) - -set(RESOURCE_FILES - Interactions/Simulation.xml - Interactions/SimulationConfig.xml -) diff --git a/Modules/Simulation/mitkExportMitkVisitor.cpp b/Modules/Simulation/mitkExportMitkVisitor.cpp deleted file mode 100644 index ce2c402466..0000000000 --- a/Modules/Simulation/mitkExportMitkVisitor.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkExportMitkVisitor.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -void ApplyMaterial(mitk::DataNode::Pointer dataNode, const sofa::core::loader::Material& material) -{ - using sofa::defaulttype::Vec4f; - - if (dataNode.IsNull() || dynamic_cast(dataNode->GetData()) == nullptr) - return; - - if (material.useDiffuse) - dataNode->SetFloatProperty("opacity", material.diffuse[3]); - - Vec4f ambient = material.useAmbient ? material.ambient : Vec4f(); - Vec4f diffuse = material.useDiffuse ? material.diffuse : Vec4f(); - Vec4f specular = material.useSpecular ? material.specular : Vec4f(); - float shininess = material.useShininess ? std::min(material.shininess, 128.0f) : 45.0f; - - if (shininess == 0.0f) - { - specular.clear(); - shininess = 1.0f; - } - - dataNode->SetFloatProperty("material.ambientCoefficient", 1.0f); - dataNode->SetProperty("material.ambientColor", mitk::ColorProperty::New(ambient.elems)); - - dataNode->SetFloatProperty("material.diffuseCoefficient", 1.0f); - dataNode->SetProperty("color", mitk::ColorProperty::New(diffuse.elems)); - - dataNode->SetFloatProperty("material.specularCoefficient", 1.0f); - dataNode->SetProperty("material.specularColor", mitk::ColorProperty::New(specular.elems)); - dataNode->SetFloatProperty("material.specularPower", shininess); -} - -static mitk::DataNode::Pointer GetSimulationDataNode(mitk::DataStorage::Pointer dataStorage, sofa::core::objectmodel::BaseNode::SPtr rootNode) -{ - if (dataStorage.IsNull()) - return nullptr; - - if (!rootNode) - return nullptr; - - mitk::TNodePredicateDataType::Pointer predicate = mitk::TNodePredicateDataType::New(); - mitk::DataStorage::SetOfObjects::ConstPointer subset = dataStorage->GetSubset(predicate); - - for (mitk::DataStorage::SetOfObjects::ConstIterator it = subset->Begin(); it != subset->End(); ++it) - { - mitk::DataNode::Pointer dataNode = it.Value(); - mitk::Simulation::Pointer simulation = static_cast(dataNode->GetData()); - - if (simulation->GetRootNode() == rootNode) - return dataNode; - } - - return nullptr; -} - - -mitk::ExportMitkVisitor::ExportMitkVisitor(DataStorage::Pointer dataStorage, const sofa::core::ExecParams* params) - : Visitor(params), - m_DataStorage(dataStorage) -{ -} - -mitk::ExportMitkVisitor::ExportMitkVisitor(DataStorage::Pointer dataStorage, const std::string& visualModelName, const sofa::core::ExecParams* params) - : Visitor(params), - m_DataStorage(dataStorage), - m_VisualModelName(visualModelName) -{ -} - -mitk::ExportMitkVisitor::~ExportMitkVisitor() -{ -} - -sofa::simulation::Visitor::Result mitk::ExportMitkVisitor::processNodeTopDown(sofa::simulation::Node* node) -{ - if (m_DataStorage.IsNotNull()) - { - for_each(this, node, node->visualModel, &ExportMitkVisitor::processVisualModel); - return RESULT_CONTINUE; - } - - return RESULT_PRUNE; -} - -void mitk::ExportMitkVisitor::processVisualModel(sofa::simulation::Node* node, sofa::core::visual::VisualModel* visualModel) -{ - using sofa::defaulttype::ResizableExtVector; - typedef sofa::component::visualmodel::VisualModelImpl::VecCoord VecCoord; - typedef sofa::component::visualmodel::VisualModelImpl::Triangle Triangle; - typedef sofa::component::visualmodel::VisualModelImpl::Quad Quad; - typedef sofa::component::visualmodel::VisualModelImpl::Deriv Deriv; - typedef sofa::component::visualmodel::VisualModelImpl::VecTexCoord VecTexCoord; - - sofa::component::visualmodel::VisualModelImpl* visualModelImpl = dynamic_cast(visualModel); - - if (visualModelImpl == nullptr) - return; - - if (!m_VisualModelName.empty() && m_VisualModelName != visualModelImpl->name.getValue()) - return; - - vtkSmartPointer polyData = vtkSmartPointer::New(); - vtkSmartPointer points = vtkSmartPointer::New(); - - const VecCoord& vertices = visualModelImpl->m_vertices2.getValue().empty() - ? visualModelImpl->m_positions.getValue() - : visualModelImpl->m_vertices2.getValue(); - - size_t numPoints = vertices.size(); - - points->SetNumberOfPoints(numPoints); - - for (size_t i = 0; i < numPoints; ++i) - points->SetPoint(i, vertices[i].elems); - - polyData->SetPoints(points); - - vtkSmartPointer polys = vtkSmartPointer::New(); - const ResizableExtVector& triangles = visualModelImpl->m_triangles.getValue(); - - if (!triangles.empty()) - { - ResizableExtVector::const_iterator trianglesEnd = triangles.end(); - - for (ResizableExtVector::const_iterator it = triangles.begin(); it != trianglesEnd; ++it) - { - const Triangle& triangle = *it; - - polys->InsertNextCell(3); - polys->InsertCellPoint(triangle[0]); - polys->InsertCellPoint(triangle[1]); - polys->InsertCellPoint(triangle[2]); - } - } - - const ResizableExtVector& quads = visualModelImpl->m_quads.getValue(); - - if (!quads.empty()) - { - ResizableExtVector::const_iterator quadsEnd = quads.end(); - - for (ResizableExtVector::const_iterator it = quads.begin(); it != quadsEnd; ++it) - { - const Quad& quad = *it; - - polys->InsertNextCell(4); - polys->InsertCellPoint(quad[0]); - polys->InsertCellPoint(quad[1]); - polys->InsertCellPoint(quad[2]); - polys->InsertCellPoint(quad[3]); - } - } - - polyData->SetPolys(polys); - - const ResizableExtVector& normals = visualModelImpl->m_vnormals.getValue(); - - if (!normals.empty()) - { - size_t numNormals = normals.size(); - - vtkSmartPointer vtkNormals = vtkSmartPointer::New(); - vtkNormals->SetNumberOfComponents(3); - vtkNormals->SetNumberOfTuples(numNormals); - - for (size_t i = 0; i < numNormals; ++i) - vtkNormals->SetTuple(i, normals[i].elems); - - polyData->GetPointData()->SetNormals(vtkNormals); - } - - const VecTexCoord& texCoords = visualModelImpl->m_vtexcoords.getValue(); - - if (!texCoords.empty()) - { - size_t numTexCoords = texCoords.size(); - - vtkSmartPointer vtkTexCoords = vtkSmartPointer::New(); - vtkTexCoords->SetNumberOfComponents(2); - vtkTexCoords->SetNumberOfTuples(numTexCoords); - - for (size_t i = 0; i < numTexCoords; ++i) - vtkTexCoords->SetTuple(i, texCoords[i].elems); - - polyData->GetPointData()->SetTCoords(vtkTexCoords); - } - - Surface::Pointer surface = Surface::New(); - surface->SetVtkPolyData(polyData); - - DataNode::Pointer dataNode = DataNode::New(); - dataNode->SetName(visualModelImpl->name.getValue()); - dataNode->SetData(surface); - - ApplyMaterial(dataNode, visualModelImpl->material.getValue()); - - DataNode::Pointer parentDataNode = GetSimulationDataNode(m_DataStorage, node->getRoot()); - - if (parentDataNode.IsNotNull()) - surface->SetGeometry(parentDataNode->GetData()->GetGeometry()); - - m_DataStorage->Add(dataNode, parentDataNode); -} diff --git a/Modules/Simulation/mitkExportMitkVisitor.h b/Modules/Simulation/mitkExportMitkVisitor.h deleted file mode 100644 index e498e4a10f..0000000000 --- a/Modules/Simulation/mitkExportMitkVisitor.h +++ /dev/null @@ -1,47 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkExportMitkVisitor_h -#define mitkExportMitkVisitor_h - -#include -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT ExportMitkVisitor : public sofa::simulation::Visitor - { - public: - explicit ExportMitkVisitor(DataStorage::Pointer dataStorage, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); - ExportMitkVisitor(DataStorage::Pointer dataStorage, const std::string& visualModelName, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); - ~ExportMitkVisitor(); - - using sofa::simulation::Visitor::processNodeTopDown; - Result processNodeTopDown(sofa::simulation::Node* node) override; - - private: - ExportMitkVisitor(const ExportMitkVisitor&); - ExportMitkVisitor& operator=(const ExportMitkVisitor&); - - void processVisualModel(sofa::simulation::Node* node, sofa::core::visual::VisualModel* visualModel); - - DataStorage::Pointer m_DataStorage; - std::string m_VisualModelName; - }; -} - -#endif diff --git a/Modules/Simulation/mitkGetSimulationService.cpp b/Modules/Simulation/mitkGetSimulationService.cpp deleted file mode 100644 index 06f144c648..0000000000 --- a/Modules/Simulation/mitkGetSimulationService.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkGetSimulationService.h" -#include -#include -#include - -mitk::ISimulationService* mitk::GetSimulationService(us::ModuleContext* moduleContext) -{ - if (moduleContext == nullptr) - return nullptr; - - us::ServiceReference serviceReference = moduleContext->GetServiceReference(); - return moduleContext->GetService(serviceReference); -} diff --git a/Modules/Simulation/mitkGetSimulationService.h b/Modules/Simulation/mitkGetSimulationService.h deleted file mode 100644 index 76981cb1d6..0000000000 --- a/Modules/Simulation/mitkGetSimulationService.h +++ /dev/null @@ -1,35 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkGetSimulationService_h -#define mitkGetSimulationService_h - -#include -#include - -namespace us -{ - class ModuleContext; -} - -namespace mitk -{ - class ISimulationService; - - MITKSIMULATION_EXPORT ISimulationService* GetSimulationService(us::ModuleContext* moduleContext = us::GetModuleContext()); -} - -#endif diff --git a/Modules/Simulation/mitkISimulationService.cpp b/Modules/Simulation/mitkISimulationService.cpp deleted file mode 100644 index 490e58332f..0000000000 --- a/Modules/Simulation/mitkISimulationService.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkISimulationService.h" - -mitk::ISimulationService::ISimulationService() -{ -} - -mitk::ISimulationService::~ISimulationService() -{ -} diff --git a/Modules/Simulation/mitkISimulationService.h b/Modules/Simulation/mitkISimulationService.h deleted file mode 100644 index dc75baf824..0000000000 --- a/Modules/Simulation/mitkISimulationService.h +++ /dev/null @@ -1,47 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkISimulationService_h -#define mitkISimulationService_h - -#include -#include -#include - -namespace mitk -{ - class Scheduler; - - class MITKSIMULATION_EXPORT ISimulationService - { - public: - virtual Simulation::Pointer GetActiveSimulation() const = 0; - virtual void SetActiveSimulation(Simulation::Pointer activeSimulation) = 0; - virtual Scheduler* GetScheduler() = 0; - - protected: - ISimulationService(); - virtual ~ISimulationService(); - - private: - ISimulationService(const ISimulationService&); - ISimulationService& operator=(const ISimulationService&); - }; -} - -MITK_DECLARE_SERVICE_INTERFACE(mitk::ISimulationService, "org.mitk.ISimulationService"); - -#endif diff --git a/Modules/Simulation/mitkIndexROI.cpp b/Modules/Simulation/mitkIndexROI.cpp deleted file mode 100644 index ac4dd538e0..0000000000 --- a/Modules/Simulation/mitkIndexROI.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkIndexROI.h" -#include -#include -#include - -mitk::IndexROI::IndexROI() - : m_First(initData(&m_First, "first", "")), - m_Last(initData(&m_Last, "last", "")), - m_Individual(initData(&m_Individual, "individual", "")), - m_Indices(initData(&m_Indices, "indices", "")), - m_PointsInROI(initData(&m_PointsInROI, "pointsInROI", "")), - m_Position(initData(&m_Position, "position", "")) -{ -} - -mitk::IndexROI::~IndexROI() -{ -} - -void mitk::IndexROI::init() -{ - using sofa::core::loader::MeshLoader; - using sofa::core::objectmodel::BaseContext; - using sofa::core::objectmodel::BaseData; - typedef sofa::core::topology::BaseMeshTopology::SetIndex SetIndex; - typedef sofa::defaulttype::ExtVec3fTypes::VecCoord VecCoord; - - if (!m_Position.isSet()) - { - MeshLoader* loader = nullptr; - this->getContext()->get(loader, BaseContext::Local); - - if (loader != nullptr) - { - BaseData* parent = loader->findField("position"); - - if (parent != nullptr) - { - m_Position.setParent(parent); - m_Position.setReadOnly(true); - } - } - } - - if (!m_Indices.isSet()) - { - sofa::helper::WriteAccessor > indices = m_Indices; - - const VecCoord& position = m_Position.getValue(); - unsigned int numPositions = static_cast(position.size()); - unsigned int first = std::min(m_First.getValue(), numPositions); - - for (size_t i = 0; i < first; ++i) - indices.push_back(i); - - unsigned int last = numPositions - std::min(m_Last.getValue(), numPositions - first); - - for (size_t i = last; i < numPositions; ++i) - indices.push_back(i); - - SetIndex individual = m_Individual.getValue(); - size_t numIndividuals = individual.size(); - - for (size_t i = 0; i < numIndividuals; ++i) - { - unsigned int index = individual[i]; - - if (index >= first && index < last) - indices.push_back(index); - } - } - - this->addInput(&m_Indices); - this->addInput(&m_Position); - - this->addOutput(&m_PointsInROI); - - this->setDirtyValue(); -} - -void mitk::IndexROI::update() -{ - typedef sofa::core::topology::BaseMeshTopology::SetIndex SetIndex; - typedef sofa::defaulttype::ExtVec3fTypes::VecCoord VecCoord; - - this->cleanDirty(); - - sofa::helper::WriteAccessor > pointsInROI = m_PointsInROI; - pointsInROI.clear(); - - const VecCoord& position = m_Position.getValue(); - SetIndex indices = m_Indices.getValue(); - size_t numIndices = indices.size(); - - for (size_t i = 0; i < numIndices; ++i) - pointsInROI.push_back(position[indices[i]]); -} diff --git a/Modules/Simulation/mitkIndexROI.h b/Modules/Simulation/mitkIndexROI.h deleted file mode 100644 index 3271c1a362..0000000000 --- a/Modules/Simulation/mitkIndexROI.h +++ /dev/null @@ -1,50 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkIndexROI_h -#define mitkIndexROI_h - -#include -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT IndexROI : public sofa::core::DataEngine - { - public: - SOFA_CLASS(IndexROI, sofa::core::DataEngine); - - void init() override; - void update() override; - - sofa::core::objectmodel::Data m_First; - sofa::core::objectmodel::Data m_Last; - sofa::core::objectmodel::Data m_Individual; - sofa::core::objectmodel::Data m_Indices; - sofa::core::objectmodel::Data m_PointsInROI; - sofa::core::objectmodel::Data m_Position; - - private: - IndexROI(); - ~IndexROI(); - - IndexROI(const MyType&); - MyType& operator=(const MyType&); - }; -} - -#endif diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp b/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp deleted file mode 100644 index 6bf0e9d5da..0000000000 --- a/Modules/Simulation/mitkPlaneIntersectionVisitor.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkPlaneIntersectionVisitor.h" -#include - -mitk::PlaneIntersectionVisitor::PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params) - : Visitor(params), - m_Point(point), - m_Normal(normal) -{ -} - -mitk::PlaneIntersectionVisitor::~PlaneIntersectionVisitor() -{ -} - -const std::vector& mitk::PlaneIntersectionVisitor::GetIntersections() const -{ - return m_Intersections; -} - -sofa::simulation::Visitor::Result mitk::PlaneIntersectionVisitor::processNodeTopDown(sofa::simulation::Node* node) -{ - for_each(this, node, node->visualModel, &PlaneIntersectionVisitor::processVisualModel); - return RESULT_CONTINUE; -} - -void mitk::PlaneIntersectionVisitor::processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel) -{ - using sofa::component::visualmodel::VisualModelImpl; - using sofa::core::topology::Triangle; - using sofa::core::topology::Quad; - using sofa::defaulttype::ResizableExtVector; - - typedef VisualModelImpl::VecCoord VecCoord; - - VisualModelImpl* visualModelImpl = dynamic_cast(visualModel); - - if (visualModelImpl == nullptr) - return; - - const sofa::core::loader::Material& material = visualModelImpl->material.getValue(); - - if (!material.useDiffuse) - return; - - const VecCoord& verts = visualModelImpl->getVertices(); - const ResizableExtVector& tris = visualModelImpl->getTriangles(); - const ResizableExtVector& quads = visualModelImpl->getQuads(); - - float n[3] = { static_cast(m_Normal[0]), static_cast(m_Normal[1]), static_cast(m_Normal[2]) }; - float p[3] = { static_cast(m_Point[0]), static_cast(m_Point[1]), static_cast(m_Point[2]) }; - float d[4]; - int j; - const float* t0; - const float* t1; - const float* t2; - float s; - Edge edge; - Intersection intersection; - - const size_t numTriangles = tris.size(); - - for (size_t i = 0; i < numTriangles; ++i) - { - t0 = verts[tris[i][0]].data(); - t1 = verts[tris[i][1]].data(); - t2 = verts[tris[i][2]].data(); - - d[0] = n[0] * (p[0] - t0[0]) + n[1] * (p[1] - t0[1]) + n[2] * (p[2] - t0[2]); - d[1] = n[0] * (p[0] - t1[0]) + n[1] * (p[1] - t1[1]) + n[2] * (p[2] - t1[2]); - d[2] = n[0] * (p[0] - t2[0]) + n[1] * (p[1] - t2[1]) + n[2] * (p[2] - t2[2]); - - if (d[0] * d[1] < 0.0f) - { - j = d[0] * d[2] < 0.0f - ? 0 - : 1; - } - else if (d[0] * d[2] < 0.0f) - { - j = 2; - } - else - { - continue; - } - - t0 = verts[tris[i][j]].data(); - t1 = verts[tris[i][(j + 1) % 3]].data(); - t2 = verts[tris[i][(j + 2) % 3]].data(); - - s = (n[0] * (p[0] - t0[0]) + n[1] * (p[1] - t0[1]) + n[2] * (p[2] - t0[2])) / (n[0] * (t1[0] - t0[0]) + n[1] * (t1[1] - t0[1]) + n[2] * (t1[2] - t0[2])); - - edge.v0[0] = static_cast(t0[0] + s * (t1[0] - t0[0])); - edge.v0[1] = static_cast(t0[1] + s * (t1[1] - t0[1])); - edge.v0[2] = static_cast(t0[2] + s * (t1[2] - t0[2])); - - s = (n[0] * (p[0] - t0[0]) + n[1] * (p[1] - t0[1]) + n[2] * (p[2] - t0[2])) / (n[0] * (t2[0] - t0[0]) + n[1] * (t2[1] - t0[1]) + n[2] * (t2[2] - t0[2])); - - edge.v1[0] = static_cast(t0[0] + s * (t2[0] - t0[0])); - edge.v1[1] = static_cast(t0[1] + s * (t2[1] - t0[1])); - edge.v1[2] = static_cast(t0[2] + s * (t2[2] - t0[2])); - - intersection.edges.push_back(edge); - } - - const float* q0; - const float* q1; - const float* q2; - const float* q3; - - const size_t numQuads = quads.size(); - - for (size_t i = 0; i < numQuads; ++i) - { - q0 = verts[quads[i][0]].data(); - q1 = verts[quads[i][1]].data(); - q2 = verts[quads[i][2]].data(); - q3 = verts[quads[i][3]].data(); - - d[0] = n[0] * (p[0] - q0[0]) + n[1] * (p[1] - q0[1]) + n[2] * (p[2] - q0[2]); - d[1] = n[0] * (p[0] - q1[0]) + n[1] * (p[1] - q1[1]) + n[2] * (p[2] - q1[2]); - d[2] = n[0] * (p[0] - q2[0]) + n[1] * (p[1] - q2[1]) + n[2] * (p[2] - q2[2]); - d[3] = n[0] * (p[0] - q3[0]) + n[1] * (p[1] - q3[1]) + n[2] * (p[2] - q3[2]); - - if (d[0] * d[2] < 0.0f) - { - if (d[0] * d[3] < 0.0f) - { - if (d[0] * d[1] < 0.0f) - { - q2 = q0; - } - else - { - const float* q = q0; - q0 = q1; - q1 = q2; - q2 = q; - } - } - else if (d[0] * d[1] >= 0.0f) - { - q0 = q1; - q1 = q2; - } - } - else if (d[1] * d[3] < 0.0f) - { - if (d[1] * d[0] < 0.0f) - { - q3 = q2; - q2 = q1; - } - else - { - q1 = q3; - } - } - else - { - continue; - } - - s = (n[0] * (p[0] - q0[0]) + n[1] * (p[1] - q0[1]) + n[2] * (p[2] - q0[2])) / (n[0] * (q1[0] - q0[0]) + n[1] * (q1[1] - q0[1]) + n[2] * (q1[2] - q0[2])); - - edge.v0[0] = static_cast(q0[0] + s * (q1[0] - q0[0])); - edge.v0[1] = static_cast(q0[1] + s * (q1[1] - q0[1])); - edge.v0[2] = static_cast(q0[2] + s * (q1[2] - q0[2])); - - s = (n[0] * (p[0] - q2[0]) + n[1] * (p[1] - q2[1]) + n[2] * (p[2] - q2[2])) / (n[0] * (q3[0] - q2[0]) + n[1] * (q3[1] - q2[1]) + n[2] * (q3[2] - q2[2])); - - edge.v1[0] = static_cast(q2[0] + s * (q3[0] - q2[0])); - edge.v1[1] = static_cast(q2[1] + s * (q3[1] - q2[1])); - edge.v1[2] = static_cast(q2[2] + s * (q3[2] - q2[2])); - - intersection.edges.push_back(edge); - } - - if (!intersection.edges.empty()) - { - intersection.color[0] = material.diffuse[0]; - intersection.color[1] = material.diffuse[1]; - intersection.color[2] = material.diffuse[2]; - intersection.color[3] = material.diffuse[3]; - - m_Intersections.push_back(intersection); - } -} diff --git a/Modules/Simulation/mitkPlaneIntersectionVisitor.h b/Modules/Simulation/mitkPlaneIntersectionVisitor.h deleted file mode 100644 index 72ec905c17..0000000000 --- a/Modules/Simulation/mitkPlaneIntersectionVisitor.h +++ /dev/null @@ -1,63 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkPlaneIntersectionVisitor_h -#define mitkPlaneIntersectionVisitor_h - -#include -#include -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT PlaneIntersectionVisitor : public sofa::simulation::Visitor - { - public: - struct Edge - { - Point3D v0; - Point3D v1; - }; - - struct Intersection - { - float color[4]; - std::vector edges; - }; - - PlaneIntersectionVisitor(const Point3D& point, const Vector3D& normal, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); - ~PlaneIntersectionVisitor(); - - const std::vector& GetIntersections() const; - - using sofa::simulation::Visitor::processNodeTopDown; - Result processNodeTopDown(sofa::simulation::Node* node) override; - - private: - PlaneIntersectionVisitor(const PlaneIntersectionVisitor&); - PlaneIntersectionVisitor& operator=(const PlaneIntersectionVisitor&); - - void processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel); - - Point3D m_Point; - Vector3D m_Normal; - - std::vector m_Intersections; - }; -} - -#endif diff --git a/Modules/Simulation/mitkRoundRobinSchedulingAlgorithm.cpp b/Modules/Simulation/mitkRoundRobinSchedulingAlgorithm.cpp deleted file mode 100644 index c7a0662c2f..0000000000 --- a/Modules/Simulation/mitkRoundRobinSchedulingAlgorithm.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSchedulableProcess.h" -#include "mitkRoundRobinSchedulingAlgorithm.h" - -mitk::RoundRobinSchedulingAlgorithm::RoundRobinSchedulingAlgorithm() -{ -} - -mitk::RoundRobinSchedulingAlgorithm::~RoundRobinSchedulingAlgorithm() -{ -} - -mitk::SchedulableProcess* mitk::RoundRobinSchedulingAlgorithm::GetNextProcess(std::vector& processQueue) -{ - size_t numProcesses = processQueue.size(); - - if (numProcesses == 0) - return nullptr; - - mitk::SchedulableProcess* process = processQueue[0]; - - if (numProcesses > 1) - { - processQueue.erase(processQueue.begin()); - processQueue.push_back(process); - } - - return process; -} diff --git a/Modules/Simulation/mitkRoundRobinSchedulingAlgorithm.h b/Modules/Simulation/mitkRoundRobinSchedulingAlgorithm.h deleted file mode 100644 index 3a2b980033..0000000000 --- a/Modules/Simulation/mitkRoundRobinSchedulingAlgorithm.h +++ /dev/null @@ -1,34 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkRoundRobinSchedulingAlgorithm_h -#define mitkRoundRobinSchedulingAlgorithm_h - -#include "mitkSchedulingAlgorithmBase.h" - -namespace mitk -{ - class RoundRobinSchedulingAlgorithm : public SchedulingAlgorithmBase - { - public: - RoundRobinSchedulingAlgorithm(); - ~RoundRobinSchedulingAlgorithm(); - - SchedulableProcess* GetNextProcess(std::vector& processQueue) override; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSchedulableProcess.cpp b/Modules/Simulation/mitkSchedulableProcess.cpp deleted file mode 100644 index 0849942deb..0000000000 --- a/Modules/Simulation/mitkSchedulableProcess.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSchedulableProcess.h" -#include - -mitk::SchedulableProcess::SchedulableProcess(int priority) - : m_Priority(priority) -{ -} - -mitk::SchedulableProcess::~SchedulableProcess() -{ -} - -int mitk::SchedulableProcess::GetPriority() const -{ - return m_Priority; -} - -boost::chrono::nanoseconds mitk::SchedulableProcess::GetTotalElapsedTime() const -{ - return m_TotalElapsedTime; -} - -void mitk::SchedulableProcess::ResetTotalElapsedTime(boost::chrono::nanoseconds carryover) -{ - m_TotalElapsedTime = carryover; -} - -boost::chrono::nanoseconds mitk::SchedulableProcess::GetElapsedTime() const -{ - return m_ElapsedTime; -} - -void mitk::SchedulableProcess::SetElapsedTime(boost::chrono::nanoseconds elapsedTime) -{ - m_TotalElapsedTime += elapsedTime; - m_ElapsedTime = elapsedTime; -} diff --git a/Modules/Simulation/mitkSchedulableProcess.h b/Modules/Simulation/mitkSchedulableProcess.h deleted file mode 100644 index 5a6eaab339..0000000000 --- a/Modules/Simulation/mitkSchedulableProcess.h +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSchedulableProcess_h -#define mitkSchedulableProcess_h - -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT SchedulableProcess - { - public: - explicit SchedulableProcess(int priority = 0); - virtual ~SchedulableProcess(); - - int GetPriority() const; - boost::chrono::nanoseconds GetTotalElapsedTime() const; - void ResetTotalElapsedTime(boost::chrono::nanoseconds carryover = boost::chrono::nanoseconds::zero()); - boost::chrono::nanoseconds GetElapsedTime() const; - - protected: - void SetElapsedTime(boost::chrono::nanoseconds elapsedTime); - - private: - SchedulableProcess(const SchedulableProcess&); - SchedulableProcess& operator=(const SchedulableProcess&); - - int m_Priority; - boost::chrono::nanoseconds m_TotalElapsedTime; - boost::chrono::nanoseconds m_ElapsedTime; - }; -} - -#endif diff --git a/Modules/Simulation/mitkScheduler.cpp b/Modules/Simulation/mitkScheduler.cpp deleted file mode 100644 index e8d765927c..0000000000 --- a/Modules/Simulation/mitkScheduler.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkRoundRobinSchedulingAlgorithm.h" -#include "mitkSchedulableProcess.h" -#include "mitkScheduler.h" -#include "mitkWeightedRoundRobinSchedulingAlgorithm.h" -#include -#include -#include - -struct mitk::Scheduler::Impl -{ - std::vector processQueue; - SchedulingAlgorithmBase* algorithm; -}; - -mitk::Scheduler::Scheduler(SchedulingAlgorithm::Enum algorithm) - : m_Impl(new Impl) -{ - switch (algorithm) - { - case mitk::SchedulingAlgorithm::RoundRobin: - m_Impl->algorithm = new mitk::RoundRobinSchedulingAlgorithm; - break; - - case mitk::SchedulingAlgorithm::WeightedRoundRobin: - m_Impl->algorithm = new mitk::WeightedRoundRobinSchedulingAlgorithm; - break; - - default: - assert(false && "Unknown scheduling algorithm!"); - } -} - -mitk::Scheduler::~Scheduler() -{ - delete m_Impl->algorithm; - delete m_Impl; -} - -void mitk::Scheduler::AddProcess(SchedulableProcess* process) -{ - if (process == nullptr) - return; - - if (std::find(m_Impl->processQueue.begin(), m_Impl->processQueue.end(), process) == m_Impl->processQueue.end()) - m_Impl->processQueue.push_back(process); -} - -void mitk::Scheduler::RemoveProcess(SchedulableProcess* process) -{ - if (process == nullptr) - return; - - auto it = std::find(m_Impl->processQueue.begin(), m_Impl->processQueue.end(), process); - - if (it != m_Impl->processQueue.end()) - m_Impl->processQueue.erase(it); -} - -bool mitk::Scheduler::IsEmpty() const -{ - return m_Impl->processQueue.empty(); -} - -mitk::SchedulableProcess* mitk::Scheduler::GetCurrentProcess() -{ - return !m_Impl->processQueue.empty() - ? m_Impl->processQueue[0] - : nullptr; -} - -mitk::SchedulableProcess* mitk::Scheduler::GetNextProcess() -{ - return m_Impl->algorithm->GetNextProcess(m_Impl->processQueue); -} diff --git a/Modules/Simulation/mitkScheduler.h b/Modules/Simulation/mitkScheduler.h deleted file mode 100644 index efcf6f0e64..0000000000 --- a/Modules/Simulation/mitkScheduler.h +++ /dev/null @@ -1,57 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkScheduler_h -#define mitkScheduler_h - -#include - -namespace mitk -{ - class SchedulableProcess; - class SchedulingAlgorithmBase; - - namespace SchedulingAlgorithm - { - enum Enum - { - RoundRobin, - WeightedRoundRobin - }; - } - - class MITKSIMULATION_EXPORT Scheduler - { - public: - explicit Scheduler(SchedulingAlgorithm::Enum algorithm = SchedulingAlgorithm::RoundRobin); - ~Scheduler(); - - void AddProcess(SchedulableProcess* process); - void RemoveProcess(SchedulableProcess* process); - bool IsEmpty() const; - SchedulableProcess* GetCurrentProcess(); - SchedulableProcess* GetNextProcess(); - - private: - Scheduler(const Scheduler&); - Scheduler& operator=(const Scheduler&); - - struct Impl; - Impl* m_Impl; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSchedulingAlgorithmBase.cpp b/Modules/Simulation/mitkSchedulingAlgorithmBase.cpp deleted file mode 100644 index 0a1586c71a..0000000000 --- a/Modules/Simulation/mitkSchedulingAlgorithmBase.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSchedulableProcess.h" -#include "mitkSchedulingAlgorithmBase.h" - -mitk::SchedulingAlgorithmBase::SchedulingAlgorithmBase() -{ -} - -mitk::SchedulingAlgorithmBase::~SchedulingAlgorithmBase() -{ -} diff --git a/Modules/Simulation/mitkSchedulingAlgorithmBase.h b/Modules/Simulation/mitkSchedulingAlgorithmBase.h deleted file mode 100644 index 3f39462171..0000000000 --- a/Modules/Simulation/mitkSchedulingAlgorithmBase.h +++ /dev/null @@ -1,40 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSchedulingAlgorithmBase_h -#define mitkSchedulingAlgorithmBase_h - -#include - -namespace mitk -{ - class SchedulableProcess; - - class SchedulingAlgorithmBase - { - public: - SchedulingAlgorithmBase(); - virtual ~SchedulingAlgorithmBase(); - - virtual SchedulableProcess* GetNextProcess(std::vector& processQueue) = 0; - - private: - SchedulingAlgorithmBase(const SchedulingAlgorithmBase&); - SchedulingAlgorithmBase& operator=(const SchedulingAlgorithmBase&); - }; -} - -#endif diff --git a/Modules/Simulation/mitkSetVtkRendererVisitor.cpp b/Modules/Simulation/mitkSetVtkRendererVisitor.cpp deleted file mode 100644 index 6ee916a666..0000000000 --- a/Modules/Simulation/mitkSetVtkRendererVisitor.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSetVtkRendererVisitor.h" -#include "mitkVtkModel.h" - -mitk::SetVtkRendererVisitor::SetVtkRendererVisitor(vtkRenderer* renderer, const sofa::core::ExecParams* params) - : Visitor(params), - m_VtkRenderer(renderer) -{ -} - -mitk::SetVtkRendererVisitor::~SetVtkRendererVisitor() -{ -} - -sofa::simulation::Visitor::Result mitk::SetVtkRendererVisitor::processNodeTopDown(sofa::simulation::Node* node) -{ - for_each(this, node, node->visualModel, &SetVtkRendererVisitor::processVisualModel); - return RESULT_CONTINUE; -} - -void mitk::SetVtkRendererVisitor::processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel) -{ - VtkModel* vtkModel = dynamic_cast(visualModel); - - if (vtkModel != nullptr) - vtkModel->SetVtkRenderer(m_VtkRenderer); -} diff --git a/Modules/Simulation/mitkSetVtkRendererVisitor.h b/Modules/Simulation/mitkSetVtkRendererVisitor.h deleted file mode 100644 index bde90696dc..0000000000 --- a/Modules/Simulation/mitkSetVtkRendererVisitor.h +++ /dev/null @@ -1,46 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSetVtkRendererVisitor_h -#define mitkSetVtkRendererVisitor_h - -#include -#include - -class vtkRenderer; - -namespace mitk -{ - class MITKSIMULATION_EXPORT SetVtkRendererVisitor : public sofa::simulation::Visitor - { - public: - explicit SetVtkRendererVisitor(vtkRenderer* renderer, const sofa::core::ExecParams* params = sofa::core::ExecParams::defaultInstance()); - ~SetVtkRendererVisitor(); - - using sofa::simulation::Visitor::processNodeTopDown; - Result processNodeTopDown(sofa::simulation::Node* node) override; - - private: - SetVtkRendererVisitor(const SetVtkRendererVisitor&); - SetVtkRendererVisitor& operator=(const SetVtkRendererVisitor&); - - void processVisualModel(sofa::simulation::Node*, sofa::core::visual::VisualModel* visualModel); - - vtkRenderer* m_VtkRenderer; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulation.cpp b/Modules/Simulation/mitkSimulation.cpp deleted file mode 100644 index 3c815459f6..0000000000 --- a/Modules/Simulation/mitkSimulation.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSimulation.h" -#include -#include "mitkGeometry3D.h" - -static sofa::simulation::Simulation::SPtr CreateSimulation() -{ - const std::string key = "MultiMappingObject"; - - if (sofa::simulation::xml::BaseElement::NodeFactory::HasKey(key)) - sofa::simulation::xml::BaseElement::NodeFactory::ResetEntry(key); - - return sofa::core::objectmodel::New(); -} - -mitk::Simulation::Simulation() - : m_SOFASimulation(CreateSimulation()) -{ -} - -mitk::Simulation::~Simulation() -{ - if (m_RootNode) - { - if (m_SOFASimulation) - m_SOFASimulation->unload(m_RootNode); - } -} - -void mitk::Simulation::Animate() -{ - if (!m_RootNode || !m_SOFASimulation) - return; - - boost::chrono::high_resolution_clock::time_point t0 = boost::chrono::high_resolution_clock::now(); - m_SOFASimulation->animate(m_RootNode.get(), m_RootNode->getDt()); - this->SetElapsedTime(boost::chrono::high_resolution_clock::now() - t0); - - this->UpdateOutputInformation(); -} - -sofa::core::visual::DrawTool* mitk::Simulation::GetDrawTool() -{ - return &m_DrawTool; -} - -sofa::simulation::Node::SPtr mitk::Simulation::GetRootNode() const -{ - return m_RootNode; -} - -sofa::simulation::Simulation::SPtr mitk::Simulation::GetSOFASimulation() const -{ - return m_SOFASimulation; -} - -void mitk::Simulation::Reset() -{ - if (!m_RootNode || !m_SOFASimulation) - return; - - m_SOFASimulation->reset(m_RootNode.get()); - m_RootNode->setTime(0.0); - m_SOFASimulation->updateContext(m_RootNode.get()); -} - -bool mitk::Simulation::GetAnimationFlag() const -{ - return m_RootNode - ? m_RootNode->getContext()->getAnimate() - : false; -} - -void mitk::Simulation::SetAnimationFlag(bool animate) -{ - if (m_RootNode) - m_RootNode->getContext()->setAnimate(animate); -} - -void mitk::Simulation::SetDt(double dt) -{ - if (m_RootNode) - m_RootNode->setDt(dt); -} - -void mitk::Simulation::SetRootNode(sofa::simulation::Node::SPtr rootNode) -{ - m_RootNode = rootNode; -} - -bool mitk::Simulation::RequestedRegionIsOutsideOfTheBufferedRegion() -{ - return false; -} - -void mitk::Simulation::SetRequestedRegion(const itk::DataObject*) -{ -} - -void mitk::Simulation::SetRequestedRegionToLargestPossibleRegion() -{ -} - -void mitk::Simulation::UpdateOutputInformation() -{ - using sofa::defaulttype::BoundingBox; - using sofa::defaulttype::Vector3; - - if (this->GetSource().IsNotNull()) - this->GetSource()->UpdateOutputInformation(); - - if (m_RootNode) - { - const BoundingBox& boundingBox = m_RootNode->f_bbox.getValue(); - mitk::Geometry3D::BoundsArrayType bounds; - - if (boundingBox.isValid()) - { - const Vector3& min = boundingBox.minBBox(); - const Vector3& max = boundingBox.maxBBox(); - - bounds[0] = static_cast(min.x()); - bounds[1] = static_cast(max.x()); - bounds[2] = static_cast(min.y()); - bounds[3] = static_cast(max.y()); - bounds[4] = static_cast(min.z()); - bounds[5] = static_cast(max.z()); - } - else - { - bounds.Fill(0.0f); - } - - mitk::BaseGeometry::Pointer geometry = this->GetGeometry(); - - if (geometry.IsNull()) - { - geometry = Geometry3D::New(); - geometry->SetBounds(bounds); - this->SetGeometry(geometry); - } - else - { - geometry->SetBounds(bounds); - } - } - - this->GetTimeGeometry()->Update(); -} - -bool mitk::Simulation::VerifyRequestedRegion() -{ - return true; -} diff --git a/Modules/Simulation/mitkSimulation.h b/Modules/Simulation/mitkSimulation.h deleted file mode 100644 index cc1af57ab8..0000000000 --- a/Modules/Simulation/mitkSimulation.h +++ /dev/null @@ -1,61 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulation_h -#define mitkSimulation_h - -#include -#include -#include -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT Simulation : public BaseData, public SchedulableProcess - { - public: - mitkClassMacro(Simulation, BaseData); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - void Animate(); - sofa::core::visual::DrawTool* GetDrawTool(); - sofa::simulation::Node::SPtr GetRootNode() const; - sofa::simulation::Simulation::SPtr GetSOFASimulation() const; - void Reset(); - bool GetAnimationFlag() const; - void SetAnimationFlag(bool animate); - void SetDt(double dt); - void SetRootNode(sofa::simulation::Node::SPtr rootNode); - - bool RequestedRegionIsOutsideOfTheBufferedRegion() override; - void SetRequestedRegion(const itk::DataObject*) override; - void SetRequestedRegionToLargestPossibleRegion() override; - void UpdateOutputInformation() override; - bool VerifyRequestedRegion() override; - - private: - Simulation(); - ~Simulation(); - - sofa::simulation::Simulation::SPtr m_SOFASimulation; - sofa::simulation::Node::SPtr m_RootNode; - sofa::core::visual::DrawToolGL m_DrawTool; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulationActivator.cpp b/Modules/Simulation/mitkSimulationActivator.cpp deleted file mode 100644 index 3650b5340a..0000000000 --- a/Modules/Simulation/mitkSimulationActivator.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSimulationIO.h" -#include "mitkSimulationService.h" -#include -#include -#include - -namespace mitk -{ - class SimulationActivator : public us::ModuleActivator - { - public: - SimulationActivator() - { - } - - ~SimulationActivator() - { - } - - void Load(us::ModuleContext* context) override - { - m_SimulationService.reset(new SimulationService); - context->RegisterService(m_SimulationService.get()); - - m_SimulationIO.reset(new SimulationIO); - } - - void Unload(us::ModuleContext*) override - { - m_SimulationIO.reset(nullptr); - m_SimulationService.reset(nullptr); - } - - private: - SimulationActivator(const SimulationActivator&); - SimulationActivator& operator=(const SimulationActivator&); - - std::unique_ptr m_SimulationService; - std::unique_ptr m_SimulationIO; - }; -} - -US_EXPORT_MODULE_ACTIVATOR(mitk::SimulationActivator); diff --git a/Modules/Simulation/mitkSimulationIO.cpp b/Modules/Simulation/mitkSimulationIO.cpp deleted file mode 100644 index a30f474275..0000000000 --- a/Modules/Simulation/mitkSimulationIO.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkGetSimulationService.h" -#include "mitkISimulationService.h" -#include "mitkSimulation.h" -#include "mitkSimulationIO.h" -#include -#include -#include -#include - -#include - -static mitk::CustomMimeType CreateSimulationMimeType() -{ - mitk::CustomMimeType mimeType(mitk::IOMimeTypes::DEFAULT_BASE_NAME() + ".simulation.sofa.scene"); - mimeType.SetCategory("Simulation"); - mimeType.AddExtension("scn"); - mimeType.AddExtension("xml"); - mimeType.SetComment("SOFA Scene File"); - - return mimeType; -} - -mitk::SimulationIO::SimulationIO() - : AbstractFileIO(Simulation::GetStaticNameOfClass(), CreateSimulationMimeType(), "SOFA Simulation Scene") -{ - this->RegisterService(); -} - -std::vector mitk::SimulationIO::Read() -{ - Simulation::Pointer simulation = Simulation::New(); - sofa::simulation::Simulation::SPtr sofaSimulation = simulation->GetSOFASimulation(); - - ISimulationService* simulationService = GetSimulationService(); - Simulation::Pointer lastActiveSimulation = simulationService->GetActiveSimulation(); - - simulationService->SetActiveSimulation(simulation); - - std::ifstream scnFile(this->GetLocalFileName().c_str()); - std::string content = std::string((std::istreambuf_iterator(scnFile)), std::istreambuf_iterator()); - scnFile.close(); - - std::istringstream stream(content); - std::string firstLine; - - if (!std::getline(stream, firstLine).good()) - mitkThrow() << "Could not load '" << this->GetLocalFileName() << "'!"; - - std::string originalPath; - - if (firstLine.size() > 21 && firstLine.substr(0, 21) == "\n"; - - scnFile << originalPath; - } - - scnFile << originalContent; -} - -mitk::IFileIO::ConfidenceLevel mitk::SimulationIO::GetWriterConfidenceLevel() const -{ - if (AbstractFileIO::GetWriterConfidenceLevel() == Unsupported) - return Unsupported; - - return dynamic_cast(this->GetInput()) == nullptr - ? Unsupported - : Supported; -} - -mitk::SimulationIO* mitk::SimulationIO::IOClone() const -{ - return new SimulationIO(*this); -} diff --git a/Modules/Simulation/mitkSimulationIO.h b/Modules/Simulation/mitkSimulationIO.h deleted file mode 100644 index 0224f0ae70..0000000000 --- a/Modules/Simulation/mitkSimulationIO.h +++ /dev/null @@ -1,42 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationIO_h -#define mitkSimulationIO_h - -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT SimulationIO : public AbstractFileIO - { - public: - SimulationIO(); - - using AbstractFileReader::Read; - std::vector Read() override; - ConfidenceLevel GetReaderConfidenceLevel() const override; - - void Write() override; - ConfidenceLevel GetWriterConfidenceLevel() const override; - - private: - SimulationIO* IOClone() const override; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulationInteractor.cpp b/Modules/Simulation/mitkSimulationInteractor.cpp deleted file mode 100644 index 398631c6c1..0000000000 --- a/Modules/Simulation/mitkSimulationInteractor.cpp +++ /dev/null @@ -1,522 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "mitkSimulation.h" -#include "mitkSimulationInteractor.h" - -using sofa::component::collision::AttachBodyPerformer; -using sofa::component::collision::BaseRayContact; -using sofa::component::collision::BodyPicked; -using sofa::component::collision::ComponentMouseInteraction; -using sofa::component::collision::FixParticlePerformerConfiguration; -using sofa::component::collision::InteractionPerformer; -using sofa::component::collision::Ray; -using sofa::component::collision::RayModel; -using sofa::component::container::MechanicalObject; -using sofa::core::behavior::BaseMechanicalState; -using sofa::core::collision::DetectionOutput; -using sofa::core::collision::Pipeline; -using sofa::core::objectmodel::BaseContext; -using sofa::core::CollisionElementIterator; -using sofa::core::ExecParams; -using sofa::core::MechanicalParams; -using sofa::core::VecCoordId; -using sofa::defaulttype::dot; -using sofa::defaulttype::Vec3d; -using sofa::defaulttype::Vec3Types; -using sofa::helper::vector; -using sofa::simulation::CollisionVisitor; -using sofa::simulation::DeleteVisitor; -using sofa::simulation::MechanicalPickParticlesVisitor; -using sofa::simulation::MechanicalPropagatePositionVisitor; -using sofa::simulation::Node; - -namespace mitk -{ - class SimulationInteractor::Impl - { - public: - Impl(); - ~Impl(); - - void Initialize(Node::SPtr rootNode); - void Uninitialize(); - void AttachMouseNode(); - void DetachMouseNode(); - bool IsInteractionPerformerNotNull() const; - void UpdatePickRay(InteractionPositionEvent* event); - void FindCollision(); - void AttachCompatibleInteraction(); - void DetachInteraction(bool setNull); - void StartInteraction(const std::string& type); - void ExecuteInteraction(); - void StopInteraction(); - - private: - Impl(const Impl&); - Impl& operator=(const Impl&); - - BodyPicked FindCollisionUsingPipeline(); - BodyPicked FindCollisionUsingBruteForce(); - void ConfigureInteractionPerformer(); - - Node::SPtr m_RootNode; - Node::SPtr m_MouseNode; - MechanicalObject::SPtr m_PickRayContainer; - RayModel::SPtr m_PickRayModel; - std::vector m_InteractionComponents; - ComponentMouseInteraction* m_Interaction; - std::unique_ptr m_InteractionPerformer; - bool m_IsMouseNodeAttached; - bool m_UseCollisionPipeline; - BodyPicked m_LastBodyPicked; - }; -} - -mitk::SimulationInteractor::Impl::Impl() - : m_Interaction(nullptr), - m_IsMouseNodeAttached(false), - m_UseCollisionPipeline(true) -{ -} - -mitk::SimulationInteractor::Impl::~Impl() -{ - this->Uninitialize(); -} - -void mitk::SimulationInteractor::Impl::Initialize(const Node::SPtr rootNode) -{ - this->Uninitialize(); - - m_RootNode = rootNode; - - m_PickRayContainer = sofa::core::objectmodel::New >(); - m_PickRayContainer->setName("MousePosition"); - m_PickRayContainer->resize(1); - - m_PickRayModel = sofa::core::objectmodel::New(); - m_PickRayModel->setName("MouseCollisionModel"); - m_PickRayModel->setNbRay(1); - - m_MouseNode = rootNode->createChild("Mouse"); - m_MouseNode->addObject(m_PickRayContainer); - m_MouseNode->addObject(m_PickRayModel); - - m_MouseNode->init(ExecParams::defaultInstance()); - m_PickRayContainer->init(); - m_PickRayModel->init(); - - typedef ComponentMouseInteraction::ComponentMouseInteractionFactory Factory; - const Factory* factory = Factory::getInstance(); - - for (Factory::const_iterator it = factory->begin(); it != factory->end(); ++it) - m_InteractionComponents.push_back(it->second->createInstance(nullptr)); - - m_MouseNode->detachFromGraph(); - - Pipeline* collisionPipeline; - rootNode->getContext()->get(collisionPipeline, BaseContext::SearchRoot); - - m_UseCollisionPipeline = collisionPipeline != nullptr; -} - -void mitk::SimulationInteractor::Impl::Uninitialize() -{ - this->DetachMouseNode(); - - if (!m_InteractionComponents.empty()) - { - for (std::vector::iterator it = m_InteractionComponents.begin(); it != m_InteractionComponents.end(); ++it) - delete *it; - - m_InteractionComponents.clear(); - m_Interaction = nullptr; - } - - if (m_MouseNode) - { - m_MouseNode->execute(ExecParams::defaultInstance()); - - m_PickRayModel.reset(); - m_PickRayContainer.reset(); - m_MouseNode.reset(); - m_RootNode.reset(); - } -} - -void mitk::SimulationInteractor::Impl::AttachMouseNode() -{ - if (!m_IsMouseNodeAttached) - { - m_RootNode->addChild(m_MouseNode); - m_IsMouseNodeAttached = true; - } -} - -void mitk::SimulationInteractor::Impl::DetachMouseNode() -{ - if (m_IsMouseNodeAttached) - { - this->DetachInteraction(false); - m_MouseNode->detachFromGraph(); - m_IsMouseNodeAttached = false; - } -} - -bool mitk::SimulationInteractor::Impl::IsInteractionPerformerNotNull() const -{ - return m_InteractionPerformer.get() != nullptr; -} - -void mitk::SimulationInteractor::Impl::UpdatePickRay(InteractionPositionEvent* event) -{ - if (!m_IsMouseNodeAttached) - return; - - vtkCamera* camera = event->GetSender()->GetVtkRenderer()->GetActiveCamera(); - - Vec3d cameraOrigin(camera->GetPosition()); - Vec3d pickedPosition(event->GetPositionInWorld().GetDataPointer()); - Vec3d pickRayDirection(pickedPosition - cameraOrigin); - Vec3d focalPoint(camera->GetFocalPoint()); - - Vec3d cameraDirection(focalPoint - cameraOrigin); - cameraDirection.normalize(); - - std::pair clippingRange; - camera->GetClippingRange(clippingRange.first, clippingRange.second); - - double dotProduct = dot(cameraDirection, pickRayDirection); - double norm = pickRayDirection.norm(); - - clippingRange.first = clippingRange.first / dotProduct * norm; - clippingRange.second = clippingRange.second / dotProduct * norm; - - pickRayDirection.normalize(); - - Ray pickRay = m_PickRayModel->getRay(0); - pickRay.setOrigin(cameraOrigin + pickRayDirection * clippingRange.first); - pickRay.setDirection(pickRayDirection); - pickRay.setL(clippingRange.second - clippingRange.first); - - MechanicalPropagatePositionVisitor(MechanicalParams::defaultInstance(), 0, VecCoordId::position(), true) - .execute(m_PickRayModel->getContext()); - - MechanicalPropagatePositionVisitor(MechanicalParams::defaultInstance(), 0, VecCoordId::freePosition(), true) - .execute(m_PickRayModel->getContext()); -} - -void mitk::SimulationInteractor::Impl::FindCollision() -{ - CollisionVisitor(ExecParams::defaultInstance()).execute(m_RootNode->getContext()); - - if (m_UseCollisionPipeline) - { - m_LastBodyPicked = this->FindCollisionUsingPipeline(); - - if (m_LastBodyPicked.body != nullptr) - return; - } - - m_LastBodyPicked = this->FindCollisionUsingBruteForce(); -} - -BodyPicked mitk::SimulationInteractor::Impl::FindCollisionUsingPipeline() -{ - BodyPicked bodyPicked; - - Ray ray = m_PickRayModel->getRay(0); - const Vec3d& origin = ray.origin(); - const Vec3d& direction = ray.direction(); - const double length = ray.l(); - - const std::set& contacts = m_PickRayModel->getContacts(); - - for (std::set::const_iterator contact = contacts.begin(); contact != contacts.end(); ++contact) - { - const vector& detectionOutputs = (*contact)->getDetectionOutputs(); - - for (vector::const_iterator detectionOutput = detectionOutputs.begin(); detectionOutput != detectionOutputs.end(); ++detectionOutput) - { - CollisionElementIterator collisionElement; - int pointIndex; - - if ((*detectionOutput)->elem.first.getCollisionModel() == m_PickRayModel) - { - collisionElement = (*detectionOutput)->elem.second; - pointIndex = 1; - } - else if ((*detectionOutput)->elem.second.getCollisionModel() == m_PickRayModel) - { - collisionElement = (*detectionOutput)->elem.first; - pointIndex = 0; - } - else - { - continue; - } - - if (!collisionElement.getCollisionModel()->isSimulated()) - continue; - - const double t = ((*detectionOutput)->point[pointIndex] - origin) * direction; - - if (t < 0.0 || t > length) - continue; - - if (bodyPicked.body == nullptr || t < bodyPicked.rayLength) - { - bodyPicked.body = collisionElement.getCollisionModel(); - bodyPicked.indexCollisionElement = collisionElement.getIndex(); - bodyPicked.point = (*detectionOutput)->point[pointIndex]; - bodyPicked.dist = ((*detectionOutput)->point[1] - (*detectionOutput)->point[0]).norm(); - bodyPicked.rayLength = t; - } - } - } - - return bodyPicked; -} - -BodyPicked mitk::SimulationInteractor::Impl::FindCollisionUsingBruteForce() -{ - BodyPicked bodyPicked; - - Ray ray = m_PickRayModel->getRay(0); - const Vec3d& origin = ray.origin(); - const Vec3d& direction = ray.direction(); - const double length = ray.l(); - - MechanicalPickParticlesVisitor pickVisitor(ExecParams::defaultInstance(), origin, direction, length); - pickVisitor.execute(m_RootNode->getContext()); - - if (!pickVisitor.particles.empty()) - { - bodyPicked.mstate = pickVisitor.particles.begin()->second.first; - bodyPicked.indexCollisionElement = pickVisitor.particles.begin()->second.second; - bodyPicked.point[0] = bodyPicked.mstate->getPX(bodyPicked.indexCollisionElement); - bodyPicked.point[1] = bodyPicked.mstate->getPY(bodyPicked.indexCollisionElement); - bodyPicked.point[2] = bodyPicked.mstate->getPZ(bodyPicked.indexCollisionElement); - bodyPicked.dist = 0; - bodyPicked.rayLength = (bodyPicked.point - origin) * direction; - } - - return bodyPicked; -} - -void mitk::SimulationInteractor::Impl::AttachCompatibleInteraction() -{ - BaseContext* context; - - if (m_LastBodyPicked.body == nullptr) - { - context = m_LastBodyPicked.mstate != nullptr - ? m_LastBodyPicked.mstate->getContext() - : nullptr; - } - else - { - context = m_LastBodyPicked.body->getContext(); - } - - if (context != nullptr) - { - if (m_Interaction == nullptr || !m_Interaction->isCompatible(context)) - { - bool foundCompatibleInteractor = false; - - for (std::vector::const_iterator it = m_InteractionComponents.begin(); it != m_InteractionComponents.end(); ++it) - { - if (*it != m_Interaction && (*it)->isCompatible(context)) - { - this->DetachInteraction(false); - m_Interaction = *it; - m_Interaction->attach(m_MouseNode.get()); - - foundCompatibleInteractor = true; - break; - } - } - - if (!foundCompatibleInteractor) - this->DetachInteraction(true); - } - } - else - { - this->DetachInteraction(true); - } - - if (m_Interaction != nullptr) - { - m_Interaction->mouseInteractor->setMouseRayModel(m_PickRayModel.get()); - m_Interaction->mouseInteractor->setBodyPicked(m_LastBodyPicked); - } -} - -void mitk::SimulationInteractor::Impl::DetachInteraction(bool setNull) -{ - if (m_Interaction != nullptr) - { - m_Interaction->detach(); - - if (setNull) - m_Interaction = nullptr; - } -} - -void mitk::SimulationInteractor::Impl::StartInteraction(const std::string& type) -{ - if (m_Interaction == nullptr) - return; - - InteractionPerformer::InteractionPerformerFactory* factory = InteractionPerformer::InteractionPerformerFactory::getInstance(); - m_InteractionPerformer.reset(factory->createObject(type, m_Interaction->mouseInteractor.get())); - - if (m_InteractionPerformer.get() != nullptr) - { - this->ConfigureInteractionPerformer(); - m_Interaction->mouseInteractor->addInteractionPerformer(m_InteractionPerformer.get()); - m_InteractionPerformer->start(); - } -} - -void mitk::SimulationInteractor::Impl::ConfigureInteractionPerformer() -{ - AttachBodyPerformer* attachBodyPerformer = dynamic_cast*>(m_InteractionPerformer.get()); - - if (attachBodyPerformer != nullptr) - { - attachBodyPerformer->setStiffness(1000); - attachBodyPerformer->setArrowSize(0); - attachBodyPerformer->setShowFactorSize(1); - return; - } - - FixParticlePerformerConfiguration* fixParticlePerformer = dynamic_cast(m_InteractionPerformer.get()); - - if (fixParticlePerformer != nullptr) - fixParticlePerformer->setStiffness(10000); -} - -void mitk::SimulationInteractor::Impl::ExecuteInteraction() -{ - if (m_InteractionPerformer.get() == nullptr) - return; - - m_InteractionPerformer->execute(); -} - -void mitk::SimulationInteractor::Impl::StopInteraction() -{ - if (m_InteractionPerformer.get() == nullptr) - return; - - AttachBodyPerformer* attachBodyPerformer = dynamic_cast*>(m_InteractionPerformer.get()); - - if (attachBodyPerformer != nullptr) - attachBodyPerformer->clear(); - - m_Interaction->mouseInteractor->removeInteractionPerformer(m_InteractionPerformer.get()); - m_InteractionPerformer.release(); -} - -mitk::SimulationInteractor::SimulationInteractor() - : m_Impl(new Impl) -{ -} - -mitk::SimulationInteractor::~SimulationInteractor() -{ -} - -void mitk::SimulationInteractor::ConnectActionsAndFunctions() -{ - CONNECT_FUNCTION("startPrimaryInteraction", StartPrimaryInteraction); - CONNECT_FUNCTION("startSecondaryInteraction", StartSecondaryInteraction); - CONNECT_FUNCTION("stopInteraction", StopInteraction); - CONNECT_FUNCTION("executeInteraction", ExecuteInteraction); - CONNECT_CONDITION("isInteractionPerformerNotNull", IsInteractionPerformerNotNull); -} - -void mitk::SimulationInteractor::DataNodeChanged() -{ - this->ResetToStartState(); - - mitk::DataNode* dataNode = this->GetDataNode(); - - if (dataNode != nullptr) - { - Simulation::Pointer simulation = dynamic_cast(dataNode->GetData()); - - if (simulation.IsNotNull()) - { - m_Impl->Initialize(simulation->GetRootNode()); - return; - } - } - - m_Impl->Uninitialize(); -} - -void mitk::SimulationInteractor::StartInteraction(const std::string& type, InteractionPositionEvent* event) -{ - m_Impl->AttachMouseNode(); - m_Impl->UpdatePickRay(event); - m_Impl->FindCollision(); - m_Impl->AttachCompatibleInteraction(); - m_Impl->StartInteraction(type); -} - -void mitk::SimulationInteractor::StartPrimaryInteraction(StateMachineAction*, InteractionEvent* event) -{ - this->StartInteraction("AttachBody", dynamic_cast(event)); -} - -void mitk::SimulationInteractor::StartSecondaryInteraction(StateMachineAction*, InteractionEvent* event) -{ - this->StartInteraction("FixParticle", dynamic_cast(event)); -} - -void mitk::SimulationInteractor::StopInteraction(StateMachineAction*, InteractionEvent*) -{ - m_Impl->StopInteraction(); - m_Impl->DetachMouseNode(); -} - -void mitk::SimulationInteractor::ExecuteInteraction(StateMachineAction*, InteractionEvent* event) -{ - m_Impl->UpdatePickRay(dynamic_cast(event)); - m_Impl->ExecuteInteraction(); -} - -bool mitk::SimulationInteractor::IsInteractionPerformerNotNull(const InteractionEvent*) -{ - return m_Impl->IsInteractionPerformerNotNull(); -} diff --git a/Modules/Simulation/mitkSimulationInteractor.h b/Modules/Simulation/mitkSimulationInteractor.h deleted file mode 100644 index 6ff5ed225d..0000000000 --- a/Modules/Simulation/mitkSimulationInteractor.h +++ /dev/null @@ -1,54 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationInteractor_h -#define mitkSimulationInteractor_h - -#include -#include - -namespace mitk -{ - class InteractionPositionEvent; - - class MITKSIMULATION_EXPORT SimulationInteractor : public DataInteractor - { - public: - mitkClassMacro(SimulationInteractor, DataInteractor); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - - protected: - void ConnectActionsAndFunctions() override; - void DataNodeChanged() override; - - private: - SimulationInteractor(); - ~SimulationInteractor(); - - void StartInteraction(const std::string& type, InteractionPositionEvent* event); - void StartPrimaryInteraction(StateMachineAction* action, InteractionEvent* event); - void StartSecondaryInteraction(StateMachineAction* action, InteractionEvent* event); - void ExecuteInteraction(StateMachineAction* action, InteractionEvent* event); - void StopInteraction(StateMachineAction* action, InteractionEvent* event); - bool IsInteractionPerformerNotNull(const InteractionEvent* event); - - class Impl; - std::unique_ptr m_Impl; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulationObjectFactory.cpp b/Modules/Simulation/mitkSimulationObjectFactory.cpp deleted file mode 100644 index 2a8dbd2252..0000000000 --- a/Modules/Simulation/mitkSimulationObjectFactory.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkIndexROI.h" -#include "mitkSimulation.h" -#include "mitkSimulationObjectFactory.h" -#include "mitkSimulationVtkMapper2D.h" -#include "mitkSimulationVtkMapper3D.h" -#include "mitkVtkModel.h" -#include -#include -#include -#include -#include -#include -#include - -static void InitializeSofa() -{ - int argc = 0; - glutInit(&argc, nullptr); - - sofa::component::init(); - sofa::simulation::xml::initXml(); - - sofa::core::visual::VisualParams::defaultInstance()->setSupported(sofa::core::visual::API_OpenGL); -} - -static void RegisterSofaClasses() -{ - using sofa::core::ObjectFactory; - using sofa::core::RegisterObject; - - int IndexROIClass = RegisterObject("").add(); - int VtkModelClass = RegisterObject("").add(); - boost::ignore_unused(IndexROIClass, VtkModelClass); - - ObjectFactory::AddAlias("VisualModel", "VtkModel", true); - ObjectFactory::AddAlias("OglModel", "VtkModel", true); -} - -mitk::SimulationObjectFactory::SimulationObjectFactory() -{ - InitializeSofa(); - RegisterSofaClasses(); -} - -mitk::SimulationObjectFactory::~SimulationObjectFactory() -{ -} - -mitk::Mapper::Pointer mitk::SimulationObjectFactory::CreateMapper(mitk::DataNode* node, MapperSlotId slotId) -{ - Mapper::Pointer mapper; - - if (dynamic_cast(node->GetData()) != nullptr) - { - if (slotId == BaseRenderer::Standard2D) - { - mapper = SimulationVtkMapper2D::New(); - } - else if (slotId == BaseRenderer::Standard3D) - { - mapper = SimulationVtkMapper3D::New(); - } - - if (mapper.IsNotNull()) - mapper->SetDataNode(node); - } - - return mapper; -} - -const char* mitk::SimulationObjectFactory::GetDescription() const -{ - return "Simulation Object Factory"; -} - -const char* mitk::SimulationObjectFactory::GetFileExtensions() -{ - return nullptr; -} - -mitk::CoreObjectFactoryBase::MultimapType mitk::SimulationObjectFactory::GetFileExtensionsMap() -{ - return MultimapType(); -} - -const char* mitk::SimulationObjectFactory::GetSaveFileExtensions() -{ - return nullptr; -} - -mitk::CoreObjectFactoryBase::MultimapType mitk::SimulationObjectFactory::GetSaveFileExtensionsMap() -{ - return MultimapType(); -} - -void mitk::SimulationObjectFactory::SetDefaultProperties(mitk::DataNode* node) -{ - if (node == nullptr) - return; - - if (dynamic_cast(node->GetData()) != nullptr) - { - SimulationVtkMapper2D::SetDefaultProperties(node); - SimulationVtkMapper3D::SetDefaultProperties(node); - } -} - -void mitk::RegisterSimulationObjectFactory() -{ - static bool alreadyRegistered = false; - - if (!alreadyRegistered) - { - CoreObjectFactory::GetInstance()->RegisterExtraFactory(SimulationObjectFactory::New()); - alreadyRegistered = true; - } -} diff --git a/Modules/Simulation/mitkSimulationObjectFactory.h b/Modules/Simulation/mitkSimulationObjectFactory.h deleted file mode 100644 index 62efd548dd..0000000000 --- a/Modules/Simulation/mitkSimulationObjectFactory.h +++ /dev/null @@ -1,47 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationObjectFactory_h -#define mitkSimulationObjectFactory_h - -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT SimulationObjectFactory : public CoreObjectFactoryBase - { - public: - mitkClassMacro(SimulationObjectFactory, CoreObjectFactoryBase); - itkFactorylessNewMacro(Self); - - Mapper::Pointer CreateMapper(DataNode* node, MapperSlotId slotId) override; - const char* GetDescription() const override; - const char* GetFileExtensions() override; - MultimapType GetFileExtensionsMap() override; - const char* GetSaveFileExtensions() override; - MultimapType GetSaveFileExtensionsMap() override; - void SetDefaultProperties(DataNode* node) override; - - private: - SimulationObjectFactory(); - ~SimulationObjectFactory(); - }; - - MITKSIMULATION_EXPORT void RegisterSimulationObjectFactory(); -} - -#endif diff --git a/Modules/Simulation/mitkSimulationSerializer.cpp b/Modules/Simulation/mitkSimulationSerializer.cpp deleted file mode 100644 index ee94b6efd7..0000000000 --- a/Modules/Simulation/mitkSimulationSerializer.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSimulation.h" -#include "mitkSimulationSerializer.h" -#include - -MITK_REGISTER_SERIALIZER(SimulationSerializer) - -mitk::SimulationSerializer::SimulationSerializer() -{ -} - -mitk::SimulationSerializer::~SimulationSerializer() -{ -} - -std::string mitk::SimulationSerializer::Serialize() -{ - const Simulation* simulation = dynamic_cast(m_Data.GetPointer()); - - if (simulation == nullptr) - { - MITK_ERROR << " Invalid simulation object cannot be serialized!"; - return ""; - } - - std::string filename(this->GetUniqueFilenameInWorkingDirectory()); - filename += "_" + m_FilenameHint + ".scn"; - - std::string fullPath = m_WorkingDirectory; - fullPath += "/" + filename; - - try - { - IOUtil::Save(const_cast(simulation), fullPath); - } - catch (const std::exception& e) - { - MITK_ERROR << " Error serializing simulation object to " << fullPath << ": " << e.what(); - return ""; - } - - return filename; -} diff --git a/Modules/Simulation/mitkSimulationSerializer.h b/Modules/Simulation/mitkSimulationSerializer.h deleted file mode 100644 index 66932b9de8..0000000000 --- a/Modules/Simulation/mitkSimulationSerializer.h +++ /dev/null @@ -1,40 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationSerializer_h -#define mitkSimulationSerializer_h - -#include -#include - -namespace mitk -{ - class MITKSIMULATION_EXPORT SimulationSerializer : public BaseDataSerializer - { - public: - mitkClassMacro(SimulationSerializer, BaseDataSerializer); - itkFactorylessNewMacro(Self); - itkCloneMacro(Self); - - std::string Serialize() override; - - protected: - SimulationSerializer(); - ~SimulationSerializer(); - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulationService.cpp b/Modules/Simulation/mitkSimulationService.cpp deleted file mode 100644 index d7e1a35a14..0000000000 --- a/Modules/Simulation/mitkSimulationService.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSimulationService.h" -#include - -static void SwitchSimuluationContext(mitk::Simulation::Pointer activeSimulation) -{ - if (activeSimulation.IsNull()) - { - sofa::simulation::setSimulation(nullptr); - sofa::core::visual::VisualParams::defaultInstance()->drawTool() = nullptr; - } - else - { - sofa::simulation::Simulation::SPtr sofaSimulation = activeSimulation->GetSOFASimulation(); - - if (sofaSimulation != sofa::simulation::getSimulation()) - { - sofa::simulation::setSimulation(sofaSimulation.get()); - sofa::core::visual::VisualParams::defaultInstance()->drawTool() = activeSimulation->GetDrawTool(); - } - } -} - -mitk::SimulationService::SimulationService() - : m_Scheduler(SchedulingAlgorithm::WeightedRoundRobin) -{ -} - -mitk::SimulationService::~SimulationService() -{ -} - -mitk::Simulation::Pointer mitk::SimulationService::GetActiveSimulation() const -{ - return m_ActiveSimulation; -} - -void mitk::SimulationService::SetActiveSimulation(Simulation::Pointer activeSimulation) -{ - SwitchSimuluationContext(activeSimulation); - m_ActiveSimulation = activeSimulation; -} - -mitk::Scheduler* mitk::SimulationService::GetScheduler() -{ - return &m_Scheduler; -} diff --git a/Modules/Simulation/mitkSimulationService.h b/Modules/Simulation/mitkSimulationService.h deleted file mode 100644 index a4ebd3dcda..0000000000 --- a/Modules/Simulation/mitkSimulationService.h +++ /dev/null @@ -1,41 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationService_h -#define mitkSimulationService_h - -#include -#include - -namespace mitk -{ - class SimulationService : public ISimulationService - { - public: - SimulationService(); - ~SimulationService(); - - Simulation::Pointer GetActiveSimulation() const override; - void SetActiveSimulation(Simulation::Pointer activeSimulation) override; - Scheduler* GetScheduler() override; - - private: - Simulation::Pointer m_ActiveSimulation; - Scheduler m_Scheduler; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulationVtkMapper2D.cpp b/Modules/Simulation/mitkSimulationVtkMapper2D.cpp deleted file mode 100644 index ce8629dbb3..0000000000 --- a/Modules/Simulation/mitkSimulationVtkMapper2D.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSimulation.h" -#include "mitkSimulationVtkMapper2D.h" -#include "mitkVtkSimulationPolyDataMapper2D.h" - -mitk::SimulationVtkMapper2D::LocalStorage::LocalStorage() - : m_Actor(vtkSmartPointer::New()) -{ -} - -mitk::SimulationVtkMapper2D::LocalStorage::~LocalStorage() -{ -} - -void mitk::SimulationVtkMapper2D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) -{ - if (node != nullptr) - { - node->AddProperty("Simulation.Visual.2D Rendering", BoolProperty::New(false), renderer, overwrite); - Superclass::SetDefaultProperties(node, renderer, overwrite); - } -} - -mitk::SimulationVtkMapper2D::SimulationVtkMapper2D() -{ -} - -mitk::SimulationVtkMapper2D::~SimulationVtkMapper2D() -{ -} - -void mitk::SimulationVtkMapper2D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) -{ -} - -void mitk::SimulationVtkMapper2D::GenerateDataForRenderer(BaseRenderer* renderer) -{ - DataNode* dataNode = this->GetDataNode(); - - if (dataNode == nullptr) - return; - - Simulation* simulation = dynamic_cast(dataNode->GetData()); - - if (simulation == nullptr) - return; - - LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); - - bool enabled = false; - dataNode->GetBoolProperty("Simulation.Visual.2D Rendering", enabled, renderer); - - if (!enabled) - { - localStorage->m_Actor->SetMapper(nullptr); - return; - } - - if (localStorage->m_Mapper == nullptr) - { - localStorage->m_Mapper = vtkSmartPointer::New(); - localStorage->m_Mapper->SetSimulation(simulation); - } - - if (localStorage->m_Actor->GetMapper() == nullptr) - localStorage->m_Actor->SetMapper(localStorage->m_Mapper); -} - -vtkProp* mitk::SimulationVtkMapper2D::GetVtkProp(BaseRenderer* renderer) -{ - return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor; -} diff --git a/Modules/Simulation/mitkSimulationVtkMapper2D.h b/Modules/Simulation/mitkSimulationVtkMapper2D.h deleted file mode 100644 index 1a58634913..0000000000 --- a/Modules/Simulation/mitkSimulationVtkMapper2D.h +++ /dev/null @@ -1,68 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationVtkMapper2D_h -#define mitkSimulationVtkMapper2D_h - -#include -#include -#include - -namespace mitk -{ - class vtkSimulationPolyDataMapper2D; - - class MITKSIMULATION_EXPORT SimulationVtkMapper2D : public VtkMapper - { - class LocalStorage : public Mapper::BaseLocalStorage - { - public: - LocalStorage(); - ~LocalStorage(); - - vtkSmartPointer m_Mapper; - vtkSmartPointer m_Actor; - - private: - LocalStorage(const LocalStorage&); - LocalStorage& operator=(const LocalStorage&); - }; - - public: - static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = nullptr, bool overwrite = false); - - mitkClassMacro(SimulationVtkMapper2D, VtkMapper); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - void ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) override; - vtkProp* GetVtkProp(BaseRenderer* renderer) override; - - protected: - void GenerateDataForRenderer(BaseRenderer* renderer) override; - - private: - SimulationVtkMapper2D(); - ~SimulationVtkMapper2D(); - - SimulationVtkMapper2D(const Self&); - Self& operator=(const Self&); - - LocalStorageHandler m_LocalStorageHandler; - }; -} - -#endif diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp b/Modules/Simulation/mitkSimulationVtkMapper3D.cpp deleted file mode 100644 index 4b56fff387..0000000000 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSetVtkRendererVisitor.h" -#include "mitkSimulation.h" -#include "mitkSimulationVtkMapper3D.h" -#include "mitkVtkSimulationPolyDataMapper3D.h" -#include -#include - -mitk::SimulationVtkMapper3D::LocalStorage::LocalStorage() - : m_Actor(vtkSmartPointer::New()) -{ -} - -mitk::SimulationVtkMapper3D::LocalStorage::~LocalStorage() -{ -} - -void mitk::SimulationVtkMapper3D::SetDefaultProperties(DataNode* node, BaseRenderer* renderer, bool overwrite) -{ - if (node != nullptr) - { - Simulation* simulation = dynamic_cast(node->GetData()); - - if (simulation != nullptr) - { - sofa::simulation::Node::SPtr rootNode = simulation->GetRootNode(); - sofa::component::visualmodel::VisualStyle::SPtr visualStyle; - - rootNode->get(visualStyle); - - if (!visualStyle) - { - visualStyle = sofa::core::objectmodel::New(); - - sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); - displayFlags->setShowVisualModels(); - visualStyle->displayFlags.endEdit(); - - rootNode->addObject(visualStyle); - } - - const sofa::core::visual::DisplayFlags& displayFlags = visualStyle->displayFlags.getValue(); - - node->AddProperty("Simulation.Behavior.Behavior Models", BoolProperty::New(displayFlags.getShowBehaviorModels()), renderer, overwrite); - node->AddProperty("Simulation.Behavior.Force Fields", BoolProperty::New(displayFlags.getShowForceFields()), renderer, overwrite); - node->AddProperty("Simulation.Behavior.Interactions", BoolProperty::New(displayFlags.getShowInteractionForceFields()), renderer, overwrite); - node->AddProperty("Simulation.Collision.Bounding Trees", BoolProperty::New(displayFlags.getShowBoundingCollisionModels()), renderer, overwrite); - node->AddProperty("Simulation.Collision.Collision Models", BoolProperty::New(displayFlags.getShowCollisionModels()), renderer, overwrite); - node->AddProperty("Simulation.Mapping.Mechanical Mappings", BoolProperty::New(displayFlags.getShowMechanicalMappings()), renderer, overwrite); - node->AddProperty("Simulation.Mapping.Visual Mappings", BoolProperty::New(displayFlags.getShowMappings()), renderer, overwrite); - node->AddProperty("Simulation.Options.Normals", BoolProperty::New(displayFlags.getShowNormals()), renderer, overwrite); - node->AddProperty("Simulation.Options.Wire Frame", BoolProperty::New(displayFlags.getShowWireFrame()), renderer, overwrite); - node->AddProperty("Simulation.Visual.Visual Models", BoolProperty::New(displayFlags.getShowVisualModels() != sofa::core::visual::tristate::false_value), renderer, overwrite); - } - - Superclass::SetDefaultProperties(node, renderer, overwrite); - } -} - -mitk::SimulationVtkMapper3D::SimulationVtkMapper3D() -{ -} - -mitk::SimulationVtkMapper3D::~SimulationVtkMapper3D() -{ -} - -void mitk::SimulationVtkMapper3D::ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) -{ -} - -void mitk::SimulationVtkMapper3D::ApplySimulationProperties(BaseRenderer* renderer) -{ - DataNode* node = this->GetDataNode(); - - bool showBehaviorModels; - bool showForceFields; - bool showInteractionForceFields; - bool showBoundingCollisionModels; - bool showCollisionModels; - bool showMechanicalMappings; - bool showMappings; - bool showNormals; - bool showWireFrame; - bool showVisualModels; - - node->GetBoolProperty("Simulation.Behavior.Behavior Models", showBehaviorModels, renderer); - node->GetBoolProperty("Simulation.Behavior.Force Fields", showForceFields, renderer); - node->GetBoolProperty("Simulation.Behavior.Interactions", showInteractionForceFields, renderer); - node->GetBoolProperty("Simulation.Collision.Bounding Trees", showBoundingCollisionModels, renderer); - node->GetBoolProperty("Simulation.Collision.Collision Models", showCollisionModels, renderer); - node->GetBoolProperty("Simulation.Mapping.Mechanical Mappings", showMechanicalMappings, renderer); - node->GetBoolProperty("Simulation.Mapping.Visual Mappings", showMappings, renderer); - node->GetBoolProperty("Simulation.Options.Normals", showNormals, renderer); - node->GetBoolProperty("Simulation.Options.Wire Frame", showWireFrame, renderer); - node->GetBoolProperty("Simulation.Visual.Visual Models", showVisualModels, renderer); - - Simulation* simulation = static_cast(node->GetData()); - sofa::component::visualmodel::VisualStyle::SPtr visualStyle; - simulation->GetRootNode()->get(visualStyle); - - sofa::core::visual::DisplayFlags* displayFlags = visualStyle->displayFlags.beginEdit(); - - displayFlags->setShowBehaviorModels(showBehaviorModels); - displayFlags->setShowForceFields(showForceFields); - displayFlags->setShowInteractionForceFields(showInteractionForceFields); - displayFlags->setShowBoundingCollisionModels(showBoundingCollisionModels); - displayFlags->setShowCollisionModels(showCollisionModels); - displayFlags->setShowMechanicalMappings(showMechanicalMappings); - displayFlags->setShowMappings(showMappings); - displayFlags->setShowNormals(showNormals); - displayFlags->setShowWireFrame(showWireFrame); - displayFlags->setShowVisualModels(showVisualModels); - - visualStyle->displayFlags.endEdit(); -} - -void mitk::SimulationVtkMapper3D::GenerateDataForRenderer(BaseRenderer* renderer) -{ - DataNode* dataNode = this->GetDataNode(); - - if (dataNode == nullptr) - return; - - Simulation* simulation = dynamic_cast(dataNode->GetData()); - - if (simulation == nullptr) - return; - - LocalStorage* localStorage = m_LocalStorageHandler.GetLocalStorage(renderer); - - if (localStorage->m_Mapper == nullptr) - { - localStorage->m_Mapper = vtkSmartPointer::New(); - localStorage->m_Mapper->SetSimulation(simulation); - - localStorage->m_Actor->SetMapper(localStorage->m_Mapper); - - SetVtkRendererVisitor setVtkRendererVisitor(renderer->GetVtkRenderer()); - simulation->GetRootNode()->executeVisitor(&setVtkRendererVisitor); - } - - this->ApplySimulationProperties(renderer); -} - -vtkProp* mitk::SimulationVtkMapper3D::GetVtkProp(BaseRenderer* renderer) -{ - return m_LocalStorageHandler.GetLocalStorage(renderer)->m_Actor; -} diff --git a/Modules/Simulation/mitkSimulationVtkMapper3D.h b/Modules/Simulation/mitkSimulationVtkMapper3D.h deleted file mode 100644 index 63c336135c..0000000000 --- a/Modules/Simulation/mitkSimulationVtkMapper3D.h +++ /dev/null @@ -1,69 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkSimulationVtkMapper3D_h -#define mitkSimulationVtkMapper3D_h - -#include -#include -#include - -namespace mitk -{ - class vtkSimulationPolyDataMapper3D; - - class MITKSIMULATION_EXPORT SimulationVtkMapper3D : public VtkMapper - { - class LocalStorage : public Mapper::BaseLocalStorage - { - public: - LocalStorage(); - ~LocalStorage(); - - vtkSmartPointer m_Mapper; - vtkSmartPointer m_Actor; - - private: - LocalStorage(const LocalStorage&); - LocalStorage& operator=(const LocalStorage&); - }; - - public: - static void SetDefaultProperties(DataNode* node, BaseRenderer* renderer = nullptr, bool overwrite = false); - - mitkClassMacro(SimulationVtkMapper3D, VtkMapper); - itkFactorylessNewMacro(Self) - itkCloneMacro(Self) - - void ApplyColorAndOpacityProperties(BaseRenderer*, vtkActor*) override; - void ApplySimulationProperties(BaseRenderer* renderer); - vtkProp* GetVtkProp(BaseRenderer* renderer) override; - - protected: - void GenerateDataForRenderer(BaseRenderer* renderer) override; - - private: - SimulationVtkMapper3D(); - ~SimulationVtkMapper3D(); - - SimulationVtkMapper3D(const Self&); - Self& operator=(const Self&); - - LocalStorageHandler m_LocalStorageHandler; - }; -} - -#endif diff --git a/Modules/Simulation/mitkVtkModel.cpp b/Modules/Simulation/mitkVtkModel.cpp deleted file mode 100644 index a7cfee8f64..0000000000 --- a/Modules/Simulation/mitkVtkModel.cpp +++ /dev/null @@ -1,633 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkVtkModel.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Defined in mitkExportMitkVisitor.cpp -void ApplyMaterial(mitk::DataNode::Pointer dataNode, const sofa::core::loader::Material& material); - -static bool InitGLEW() -{ - static bool isInitialized = false; - - // If no render window is shown, OpenGL is potentially not initialized, e.g., the - // Display tab of the Workbench might be closed while loading a SOFA scene file. - // In this case initialization is deferred (see mitk::VtkModel::internalDraw()). - if (mitk::RenderingManager::GetInstance()->GetAllRegisteredRenderWindows().empty()) - return false; - - if (!isInitialized) - { - GLenum error = glewInit(); - - if (error != GLEW_OK) - { - MITK_ERROR("glewInit") << glewGetErrorString(error); - } - else - { - isInitialized = true; - } - } - - return isInitialized; -} - -mitk::VtkModel::VtkModel() - : m_GlewIsInitialized(InitGLEW()), - m_BuffersWereCreated(false), - m_LastNumberOfVertices(0), - m_LastNumberOfTriangles(0), - m_LastNumberOfQuads(0), - m_VertexBuffer(0), - m_IndexBuffer(0), - m_VtkRenderer(nullptr), - m_Mode(OpenGL) -{ -} - -mitk::VtkModel::~VtkModel() -{ - if (m_Mode == OpenGL && m_BuffersWereCreated) - { - glDeleteBuffers(1, &m_IndexBuffer); - glDeleteBuffers(1, &m_VertexBuffer); - } -} - -void mitk::VtkModel::CreateIndexBuffer() -{ - if (m_Mode == OpenGL) - { - glGenBuffers(1, &m_IndexBuffer); - } - else if (m_Mode == Surface) - { - m_Polys = vtkSmartPointer::New(); - } - - this->InitIndexBuffer(); -} - -void mitk::VtkModel::CreateVertexBuffer() -{ - if (m_Mode == OpenGL) - { - glGenBuffers(1, &m_VertexBuffer); - } - else if (m_Mode == Surface) - { - m_Points = vtkSmartPointer::New(); - m_Normals = vtkSmartPointer::New(); - m_TexCoords = vtkSmartPointer::New(); - } - - this->InitVertexBuffer(); -} - -void mitk::VtkModel::DrawGroup(int group, bool transparent) -{ - if (m_Mode == OpenGL) - { - this->DrawOpenGLGroup(group, transparent); - } - else if (m_Mode == Surface) - { - this->DrawSurfaceGroup(group, transparent); - } -} - -void mitk::VtkModel::DrawOpenGLGroup(int group, bool) -{ - using sofa::core::loader::Material; - using sofa::defaulttype::ResizableExtVector; - using sofa::defaulttype::Vec4f; - - const VecCoord& vertices = this->getVertices(); - const ResizableExtVector& normals = this->getVnormals(); - const ResizableExtVector& triangles = this->getTriangles(); - const ResizableExtVector& quads = this->getQuads(); - - FaceGroup faceGroup; - - if (group == -1) - { - faceGroup.nbt = triangles.size(); - faceGroup.nbq = quads.size(); - } - else - { - faceGroup = groups.getValue()[group]; - } - - Material material = faceGroup.materialId != -1 - ? materials.getValue()[faceGroup.materialId] - : this->material.getValue(); - - if (material.useTexture && material.activated) - { - m_Textures[faceGroup.materialId]->Load(m_VtkRenderer); - - glEnable(GL_TEXTURE_2D); - glTexCoordPointer(2, GL_FLOAT, 0, reinterpret_cast(vertices.size() * sizeof(VecCoord::value_type) + normals.size() * sizeof(Deriv))); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - } - - Vec4f ambient = material.useAmbient ? material.ambient : Vec4f(); - Vec4f diffuse = material.useDiffuse ? material.diffuse : Vec4f(); - Vec4f specular = material.useSpecular ? material.specular : Vec4f(); - Vec4f emissive = material.useEmissive ? material.emissive : Vec4f(); - float shininess = material.useShininess ? std::min(material.shininess, 128.0f) : 45.0f; - - if (shininess == 0.0f) - { - specular.clear(); - shininess = 1.0f; - } - - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient.ptr()); - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse.ptr()); - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular.ptr()); - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, emissive.ptr()); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); - - if (faceGroup.nbt != 0) - glDrawElements(GL_TRIANGLES, faceGroup.nbt * 3, GL_UNSIGNED_INT, reinterpret_cast(faceGroup.tri0 * sizeof(Triangle))); - - if (faceGroup.nbq != 0) - glDrawElements(GL_QUADS, faceGroup.nbq * 4, GL_UNSIGNED_INT, reinterpret_cast(triangles.size() * sizeof(Triangle) + faceGroup.quad0 * sizeof(Quad))); - - if (material.useTexture && material.activated) - { - glDisableClientState(GL_TEXTURE_COORD_ARRAY); - glDisable(GL_TEXTURE_2D); - - m_Textures[faceGroup.materialId]->PostRender(m_VtkRenderer); - } -} - -void mitk::VtkModel::DrawSurfaceGroup(int, bool) -{ - m_PolyData->SetPoints(m_Points); - m_PolyData->SetPolys(m_Polys); - - vtkPointData* pointData = m_PolyData->GetPointData(); - - pointData->SetNormals(m_Normals->GetSize() != 0 - ? m_Normals - : nullptr); - - pointData->SetTCoords(m_TexCoords->GetSize() != 0 - ? m_TexCoords - : nullptr); - - m_PolyData->Modified(); -} - -void mitk::VtkModel::DrawGroups(bool transparent) -{ - using sofa::core::objectmodel::Data; - using sofa::helper::ReadAccessor; - using sofa::helper::vector; - - ReadAccessor > > groups = this->groups; - - if (groups.empty()) - { - this->DrawGroup(-1, transparent); - } - else - { - int numGroups = static_cast(groups.size()); - - for (int i = 0; i < numGroups; ++i) - this->DrawGroup(i, transparent); - } -} - -void mitk::VtkModel::InitIndexBuffer() -{ - using sofa::defaulttype::ResizableExtVector; - - const ResizableExtVector& triangles = this->getTriangles(); - const ResizableExtVector& quads = this->getQuads(); - - if (m_Mode == OpenGL) - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IndexBuffer); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, triangles.size() * sizeof(Triangle) + quads.size() * sizeof(Quad), nullptr, GL_DYNAMIC_DRAW); - } - - this->UpdateIndexBuffer(); -} - -void mitk::VtkModel::InitVertexBuffer() -{ - using sofa::defaulttype::ResizableExtVector; - - const VecCoord& vertices = this->getVertices(); - const ResizableExtVector normals = this->getVnormals(); - const VecTexCoord& texCoords = this->getVtexcoords(); - - if (m_Mode == OpenGL) - { - glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); - glBufferData(GL_ARRAY_BUFFER, vertices.size() * sizeof(VecCoord::value_type) + normals.size() * sizeof(Deriv) + texCoords.size() * sizeof(VecTexCoord::value_type), nullptr, GL_DYNAMIC_DRAW); - } - else if (m_Mode == Surface) - { - m_Points->SetNumberOfPoints(vertices.size()); - - m_Normals->SetNumberOfComponents(3); - m_Normals->SetNumberOfTuples(normals.size()); - - m_TexCoords->SetNumberOfComponents(2); - m_TexCoords->SetNumberOfTuples(texCoords.size()); - } - - this->UpdateVertexBuffer(); -} - -void mitk::VtkModel::internalDraw(const sofa::core::visual::VisualParams* vparams, bool transparent) -{ - using sofa::core::visual::DisplayFlags; - using sofa::defaulttype::ResizableExtVector; - - if (m_Mode == OpenGL && !m_GlewIsInitialized) - { - // Try lazy initialization since initialization potentially failed so far - // due to missing render windows (see InitGLEW()). - m_GlewIsInitialized = InitGLEW(); - - if (m_GlewIsInitialized) - { - this->updateBuffers(); - } - else - { - return; - } - } - - const DisplayFlags& displayFlags = vparams->displayFlags(); - - if (!displayFlags.getShowVisualModels()) - return; - - if (m_BuffersWereCreated == false) - return; - - if (m_Mode == OpenGL) - { - glEnable(GL_LIGHTING); - glColor3f(1.0f, 1.0f, 1.0f); - glPolygonMode(GL_FRONT_AND_BACK, displayFlags.getShowWireFrame() ? GL_LINE : GL_FILL); - - const VecCoord& vertices = this->getVertices(); - - glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IndexBuffer); - - this->ValidateBoundBuffers(); - - glVertexPointer(3, GL_FLOAT, 0, nullptr); - glNormalPointer(GL_FLOAT, 0, reinterpret_cast(vertices.size() * sizeof(VecCoord::value_type))); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_NORMAL_ARRAY); - } - - this->DrawGroups(transparent); - - if (m_Mode == OpenGL) - { - glDisableClientState(GL_NORMAL_ARRAY); - glDisableClientState(GL_VERTEX_ARRAY); - - if (displayFlags.getShowWireFrame()) - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - - glDisable(GL_LIGHTING); - } - - if (displayFlags.getShowNormals()) - this->DrawNormals(); -} - -void mitk::VtkModel::DrawNormals() -{ - using sofa::defaulttype::ResizableExtVector; - - if (m_Mode == OpenGL) - { - const VecCoord& vertices = this->getVertices(); - const ResizableExtVector& normals = this->getVnormals(); - size_t numVertices = vertices.size(); - Coord normal; - - glBegin(GL_LINES); - - for (size_t i = 0; i < numVertices; ++i) - { - glVertex3fv(vertices[i].ptr()); - normal = vertices[i] + normals[i]; - glVertex3fv(normal.ptr()); - } - - glEnd(); - } -} - -bool mitk::VtkModel::loadTextures() -{ - using sofa::helper::system::DataRepository; - using sofa::helper::vector; - using sofa::core::loader::Material; - - m_Textures.clear(); - - std::vector materialIndices; - - const vector& materials = this->materials.getValue(); - unsigned int numMaterials = materials.size(); - - for (unsigned int i = 0; i < numMaterials; ++i) - { - const Material& material = materials[i]; - - if (material.useTexture && material.activated) - materialIndices.push_back(i); - } - - bool retValue = true; - size_t numTextures = materialIndices.size(); - - for (size_t i = 0; i < numTextures; ++i) - { - std::string filename = materials[materialIndices[i]].textureFilename; - - if (!DataRepository.findFile(filename)) - { - MITK_ERROR("VtkModel") << "File \"" << filename << "\" not found!"; - retValue = false; - continue; - } - - vtkSmartPointer imageReader = vtkSmartPointer::Take(vtkImageReader2Factory::CreateImageReader2(filename.c_str())); - - if (imageReader == nullptr) - { - MITK_ERROR("VtkModel") << "File \"" << filename << "\" has unknown image format!"; - retValue = false; - continue; - } - - imageReader->SetFileName(filename.c_str()); - imageReader->UpdateWholeExtent(); - - vtkSmartPointer texture = vtkSmartPointer::New(); - texture->SetInputConnection(imageReader->GetOutputPort()); - texture->InterpolateOn(); - - m_Textures.insert(std::make_pair(materialIndices[i], texture)); - } - - return retValue; -} - -mitk::DataNode::Pointer mitk::VtkModel::GetDataNode() const -{ - return m_DataNode; -} - -mitk::VtkModel::Mode mitk::VtkModel::GetMode() const -{ - return m_Mode; -} - -void mitk::VtkModel::SetMode(Mode mode) -{ - if (m_Mode == mode) - return; - - if (mode == OpenGL) - { - m_DataNode = nullptr; - m_Surface = nullptr; - m_PolyData = nullptr; - m_TexCoords = nullptr; - m_Normals = nullptr; - m_Polys = nullptr; - m_Points = nullptr; - } - else if (mode == Surface) - { - if (m_Mode == OpenGL && m_BuffersWereCreated) - { - glDeleteBuffers(1, &m_IndexBuffer); - m_IndexBuffer = 0; - - glDeleteBuffers(1, &m_VertexBuffer); - m_VertexBuffer = 0; - } - - m_PolyData = vtkSmartPointer::New(); - - m_Surface = Surface::New(); - m_Surface->SetVtkPolyData(m_PolyData); - - m_DataNode = DataNode::New(); - m_DataNode->SetName(name.getValue()); - m_DataNode->SetData(m_Surface); - - ApplyMaterial(m_DataNode, this->material.getValue()); - } - - m_Mode = mode; - - m_BuffersWereCreated = false; - this->updateBuffers(); -} - -void mitk::VtkModel::SetVtkRenderer(vtkRenderer* renderer) -{ - m_VtkRenderer = renderer; -} - -void mitk::VtkModel::updateBuffers() -{ - using sofa::defaulttype::ResizableExtVector; - - if (m_Mode == OpenGL && !m_GlewIsInitialized) - return; - - const VecCoord& vertices = this->getVertices(); - const ResizableExtVector& triangles = this->getTriangles(); - const ResizableExtVector& quads = this->getQuads(); - - if (!m_BuffersWereCreated) - { - this->CreateVertexBuffer(); - this->CreateIndexBuffer(); - - m_BuffersWereCreated = true; - } - else - { - if (m_LastNumberOfVertices != vertices.size()) - this->InitVertexBuffer(); - else - this->UpdateVertexBuffer(); - - if (m_LastNumberOfTriangles != triangles.size() || m_LastNumberOfQuads != quads.size()) - this->InitIndexBuffer(); - else - this->UpdateIndexBuffer(); - } - - m_LastNumberOfVertices = vertices.size(); - m_LastNumberOfTriangles = triangles.size(); - m_LastNumberOfQuads = quads.size(); -} - -void mitk::VtkModel::UpdateIndexBuffer() -{ - using sofa::defaulttype::ResizableExtVector; - - const ResizableExtVector& triangles = this->getTriangles(); - const ResizableExtVector& quads = this->getQuads(); - - GLsizeiptr sizeOfTriangleIndices = triangles.size() * sizeof(Triangle); - GLsizeiptr sizeOfQuadIndices = quads.size() * sizeof(Quad); - - if (m_Mode == OpenGL) - { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IndexBuffer); - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, sizeOfTriangleIndices, triangles.getData()); - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, sizeOfTriangleIndices, sizeOfQuadIndices, quads.getData()); - } - else if (m_Mode == Surface) - { - m_Polys->Initialize(); - - if (!triangles.empty()) - { - ResizableExtVector::const_iterator trianglesEnd = triangles.end(); - - for (ResizableExtVector::const_iterator it = triangles.begin(); it != trianglesEnd; ++it) - { - const Triangle& triangle = *it; - - m_Polys->InsertNextCell(3); - m_Polys->InsertCellPoint(triangle[0]); - m_Polys->InsertCellPoint(triangle[1]); - m_Polys->InsertCellPoint(triangle[2]); - } - } - - if (!quads.empty()) - { - ResizableExtVector::const_iterator quadsEnd = quads.end(); - - for (ResizableExtVector::const_iterator it = quads.begin(); it != quadsEnd; ++it) - { - const Quad& quad = *it; - - m_Polys->InsertNextCell(4); - m_Polys->InsertCellPoint(quad[0]); - m_Polys->InsertCellPoint(quad[1]); - m_Polys->InsertCellPoint(quad[2]); - m_Polys->InsertCellPoint(quad[3]); - } - } - } -} - -void mitk::VtkModel::UpdateVertexBuffer() -{ - using sofa::defaulttype::ResizableExtVector; - - const VecCoord& vertices = this->getVertices(); - const ResizableExtVector normals = this->getVnormals(); - const VecTexCoord& texCoords = this->getVtexcoords(); - - if (m_Mode == OpenGL) - { - GLsizeiptr sizeOfVertices = vertices.size() * sizeof(VecCoord::value_type); - GLsizeiptr sizeOfNormals = normals.size() * sizeof(Deriv); - - glBindBuffer(GL_ARRAY_BUFFER, m_VertexBuffer); - glBufferSubData(GL_ARRAY_BUFFER, 0, sizeOfVertices, vertices.getData()); - glBufferSubData(GL_ARRAY_BUFFER, sizeOfVertices, sizeOfNormals, normals.getData()); - - if (!m_Textures.empty()) - { - GLsizeiptr sizeOfTexCoords = texCoords.size() * sizeof(VecTexCoord::value_type); - glBufferSubData(GL_ARRAY_BUFFER, sizeOfVertices + sizeOfNormals, sizeOfTexCoords, texCoords.getData()); - } - } - else if (m_Mode == Surface) - { - size_t numPoints = vertices.size(); - - for (size_t i = 0; i < numPoints; ++i) - m_Points->SetPoint(i, vertices[i].elems); - - if (!normals.empty()) - { - size_t numNormals = normals.size(); - - for (size_t i = 0; i < numNormals; ++i) - m_Normals->SetTuple(i, normals[i].elems); - } - - if (!texCoords.empty()) - { - size_t numTexCoords = texCoords.size(); - - for (size_t i = 0; i < numTexCoords; ++i) - m_TexCoords->SetTuple(i, normals[i].elems); - } - } -} - -void mitk::VtkModel::ValidateBoundBuffers() -{ - if (m_Mode != OpenGL) - return; - - GLint indexBufferSize; - glGetBufferParameteriv(GL_ELEMENT_ARRAY_BUFFER, GL_BUFFER_SIZE, &indexBufferSize); - - if (indexBufferSize == 0) - { - glDeleteBuffers(1, &m_IndexBuffer); - this->CreateIndexBuffer(); - - glDeleteBuffers(1, &m_VertexBuffer); - this->CreateVertexBuffer(); - } -} diff --git a/Modules/Simulation/mitkVtkModel.h b/Modules/Simulation/mitkVtkModel.h deleted file mode 100644 index 7939e888d7..0000000000 --- a/Modules/Simulation/mitkVtkModel.h +++ /dev/null @@ -1,99 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkVtkModel_h -#define mitkVtkModel_h - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class vtkOpenGLTexture; -class vtkRenderer; - -namespace mitk -{ - class MITKSIMULATION_EXPORT VtkModel : public sofa::component::visualmodel::VisualModelImpl - { - public: - enum Mode - { - OpenGL, - Surface - }; - - SOFA_CLASS(VtkModel, sofa::component::visualmodel::VisualModelImpl); - - void internalDraw(const sofa::core::visual::VisualParams* vparams, bool transparent) override; - bool loadTextures() override; - void SetVtkRenderer(vtkRenderer* renderer); - void updateBuffers() override; - - DataNode::Pointer GetDataNode() const; - - Mode GetMode() const; - void SetMode(Mode mode); - - private: - VtkModel(); - ~VtkModel(); - - VtkModel(MyType&); - MyType& operator=(const MyType&); - - void CreateIndexBuffer(); - void CreateVertexBuffer(); - void DrawGroup(int group, bool transparent); - void DrawOpenGLGroup(int group, bool transparent); - void DrawSurfaceGroup(int group, bool transparent); - void DrawGroups(bool transparent); - void DrawNormals(); - void InitIndexBuffer(); - void InitVertexBuffer(); - void UpdateIndexBuffer(); - void UpdateVertexBuffer(); - void ValidateBoundBuffers(); - - bool m_GlewIsInitialized; - bool m_BuffersWereCreated; - size_t m_LastNumberOfVertices; - size_t m_LastNumberOfTriangles; - size_t m_LastNumberOfQuads; - GLuint m_VertexBuffer; - GLuint m_IndexBuffer; - std::map > m_Textures; - vtkRenderer* m_VtkRenderer; - Mode m_Mode; - vtkSmartPointer m_Points; - vtkSmartPointer m_Polys; - vtkSmartPointer m_Normals; - vtkSmartPointer m_TexCoords; - vtkSmartPointer m_PolyData; - Surface::Pointer m_Surface; - DataNode::Pointer m_DataNode; - }; -} - -#endif diff --git a/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp b/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp deleted file mode 100644 index 18cd79fce4..0000000000 --- a/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkGetSimulationService.h" -#include "mitkISimulationService.h" -#include "mitkPlaneIntersectionVisitor.h" -#include "mitkVtkSimulationPolyDataMapper2D.h" -#include -#include -#include -#include -#include -#include - -namespace mitk -{ - vtkStandardNewMacro(vtkSimulationPolyDataMapper2D); -} - -mitk::vtkSimulationPolyDataMapper2D::vtkSimulationPolyDataMapper2D() - : m_SimulationService(GetSimulationService()) -{ -} - -mitk::vtkSimulationPolyDataMapper2D::~vtkSimulationPolyDataMapper2D() -{ -} - -void mitk::vtkSimulationPolyDataMapper2D::Render(vtkRenderer* renderer, vtkActor*) -{ - typedef PlaneIntersectionVisitor::Edge Edge; - typedef PlaneIntersectionVisitor::Intersection Intersection; - - vtkRenderWindow* renderWindow = renderer->GetRenderWindow(); - - if (renderWindow->CheckAbortStatus() == 1) - return; - - if (renderWindow->SupportsOpenGL() == 0) - return; - - if (m_Simulation.IsNull()) - return; - - if (!renderWindow->IsCurrent()) - renderWindow->MakeCurrent(); - - BaseRenderer* mitkRenderer = BaseRenderer::GetInstance(renderer->GetRenderWindow()); - - if (mitkRenderer == nullptr) - return; - - SliceNavigationController* sliceNavigationController = mitkRenderer->GetSliceNavigationController(); - - if (sliceNavigationController == nullptr) - return; - - const PlaneGeometry* planeGeometry = sliceNavigationController->GetCurrentPlaneGeometry(); - - if (planeGeometry == nullptr) - return; - - renderer->GetRenderWindow()->MakeCurrent(); - - m_SimulationService->SetActiveSimulation(m_Simulation); - - PlaneIntersectionVisitor planeIntersectionVisitor(planeGeometry->GetOrigin(), planeGeometry->GetNormal()); - m_Simulation->GetRootNode()->executeVisitor(&planeIntersectionVisitor); - - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - glEnable(GL_COLOR_MATERIAL); - - const std::vector& intersections = planeIntersectionVisitor.GetIntersections(); - std::vector::const_iterator intersectionsEnd = intersections.end(); - - for (std::vector::const_iterator intersectionIt = intersections.begin(); intersectionIt != intersectionsEnd; ++intersectionIt) - { - const std::vector& edges = intersectionIt->edges; - std::vector::const_iterator edgesEnd = edges.end(); - - glColor4fv(intersectionIt->color); - glBegin(GL_LINES); - - for (std::vector::const_iterator edgeIt = edges.begin(); edgeIt != edgesEnd; ++edgeIt) - { - glVertex3dv(edgeIt->v0.GetDataPointer()); - glVertex3dv(edgeIt->v1.GetDataPointer()); - } - - glEnd(); - } - - glDisable(GL_COLOR_MATERIAL); -} - -void mitk::vtkSimulationPolyDataMapper2D::RenderPiece(vtkRenderer*, vtkActor*) -{ -} - -void mitk::vtkSimulationPolyDataMapper2D::SetSimulation(Simulation::Pointer simulation) -{ - m_Simulation = simulation; -} - -double* mitk::vtkSimulationPolyDataMapper2D::GetBounds() -{ - if (m_Simulation.IsNull()) - return Superclass::GetBounds(); - - sofa::simulation::Node::SPtr rootNode = m_Simulation->GetRootNode(); - const sofa::defaulttype::BoundingBox& bbox = rootNode->f_bbox.getValue(); - const sofa::defaulttype::Vector3& min = bbox.minBBox(); - const sofa::defaulttype::Vector3& max = bbox.maxBBox(); - - Bounds[0] = min.x(); - Bounds[1] = max.x(); - Bounds[2] = min.y(); - Bounds[3] = max.y(); - Bounds[4] = min.z(); - Bounds[5] = max.z(); - - return this->Bounds; -} diff --git a/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.h b/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.h deleted file mode 100644 index a414706fe5..0000000000 --- a/Modules/Simulation/mitkVtkSimulationPolyDataMapper2D.h +++ /dev/null @@ -1,49 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkVtkSimulationPolyDataMapper2D_h -#define mitkVtkSimulationPolyDataMapper2D_h - -#include -#include -#include - -namespace mitk -{ - class ISimulationService; - - class MITKSIMULATION_EXPORT vtkSimulationPolyDataMapper2D : public vtkPolyDataMapper - { - public: - static vtkSimulationPolyDataMapper2D* New(); - vtkTypeMacro(vtkSimulationPolyDataMapper2D, vtkPolyDataMapper); - - using vtkPolyDataMapper::GetBounds; - double* GetBounds() override; - void Render(vtkRenderer* renderer, vtkActor* actor) override; - void RenderPiece(vtkRenderer*, vtkActor*) override; - void SetSimulation(mitk::Simulation::Pointer simulation); - - private: - vtkSimulationPolyDataMapper2D(); - ~vtkSimulationPolyDataMapper2D(); - - Simulation::Pointer m_Simulation; - ISimulationService* m_SimulationService; - }; -} - -#endif diff --git a/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp b/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp deleted file mode 100644 index 6d6e7c528b..0000000000 --- a/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkGetSimulationService.h" -#include "mitkISimulationService.h" -#include "mitkVtkSimulationPolyDataMapper3D.h" -#include -#include -#include -#include - -namespace mitk -{ - vtkStandardNewMacro(vtkSimulationPolyDataMapper3D); -} - -mitk::vtkSimulationPolyDataMapper3D::vtkSimulationPolyDataMapper3D() - : m_SimulationService(GetSimulationService()) -{ -} - -mitk::vtkSimulationPolyDataMapper3D::~vtkSimulationPolyDataMapper3D() -{ -} - -void mitk::vtkSimulationPolyDataMapper3D::Render(vtkRenderer* renderer, vtkActor*) -{ - vtkRenderWindow* renderWindow = renderer->GetRenderWindow(); - - if (renderWindow->CheckAbortStatus() == 1) - return; - - if (renderWindow->SupportsOpenGL() == 0) - return; - - if (m_Simulation.IsNull()) - return; - - if (!renderWindow->IsCurrent()) - renderWindow->MakeCurrent(); - - m_SimulationService->SetActiveSimulation(m_Simulation); - - sofa::core::visual::VisualParams* vParams = sofa::core::visual::VisualParams::defaultInstance(); - sofa::simulation::Simulation::SPtr sofaSimulation = m_Simulation->GetSOFASimulation(); - sofa::simulation::Node::SPtr rootNode = m_Simulation->GetRootNode(); - - sofaSimulation->updateVisual(rootNode.get()); - sofaSimulation->draw(vParams, rootNode.get()); - - // SOFA potentially disables GL_BLEND but VTK relies on it. - glEnable(GL_BLEND); -} - -void mitk::vtkSimulationPolyDataMapper3D::RenderPiece(vtkRenderer*, vtkActor*) -{ -} - -void mitk::vtkSimulationPolyDataMapper3D::SetSimulation(Simulation::Pointer simulation) -{ - m_Simulation = simulation; -} - -double* mitk::vtkSimulationPolyDataMapper3D::GetBounds() -{ - if (m_Simulation.IsNull()) - return Superclass::GetBounds(); - - sofa::simulation::Node::SPtr rootNode = m_Simulation->GetRootNode(); - const sofa::defaulttype::BoundingBox& bbox = rootNode->f_bbox.getValue(); - const sofa::defaulttype::Vector3& min = bbox.minBBox(); - const sofa::defaulttype::Vector3& max = bbox.maxBBox(); - - Bounds[0] = min.x(); - Bounds[1] = max.x(); - Bounds[2] = min.y(); - Bounds[3] = max.y(); - Bounds[4] = min.z(); - Bounds[5] = max.z(); - - return this->Bounds; -} diff --git a/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.h b/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.h deleted file mode 100644 index 57ec13c93f..0000000000 --- a/Modules/Simulation/mitkVtkSimulationPolyDataMapper3D.h +++ /dev/null @@ -1,50 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkVtkSimulationPolyDataMapper3D_h -#define mitkVtkSimulationPolyDataMapper3D_h - -#include -#include -#include - -namespace mitk -{ - class ISimulationService; - - class MITKSIMULATION_EXPORT vtkSimulationPolyDataMapper3D : public vtkPolyDataMapper - { - public: - static vtkSimulationPolyDataMapper3D* New(); - vtkTypeMacro(vtkSimulationPolyDataMapper3D, vtkPolyDataMapper); - - using vtkPolyDataMapper::GetBounds; - double* GetBounds() override; - - void Render(vtkRenderer* renderer, vtkActor* actor) override; - void RenderPiece(vtkRenderer*, vtkActor*) override; - void SetSimulation(mitk::Simulation::Pointer simulation); - - private: - vtkSimulationPolyDataMapper3D(); - ~vtkSimulationPolyDataMapper3D(); - - Simulation::Pointer m_Simulation; - ISimulationService* m_SimulationService; - }; -} - -#endif diff --git a/Modules/Simulation/mitkWeightedRoundRobinSchedulingAlgorithm.cpp b/Modules/Simulation/mitkWeightedRoundRobinSchedulingAlgorithm.cpp deleted file mode 100644 index a8049f71b0..0000000000 --- a/Modules/Simulation/mitkWeightedRoundRobinSchedulingAlgorithm.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkSchedulableProcess.h" -#include "mitkWeightedRoundRobinSchedulingAlgorithm.h" -#include - -static bool CompareElapsedTime(mitk::SchedulableProcess* lhs, mitk::SchedulableProcess* rhs) -{ - return lhs->GetElapsedTime() < rhs->GetElapsedTime(); -} - -mitk::WeightedRoundRobinSchedulingAlgorithm::WeightedRoundRobinSchedulingAlgorithm() -{ -} - -mitk::WeightedRoundRobinSchedulingAlgorithm::~WeightedRoundRobinSchedulingAlgorithm() -{ -} - -mitk::SchedulableProcess* mitk::WeightedRoundRobinSchedulingAlgorithm::GetNextProcess(std::vector& processQueue) -{ - const double threshold = 1.5; - size_t numProcesses = processQueue.size(); - - if (numProcesses == 0) - return nullptr; - - boost::chrono::nanoseconds maxElapsedTime = (*std::max_element(processQueue.begin(), processQueue.end(), CompareElapsedTime))->GetElapsedTime(); - mitk::SchedulableProcess* process = processQueue[0]; - - if (numProcesses > 1) - { - boost::chrono::nanoseconds totalElapsedTime = process->GetTotalElapsedTime(); - boost::chrono::nanoseconds elapsedTime = process->GetElapsedTime(); - - if (totalElapsedTime >= maxElapsedTime || totalElapsedTime + elapsedTime >= maxElapsedTime * threshold) - { - process->ResetTotalElapsedTime(); - - processQueue.erase(processQueue.begin()); - processQueue.push_back(process); - } - } - - return process; -} diff --git a/Modules/Simulation/mitkWeightedRoundRobinSchedulingAlgorithm.h b/Modules/Simulation/mitkWeightedRoundRobinSchedulingAlgorithm.h deleted file mode 100644 index 6b97227ecf..0000000000 --- a/Modules/Simulation/mitkWeightedRoundRobinSchedulingAlgorithm.h +++ /dev/null @@ -1,34 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkWeightedRoundRobinSchedulingAlgorithm_h -#define mitkWeightedRoundRobinSchedulingAlgorithm_h - -#include "mitkSchedulingAlgorithmBase.h" - -namespace mitk -{ - class WeightedRoundRobinSchedulingAlgorithm : public SchedulingAlgorithmBase - { - public: - WeightedRoundRobinSchedulingAlgorithm(); - ~WeightedRoundRobinSchedulingAlgorithm(); - - SchedulableProcess* GetNextProcess(std::vector& processQueue) override; - }; -} - -#endif diff --git a/Plugins/PluginList.cmake b/Plugins/PluginList.cmake index 6365beaa12..5a9b0f4d48 100644 --- a/Plugins/PluginList.cmake +++ b/Plugins/PluginList.cmake @@ -1,101 +1,99 @@ # Plug-ins must be ordered according to their dependencies set(MITK_PLUGINS org.blueberry.core.runtime:ON org.blueberry.core.expressions:OFF org.blueberry.core.commands:OFF org.blueberry.core.jobs:OFF org.blueberry.ui.qt:OFF org.blueberry.ui.qt.help:ON org.blueberry.ui.qt.log:ON org.blueberry.ui.qt.objectinspector:OFF #org.blueberry.test:ON #org.blueberry.uitest:ON #Testing/org.blueberry.core.runtime.tests:ON #Testing/org.blueberry.osgi.tests:ON org.mitk.core.services:ON org.mitk.gui.common:ON org.mitk.planarfigure:ON org.mitk.core.ext:OFF org.mitk.core.jobs:OFF - org.mitk.simulation:OFF org.mitk.gui.qt.application:ON org.mitk.gui.qt.coreapplication:OFF org.mitk.gui.qt.ext:OFF org.mitk.gui.qt.extapplication:OFF org.mitk.gui.qt.common:ON org.mitk.gui.qt.stdmultiwidgeteditor:ON org.mitk.gui.qt.common.legacy:OFF org.mitk.gui.qt.cmdlinemodules:OFF org.mitk.gui.qt.diffusionimagingapp:OFF org.mitk.gui.qt.datamanager:ON org.mitk.gui.qt.datamanagerlight:OFF org.mitk.gui.qt.properties:ON org.mitk.gui.qt.basicimageprocessing:OFF org.mitk.gui.qt.dicom:OFF org.mitk.gui.qt.dicominspector:OFF org.mitk.gui.qt.diffusionimaging:OFF org.mitk.gui.qt.diffusionimaging.connectomics:OFF org.mitk.gui.qt.diffusionimaging.denoising:OFF org.mitk.gui.qt.diffusionimaging.fiberfox:OFF org.mitk.gui.qt.diffusionimaging.fiberprocessing:OFF org.mitk.gui.qt.diffusionimaging.ivim:OFF org.mitk.gui.qt.diffusionimaging.odfpeaks:OFF org.mitk.gui.qt.diffusionimaging.partialvolume:OFF org.mitk.gui.qt.diffusionimaging.preprocessing:OFF org.mitk.gui.qt.diffusionimaging.reconstruction:OFF org.mitk.gui.qt.diffusionimaging.registration:OFF org.mitk.gui.qt.diffusionimaging.tbss:OFF org.mitk.gui.qt.diffusionimaging.tractography:OFF org.mitk.gui.qt.dosevisualization:OFF org.mitk.gui.qt.geometrytools:OFF org.mitk.gui.qt.igtexamples:OFF org.mitk.gui.qt.igttracking:OFF org.mitk.gui.qt.lasercontrol:OFF org.mitk.gui.qt.openigtlink:OFF org.mitk.gui.qt.imagecropper:OFF org.mitk.gui.qt.imagenavigator:ON org.mitk.gui.qt.viewnavigator:OFF org.mitk.gui.qt.materialeditor:OFF org.mitk.gui.qt.measurementtoolbox:OFF org.mitk.gui.qt.moviemaker:OFF org.mitk.gui.qt.pointsetinteraction:OFF org.mitk.gui.qt.pointsetinteractionmultispectrum:OFF org.mitk.gui.qt.python:OFF org.mitk.gui.qt.remeshing:OFF org.mitk.gui.qt.segmentation:OFF - org.mitk.gui.qt.simulation:OFF org.mitk.gui.qt.aicpregistration:OFF org.mitk.gui.qt.renderwindowmanager:OFF org.mitk.gui.qt.toftutorial:OFF org.mitk.gui.qt.tofutil:OFF org.mitk.gui.qt.tubegraph:OFF org.mitk.gui.qt.ugvisualization:OFF org.mitk.gui.qt.ultrasound:OFF org.mitk.gui.qt.volumevisualization:OFF org.mitk.gui.qt.eventrecorder:OFF org.mitk.gui.qt.xnat:OFF org.mitk.gui.qt.igt.app.echotrack:OFF org.mitk.gui.qt.spectrocamrecorder:OFF org.mitk.gui.qt.classificationsegmentation:OFF org.mitk.gui.qt.overlaymanager:OFF org.mitk.gui.qt.igt.app.hummelprotocolmeasurements:OFF org.mitk.gui.qt.multilabelsegmentation:OFF org.mitk.matchpoint.core.helper:OFF org.mitk.gui.qt.matchpoint.algorithm.browser:OFF org.mitk.gui.qt.matchpoint.algorithm.control:OFF org.mitk.gui.qt.matchpoint.algorithm.batch:OFF org.mitk.gui.qt.matchpoint.mapper:OFF org.mitk.gui.qt.matchpoint.framereg:OFF org.mitk.gui.qt.matchpoint.visualizer:OFF org.mitk.gui.qt.matchpoint.evaluator:OFF org.mitk.gui.qt.matchpoint.manipulator:OFF org.mitk.gui.qt.photoacoustics.pausviewer:OFF org.mitk.gui.qt.photoacoustics.imageprocessing:OFF org.mitk.gui.qt.cest:OFF ) diff --git a/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt b/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt deleted file mode 100644 index 87a8a37ede..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(org_mitk_gui_qt_simulation) - -mitk_create_plugin( - EXPORT_DIRECTIVE SIMULATION_EXPORT - EXPORTED_INCLUDE_SUFFIXES src - MODULE_DEPENDS MitkQtWidgets MitkSimulation -) diff --git a/Plugins/org.mitk.gui.qt.simulation/files.cmake b/Plugins/org.mitk.gui.qt.simulation/files.cmake deleted file mode 100644 index 744bd1618c..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/files.cmake +++ /dev/null @@ -1,47 +0,0 @@ -set(SRC_CPP_FILES -) - -set(INTERNAL_CPP_FILES - org_mitk_gui_qt_simulation_Activator.cpp - QmitkBaseItemDelegate.cpp - QmitkBaseTreeWidget.cpp - QmitkNoEditItemDelegate.cpp - QmitkSceneTreeWidget.cpp - QmitkSimulationPreferencePage.cpp - QmitkSimulationView.cpp -) - -set(UI_FILES - src/internal/QmitkSimulationPreferencePageControls.ui - src/internal/QmitkSimulationViewControls.ui -) - -set(MOC_H_FILES - src/internal/org_mitk_gui_qt_simulation_Activator.h - src/internal/QmitkBaseItemDelegate.h - src/internal/QmitkBaseTreeWidget.h - src/internal/QmitkNoEditItemDelegate.h - src/internal/QmitkSceneTreeWidget.h - src/internal/QmitkSimulationPreferencePage.h - src/internal/QmitkSimulationView.h -) - -set(CACHED_RESOURCE_FILES - resources/SOFAIcon.png - plugin.xml -) - -set(QRC_FILES - resources/Simulation.qrc -) - -set(CPP_FILES -) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach() - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach() diff --git a/Plugins/org.mitk.gui.qt.simulation/manifest_headers.cmake b/Plugins/org.mitk.gui.qt.simulation/manifest_headers.cmake deleted file mode 100644 index 8ff31cfca6..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/manifest_headers.cmake +++ /dev/null @@ -1,5 +0,0 @@ -set(Plugin-Name "MITK Simulation") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.simulation org.mitk.gui.qt.datamanager) diff --git a/Plugins/org.mitk.gui.qt.simulation/plugin.xml b/Plugins/org.mitk.gui.qt.simulation/plugin.xml deleted file mode 100644 index 5c5526c5a7..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/plugin.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.simulation/resources/Node_16x16.png b/Plugins/org.mitk.gui.qt.simulation/resources/Node_16x16.png deleted file mode 100644 index 411df8608d..0000000000 Binary files a/Plugins/org.mitk.gui.qt.simulation/resources/Node_16x16.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.simulation/resources/Object_16x16.png b/Plugins/org.mitk.gui.qt.simulation/resources/Object_16x16.png deleted file mode 100644 index 4832b76336..0000000000 Binary files a/Plugins/org.mitk.gui.qt.simulation/resources/Object_16x16.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.simulation/resources/SOFAIcon.png b/Plugins/org.mitk.gui.qt.simulation/resources/SOFAIcon.png deleted file mode 100644 index 3e0ce703ea..0000000000 Binary files a/Plugins/org.mitk.gui.qt.simulation/resources/SOFAIcon.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.simulation/resources/Simulation.qrc b/Plugins/org.mitk.gui.qt.simulation/resources/Simulation.qrc deleted file mode 100644 index 2684648ed4..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/resources/Simulation.qrc +++ /dev/null @@ -1,8 +0,0 @@ - - - Node_16x16.png - Object_16x16.png - Slave_16x16.png - SOFAIcon.png - - diff --git a/Plugins/org.mitk.gui.qt.simulation/resources/Slave_16x16.png b/Plugins/org.mitk.gui.qt.simulation/resources/Slave_16x16.png deleted file mode 100644 index 77a02cd4fa..0000000000 Binary files a/Plugins/org.mitk.gui.qt.simulation/resources/Slave_16x16.png and /dev/null differ diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseItemDelegate.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseItemDelegate.cpp deleted file mode 100644 index 27c630c59b..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseItemDelegate.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "QmitkBaseItemDelegate.h" -#include - -using namespace sofa::defaulttype; -using namespace sofa::core::objectmodel; - -static inline BaseData* GetBaseData(const QModelIndex& index) -{ - return index.data(Qt::UserRole).value(); -} - -QmitkBaseItemDelegate::QmitkBaseItemDelegate(QObject* parent) - : QStyledItemDelegate(parent) -{ -} - -QmitkBaseItemDelegate::~QmitkBaseItemDelegate() -{ -} - -QWidget* QmitkBaseItemDelegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - BaseData* baseData = GetBaseData(index); - const AbstractTypeInfo* typeInfo = baseData->getValueTypeInfo(); - - if (typeInfo->name() == "bool") - { - assert(false && "Bool type is directly handled by QmitkBaseTreeWidget!"); - } - else if (typeInfo->size() == 1) - { - if (typeInfo->Integer() || typeInfo->Scalar() || typeInfo->Text()) - { - // TODO: TagSet - return QStyledItemDelegate::createEditor(parent, option, index); - } - - // TODO - } - else - { - // TODO - } - - return nullptr; -} - -void QmitkBaseItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -{ - QStyledItemDelegate::paint(painter, option, index); -} - -void QmitkBaseItemDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const -{ - QStyledItemDelegate::setEditorData(editor, index); -} - -void QmitkBaseItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const -{ - QStyledItemDelegate::setModelData(editor, model, index); -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseItemDelegate.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseItemDelegate.h deleted file mode 100644 index 3ec0e70969..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseItemDelegate.h +++ /dev/null @@ -1,39 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkBaseItemDelegate_h -#define QmitkBaseItemDelegate_h - -#include -#include - -class QmitkBaseItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - explicit QmitkBaseItemDelegate(QObject* parent = nullptr); - ~QmitkBaseItemDelegate(); - - QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; - void setEditorData(QWidget* editor, const QModelIndex& index) const override; - void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override; -}; - -Q_DECLARE_METATYPE(sofa::core::objectmodel::BaseData*) - -#endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseTreeWidget.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseTreeWidget.cpp deleted file mode 100644 index 8e0b67255c..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseTreeWidget.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include -#include "QmitkBaseTreeWidget.h" -#include "QmitkBaseItemDelegate.h" -#include "QmitkNoEditItemDelegate.h" -#include "QmitkSceneTreeWidget.h" - -QmitkBaseTreeWidget::QmitkBaseTreeWidget(QWidget* parent) - : QTreeWidget(parent), - m_Base(nullptr) -{ - this->setItemDelegateForColumn(0, new QmitkNoEditItemDelegate); - this->setItemDelegateForColumn(1, new QmitkBaseItemDelegate); - - this->setSortingEnabled(true); - this->header()->setSortIndicator(0, Qt::AscendingOrder); -} - -QmitkBaseTreeWidget::~QmitkBaseTreeWidget() -{ -} - -void QmitkBaseTreeWidget::clear() -{ - m_Base = nullptr; - m_GroupItemMap.clear(); - - QTreeWidget::clear(); -} - -void QmitkBaseTreeWidget::OnSelectedBaseChanged(Base* base) -{ - this->clear(); - - m_Base = base; - - if (base != nullptr) - this->FillTreeWidget(); -} - -void QmitkBaseTreeWidget::FillTreeWidget() -{ - const Base::VecData& dataFields = m_Base->getDataFields(); - - for (auto dataField = dataFields.begin(); dataField != dataFields.end(); ++dataField) - { - if (!(*dataField)->isDisplayed()) - continue; - - QString name = QString::fromStdString((*dataField)->getName()); - - if (name.isEmpty()) - continue; - - QString group = (*dataField)->getGroup(); - - if (!group.isEmpty() && !m_GroupItemMap.contains(group)) - m_GroupItemMap.insert(group, new QTreeWidgetItem(this, QStringList() << group)); - - QTreeWidgetItem* item = new QTreeWidgetItem(QStringList() << name); - item->setToolTip(0, (*dataField)->getHelp()); - - item->setFlags(!(*dataField)->isReadOnly() - ? item->flags() | Qt::ItemIsEditable - : Qt::ItemIsSelectable); - - QString type = QString::fromStdString((*dataField)->getValueTypeString()); - - if (type == "bool") - { - item->setFlags((item->flags() & ~Qt::EditRole) | Qt::ItemIsUserCheckable); - item->setCheckState(1, (*dataField)->getValueString() == "1" ? Qt::Checked : Qt::Unchecked); - } - else - { - if (type == "double" || type == "float" || type == "int" || type == "string" || type == "unsigned int") - { - item->setData(1, Qt::DisplayRole, QVariant::fromValue(QString::fromStdString((*dataField)->getValueString()))); - } - else - { - item->setData(1, Qt::DisplayRole, QVariant::fromValue("[" + type + "]")); - } - - item->setData(1, Qt::UserRole, QVariant::fromValue(*dataField)); - } - - if (group.isEmpty()) - { - this->addTopLevelItem(item); - } - else - { - m_GroupItemMap[group]->addChild(item); - } - } - - this->setRootIsDecorated(!m_GroupItemMap.isEmpty()); - this->expandAll(); -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseTreeWidget.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseTreeWidget.h deleted file mode 100644 index 730695631f..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkBaseTreeWidget.h +++ /dev/null @@ -1,60 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkBaseTreeWidget_h -#define QmitkBaseTreeWidget_h - -#include -#include - -namespace sofa -{ - namespace core - { - namespace objectmodel - { - class Base; - } - } -} - -class QmitkSceneTreeWidget; - -class QmitkBaseTreeWidget : public QTreeWidget -{ - Q_OBJECT - -public: - typedef sofa::core::objectmodel::Base Base; - - explicit QmitkBaseTreeWidget(QWidget* parent = nullptr); - ~QmitkBaseTreeWidget(); - - // QTreeWidget, QTreeView, and QAbstractItemView Interfaces ///////////////// - void clear(); - ///////////////////////////////////////////////////////////////////////////// - -public slots: - void OnSelectedBaseChanged(Base* base); - -private: - void FillTreeWidget(); - - Base* m_Base; - QMap m_GroupItemMap; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkNoEditItemDelegate.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkNoEditItemDelegate.cpp deleted file mode 100644 index 7685bf5ffc..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkNoEditItemDelegate.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "QmitkNoEditItemDelegate.h" - -QmitkNoEditItemDelegate::QmitkNoEditItemDelegate(QObject* parent) - : QStyledItemDelegate(parent) -{ -} - -QmitkNoEditItemDelegate::~QmitkNoEditItemDelegate() -{ -} - -QWidget* QmitkNoEditItemDelegate::createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const -{ - return nullptr; -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkNoEditItemDelegate.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkNoEditItemDelegate.h deleted file mode 100644 index 67bb3fcb82..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkNoEditItemDelegate.h +++ /dev/null @@ -1,33 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkNoEditItemDelegate_h -#define QmitkNoEditItemDelegate_h - -#include - -class QmitkNoEditItemDelegate : public QStyledItemDelegate -{ - Q_OBJECT - -public: - explicit QmitkNoEditItemDelegate(QObject* parent = nullptr); - ~QmitkNoEditItemDelegate(); - - QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSceneTreeWidget.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSceneTreeWidget.cpp deleted file mode 100644 index c3946e27a3..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSceneTreeWidget.cpp +++ /dev/null @@ -1,384 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "QmitkSceneTreeWidget.h" -#include -#include -#include -#include - -template -static inline T* as(QmitkSceneTreeWidget::Base* base) -{ - return dynamic_cast(base); -} - -template -static inline bool is(QmitkSceneTreeWidget::Base* base) -{ - return dynamic_cast(base) != nullptr; -} - -template -static inline bool is(QmitkSceneTreeWidget::Base* base) -{ - return is(base) || is(base); -} - -template -static inline bool is(QmitkSceneTreeWidget::Base* base) -{ - return is(base) || is(base) || is(base); -} - -static inline bool isBaseInteractionForceField(QmitkSceneTreeWidget::Base* base) -{ - sofa::core::behavior::BaseInteractionForceField* iff = dynamic_cast(base); - return iff != nullptr && iff->getMechModel1() != iff->getMechModel2(); -} - -static inline bool isMechanicalMapping(QmitkSceneTreeWidget::Base* base) -{ - sofa::core::BaseMapping* mm = dynamic_cast(base); - return mm != nullptr && mm->isMechanical(); -} - -static QRgb GetColor(QmitkSceneTreeWidget::Base* base) -{ - using namespace sofa::core; - using namespace sofa::core::behavior; - using namespace sofa::core::collision; - using namespace sofa::core::loader; - using namespace sofa::core::objectmodel; - using namespace sofa::core::topology; - using namespace sofa::core::visual; - using namespace sofa::simulation::Colors; - - QString hexColor; - - if (is(base)) - { - hexColor = COLOR[NODE]; - } - else if (is(base)) - { - if (is(base)) - hexColor = COLOR[sofa::simulation::Colors::CONTEXT]; - else if (is(base)) - hexColor = COLOR[BMODEL]; - else if (is(base)) - hexColor = COLOR[CMODEL]; - else if (is(base)) - hexColor = COLOR[MMODEL]; - else if (is(base)) - hexColor = COLOR[PROJECTIVECONSTRAINTSET]; - else if (is(base)) - hexColor = COLOR[CONSTRAINTSET]; - else if (is(base)) - hexColor = COLOR[MASS]; - else if (isBaseInteractionForceField(base)) - hexColor = COLOR[IFFIELD]; - else if (is(base)) - hexColor = COLOR[FFIELD]; - else if (is(base)) - hexColor = COLOR[SOLVER]; - else if (is(base)) - hexColor = COLOR[COLLISION]; - else if (isMechanicalMapping(base)) - hexColor = COLOR[MMAPPING]; - else if (is(base)) - hexColor = COLOR[MAPPING]; - else if (is(base)) - hexColor = COLOR[TOPOLOGY]; - else if (is(base)) - hexColor = COLOR[LOADER]; - else if (is(base)) - hexColor = COLOR[CONFIGURATIONSETTING]; - else if (is(base)) - hexColor = COLOR[VMODEL]; - else - hexColor = COLOR[OBJECT]; - } - else - { - hexColor = "#000"; - } - - QColor color; - color.setNamedColor(hexColor); - - return color.rgb(); -} - -static QPixmap ReplaceColor(const QPixmap& pixmap, QRgb from, QRgb to) -{ - QImage image = pixmap.toImage(); - - const int width = image.width(); - const int height = image.height(); - int x, y; - - for (y = 0; y < height; ++y) - { - for (x = 0; x < width; ++x) - { - if (image.pixel(x, y) == from) - image.setPixel(x, y, to); - } - } - - return QPixmap::fromImage(image); -} - -static inline QIcon CreateObjectIcon(QmitkSceneTreeWidget::Base* base) -{ - return QIcon(ReplaceColor(QPixmap(":/Simulation/Object"), 0xff00ff00, GetColor(base))); -} - -static inline QIcon CreateNodeIcon(QmitkSceneTreeWidget::BaseNode* node) -{ - return QIcon(ReplaceColor(QPixmap(":/Simulation/Node"), 0xff00ff00, GetColor(node))); -} - -static inline QIcon CreateSlaveIcon(QmitkSceneTreeWidget::Base* base) -{ - return QIcon(ReplaceColor(QPixmap(":/Simulation/Slave"), 0xff00ff00, GetColor(base))); -} - -static inline QString GetName(QmitkSceneTreeWidget::Base* base) -{ - return QString::fromStdString(base->getName()); -} - -static inline QString GetClassName(QmitkSceneTreeWidget::Base* base) -{ - return QString::fromStdString(base->getClassName()); -} - -QmitkSceneTreeWidget::QmitkSceneTreeWidget(QWidget* parent) - : QTreeWidget(parent) -{ -} - -QmitkSceneTreeWidget::~QmitkSceneTreeWidget() -{ -} - -void QmitkSceneTreeWidget::clear() -{ - QTreeWidgetItem* rootItem = this->topLevelItem(0); - - if (rootItem != nullptr) - this->removeChild(nullptr, as(m_ItemBaseMap[rootItem])); - - this->ClearMaps(); - - QTreeWidget::clear(); -} - -void QmitkSceneTreeWidget::addChild(Node* parent, Node* child) -{ - assert(child != nullptr && "Child node is nullptr!"); - assert(!m_BaseItemMap.contains(child) && "TODO: Support nodes with multiple parents!"); - - QTreeWidgetItem* item; - - if (parent == nullptr) - { - item = new QTreeWidgetItem(QStringList() << GetName(child)); - this->addTopLevelItem(item); - } - else - { - assert(m_BaseItemMap.contains(parent) && "Unknown parent node!"); - item = new QTreeWidgetItem(m_BaseItemMap[parent], QStringList() << GetName(child)); - } - - item->setIcon(0, CreateNodeIcon(child)); - this->InsertIntoMaps(child, item); - - MutationListener::addChild(parent, child); -} - -void QmitkSceneTreeWidget::removeChild(Node* parent, Node* child) -{ - assert(child != nullptr && "Child node is nullptr!"); - assert(m_BaseItemMap.contains(child) && "Child node has already been removed!"); - - MutationListener::removeChild(parent, child); - - if (parent == nullptr) - { - delete m_BaseItemMap[child]; - } - else - { - assert(m_BaseItemMap.contains(parent) && "Unknown parent node!"); - m_BaseItemMap[parent]->removeChild(m_BaseItemMap[child]); - } - - this->RemoveFromMaps(child); -} - -void QmitkSceneTreeWidget::moveChild(Node* previous, Node* parent, Node* child) -{ - if (previous == nullptr) - { - this->addChild(parent, child); - } - else if (parent == nullptr) - { - this->removeChild(previous, child); - } - else - { - assert(child != nullptr && "Child node is nullptr!"); - assert(m_BaseItemMap.contains(previous) && "Unknown previous parent node!"); - assert(m_BaseItemMap.contains(parent) && "Unknown parent node!"); - assert(m_BaseItemMap.contains(child) && "Unknown child node!"); - - QTreeWidgetItem* previousItem = m_BaseItemMap[previous]; - m_BaseItemMap[parent]->addChild(previousItem->takeChild(previousItem->indexOfChild(m_BaseItemMap[child]))); - } -} - -void QmitkSceneTreeWidget::addObject(Node* parent, BaseObject* object) -{ - assert(parent != nullptr && "Parent node is nullptr!"); - assert(object != nullptr && "Object is nullptr!"); - assert(m_BaseItemMap.contains(parent) && "Unknown parent node!"); - // assert(!m_BaseItemMap.contains(object) && "Object has already been added!"); - - if (!m_BaseItemMap.contains(object)) - { - QTreeWidgetItem* item = new QTreeWidgetItem(m_BaseItemMap[parent], QStringList() << GetName(object)); - item->setToolTip(0, GetClassName(object)); - item->setIcon(0, CreateObjectIcon(object)); - this->InsertIntoMaps(object, item); - } - - MutationListener::addObject(parent, object); -} - -void QmitkSceneTreeWidget::removeObject(Node* parent, BaseObject* object) -{ - assert(parent != nullptr && "Parent node is nullptr!"); - assert(object != nullptr && "Object is nullptr!"); - assert(m_BaseItemMap.contains(parent) && "Unknown parent node!"); - assert(m_BaseItemMap.contains(object) && "Object has already been removed!"); - - MutationListener::removeObject(parent, object); - - m_BaseItemMap[parent]->removeChild(m_BaseItemMap[object]); - this->RemoveFromMaps(object); -} - -void QmitkSceneTreeWidget::moveObject(Node* previous, Node* parent, BaseObject* object) -{ - if (previous == nullptr) - { - this->addObject(parent, object); - } - else if (parent == nullptr) - { - this->removeObject(previous, object); - } - else - { - assert(object != nullptr && "Object is nullptr!"); - assert(m_BaseItemMap.contains(previous) && "Unknown previous parent node!"); - assert(m_BaseItemMap.contains(parent) && "Unknown parent node!"); - assert(m_BaseItemMap.contains(object) && "Unknown object!"); - - QTreeWidgetItem* previousItem = m_BaseItemMap[previous]; - m_BaseItemMap[parent]->addChild(previousItem->takeChild(previousItem->indexOfChild(m_BaseItemMap[object]))); - } -} - -void QmitkSceneTreeWidget::addSlave(BaseObject* master, BaseObject* slave) -{ - assert(master != nullptr && "Master object is nullptr!"); - assert(slave != nullptr && "Slave object is nullptr!"); - assert(m_BaseItemMap.contains(master) && "Unknown master object!"); - assert(!m_BaseItemMap.contains(slave) && "Slave object has already been added!"); - - QTreeWidgetItem* item = new QTreeWidgetItem(m_BaseItemMap[master], QStringList() << GetName(slave)); - item->setToolTip(0, GetClassName(slave)); - item->setIcon(0, CreateSlaveIcon(slave)); - this->InsertIntoMaps(slave, item); - - MutationListener::addSlave(master, slave); -} - -void QmitkSceneTreeWidget::removeSlave(BaseObject* master, BaseObject* slave) -{ - assert(master != nullptr && "Master object is nullptr!"); - assert(slave != nullptr && "Slave object is nullptr!"); - assert(m_BaseItemMap.contains(master) && "Unknown master object!"); - assert(m_BaseItemMap.contains(slave) && "Slave object has already been removed!"); - - MutationListener::removeSlave(master, slave); - - m_BaseItemMap[master]->removeChild(m_BaseItemMap[slave]); - this->RemoveFromMaps(slave); -} - -void QmitkSceneTreeWidget::moveSlave(BaseObject* previousMaster, BaseObject* master, BaseObject* slave) -{ - if (previousMaster == nullptr) - { - this->addSlave(master, slave); - } - else if (master == nullptr) - { - this->removeSlave(previousMaster, slave); - } - else - { - assert(slave != nullptr && "Slave object is nullptr!"); - assert(m_BaseItemMap.contains(previousMaster) && "Unknown previous master object!"); - assert(m_BaseItemMap.contains(master) && "Unknown master object!"); - assert(m_BaseItemMap.contains(slave) && "Unknown slave object!"); - - QTreeWidgetItem* previousMasterItem = m_BaseItemMap[previousMaster]; - m_BaseItemMap[master]->addChild(previousMasterItem->takeChild(previousMasterItem->indexOfChild(m_BaseItemMap[slave]))); - } -} - -QmitkSceneTreeWidget::Base* QmitkSceneTreeWidget::GetBaseFromItem(QTreeWidgetItem* item) const -{ - return m_ItemBaseMap.contains(item) - ? m_ItemBaseMap[item] - : nullptr; -} - -void QmitkSceneTreeWidget::ClearMaps() -{ - m_BaseItemMap.clear(); - m_ItemBaseMap.clear(); -} - -void QmitkSceneTreeWidget::InsertIntoMaps(Base* base, QTreeWidgetItem* item) -{ - m_BaseItemMap.insert(base, item); - m_ItemBaseMap.insert(item, base); -} - -void QmitkSceneTreeWidget::RemoveFromMaps(Base* base) -{ - m_ItemBaseMap.remove(m_BaseItemMap[base]); - m_BaseItemMap.remove(base); -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSceneTreeWidget.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSceneTreeWidget.h deleted file mode 100644 index 09fe9f431e..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSceneTreeWidget.h +++ /dev/null @@ -1,82 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkSceneTreeWidget_h -#define QmitkSceneTreeWidget_h - -#include -#include -#include - -namespace sofa -{ - namespace core - { - namespace objectmodel - { - class Base; - class BaseNode; - class BaseObject; - } - } - - namespace simulation - { - class Node; - } -} - -class QmitkSceneTreeWidget : public QTreeWidget, public sofa::simulation::MutationListener -{ - Q_OBJECT - -public: - typedef sofa::core::objectmodel::Base Base; - typedef sofa::core::objectmodel::BaseNode BaseNode; - typedef sofa::core::objectmodel::BaseObject BaseObject; - typedef sofa::simulation::Node Node; - - explicit QmitkSceneTreeWidget(QWidget* parent = nullptr); - ~QmitkSceneTreeWidget(); - - Base* GetBaseFromItem(QTreeWidgetItem* item) const; - - // QTreeWidget, QTreeView, and QAbstractItemView Interfaces ///////////////// - void clear(); - ///////////////////////////////////////////////////////////////////////////// - - // MutationListener Interface /////////////////////////////////////////////// - void addChild(Node* parent, Node* child) override; - void removeChild(Node* parent, Node* child) override; - void moveChild(Node* previous, Node* parent, Node* child) override; - void addObject(Node* parent, BaseObject* object) override; - void removeObject(Node* parent, BaseObject* object) override; - void moveObject(Node* previous, Node* parent, BaseObject* object) override; - void addSlave(BaseObject* master, BaseObject* slave) override; - void removeSlave(BaseObject* master, BaseObject* slave) override; - void moveSlave(BaseObject* previousMaster, BaseObject* master, BaseObject* slave) override; - ///////////////////////////////////////////////////////////////////////////// - -private: - void ClearMaps(); - void InsertIntoMaps(Base* base, QTreeWidgetItem* item); - void RemoveFromMaps(Base* base); - - QMap m_BaseItemMap; - QMap m_ItemBaseMap; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePage.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePage.cpp deleted file mode 100644 index 0ec393bfd4..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePage.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "QmitkSimulationPreferencePage.h" -#include -#include -#include -#include - -typedef sofa::helper::system::Plugin Plugin; -typedef sofa::helper::system::PluginManager PluginManager; -typedef sofa::helper::system::PluginManager::PluginIterator PluginIterator; -typedef sofa::helper::system::PluginManager::PluginMap PluginMap; - -QmitkSimulationPreferencePage::QmitkSimulationPreferencePage() - : m_Preferences(mitk::GetSimulationPreferences()), - m_Control(nullptr) -{ -} - -QmitkSimulationPreferencePage::~QmitkSimulationPreferencePage() -{ -} - -void QmitkSimulationPreferencePage::CreateQtControl(QWidget* parent) -{ - m_Control = new QWidget(parent); - m_Controls.setupUi(m_Control); - - QStringList headerLabels; - headerLabels << "Name" << "License" << "Version" << "Path"; - m_Controls.pluginsTreeWidget->setHeaderLabels(headerLabels); - - connect(m_Controls.pluginsTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnSelectedPluginChanged())); - connect(m_Controls.addButton, SIGNAL(clicked()), this, SLOT(OnAddButtonClicked())); - connect(m_Controls.removeButton, SIGNAL(clicked()), this, SLOT(OnRemoveButtonClicked())); - - this->Update(); -} - -QWidget* QmitkSimulationPreferencePage::GetQtControl() const -{ - return m_Control; -} - -void QmitkSimulationPreferencePage::Init(berry::IWorkbench::Pointer) -{ -} - -void QmitkSimulationPreferencePage::OnAddButtonClicked() -{ - QString filter = "SOFA Plugins "; - -#if defined(__APPLE__) - filter += "(*.dylib*)"; -#elif defined(WIN32) - filter += "(*.dll)"; -#else - filter += "(*.so)"; -#endif - - std::string path = QFileDialog::getOpenFileName(m_Control, "Add SOFA Plugin", "", filter).toStdString(); - - if (path.empty()) - return; - - PluginManager &pluginManager = PluginManager::getInstance(); - std::ostringstream errlog; - - if (pluginManager.loadPlugin(path, &errlog)) - { - if (!errlog.str().empty()) - { - auto messageBox = new QMessageBox(m_Control); - messageBox->setIcon(QMessageBox::Warning); - messageBox->setStandardButtons(QMessageBox::Ok); - messageBox->setText(errlog.str().c_str()); - messageBox->setWindowTitle("Warning"); - messageBox->show(); - } - - Plugin& plugin = pluginManager.getPluginMap()[path]; - plugin.initExternalModule(); - - QStringList pluginItem; - - pluginItem - << plugin.getModuleName() - << plugin.getModuleLicense() - << plugin.getModuleVersion() - << path.c_str(); - - m_Controls.pluginsTreeWidget->addTopLevelItem(new QTreeWidgetItem(pluginItem)); - } - else - { - auto messageBox = new QMessageBox(m_Control); - messageBox->setIcon(QMessageBox::Critical); - messageBox->setStandardButtons(QMessageBox::Ok); - messageBox->setText(errlog.str().c_str()); - messageBox->setWindowTitle("Error"); - messageBox->show(); - } -} - -void QmitkSimulationPreferencePage::OnSelectedPluginChanged() -{ - QList selectedItems = m_Controls.pluginsTreeWidget->selectedItems(); - - m_Controls.componentsListWidget->clear(); - - if (!selectedItems.isEmpty()) - { - PluginMap& pluginMap = sofa::helper::system::PluginManager::getInstance().getPluginMap(); - std::string path = selectedItems[0]->text(3).toStdString(); - - m_Controls.descriptionPlainTextEdit->setPlainText(pluginMap[path].getModuleDescription()); - m_Controls.componentsListWidget->addItems(QString(pluginMap[path].getModuleComponentList()).split(' ', QString::SkipEmptyParts)); - m_Controls.removeButton->setEnabled(true); - } - else - { - m_Controls.descriptionPlainTextEdit->clear(); - m_Controls.removeButton->setEnabled(false); - } -} - -void QmitkSimulationPreferencePage::OnRemoveButtonClicked() -{ - QList selectedItems = m_Controls.pluginsTreeWidget->selectedItems(); - - if (selectedItems.isEmpty()) - return; - - std::string path = selectedItems[0]->text(3).toStdString(); - - PluginManager& pluginManager = PluginManager::getInstance(); - std::ostringstream errlog; - - if (pluginManager.unloadPlugin(path, &errlog)) - { - delete selectedItems[0]; - } - else - { - auto messageBox = new QMessageBox(m_Control); - messageBox->setIcon(QMessageBox::Critical); - messageBox->setStandardButtons(QMessageBox::Ok); - messageBox->setText(errlog.str().c_str()); - messageBox->setWindowTitle("Error"); - messageBox->show(); - } -} - -void QmitkSimulationPreferencePage::PerformCancel() -{ -} - -bool QmitkSimulationPreferencePage::PerformOk() -{ - PluginManager& pluginManager = PluginManager::getInstance(); - PluginMap& pluginMap = pluginManager.getPluginMap(); - QString plugins; - - for (auto it = pluginMap.begin(); it != pluginMap.end(); ++it) - { - if (!plugins.isEmpty()) - plugins += ";"; - - plugins += QString::fromStdString(it->first); - } - - m_Preferences->Put("plugins", plugins); - return true; -} - -void QmitkSimulationPreferencePage::Update() -{ - PluginManager& pluginManager = PluginManager::getInstance(); - PluginMap& pluginMap = pluginManager.getPluginMap(); - - for (auto it = pluginMap.begin(); it != pluginMap.end(); ++it) - { - Plugin& plugin = it->second; - - QStringList pluginItem; - - pluginItem - << plugin.getModuleName() - << plugin.getModuleLicense() - << plugin.getModuleVersion() - << it->first.c_str(); - - m_Controls.pluginsTreeWidget->addTopLevelItem(new QTreeWidgetItem(pluginItem)); - } -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePage.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePage.h deleted file mode 100644 index 291fe656d3..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePage.h +++ /dev/null @@ -1,52 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkSimulationPreferencePage_h -#define QmitkSimulationPreferencePage_h - -#include -#include -#include -#include - -class SIMULATION_EXPORT QmitkSimulationPreferencePage : public QObject, public berry::IQtPreferencePage -{ - Q_OBJECT - Q_INTERFACES(berry::IPreferencePage); - -public: - QmitkSimulationPreferencePage(); - ~QmitkSimulationPreferencePage(); - - void CreateQtControl(QWidget* parent) override; - QWidget* GetQtControl() const override; - void Init(berry::IWorkbench::Pointer) override; - void PerformCancel() override; - bool PerformOk() override; - void Update() override; - -private slots: - void OnAddButtonClicked(); - void OnSelectedPluginChanged(); - void OnRemoveButtonClicked(); - -private: - berry::IPreferences::Pointer m_Preferences; - Ui::QmitkSimulationPreferencePageControls m_Controls; - QWidget* m_Control; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePageControls.ui b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePageControls.ui deleted file mode 100644 index a7320be2ce..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationPreferencePageControls.ui +++ /dev/null @@ -1,157 +0,0 @@ - - - QmitkSimulationPreferencePageControls - - - - 0 - 0 - 640 - 480 - - - - - - - Plugins - - - - - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - 0 - - - false - - - false - - - true - - - false - - - 4 - - - false - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - - - - - - Components - - - - - - - Description - - - - - - - true - - - - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::NoSelection - - - QAbstractItemView::SelectRows - - - true - - - - - - - - - - - Add... - - - - - - - false - - - Remove - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp deleted file mode 100644 index cdbc729651..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "org_mitk_gui_qt_simulation_Activator.h" -#include "QmitkBaseItemDelegate.h" -#include "QmitkNoEditItemDelegate.h" -#include "QmitkSimulationView.h" -#include -#include -#include -#include -#include -#include -#include - -template -static T* GetService() -{ - ctkPluginContext* context = mitk::org_mitk_gui_qt_simulation_Activator::GetContext(); - - if (context == nullptr) - return nullptr; - - ctkServiceReference serviceReference = context->getServiceReference(); - - return serviceReference - ? context->getService(serviceReference) - : nullptr; -} - -static mitk::SimulationInteractor::Pointer CreateSimulationInteractor() -{ - const us::Module* simulationModule = us::ModuleRegistry::GetModule("MitkSimulation"); - - mitk::SimulationInteractor::Pointer interactor = mitk::SimulationInteractor::New(); - interactor->LoadStateMachine("Simulation.xml", simulationModule); - interactor->SetEventConfig("SimulationConfig.xml", simulationModule); - - return interactor; -} - -class Equals -{ -public: - explicit Equals(mitk::DataNode::Pointer dataNode) - : m_DataNode(dataNode) - { - } - - bool operator()(const mitk::DataStorage::SetOfObjects::value_type& object) - { - return object == m_DataNode; - } - -private: - mitk::DataNode::Pointer m_DataNode; -}; - -QmitkSimulationView::QmitkSimulationView() - : m_SimulationService(GetService()), - m_Interactor(CreateSimulationInteractor()), - m_VtkModelContextMenu(nullptr), - m_Timer(this) -{ - this->GetDataStorage()->RemoveNodeEvent.AddListener( - mitk::MessageDelegate1(this, &QmitkSimulationView::OnNodeRemovedFromDataStorage)); - - connect(&m_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout())); -} - -QmitkSimulationView::~QmitkSimulationView() -{ - this->GetDataStorage()->RemoveNodeEvent.RemoveListener( - mitk::MessageDelegate1(this, &QmitkSimulationView::OnNodeRemovedFromDataStorage)); -} - -void QmitkSimulationView::CreateQtPartControl(QWidget* parent) -{ - m_Ui.setupUi(parent); - - m_Ui.simulationComboBox->SetDataStorage(this->GetDataStorage()); - m_Ui.simulationComboBox->SetPredicate(mitk::NodePredicateDataType::New("Simulation")); - - QAction* vtkModelModeAction = new QAction(/*QIcon(":/Qmitk/Surface_48.png"),*/ "Render to Surface", m_VtkModelContextMenu); - vtkModelModeAction->setCheckable(true); - - m_VtkModelContextMenu = new QMenu(m_Ui.sceneTreeWidget); - m_VtkModelContextMenu->addAction(vtkModelModeAction); - - connect(m_Ui.simulationComboBox, SIGNAL(OnSelectionChanged(const mitk::DataNode*)), this, SLOT(OnSelectedSimulationChanged(const mitk::DataNode*))); - connect(m_Ui.animateButton, SIGNAL(toggled(bool)), this, SLOT(OnAnimateButtonToggled(bool))); - connect(m_Ui.stepButton, SIGNAL(clicked()), this, SLOT(OnStepButtonClicked())); - connect(m_Ui.resetButton, SIGNAL(clicked()), this, SLOT(OnResetButtonClicked())); - connect(m_Ui.dtSpinBox, SIGNAL(valueChanged(double)), this, SLOT(OnDtChanged(double))); - connect(m_Ui.sceneTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(OnSelectedBaseChanged())); - connect(m_Ui.sceneTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(OnBaseContextMenuRequested(const QPoint&))); - - if (m_Ui.simulationComboBox->GetSelectedNode().IsNotNull()) - { - this->OnSelectedSimulationChanged(m_Ui.simulationComboBox->GetSelectedNode()); - } - else - { - this->SetSimulationControlsEnabled(false); - } -} - -void QmitkSimulationView::OnAnimateButtonToggled(bool toggled) -{ - mitk::Scheduler* scheduler = m_SimulationService->GetScheduler(); - - if (toggled) - { - mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); - - simulation->SetAnimationFlag(true); - scheduler->AddProcess(simulation); - - m_Ui.stepButton->setEnabled(false); - } - else if (m_Selection.IsNotNull()) - { - mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); - - scheduler->RemoveProcess(simulation); - simulation->SetAnimationFlag(false); - - m_Ui.stepButton->setEnabled(true); - } - - if (!scheduler->IsEmpty()) - { - if (!m_Timer.isActive()) - m_Timer.start(0); - } - else - { - m_Timer.stop(); - } -} - -void QmitkSimulationView::OnBaseContextMenuRequested(const QPoint& point) -{ - typedef mitk::DataStorage::SetOfObjects SetOfObjects; - - QTreeWidgetItem* item = m_Ui.sceneTreeWidget->itemAt(point); - - if (item == nullptr) - return; - - QmitkSceneTreeWidget::Base* base = m_Ui.sceneTreeWidget->GetBaseFromItem(item); - - if (base == nullptr) - return; - - mitk::VtkModel* vtkModel = dynamic_cast(base); - - if (vtkModel == nullptr) - return; - - m_VtkModelContextMenu->actions().first()->setChecked(vtkModel->GetMode() == mitk::VtkModel::Surface); - - QAction* action = m_VtkModelContextMenu->exec(m_Ui.sceneTreeWidget->mapToGlobal(point)); - - if (action == nullptr) - return; - - if (action->text() == "Render to Surface") - { - mitk::DataStorage::Pointer dataStorage = this->GetDataStorage(); - SetOfObjects::ConstPointer objects = dataStorage->GetSubset(nullptr); - - if (action->isChecked()) - { - vtkModel->SetMode(mitk::VtkModel::Surface); - mitk::DataNode::Pointer dataNode = vtkModel->GetDataNode(); - - if (std::find_if(objects->begin(), objects->end(), Equals(dataNode)) == objects->end()) - dataStorage->Add(dataNode, m_Selection); - } - else - { - mitk::DataNode::Pointer dataNode = vtkModel->GetDataNode(); - - if (std::find_if(objects->begin(), objects->end(), Equals(dataNode)) != objects->end()) - dataStorage->Remove(dataNode); - - vtkModel->SetMode(mitk::VtkModel::OpenGL); - } - } -} - -void QmitkSimulationView::OnDtChanged(double dt) -{ - if (m_Selection.IsNull()) - return; - - mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); - simulation->SetDt(std::max(0.0, dt)); -} - -void QmitkSimulationView::OnNodeRemovedFromDataStorage(const mitk::DataNode* node) -{ - mitk::Simulation::Pointer simulation = dynamic_cast(node->GetData()); - - if (simulation.IsNotNull()) - { - mitk::Scheduler* scheduler = m_SimulationService->GetScheduler(); - - scheduler->RemoveProcess(simulation); - - if (scheduler->IsEmpty() && m_Timer.isActive()) - m_Timer.stop(); - - if (m_SimulationService->GetActiveSimulation() == simulation) - m_SimulationService->SetActiveSimulation(nullptr); - } -} - -void QmitkSimulationView::OnResetButtonClicked() -{ - mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); - m_SimulationService->SetActiveSimulation(simulation); - - m_Ui.dtSpinBox->setValue(simulation->GetRootNode()->getDt()); - simulation->Reset(); - - this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_ALL); -} - -void QmitkSimulationView::OnSelectedSimulationChanged(const mitk::DataNode* node) -{ - if (node != nullptr) - { - m_Selection = m_Ui.simulationComboBox->GetSelectedNode(); - mitk::Simulation* simulation = static_cast(m_Selection->GetData()); - - m_Ui.animateButton->setChecked(simulation->GetAnimationFlag()); - m_Ui.dtSpinBox->setValue(simulation->GetRootNode()->getDt()); - this->SetSimulationControlsEnabled(true); - } - else - { - m_Selection = nullptr; - - this->SetSimulationControlsEnabled(false); - m_Ui.animateButton->setChecked(false); - m_Ui.dtSpinBox->setValue(0.0); - } - - m_Interactor->SetDataNode(m_Selection); - - this->ResetSceneTreeWidget(); -} - -void QmitkSimulationView::OnSelectedBaseChanged() -{ - QList selectedBaseItems = m_Ui.sceneTreeWidget->selectedItems(); - - m_Ui.baseTreeWidget->OnSelectedBaseChanged(!selectedBaseItems.isEmpty() - ? m_Ui.sceneTreeWidget->GetBaseFromItem(selectedBaseItems[0]) - : nullptr); -} - -void QmitkSimulationView::OnStep(bool renderWindowUpdate) -{ - mitk::Scheduler* scheduler = m_SimulationService->GetScheduler(); - mitk::Simulation::Pointer simulation = dynamic_cast(scheduler->GetNextProcess()); - - m_SimulationService->SetActiveSimulation(simulation); - - if (simulation.IsNotNull()) - simulation->Animate(); - - if (renderWindowUpdate) - this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_ALL); -} - -void QmitkSimulationView::OnStepButtonClicked() -{ - if (m_Selection.IsNull()) - return; - - mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); - - m_SimulationService->SetActiveSimulation(simulation); - simulation->Animate(); - - this->RequestRenderWindowUpdate(mitk::RenderingManager::REQUEST_UPDATE_ALL); -} - -void QmitkSimulationView::OnTimeout() -{ - QTime currentTime = QTime::currentTime(); - - if (currentTime.msecsTo(m_NextRenderWindowUpdate) > 0) - { - this->OnStep(false); - } - else - { - m_NextRenderWindowUpdate = currentTime.addMSecs(MSecsPerFrame); - this->OnStep(true); - } -} - -void QmitkSimulationView::ResetSceneTreeWidget() -{ - m_Ui.sceneTreeWidget->clear(); - - if (m_Selection.IsNull()) - return; - - mitk::Simulation::Pointer simulation = static_cast(m_Selection->GetData()); - - m_Ui.sceneTreeWidget->addChild(nullptr, simulation->GetRootNode().get()); - m_Ui.sceneTreeWidget->expandItem(m_Ui.sceneTreeWidget->topLevelItem(0)); -} - -void QmitkSimulationView::SetSimulationControlsEnabled(bool enabled) -{ - m_Ui.animateButton->setEnabled(enabled); - m_Ui.stepButton->setEnabled(enabled); - m_Ui.resetButton->setEnabled(enabled); - m_Ui.dtLabel->setEnabled(enabled); - m_Ui.dtSpinBox->setEnabled(enabled); -} - -void QmitkSimulationView::SetFocus() -{ - m_Ui.animateButton->setFocus(); -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h deleted file mode 100644 index 6e33c1904e..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationView.h +++ /dev/null @@ -1,70 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef QmitkSimulationView_h -#define QmitkSimulationView_h - -#include -#include -#include -#include -#include -#include - -namespace mitk -{ - class ISimulationService; -} - -class QmitkSimulationView : public QmitkAbstractView -{ - Q_OBJECT - -public: - QmitkSimulationView(); - ~QmitkSimulationView(); - - void CreateQtPartControl(QWidget* parent) override; - void SetFocus() override; - -private slots: - void OnAnimateButtonToggled(bool toggled); - void OnBaseContextMenuRequested(const QPoint& point); - void OnDtChanged(double dt); - void OnResetButtonClicked(); - void OnSelectedSimulationChanged(const mitk::DataNode* node); - void OnSelectedBaseChanged(); - void OnStep(bool renderWindowUpdate); - void OnStepButtonClicked(); - void OnTimeout(); - -private: - void OnNodeRemovedFromDataStorage(const mitk::DataNode* node); - void ResetSceneTreeWidget(); - void SetSimulationControlsEnabled(bool enabled); - - static const int MSecsPerFrame = 17; - - Ui::QmitkSimulationViewControls m_Ui; - mitk::ISimulationService* m_SimulationService; - mitk::DataNode::Pointer m_Selection; - mitk::SimulationInteractor::Pointer m_Interactor; - QMenu* m_VtkModelContextMenu; - QTimer m_Timer; - QTime m_NextRenderWindowUpdate; -}; - -#endif diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui b/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui deleted file mode 100644 index f1943335fa..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/QmitkSimulationViewControls.ui +++ /dev/null @@ -1,182 +0,0 @@ - - - QmitkSimulationViewControls - - - true - - - - 0 - 0 - 248 - 751 - - - - Simulation - - - - - - - - - 0 - 0 - - - - - - - - - 0 - 0 - - - - Animate - - - true - - - false - - - - - - - - 0 - 0 - - - - Step - - - - - - - - 0 - 0 - - - - Reset - - - - - - - - 0 - 0 - - - - dt - - - - - - - - 0 - 0 - - - - s - - - 3 - - - 0.010000000000000 - - - - - - - - - Qt::Vertical - - - - Qt::CustomContextMenu - - - QAbstractItemView::NoEditTriggers - - - true - - - false - - - 1 - - - false - - - - Name - - - - - - true - - - 120 - - - - Property - - - - - Value - - - - - - - - - - QmitkDataStorageComboBox - QComboBox -
QmitkDataStorageComboBox.h
-
- - QmitkSceneTreeWidget - QTreeWidget -
internal/QmitkSceneTreeWidget.h
-
- - QmitkBaseTreeWidget - QTreeWidget -
internal/QmitkBaseTreeWidget.h
-
-
- - -
diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/org_mitk_gui_qt_simulation_Activator.cpp b/Plugins/org.mitk.gui.qt.simulation/src/internal/org_mitk_gui_qt_simulation_Activator.cpp deleted file mode 100644 index de183e97ad..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/org_mitk_gui_qt_simulation_Activator.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "org_mitk_gui_qt_simulation_Activator.h" -#include "QmitkSimulationPreferencePage.h" -#include "QmitkSimulationView.h" - -ctkPluginContext* mitk::org_mitk_gui_qt_simulation_Activator::Context = nullptr; - -ctkPluginContext* mitk::org_mitk_gui_qt_simulation_Activator::GetContext() -{ - return Context; -} - -void mitk::org_mitk_gui_qt_simulation_Activator::start(ctkPluginContext* context) -{ - BERRY_REGISTER_EXTENSION_CLASS(QmitkSimulationPreferencePage, context); - BERRY_REGISTER_EXTENSION_CLASS(QmitkSimulationView, context); - Context = context; -} - -void mitk::org_mitk_gui_qt_simulation_Activator::stop(ctkPluginContext*) -{ - Context = nullptr; -} diff --git a/Plugins/org.mitk.gui.qt.simulation/src/internal/org_mitk_gui_qt_simulation_Activator.h b/Plugins/org.mitk.gui.qt.simulation/src/internal/org_mitk_gui_qt_simulation_Activator.h deleted file mode 100644 index 2efd8b73b0..0000000000 --- a/Plugins/org.mitk.gui.qt.simulation/src/internal/org_mitk_gui_qt_simulation_Activator.h +++ /dev/null @@ -1,41 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef org_mitk_gui_qt_simulation_Activator_h -#define org_mitk_gui_qt_simulation_Activator_h - -#include - -namespace mitk -{ - class org_mitk_gui_qt_simulation_Activator : public QObject, public ctkPluginActivator - { - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_mitk_gui_qt_simulation") - Q_INTERFACES(ctkPluginActivator); - - public: - static ctkPluginContext* GetContext(); - - void start(ctkPluginContext* context) override; - void stop(ctkPluginContext*) override; - - private: - static ctkPluginContext* Context; - }; -} - -#endif diff --git a/Plugins/org.mitk.simulation/CMakeLists.txt b/Plugins/org.mitk.simulation/CMakeLists.txt deleted file mode 100644 index 4f22676df7..0000000000 --- a/Plugins/org.mitk.simulation/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -project(org_mitk_simulation) - -mitk_create_plugin( - EXPORT_DIRECTIVE SIMULATION_INIT_EXPORT - EXPORTED_INCLUDE_SUFFIXES src - MODULE_DEPENDS MitkQtWidgets MitkSimulation -) diff --git a/Plugins/org.mitk.simulation/files.cmake b/Plugins/org.mitk.simulation/files.cmake deleted file mode 100644 index 93637cdfb7..0000000000 --- a/Plugins/org.mitk.simulation/files.cmake +++ /dev/null @@ -1,31 +0,0 @@ -set(SRC_CPP_FILES - mitkGetSimulationPreferences.cpp - mitkMeshMitkLoader.cpp -) - -set(INTERNAL_CPP_FILES - org_mitk_simulation_Activator.cpp -) - -set(MOC_H_FILES - src/internal/org_mitk_simulation_Activator.h -) - -set(CACHED_RESOURCE_FILES - resources/SOFAIcon.png -) - -set(QRC_FILES - resources/Simulation.qrc -) - -set(CPP_FILES -) - -foreach(file ${SRC_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/${file}) -endforeach() - -foreach(file ${INTERNAL_CPP_FILES}) - set(CPP_FILES ${CPP_FILES} src/internal/${file}) -endforeach() diff --git a/Plugins/org.mitk.simulation/manifest_headers.cmake b/Plugins/org.mitk.simulation/manifest_headers.cmake deleted file mode 100644 index 893c3d887f..0000000000 --- a/Plugins/org.mitk.simulation/manifest_headers.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(Plugin-Name "MITK Simulation Initialization") -set(Plugin-Version "0.1") -set(Plugin-Vendor "DKFZ, Medical and Biological Informatics") -set(Plugin-ContactAddress "http://www.mitk.org") -set(Require-Plugin org.mitk.gui.common) -set(Plugin-ActivationPolicy eager) diff --git a/Plugins/org.mitk.simulation/resources/SOFAIcon.png b/Plugins/org.mitk.simulation/resources/SOFAIcon.png deleted file mode 100644 index 3e0ce703ea..0000000000 Binary files a/Plugins/org.mitk.simulation/resources/SOFAIcon.png and /dev/null differ diff --git a/Plugins/org.mitk.simulation/resources/Simulation.qrc b/Plugins/org.mitk.simulation/resources/Simulation.qrc deleted file mode 100644 index 53480e1d88..0000000000 --- a/Plugins/org.mitk.simulation/resources/Simulation.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - SOFAIcon.png - - diff --git a/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp b/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp deleted file mode 100644 index 78fdd5fffe..0000000000 --- a/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "org_mitk_simulation_Activator.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void RegisterSofaClasses() -{ - int MeshMitkLoaderClass = sofa::core::RegisterObject("").add(); - boost::ignore_unused(MeshMitkLoaderClass); -} - -static void LoadSofaPlugins() -{ - berry::IPreferences::Pointer preferences = mitk::GetSimulationPreferences(); - - if (preferences.IsNull()) - return; - - QString plugins = preferences->Get("plugins", ""); - - if (plugins.isEmpty()) - return; - - QStringList pluginList = plugins.split(';', QString::SkipEmptyParts); - QStringListIterator it(pluginList); - - typedef sofa::helper::system::PluginManager PluginManager; - PluginManager& pluginManager = PluginManager::getInstance(); - - while (it.hasNext()) - { - std::string plugin = it.next().toStdString(); - std::ostringstream errlog; - - pluginManager.loadPlugin(plugin, &errlog); - - if (errlog.str().empty()) - pluginManager.getPluginMap()[plugin].initExternalModule(); - } -} - -static void AddPropertyFilters() -{ - mitk::IPropertyFilters* filters = mitk::org_mitk_simulation_Activator::GetService(); - - if (filters == nullptr) - return; - - mitk::PropertyFilter filter; - - filter.AddEntry("layer", mitk::PropertyFilter::Blacklist); - filter.AddEntry("name", mitk::PropertyFilter::Blacklist); - filter.AddEntry("path", mitk::PropertyFilter::Blacklist); - filter.AddEntry("selected", mitk::PropertyFilter::Blacklist); - filter.AddEntry("visible", mitk::PropertyFilter::Blacklist); - - filters->AddFilter(filter, "Simulation"); -} - -ctkPluginContext* mitk::org_mitk_simulation_Activator::Context = nullptr; - -void mitk::org_mitk_simulation_Activator::start(ctkPluginContext* context) -{ - Context = context; - - RegisterSimulationObjectFactory(); - RegisterSofaClasses(); - LoadSofaPlugins(); - AddPropertyFilters(); - - QmitkNodeDescriptorManager* nodeDescriptorManager = QmitkNodeDescriptorManager::GetInstance(); - - if (nodeDescriptorManager != nullptr) - { - mitk::NodePredicateDataType::Pointer simulationPredicate = mitk::NodePredicateDataType::New("Simulation"); - nodeDescriptorManager->AddDescriptor(new QmitkNodeDescriptor("Simulation", ":/Simulation/SOFAIcon.png", simulationPredicate, nodeDescriptorManager)); - } -} - -void mitk::org_mitk_simulation_Activator::stop(ctkPluginContext*) -{ - Context = nullptr; -} diff --git a/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.h b/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.h deleted file mode 100644 index ad63a1f394..0000000000 --- a/Plugins/org.mitk.simulation/src/internal/org_mitk_simulation_Activator.h +++ /dev/null @@ -1,52 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef org_mitk_simulation_Activator_h -#define org_mitk_simulation_Activator_h - -#include - -namespace mitk -{ - class org_mitk_simulation_Activator : public QObject, public ctkPluginActivator - { - Q_OBJECT - Q_PLUGIN_METADATA(IID "org_mitk_simulation") - Q_INTERFACES(ctkPluginActivator); - - public: - template - static T* GetService() - { - if (Context == nullptr) - return nullptr; - - ctkServiceReference serviceReference = Context->getServiceReference(); - - return serviceReference - ? Context->getService(serviceReference) - : nullptr; - } - - void start(ctkPluginContext* context) override; - void stop(ctkPluginContext*) override; - - private: - static ctkPluginContext* Context; - }; -} - -#endif diff --git a/Plugins/org.mitk.simulation/src/mitkGetSimulationPreferences.cpp b/Plugins/org.mitk.simulation/src/mitkGetSimulationPreferences.cpp deleted file mode 100644 index ecbccb38ca..0000000000 --- a/Plugins/org.mitk.simulation/src/mitkGetSimulationPreferences.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "mitkGetSimulationPreferences.h" -#include -#include - -berry::IPreferences::Pointer mitk::GetSimulationPreferences() -{ - return berry::Platform::GetPreferencesService()->GetSystemPreferences()->Node("/org.mitk.views.simulation"); -} diff --git a/Plugins/org.mitk.simulation/src/mitkGetSimulationPreferences.h b/Plugins/org.mitk.simulation/src/mitkGetSimulationPreferences.h deleted file mode 100644 index debded83a3..0000000000 --- a/Plugins/org.mitk.simulation/src/mitkGetSimulationPreferences.h +++ /dev/null @@ -1,28 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkGetSimulationPreferences_h -#define mitkGetSimulationPreferences_h - -#include -#include - -namespace mitk -{ - SIMULATION_INIT_EXPORT berry::IPreferences::Pointer GetSimulationPreferences(); -} - -#endif diff --git a/Plugins/org.mitk.simulation/src/mitkMeshMitkLoader.cpp b/Plugins/org.mitk.simulation/src/mitkMeshMitkLoader.cpp deleted file mode 100644 index f69e1eaa2d..0000000000 --- a/Plugins/org.mitk.simulation/src/mitkMeshMitkLoader.cpp +++ /dev/null @@ -1,184 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#include "internal/org_mitk_simulation_Activator.h" -#include "mitkMeshMitkLoader.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static mitk::DataStorage::Pointer GetDataStorage() -{ - mitk::IDataStorageService* dataStorageService = mitk::org_mitk_simulation_Activator::GetService(); - - if (dataStorageService != nullptr) - { - mitk::IDataStorageReference::Pointer dataStorageReference = dataStorageService->GetDefaultDataStorage(); - - if (dataStorageReference.IsNotNull()) - return dataStorageReference->GetDataStorage(); - } - - return nullptr; -} - -template -typename T::Pointer GetData(const std::string& name) -{ - mitk::DataStorage::Pointer dataStorage = GetDataStorage(); - - if (dataStorage.IsNull()) - return nullptr; - - typename mitk::TNodePredicateDataType::Pointer predicate = mitk::TNodePredicateDataType::New(); - mitk::DataStorage::SetOfObjects::ConstPointer subset = dataStorage->GetSubset(predicate); - - for (mitk::DataStorage::SetOfObjects::ConstIterator it = subset->Begin(); it != subset->End(); ++it) - { - mitk::DataNode::Pointer dataNode = it.Value(); - - if (dataNode->GetName() == name) - { - typename T::Pointer data = static_cast(dataNode->GetData()); - - if (data.IsNotNull()) - return data; - } - } - - return nullptr; -} - -mitk::MeshMitkLoader::MeshMitkLoader() -{ - this->addAlias(&m_filename, "dataNode"); - this->addAlias(&m_filename, "surface"); -} - -mitk::MeshMitkLoader::~MeshMitkLoader() -{ -} - -bool mitk::MeshMitkLoader::canLoad() -{ - Surface::Pointer surface = GetData(m_filename.getValue()); - - if (surface.IsNull()) - return false; - - vtkPolyData* polyData = surface->GetVtkPolyData(); - - if (polyData == nullptr || polyData->GetNumberOfCells() == 0) - return false; - - return true; -} - -bool mitk::MeshMitkLoader::load() -{ - Surface::Pointer surface = GetData(m_filename.getValue()); - vtkPolyData* polyData = surface->GetVtkPolyData(); - - // vtkSmartPointer transformFilter = vtkSmartPointer::New(); - // transformFilter->SetTransform(surface->GetGeometry()->GetVtkTransform()); - // transformFilter->SetInputConnection(polyData->GetProducerPort()); - // transformFilter->Update(); - - // polyData = vtkPolyData::SafeDownCast(transformFilter->GetOutputDataObject(0)); - - sofa::helper::vector& positions = *this->positions.beginEdit(); - sofa::helper::vector& edges = *this->edges.beginEdit(); - sofa::helper::vector& triangles = *this->triangles.beginEdit(); - sofa::helper::vector& quads = *this->quads.beginEdit(); - sofa::helper::vector > polygons = *this->polygons.beginEdit(); - - vtkPoints* points = polyData->GetPoints(); - vtkIdType numPoints = points->GetNumberOfPoints(); - double point[3]; - - for (vtkIdType i = 0; i < numPoints; ++i) - { - points->GetPoint(i, point); - positions.push_back(sofa::defaulttype::Vec3d(point[0], point[1], point[2])); - } - - vtkCellArray* polys = polyData->GetPolys(); - vtkSmartPointer poly = vtkSmartPointer::New(); - Edge edge; - Triangle triangle; - Quad quad; - - polys->InitTraversal(); - - while (polys->GetNextCell(poly) != 0) - { - switch (poly->GetNumberOfIds()) - { - case 1: - break; - - case 2: - edge[0] = poly->GetId(0); - edge[1] = poly->GetId(1); - - edges.push_back(edge); - break; - - case 3: - triangle[0] = poly->GetId(0); - triangle[1] = poly->GetId(1); - triangle[2] = poly->GetId(2); - - triangles.push_back(triangle); - break; - - case 4: - quad[0] = poly->GetId(0); - quad[1] = poly->GetId(1); - quad[2] = poly->GetId(2); - quad[3] = poly->GetId(3); - - quads.push_back(quad); - break; - - default: - sofa::helper::vector polygon; - vtkIdType numIds = poly->GetNumberOfIds(); - - polygon.reserve(numIds); - - for (vtkIdType i = 0; i < numIds; ++i) - polygon.push_back(poly->GetId(i)); - - polygons.push_back(polygon); - break; - } - } - - this->positions.endEdit(); - this->edges.endEdit(); - this->triangles.endEdit(); - this->quads.endEdit(); - this->polygons.endEdit(); - - return true; -} diff --git a/Plugins/org.mitk.simulation/src/mitkMeshMitkLoader.h b/Plugins/org.mitk.simulation/src/mitkMeshMitkLoader.h deleted file mode 100644 index 6c48f5b501..0000000000 --- a/Plugins/org.mitk.simulation/src/mitkMeshMitkLoader.h +++ /dev/null @@ -1,42 +0,0 @@ -/*=================================================================== - -The Medical Imaging Interaction Toolkit (MITK) - -Copyright (c) German Cancer Research Center, -Division of Medical and Biological Informatics. -All rights reserved. - -This software is distributed WITHOUT ANY WARRANTY; without -even the implied warranty of MERCHANTABILITY or FITNESS FOR -A PARTICULAR PURPOSE. - -See LICENSE.txt or http://www.mitk.org for details. - -===================================================================*/ - -#ifndef mitkMeshMitkLoader_h -#define mitkMeshMitkLoader_h - -#include -#include - -namespace mitk -{ - class SIMULATION_INIT_EXPORT MeshMitkLoader : public sofa::core::loader::MeshLoader - { - public: - SOFA_CLASS(MeshMitkLoader, sofa::core::loader::MeshLoader); - - bool canLoad() override; - bool load() override; - - private: - MeshMitkLoader(); - ~MeshMitkLoader(); - - MeshMitkLoader(const MyType&); - MyType& operator=(const MyType&); - }; -} - -#endif