From 5769afeb988970ea10eccde5df041e8555243fac Mon Sep 17 00:00:00 2001 From: Rinat Mukhometzianov Date: Fri, 28 Jun 2019 04:09:41 -0400 Subject: [PATCH] Fix for MS Win build --- CMake/ITKSetStandardCompilerFlags.cmake | 21 +- CMakeLists.txt | 10 +- Common.cmake | 3 + SuperBuild.cmake | 1 + SuperBuild/External_Boost.cmake | 278 +++++++++--------- SuperBuild/External_Eigen.cmake | 2 +- SuperBuild/External_ITK.cmake | 5 +- .../External_SlicerExecutionModel.cmake | 1 + SuperBuild/External_VTK.cmake | 18 +- SuperBuild/External_zlib.cmake | 6 +- UKFTractography.cmake | 7 + UKFTractography/CMakeLists.txt | 1 - fibertractdispersion/computedispersion.cxx | 6 +- fibertractdispersion/fiberbundle.cxx | 2 +- ukf/NrrdData.cc | 20 +- ukf/QuadProg++_Eigen.cc | 26 +- ukf/cli.cc | 2 +- ukf/unscented_kalman_filter.cc | 2 +- ukf/utilities.cc | 6 +- ukf/vtk_writer.cc | 54 ++-- vtk2mask/Converter.cc | 6 +- vtkFilter/vtkWriter.cc | 16 +- vtkFilter/vtkWriter.h | 8 +- 23 files changed, 282 insertions(+), 219 deletions(-) diff --git a/CMake/ITKSetStandardCompilerFlags.cmake b/CMake/ITKSetStandardCompilerFlags.cmake index b4e00c1..6cc23e4 100644 --- a/CMake/ITKSetStandardCompilerFlags.cmake +++ b/CMake/ITKSetStandardCompilerFlags.cmake @@ -21,6 +21,8 @@ include(ITK_CheckCCompilerFlag) include(ITK_CheckCXXCompilerFlag) +include(CheckCXXCompilerFlag) +include(CheckCCompilerFlag) if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.14.0) cmake_policy(SET CMP0083 NEW) @@ -33,7 +35,11 @@ function(check_c_compiler_flags c_flag_var) set(flag_list "${ARGN}") foreach(flag IN LISTS flag_list) string(REPLACE "=" "_" flag_var ${flag} ) - ITK_CHECK_C_COMPILER_FLAG(${flag} C_HAS_WARNING${flag_var}) + if(CMAKE_VERSION VERSION_LESS 2.8.9) + ITK_CHECK_C_COMPILER_FLAG(${flag} C_HAS_WARNING${flag_var}) + else() + check_c_compiler_flag(${flag} C_HAS_WARNING${flag_var}) + endif() if(${C_HAS_WARNING${flag_var}}) set(local_c_flags "${local_c_flags} ${flag}") endif() @@ -46,7 +52,11 @@ function(check_cxx_compiler_flags cxx_flag_var) set(flag_list "${ARGN}") foreach(flag IN LISTS flag_list) string(REPLACE "=" "_" flag_var ${flag} ) - ITK_CHECK_CXX_COMPILER_FLAG(${flag} CXX_HAS_WARNING${flag_var}) + if(CMAKE_VERSION VERSION_LESS 2.8.9) + ITK_CHECK_CXX_COMPILER_FLAG(${flag} CXX_HAS_WARNING${flag_var}) + else() + check_cxx_compiler_flag(${flag} CXX_HAS_WARNING${flag_var}) + endif() if(${CXX_HAS_WARNING${flag_var}}) set(local_cxx_flags "${local_cxx_flags} ${flag}") endif() @@ -103,7 +113,7 @@ function(check_compiler_warning_flags c_warning_flags_var cxx_warning_flags_var) # Check this list on both C and C++ compilers set(c_and_cxx_flags ${VerboseWarningsFlag} - -Wno-long-double #Needed on APPLE + -Wno-long-double #Needed on APPLE -Wcast-align -Wdisabled-optimization -Wextra @@ -122,7 +132,7 @@ function(check_compiler_warning_flags c_warning_flags_var cxx_warning_flags_var) set(cxx_flags -Wno-deprecated -Wno-invalid-offsetof - -Wno-undefined-var-template # suppress invalid warning when explicitly instantiated in another translation unit + -Wno-undefined-var-template # suppress invalid warning when explicitly instantiated in another translation unit -Woverloaded-virtual -Wstrict-null-sentinel ) @@ -422,5 +432,4 @@ string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") string(REPLACE " " ";" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${PROJECT_NAME}_CXX_OPTIMIZATION_FLAGS} ${${PROJECT_NAME}_CXX_WARNING_FLAGS}") list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS) -string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - +string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index cb37c1f..969b254 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.7) if(POLICY CMP0074) cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``_ROOT`` variables. @@ -70,6 +70,14 @@ endif() option(${PRIMARY_PROJECT_NAME}_SUPERBUILD "Build ${PRIMARY_PROJECT_NAME} and the projects it depends on via SuperBuild.cmake." ${default_superbuild_value}) mark_as_advanced(${PRIMARY_PROJECT_NAME}_SUPERBUILD) +#----------------------------------------------------------------------------- +# Additional CXX/C Flags +#----------------------------------------------------------------------------- +set(ADDITIONAL_C_FLAGS "" CACHE STRING "Additional C Flags") +mark_as_advanced(ADDITIONAL_C_FLAGS) +set(ADDITIONAL_CXX_FLAGS "" CACHE STRING "Additional CXX Flags") +mark_as_advanced(ADDITIONAL_CXX_FLAGS) + #----------------------------------------------------------------------------- # Required by Slicer extension build system for reasons. See # https://github.com/Slicer/Slicer/commit/b160ec13f276a86306513954ef8b08a5332afc2e diff --git a/Common.cmake b/Common.cmake index 20af12d..9c9dcf1 100644 --- a/Common.cmake +++ b/Common.cmake @@ -1,6 +1,9 @@ include(ExternalProject) include(ExternalProjectDependency) +set(ep_common_c_flags "${CMAKE_C_FLAGS_INIT} ${ADDITIONAL_C_FLAGS}") +set(ep_common_cxx_flags "${CMAKE_CXX_FLAGS_INIT} ${ADDITIONAL_CXX_FLAGS}") + #----------------------------------------------------------------------------- if(APPLE) # Note: By setting CMAKE_OSX_* variables before any enable_language() or project() calls, diff --git a/SuperBuild.cmake b/SuperBuild.cmake index 46c598c..0f24a92 100644 --- a/SuperBuild.cmake +++ b/SuperBuild.cmake @@ -31,6 +31,7 @@ set_property(CACHE EXTERNAL_PROJECT_BUILD_TYPE PROPERTY option(USE_SYSTEM_ITK "Build using an externally defined version of ITK" OFF) option(USE_SYSTEM_SlicerExecutionModel "Build using an externally defined version of SlicerExecutionModel" OFF) option(USE_SYSTEM_VTK "Build using an externally defined version of VTK" OFF) +option(USE_SYSTEM_BOOST "Build using an externally defined version of BOOST" OFF) #------------------------------------------------------------------------------ set(SlicerExecutionModel_DEFAULT_CLI_RUNTIME_OUTPUT_DIRECTORY bin) diff --git a/SuperBuild/External_Boost.cmake b/SuperBuild/External_Boost.cmake index f3b4fc4..4eda1a4 100644 --- a/SuperBuild/External_Boost.cmake +++ b/SuperBuild/External_Boost.cmake @@ -1,132 +1,146 @@ -# Make sure that the ExtProjName/IntProjName variables are unique globally -# even if other External_${ExtProjName}.cmake files are sourced by -# SlicerMacroCheckExternalProjectDependency -set(extProjName BOOST) #The find_package known name -set(proj Boost) #This local name -set(${extProjName}_REQUIRED_VERSION "") #If a required version is necessary, then set this, else leave blank - -#if(${USE_SYSTEM_${extProjName}}) -# unset(${extProjName}_DIR CACHE) -#endif() - -# Sanity checks -if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) - message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") -endif() - -# Set dependency list -set(${proj}_DEPENDENCIES "") - -# Include dependent projects if any -ExternalProject_Include_Dependencies(${proj} PROJECT_VAR proj DEPENDS_VAR ${proj}_DEPENDENCIES) - -if(NOT ( DEFINED "USE_SYSTEM_${extProjName}" AND "${USE_SYSTEM_${extProjName}}" ) ) - #message(STATUS "${__indent}Adding project ${proj}") - - # Set CMake OSX variable to pass down the external project - set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) - if(APPLE) - list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS - -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} - -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT} - -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}) - endif() - - ### --- Project specific additions here - set(Boost_Install_Dir ${CMAKE_CURRENT_BINARY_DIR}/${proj}-install) - - if(CMAKE_COMPILER_IS_CLANGXX) - set(CLANG_ARG -DCMAKE_COMPILER_IS_CLANGXX:BOOL=ON) - endif() - - ### --- End Project specific additions - if(CMAKE_COMPILER_IS_CLANGXX) - set(CLANG_ARG -DCMAKE_COMPILER_IS_CLANGXX:BOOL=ON) - endif() - set(BOOST_SOURCE_DIR ${SOURCE_DOWNLOAD_CACHE}/${proj}) - - if(UNIX) - set(Boost_url "http://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz") - set(Boost_md5 fea771fe8176828fabf9c09242ee8c26) - set(Boost_Bootstrap_Command ./bootstrap.sh) - set(Boost_b2_Command ./b2) - else() - if(WIN32) - set(Boost_url "http://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.zip") - set(Boost_md5 a110ebd91a3d2c34c72ace09c92ae50b) - set(Boost_Bootstrap_Command ./bootstrap.bat) - set(Boost_b2_Command ./b2.exe) - endif() - endif() - - if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500) - list(APPEND Boost_b2_Command toolset=msvc-8.0) - elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600) - list(APPEND Boost_b2_Command toolset=msvc-9.0) - elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700) - list(APPEND Boost_b2_Command toolset=msvc-10.0) - elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800) - list(APPEND Boost_b2_Command toolset=msvc-11.0) - elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) - list(APPEND Boost_b2_Command toolset=msvc-12.0) - elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910) - list(APPEND Boost_b2_Command toolset=msvc-14.0) - elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920) - list(APPEND Boost_b2_Command toolset=msvc-14.1) - elseif(ENV{CC}) - # CMake apprarently puts the full path of the compiler into CC - # The user might specify a non-default gcc compiler through ENV - message(STATUS "ENV{CC}=$ENV{CC}") - get_filename_component( gccToolset "$ENV{CC}" NAME ) - - # see: https://svn.boost.org/trac/boost/ticket/5917 - string(TOLOWER ${gccToolset} gccToolset) - if(gccToolset STREQUAL "cc") - set(gccToolset "gcc") - endif() - list(APPEND Boost_b2_Command toolset=${gccToolset}) - endif() - - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(Boost_address_model 64) - else() - set(Boost_address_model 32) - endif() - - ExternalProject_Add(${proj} - ${${proj}_EP_ARGS} - BUILD_IN_SOURCE 1 - URL ${Boost_url} - URL_MD5 ${Boost_md5} - UPDATE_COMMAND "" - CONFIGURE_COMMAND ${Boost_Bootstrap_Command} --prefix=${Boost_Install_Dir}/lib - BUILD_COMMAND ${Boost_b2_Command} install -j8 --prefix=${Boost_Install_Dir} --with-thread --with-filesystem --with-system --with-date_time --with-program_options --with-atomic address-model=${Boost_address_model} link=static,shared - INSTALL_COMMAND "" - ) - - if(NOT WIN32) - set(BOOST_ROOT ${Boost_Install_Dir}) - set(BOOST_INCLUDE_DIR ${Boost_Install_Dir}/include) - else() - set(BOOST_ROOT ${Boost_Install_Dir}) - set(Boost_INCLUDE_DIR ${Boost_Install_Dir}/include/boost-1_70) - endif() - - set(Boost_LIBRARY_DIR ${Boost_Install_Dir}/lib) - -else() - if(${USE_SYSTEM_${extProjName}}) - find_package(${proj} ${${extProjName}_REQUIRED_VERSION} REQUIRED) - message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") - endif() - # The project is provided using ${extProjName}_DIR, nevertheless since other - # project may depend on ${extProjName}, let's add an 'empty' one - ExternalProject_Add_Empty(${proj} "${${proj}_DEPENDENCIES}") -endif() - -mark_as_superbuild( - VARS - ${extProjName}_DIR:PATH - LABELS - "FIND_PACKAGE" -) +# Make sure that the ExtProjName/IntProjName variables are unique globally +# even if other External_${ExtProjName}.cmake files are sourced by +# SlicerMacroCheckExternalProjectDependency +set(extProjName BOOST) #The find_package known name +set(proj Boost) #This local name +set(${extProjName}_REQUIRED_VERSION "") #If a required version is necessary, then set this, else leave blank + +#if(${USE_SYSTEM_${extProjName}}) +# unset(${extProjName}_DIR CACHE) +#endif() + +# Sanity checks +if(DEFINED ${extProjName}_DIR AND NOT EXISTS ${${extProjName}_DIR}) + message(FATAL_ERROR "${extProjName}_DIR variable is defined but corresponds to non-existing directory (${${extProjName}_DIR})") +endif() + +# Set dependency list +set(${proj}_DEPENDENCIES "") + +# Include dependent projects if any +ExternalProject_Include_Dependencies(${proj} PROJECT_VAR proj DEPENDS_VAR ${proj}_DEPENDENCIES) + +if(NOT ( DEFINED "USE_SYSTEM_${extProjName}" AND "${USE_SYSTEM_${extProjName}}" ) ) + #message(STATUS "${__indent}Adding project ${proj}") + + # Set CMake OSX variable to pass down the external project + set(CMAKE_OSX_EXTERNAL_PROJECT_ARGS) + if(APPLE) + list(APPEND CMAKE_OSX_EXTERNAL_PROJECT_ARGS + -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES} + -DCMAKE_OSX_SYSROOT:STRING=${CMAKE_OSX_SYSROOT} + -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}) + endif() + + ### --- Project specific additions here + set(Boost_Install_Dir ${CMAKE_CURRENT_BINARY_DIR}/${proj}-install) + + if(CMAKE_COMPILER_IS_CLANGXX) + set(CLANG_ARG -DCMAKE_COMPILER_IS_CLANGXX:BOOL=ON) + endif() + + ### --- End Project specific additions + if(CMAKE_COMPILER_IS_CLANGXX) + set(CLANG_ARG -DCMAKE_COMPILER_IS_CLANGXX:BOOL=ON) + endif() + set(BOOST_SOURCE_DIR ${SOURCE_DOWNLOAD_CACHE}/${proj}) + + if(UNIX) + set(Boost_url "http://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.tar.gz") + set(Boost_md5 fea771fe8176828fabf9c09242ee8c26) + set(Boost_Bootstrap_Command ./bootstrap.sh) + set(Boost_b2_Command ./b2) + else() + if(WIN32) + set(Boost_url "http://sourceforge.net/projects/boost/files/boost/1.70.0/boost_1_70_0.zip") + set(Boost_md5 a110ebd91a3d2c34c72ace09c92ae50b) + set(Boost_Bootstrap_Command ./bootstrap.bat) + set(Boost_b2_Command b2) + endif() + endif() + + if(MSVC) + if(MSVC_VERSION GREATER_EQUAL 1400 AND MSVC_VERSION LESS 1500) + list(APPEND Boost_b2_Command toolset=msvc-8.0) + elseif(MSVC_VERSION GREATER_EQUAL 1500 AND MSVC_VERSION LESS 1600) + list(APPEND Boost_b2_Command toolset=msvc-9.0) + elseif(MSVC_VERSION GREATER_EQUAL 1600 AND MSVC_VERSION LESS 1700) + list(APPEND Boost_b2_Command toolset=msvc-10.0) + elseif(MSVC_VERSION GREATER_EQUAL 1700 AND MSVC_VERSION LESS 1800) + list(APPEND Boost_b2_Command toolset=msvc-11.0) + elseif(MSVC_VERSION GREATER_EQUAL 1800 AND MSVC_VERSION LESS 1900) + list(APPEND Boost_b2_Command toolset=msvc-12.0) + elseif(MSVC_VERSION GREATER_EQUAL 1900 AND MSVC_VERSION LESS 1910) + list(APPEND Boost_b2_Command toolset=msvc-14.0) + elseif(MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS 1920) + list(APPEND Boost_b2_Command toolset=msvc-14.1) + elseif(MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1922) + list(APPEND Boost_b2_Command toolset=msvc-14.2) + else() + message(FATAL_ERROR "Unknown MSVC compiler version [${MSVC_VERSION}]") + endif() + endif() + + if(XCODE_VERSION OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) + list(APPEND Boost_b2_Command toolset=clang) + elseif(CMAKE_COMPILER_IS_GNUCXX) + list(APPEND Boost_b2_Command toolset=gcc) + endif() + + if(ENV{CC}) + # CMake apprarently puts the full path of the compiler into CC + # The user might specify a non-default gcc compiler through ENV + message(STATUS "ENV{CC}=$ENV{CC}") + get_filename_component( gccToolset "$ENV{CC}" NAME ) + + # see: https://svn.boost.org/trac/boost/ticket/5917 + string(TOLOWER ${gccToolset} gccToolset) + if(gccToolset STREQUAL "cc") + set(gccToolset "gcc") + endif() + list(APPEND Boost_b2_Command toolset=${gccToolset}) + endif() + + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(Boost_address_model 64) + else() + set(Boost_address_model 32) + endif() + + ExternalProject_Add(${proj} + ${${proj}_EP_ARGS} + BUILD_IN_SOURCE 1 + URL ${Boost_url} + URL_MD5 ${Boost_md5} + UPDATE_COMMAND "" + CONFIGURE_COMMAND ${Boost_Bootstrap_Command} --prefix=${Boost_Install_Dir}/lib + BUILD_COMMAND ${Boost_b2_Command} install -j8 --prefix=${Boost_Install_Dir} --with-thread --with-filesystem --with-system --with-date_time --with-program_options --with-atomic address-model=${Boost_address_model} link=static + INSTALL_COMMAND "" + ) + + if(NOT WIN32) + set(BOOST_ROOT ${Boost_Install_Dir}) + set(BOOST_INCLUDE_DIR ${Boost_Install_Dir}/include) + else() + set(BOOST_ROOT ${Boost_Install_Dir}) + set(Boost_INCLUDE_DIR ${Boost_Install_Dir}/include/boost-1_70) + endif() + + set(Boost_LIBRARY_DIR ${Boost_Install_Dir}/lib) + +else() + if(${USE_SYSTEM_${extProjName}}) + find_package(${proj} ${${extProjName}_REQUIRED_VERSION} REQUIRED) + message("USING the system ${extProjName}, set ${extProjName}_DIR=${${extProjName}_DIR}") + endif() + # The project is provided using ${extProjName}_DIR, nevertheless since other + # project may depend on ${extProjName}, let's add an 'empty' one + ExternalProject_Add_Empty(${proj} "${${proj}_DEPENDENCIES}") +endif() + +mark_as_superbuild( + VARS + ${extProjName}_DIR:PATH + LABELS + "FIND_PACKAGE" +) \ No newline at end of file diff --git a/SuperBuild/External_Eigen.cmake b/SuperBuild/External_Eigen.cmake index bb8ddae..691fd85 100644 --- a/SuperBuild/External_Eigen.cmake +++ b/SuperBuild/External_Eigen.cmake @@ -48,7 +48,7 @@ if(NOT ( DEFINED "USE_SYSTEM_${extProjName}" AND "${USE_SYSTEM_${extProjName}}" LOG_INSTALL 0 # Wrap install in script to to ignore log output from dashboards INSTALL_DIR ${${proj}_INSTALL_DIR} CMAKE_GENERATOR ${gen} - CMAKE_ARGS -Wno-dev --no-warn-unused-cli -DBOOST_ROOT:PATH=${BOOST_ROOT} -DBoost_NO_BOOST_CMAKE=TRUE -DBoost_NO_SYSTEM_PATHS=TRUE -DBoost_LIBRARY_DIRS:FILEPATH=${BOOST_ROOT}/lib + CMAKE_ARGS -Wno-dev --no-warn-unused-cli -DBOOST_ROOT:PATH=${BOOST_ROOT} -DBoost_NO_BOOST_CMAKE:BOOL=TRUE -DBoost_NO_SYSTEM_PATHS:BOOL=TRUE -DBoost_LIBRARY_DIRS:FILEPATH=${BOOST_ROOT}/lib CMAKE_CACHE_ARGS ${CMAKE_OSX_EXTERNAL_PROJECT_ARGS} ${COMMON_EXTERNAL_PROJECT_ARGS} diff --git a/SuperBuild/External_ITK.cmake b/SuperBuild/External_ITK.cmake index 8c5e574..241ec5e 100644 --- a/SuperBuild/External_ITK.cmake +++ b/SuperBuild/External_ITK.cmake @@ -26,7 +26,7 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) ExternalProject_SetIfNotDefined( ${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG - "f9ae0a051440b674c82dfa41c5054b2c7308417e" # slicer-v4.13.0-2017-12-20-d92873e-2 + "f9ae0a051440b674c82dfa41c5054b2c7308417e" # 9825d546c457ebe84948fd6f9db3d2a966811ace # slicer-v4.13.0-2017-12-20-d92873e-2 QUIET ) @@ -45,10 +45,11 @@ if(NOT DEFINED ITK_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) ${${proj}_EP_ARGS} GIT_REPOSITORY "${${CMAKE_PROJECT_NAME}_${proj}_GIT_REPOSITORY}" GIT_TAG "${${CMAKE_PROJECT_NAME}_${proj}_GIT_TAG}" - GIT_SHALLOW TRUE + #GIT_SHALLOW TRUE SOURCE_DIR ${EP_SOURCE_DIR} BINARY_DIR ${EP_BINARY_DIR} CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} diff --git a/SuperBuild/External_SlicerExecutionModel.cmake b/SuperBuild/External_SlicerExecutionModel.cmake index 2e2d23e..01e54af 100644 --- a/SuperBuild/External_SlicerExecutionModel.cmake +++ b/SuperBuild/External_SlicerExecutionModel.cmake @@ -60,6 +60,7 @@ if(NOT DEFINED SlicerExecutionModel_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM CMAKE_ARGS -Wno-dev --no-warn-unused-cli CMAKE_CACHE_ARGS ${COMMON_EXTERNAL_PROJECT_ARGS} + -DCMAKE_BUILD_TYPE:STRING=Debug -DBUILD_TESTING:BOOL=OFF -DITK_DIR:PATH=${ITK_DIR} -DSlicerExecutionModel_LIBRARY_PROPERTIES:STRING=${Slicer_LIBRARY_PROPERTIES} diff --git a/SuperBuild/External_VTK.cmake b/SuperBuild/External_VTK.cmake index 0c8ab40..97c24a8 100644 --- a/SuperBuild/External_VTK.cmake +++ b/SuperBuild/External_VTK.cmake @@ -24,10 +24,19 @@ if(DEFINED VTK_SOURCE_DIR AND NOT EXISTS ${VTK_SOURCE_DIR}) message(FATAL_ERROR "VTK_SOURCE_DIR variable is defined but corresponds to non-existing directory") endif() +# For MinGW for case of compilation failure cause of 'too many sections' error +if (CMAKE_SIZEOF_VOID_P EQUAL 8) + if(MINGW) + set(ep_common_cxx_flags "${ep_common_cxx_flags} -Wa,-mbig-obj") + elseif(MSVC) + set(ep_common_cxx_flags "${ep_common_cxx_flags} /bigobj") + endif() +endif() + if((NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR) AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) set(${proj}_GIT_REPOSITORY "${git_protocol}://www.vtk.org/VTK.git" CACHE STRING "Repository from which to get VTK" FORCE) - set(${proj}_GIT_TAG "b86da7eef93f75c4a7f524b3644523ae6b651bc4") # VTK v7.1.1 + set(${proj}_GIT_TAG "v7.1.1") #"b86da7eef93f75c4a7f524b3644523ae6b651bc4") # VTK v7.1.1 ## Use ../VTK/Utilities/Maintenance/WhatModulesVTK.py ../VTK ./ ## to identify necessary modules for VTK @@ -41,6 +50,13 @@ if((NOT DEFINED VTK_DIR OR NOT DEFINED VTK_SOURCE_DIR) AND NOT ${CMAKE_PROJECT_N CMAKE_ARGS -Wno-dev --no-warn-unused-cli CMAKE_CACHE_ARGS ${COMMON_EXTERNAL_PROJECT_ARGS} + -DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER} + -DCMAKE_CXX_FLAGS:STRING=${ep_common_cxx_flags} + -DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER} + -DCMAKE_C_FLAGS:STRING=${ep_common_c_flags} + -DCMAKE_CXX_STANDARD:STRING=${CMAKE_CXX_STANDARD} + -DCMAKE_CXX_STANDARD_REQUIRED:BOOL=${CMAKE_CXX_STANDARD_REQUIRED} + -DCMAKE_CXX_EXTENSIONS:BOOL=${CMAKE_CXX_EXTENSIONS} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/${proj}-install -DCMAKE_INCLUDE_DIRECTORIES_BEFORE:BOOL=OFF -DBUILD_TESTING:BOOL=OFF diff --git a/SuperBuild/External_zlib.cmake b/SuperBuild/External_zlib.cmake index 00357d2..3818364 100644 --- a/SuperBuild/External_zlib.cmake +++ b/SuperBuild/External_zlib.cmake @@ -61,7 +61,11 @@ if(NOT DEFINED zlib_DIR AND NOT ${CMAKE_PROJECT_NAME}_USE_SYSTEM_${proj}) set(ZLIB_ROOT ${zlib_DIR}) set(ZLIB_INCLUDE_DIR ${zlib_DIR}/include) if(WIN32) - set(ZLIB_LIBRARY ${zlib_DIR}/lib/zlib.lib) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") #to make compatible with msys2 gcc build + set(ZLIB_LIBRARY ${zlib_DIR}/lib/libzlib.a) + else() + set(ZLIB_LIBRARY ${zlib_DIR}/lib/zlib.lib) + endif() else() set(ZLIB_LIBRARY ${zlib_DIR}/lib/libzlib.a) endif() diff --git a/UKFTractography.cmake b/UKFTractography.cmake index ae34df7..a976bd7 100644 --- a/UKFTractography.cmake +++ b/UKFTractography.cmake @@ -77,6 +77,13 @@ endif() #----------------------------------------------------------------------------- include_directories(${CMAKE_CURRENT_SOURCE_DIR}/common) +set(UKF_STATIC) +if(NOT BUILD_SHARED_LIBS) + set(UKF_STATIC 1) + if(WIN32) + add_definitions("-DUKF_STATIC") + endif() +endif() add_subdirectory(ukf) add_subdirectory(UKFTractography) diff --git a/UKFTractography/CMakeLists.txt b/UKFTractography/CMakeLists.txt index f99c242..2e388d9 100644 --- a/UKFTractography/CMakeLists.txt +++ b/UKFTractography/CMakeLists.txt @@ -19,7 +19,6 @@ set(MODULE_TARGET_LIBRARIES UKFBase ) - #----------------------------------------------------------------------------- SEMMacroBuildCLI( NAME UKFTractography diff --git a/fibertractdispersion/computedispersion.cxx b/fibertractdispersion/computedispersion.cxx index af88b03..ec60a05 100644 --- a/fibertractdispersion/computedispersion.cxx +++ b/fibertractdispersion/computedispersion.cxx @@ -97,7 +97,7 @@ typedef Eigen::Matrix VectorType; void cell2mat(const MatrixVector &fibers /*in*/,MatrixType &tractMatrix /*out*/) { - const unsigned int fibersSize(fibers.size()); + const size_t fibersSize(fibers.size()); unsigned int numCols(0); for(unsigned i = 0; i < fibersSize; ++i) { @@ -144,7 +144,7 @@ void FiberVector2EigenFiberVector(const fiberbundle::FiberVector &fv /* in */, MatrixVector &lv) { - const unsigned long fiberSize(fv.size()); + const size_t fiberSize(fv.size()); lv.clear(); // possibly reusing existing vector lv.resize(fiberSize); // same size as input fiberbundle @@ -152,7 +152,7 @@ FiberVector2EigenFiberVector(const fiberbundle::FiberVector &fv /* in */, for(unsigned long i = 0; i < fiberSize; ++i) { const stdVec_t &curFiber = fv[i].Points; - const unsigned long curFiberSize(curFiber.size()); + const size_t curFiberSize(curFiber.size()); MatrixType &curLocalFiber = lv[i]; curLocalFiber.conservativeResize(3, curFiberSize); diff --git a/fibertractdispersion/fiberbundle.cxx b/fibertractdispersion/fiberbundle.cxx index f7b0c94..1013b8d 100644 --- a/fibertractdispersion/fiberbundle.cxx +++ b/fibertractdispersion/fiberbundle.cxx @@ -90,7 +90,7 @@ ::WriteFibers( std::string outputFibersFileName, bool writeAscii, bool writeUnCo for(FiberVector::iterator it = this->m_FiberBundle.begin(); it != this->m_FiberBundle.end(); ++it) { - int fiber_size = (*it).Points.size(); + int fiber_size = static_cast((*it).Points.size()); vtkIdType *ids = new vtkIdType[fiber_size]; for(vtkIdType curPoint = 0; curPoint < fiber_size; ++curPoint,++counter) { diff --git a/ukf/NrrdData.cc b/ukf/NrrdData.cc index f63c718..bdb02d9 100644 --- a/ukf/NrrdData.cc +++ b/ukf/NrrdData.cc @@ -244,9 +244,9 @@ void NrrdData::GetSeeds(const std::vector& labels, std::vector::const_iterator cit; // Go through the volume. - int nx = _seed_nrrd->axis[2].size; - int ny = _seed_nrrd->axis[1].size; - int nz = _seed_nrrd->axis[0].size; + size_t nx = _seed_nrrd->axis[2].size; + size_t ny = _seed_nrrd->axis[1].size; + size_t nz = _seed_nrrd->axis[0].size; assert(_seed_data); if ( !(nx == _dim[0] && ny == _dim[1] && nz == _dim[2]) ) @@ -254,16 +254,16 @@ void NrrdData::GetSeeds(const std::vector& labels, itkGenericExceptionMacro(<< "Labelmap ROI volume dimensions DO NOT match DWI dimensions"); } - for( int i = 0; i < nx; ++i ) + for( size_t i = 0; i < nx; ++i ) { - for( int j = 0; j < ny; ++j ) + for( size_t j = 0; j < ny; ++j ) { - for( int k = 0; k < nz; ++k ) + for( size_t k = 0; k < nz; ++k ) { for( cit = labels.begin(); cit != labels.end(); ++cit ) { int value = 0; - int index = ny * nz * i + nz * j + k; + size_t index = ny * nz * i + nz * j + k; switch( _seed_data_type ) { @@ -475,7 +475,7 @@ bool NrrdData::LoadSignal(Nrrd* input_nrrd, const bool normalizedDWIData) // otherwise the bValues are taken from the header // if bValue not in header also take the norm // normalizing the gradients - const unsigned int gradientCount = _gradients.size(); + const size_t gradientCount = _gradients.size(); _b_values.resize(gradientCount * 2 ); for( unsigned int i = 0; i < gradientCount; ++i ) { @@ -518,7 +518,7 @@ bool NrrdData::LoadSignal(Nrrd* input_nrrd, const bool normalizedDWIData) // std::cout << "dim: " << _dim[0] << " " << _dim[1] << " " << _dim[2] << std::endl; - _num_gradients = _data_nrrd->axis[0].size; + _num_gradients = static_cast(_data_nrrd->axis[0].size); assert(_num_gradients == static_cast(gradientCount ) ); // Get the measurement frame. @@ -600,7 +600,7 @@ bool NrrdData::LoadSignal(Nrrd* input_nrrd, const bool normalizedDWIData) // To get the data for the other half-sphere, simply reverse the gradients and duplicate the signals for( unsigned int i = 0; i < gradientCount; ++i ) { - const unsigned int dupIndex = i + gradientCount; + const unsigned int dupIndex = static_cast(i + gradientCount); // Duplicate and reverse direction. _gradients.push_back(-_gradients[i]); _b_values[dupIndex] =_b_values[i]; diff --git a/ukf/QuadProg++_Eigen.cc b/ukf/QuadProg++_Eigen.cc index aeaada5..5b8b593 100644 --- a/ukf/QuadProg++_Eigen.cc +++ b/ukf/QuadProg++_Eigen.cc @@ -29,7 +29,7 @@ namespace QuadProgPP // Utility functions for updating some data needed by the solution method inline void compute_d(ukfVectorType& d, const ukfMatrixType& J, const ukfVectorType& np) { - const int n = d.size(); + const int n = static_cast(d.size()); /* compute d = H^T * np */ for( int c = 0; c < n; ++c ) @@ -45,7 +45,7 @@ inline void compute_d(ukfVectorType& d, const ukfMatrixType& J, const ukfVectorT inline void update_z(ukfVectorType& z, const ukfMatrixType& J, const ukfVectorType& d, int iq) { - const int n = z.size(); + const int n = static_cast(z.size()); /* setting of z = H * d */ for( int i = 0; i < n; ++i ) @@ -91,7 +91,7 @@ inline ukfPrecisionType distance(ukfPrecisionType a, ukfPrecisionType b) bool add_constraint(ukfMatrixType& R, ukfMatrixType& J, ukfVectorType& d, int& iq, ukfPrecisionType& R_norm) { - const int n = d.size(); + const int n = static_cast(d.size()); #ifdef TRACE_SOLVER std::cout << "Add constraint " << iq << '/'; @@ -252,7 +252,7 @@ void delete_constraint(ukfMatrixType& R, ukfMatrixType& J, Eigen::VectorXi& A, u void cholesky_decomposition(ukfMatrixType& A) { - const int n = A.rows(); + const int n = static_cast(A.rows()); for( int i = 0; i < n; ++i ) { @@ -289,7 +289,7 @@ void cholesky_decomposition(ukfMatrixType& A) inline void forward_elimination(const ukfMatrixType& L, ukfVectorType& y, const ukfVectorType& b) { - const int n = L.rows(); + const int n = static_cast(L.rows()); y[0] = b[0] / L(0,0); for( int i = 1; i < n; ++i ) @@ -305,7 +305,7 @@ inline void forward_elimination(const ukfMatrixType& L, ukfVectorType& y, const inline void backward_elimination(const ukfMatrixType& U, ukfVectorType& x, const ukfVectorType& y) { - const int n = U.rows(); + const int n = static_cast(U.rows()); x[n - 1] = y[n - 1] / U(n - 1,n - 1); for( int i = n - 2; i >= 0; i-- ) @@ -321,7 +321,7 @@ inline void backward_elimination(const ukfMatrixType& U, ukfVectorType& x, const void cholesky_solve(const ukfMatrixType& L, ukfVectorType& x, const ukfVectorType& b) { - const int n = L.rows(); + const int n = static_cast(L.rows()); ukfVectorType y(n); @@ -334,7 +334,7 @@ void cholesky_solve(const ukfMatrixType& L, ukfVectorType& x, const ukfVectorTyp inline ukfPrecisionType dot_product(const ukfVectorType& x, const ukfVectorType& y) { - int n = x.size(); + int n = static_cast(x.size()); ukfPrecisionType sum; sum = ukfZero; @@ -353,11 +353,11 @@ void print_matrix(const char* name, const ukfMatrixType& A, int n, int m) if( n == -1 ) { - n = A.rows(); + n = static_cast(A.rows()); } if( m == -1 ) { - m = A.cols(); + m = static_cast(A.cols()); } s << name << ": " << std::endl; @@ -423,9 +423,9 @@ ukfPrecisionType solve_quadprog(ukfMatrixType& G, ukfVectorType& g0, throw std::logic_error(msg.str()); } - const int n = G.cols(); - const int p = CE.cols(); - const int m = CI.cols(); + const int n = static_cast(G.cols()); + const int p = static_cast(CE.cols()); + const int m = static_cast(CI.cols()); if( (int)G.rows() != n ) { diff --git a/ukf/cli.cc b/ukf/cli.cc index 91ed49b..cc807e6 100644 --- a/ukf/cli.cc +++ b/ukf/cli.cc @@ -30,7 +30,7 @@ void ukf_tell(const ukfPrecisionType & x, const std::string &name) } }; // anonymous namespace -UKFBASELIB_EXPORTS int ukf_parse_cli(int argc, char** argv, UKFSettings& s) +int ukf_parse_cli(int argc, char** argv, UKFSettings& s) { PARSE_ARGS ; diff --git a/ukf/unscented_kalman_filter.cc b/ukf/unscented_kalman_filter.cc index 2be3d81..eacc123 100644 --- a/ukf/unscented_kalman_filter.cc +++ b/ukf/unscented_kalman_filter.cc @@ -96,7 +96,7 @@ void UnscentedKalmanFilter::Constrain(ukfVectorType& x, const ukfMatrixType& W) // matrix version void UnscentedKalmanFilter::Constrain(ukfMatrixType& localX, const ukfMatrixType& localW) { - const unsigned int numCols = localX.cols(); + const unsigned int numCols = static_cast(localX.cols()); for( unsigned int i = 0; i < numCols; ++i ) { diff --git a/ukf/utilities.cc b/ukf/utilities.cc index 8d64133..e9f8542 100644 --- a/ukf/utilities.cc +++ b/ukf/utilities.cc @@ -28,7 +28,7 @@ ukfPrecisionType l2fa(ukfPrecisionType l1, ukfPrecisionType l2, ukfPrecisionType ukfPrecisionType s2ga(const ukfMatrixType& signal) { - int n = signal.rows(); + int n = static_cast(signal.rows()); assert(signal.cols() == 1); @@ -55,7 +55,7 @@ ukfPrecisionType s2ga(const ukfMatrixType& signal) ukfPrecisionType s2adc(const ukfMatrixType& signal) { - int n = signal.rows(); + int n = static_cast(signal.rows()); assert(signal.cols() == 1); @@ -72,7 +72,7 @@ ukfPrecisionType s2adc(const ukfMatrixType& signal) ukfPrecisionType curve_radius(const stdVec_t& fiber) { - int length = fiber.size(); + size_t length = fiber.size(); if( length < 3 ) { diff --git a/ukf/vtk_writer.cc b/ukf/vtk_writer.cc index 952aeda..e93d834 100644 --- a/ukf/vtk_writer.cc +++ b/ukf/vtk_writer.cc @@ -146,9 +146,9 @@ ::PopulateFibersAndTensors(vtkPolyData* polyData, vtkIdType counter = 0; for(size_t i = 0; i < num_fibers; ++i) { - size_t fiber_size = fibers[i].position.size(); + int fiber_size = static_cast(fibers[i].position.size()); vtkIdType *ids = new vtkIdType[fiber_size]; - for(size_t j = 0; j < fiber_size; ++j) + for(int j = 0; j < fiber_size; ++j) { ids[j] = counter; counter++; @@ -199,7 +199,7 @@ ::PopulateFibersAndTensors(vtkPolyData* polyData, curTensor->InsertNextTuple(tmp); } } - const size_t idx = pointData->AddArray(curTensor); + const int idx = static_cast(pointData->AddArray(curTensor)); pointData->SetActiveAttribute(idx,vtkDataSetAttributes::TENSORS); } } @@ -312,8 +312,8 @@ ::Write(const std::string& file_name, // object. vtkPointData *pointData = polyData->GetPointData(); - int num_fibers = fibers.size(); - int num_points = 0; + int num_fibers = static_cast(fibers.size()); + size_t num_points = 0; for( int i = 0; i < num_fibers; ++i ) { num_points += fibers[i].position.size(); @@ -327,8 +327,8 @@ ::Write(const std::string& file_name, norms->SetName("EstimatedUncertainty"); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j) + size_t fiber_size = fibers[i].position.size(); + for ( size_t j = 0; j < fiber_size; ++j ) { norms->InsertNextValue(fibers[i].norm[j]); } @@ -349,8 +349,8 @@ ::Write(const std::string& file_name, fa->SetName("FA1"); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for ( size_t j = 0; j < fiber_size; ++j ) { fa->InsertNextValue(fibers[i].fa[j]); } @@ -371,8 +371,8 @@ ::Write(const std::string& file_name, fa2->Allocate(num_points); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for( size_t j = 0; j < fiber_size; ++j ) { fa2->InsertNextValue(fibers[i].fa2[j]); } @@ -393,8 +393,8 @@ ::Write(const std::string& file_name, trace->SetName("trace1"); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for( size_t j = 0; j < fiber_size; ++j ) { trace->InsertNextValue(fibers[i].trace[j]); } @@ -415,8 +415,8 @@ ::Write(const std::string& file_name, trace2->SetName("trace2"); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for( size_t j = 0; j < fiber_size; ++j ) { trace2->InsertNextValue(fibers[i].trace2[j]); } @@ -436,8 +436,8 @@ ::Write(const std::string& file_name, free_water->SetName("FreeWater"); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for( size_t j = 0; j < fiber_size; ++j ) { free_water->InsertNextValue(fibers[i].free_water[j]); } @@ -456,8 +456,8 @@ ::Write(const std::string& file_name, normMSE->SetName("NormalizedSignalEstimationError"); for( int i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for( size_t j = 0; j < fiber_size; ++j ) { normMSE->InsertNextValue(fibers[i].normMSE[j]); nmse_sum += fibers[i].normMSE[j]; @@ -552,22 +552,22 @@ int VtkWriter::WriteGlyphs(const std::string& file_name, vtkSmartPointer polyData = vtkSmartPointer::New(); vtkSmartPointer points = vtkSmartPointer::New(); - int num_fibers = fibers.size(); - int num_points = 0; - for( int i = 0; i < num_fibers; ++i ) + size_t num_fibers = fibers.size(); + size_t num_points = 0; + for( size_t i = 0; i < num_fibers; ++i ) { num_points += fibers[i].position.size(); } - int num_tensors = fibers[0].state[0].size() / 5; + size_t num_tensors = fibers[0].state[0].size() / 5; const ukfPrecisionType scale = ukfHalf * _scale_glyphs; - for( int i = 0; i < num_fibers; ++i ) + for( size_t i = 0; i < num_fibers; ++i ) { - int fiber_size = fibers[i].position.size(); - for( int j = 0; j < fiber_size; ++j ) + size_t fiber_size = fibers[i].position.size(); + for( size_t j = 0; j < fiber_size; ++j ) { vec3_t point = fibers[i].position[j]; const State& state = fibers[i].state[j]; @@ -680,7 +680,7 @@ int VtkWriter::WriteGlyphs(const std::string& file_name, // do the lines vtkSmartPointer lines = vtkSmartPointer::New(); - for( int i = 0; i < num_points * num_tensors; ++i ) + for( size_t i = 0; i < num_points * num_tensors; ++i ) { vtkSmartPointer line = vtkSmartPointer::New(); vtkIdType ids[2]; diff --git a/vtk2mask/Converter.cc b/vtk2mask/Converter.cc index 845e087..72a4507 100644 --- a/vtk2mask/Converter.cc +++ b/vtk2mask/Converter.cc @@ -42,7 +42,7 @@ bool Converter::Run() LoadLabel(); if( _bVerbose ) { - std::cout << "Using Label " << (uint)_nLabelOfInterest << " from label file\n"; + std::cout << "Using Label " << (unsigned int)_nLabelOfInterest << " from label file\n"; } } @@ -213,7 +213,7 @@ void Converter::AverageVoxels() current[0] = x; current[1] = y; current[2] = z; - if( (!_bHasLabel || _Label->GetPixel( current) == (uint)_nLabelOfInterest) && _matField->_[x][y][z].size() > 0 ) + if( (!_bHasLabel || _Label->GetPixel( current) == (unsigned int)_nLabelOfInterest) && _matField->_[x][y][z].size() > 0 ) { mean = CalcMean(_matField->_[x][y][z]); _nrrdDataOut->SetPixel( current, mean ); @@ -332,7 +332,7 @@ float Converter::CalcStdDev(const std::vector & vec, const float & mean) { float sum = 0; - for( uint i = 0; i < vec.size(); ++i ) + for(unsigned int i = 0; i < vec.size(); ++i ) { sum += (vec[i] - mean) * (vec[i] - mean); } diff --git a/vtkFilter/vtkWriter.cc b/vtkFilter/vtkWriter.cc index a8b5547..cde30aa 100644 --- a/vtkFilter/vtkWriter.cc +++ b/vtkFilter/vtkWriter.cc @@ -50,8 +50,8 @@ void vtkWriter::SetInputFibers(std::vector & fibers) _fiberLengths.resize(_nNumOfFibers); _nNumOfPoints = 0; - int nCurrSize; - for( int i = 0; i < _nNumOfFibers; ++i ) + size_t nCurrSize; + for( size_t i = 0; i < _nNumOfFibers; ++i ) { nCurrSize = (*_fibers)[i].Points.size(); _fiberLengths[i] = nCurrSize; @@ -78,9 +78,9 @@ void vtkWriter::WritePoints(std::ofstream & output) output << "POINTS " << _nNumOfPoints << " float"; int nCounter = 0; - for( int i = 0; i < _nNumOfFibers; ++i ) + for( size_t i = 0; i < _nNumOfFibers; ++i ) { - for( int j = 0; j < _fiberLengths[i]; ++j ) + for( size_t j = 0; j < _fiberLengths[i]; ++j ) { if( nCounter % 3 == 0 ) { @@ -106,10 +106,10 @@ void vtkWriter::WriteLines(std::ofstream & output) output << _nNumOfFibers << " " << _nNumOfFibers + _nNumOfPoints << std::endl; int counter = 0; - for( int i = 0; i < _nNumOfFibers; ++i ) + for( size_t i = 0; i < _nNumOfFibers; ++i ) { output << _fiberLengths[i]; - for( int j = 0; j < _fiberLengths[i]; ++j ) + for( size_t j = 0; j < _fiberLengths[i]; ++j ) { output << " " << counter++; } @@ -131,9 +131,9 @@ void vtkWriter::WriteFields(std::ofstream & output) output << cit->first; output << " 1 " << _nNumOfPoints; output << " float" << std::endl; - for( int i = 0; i < _nNumOfFibers; ++i ) + for( size_t i = 0; i < _nNumOfFibers; ++i ) { - for( int j = 0; j < _fiberLengths[i]; ++j ) + for( size_t j = 0; j < _fiberLengths[i]; ++j ) { output << (*_fibers)[i].Fields[cit->first][j]; nCounter++; diff --git a/vtkFilter/vtkWriter.h b/vtkFilter/vtkWriter.h index b07c0dd..7872e3b 100644 --- a/vtkFilter/vtkWriter.h +++ b/vtkFilter/vtkWriter.h @@ -49,16 +49,16 @@ class vtkWriter std::vector * _fibers; /** Number of points of all fibers */ - int _nNumOfPoints; + size_t _nNumOfPoints; /** Number of fibers */ - int _nNumOfFibers; + size_t _nNumOfFibers; /** Number of scalar fields of the fiber */ - int _nNumOfFields; + size_t _nNumOfFields; /** The respective lengths of each fiber */ - std::vector _fiberLengths; + std::vector _fiberLengths; /** Write the top line of the vtk file */ void WriteHeader(std::ofstream & output);