From: tbaudier Date: Mon, 15 May 2017 09:48:45 +0000 (+0200) Subject: Merge branch 'master' into clitkImage2Dicom X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=1865f86b7420682f57e160c911cfebabbfaa8375;hp=8786715f17744e1a8d97bdf4fec517d443875bb0;p=clitk.git Merge branch 'master' into clitkImage2Dicom --- diff --git a/.travis.yml b/.travis.yml index 43121da..e7bb44e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,16 +12,33 @@ compiler: - gcc - clang env: - - WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=5.5.1 - - WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 - - WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=5.5.1 - - WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 - - WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 + - WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=5.5.1 C11=false + - WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=false + - WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=5.5.1 C11=false + - WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=false + - WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 C11=false + - WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=5.5.1 C11=true + - WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=true + - WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=5.5.1 C11=true + - WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=true + - WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 C11=true matrix: exclude: - os: osx - env: WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 #VTK6.0 doesn't work with osX + env: WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 C11=false #VTK5.10 doesn't work with osX + - os: osx + env: WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 C11=true #VTK5.10 doesn't work with osX + - os: osx + env: WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=false #Qt4 doesn't work with brew anymore + - os: osx + env: WITH_CMAKE=true VTK_VERSION=6.3 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=true #Qt4 doesn't work with brew anymore + - os: osx + env: WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=false + - os: osx + env: WITH_CMAKE=true VTK_VERSION=7.0.0 ITK_VERSION=4.9.1 QT_VERSION=4.8.7 C11=true + - os: linux + env: WITH_CMAKE=true VTK_VERSION=5.10 ITK_VERSION=4.5 QT_VERSION=4.8.7 C11=true #Problem with VTK 5.10 and c++11 language: cpp @@ -30,6 +47,10 @@ notifications: on_success: never on_failure: never +branches: +only: +- master + before_install: - if test $TRAVIS_OS_NAME == osx ; then brew update; fi - if test $TRAVIS_OS_NAME == linux ; then sudo add-apt-repository --yes ppa:kubuntu-ppa/backports; fi @@ -52,8 +73,10 @@ install: - if test $TRAVIS_OS_NAME == linux; then sudo apt-get -y install libgdcm2-dev libpq-dev; fi - if test $TRAVIS_OS_NAME == linux; then if [[ "$QT_VERSION" == "5.5.1" ]] ; then QTDIR="/opt/qt55" && PATH="$PATH:$QTDIR/bin" && qt55-env.sh ; fi; fi - if test $TRAVIS_OS_NAME == osx ; then export HOMEBREW_QT_VERSION=$(brew list --versions qt | rev | cut -d' ' -f1 | rev); fi -- if test $TRAVIS_OS_NAME == osx ; then if [[ "$QT_VERSION" == "5.5.1" ]] ; then ln -s /usr/local/Cellar/qt@5.5/5.5.1/mkspecs /usr/local/mkspecs; fi; fi -- if test $TRAVIS_OS_NAME == osx ; then if [[ "$QT_VERSION" == "5.5.1" ]] ; then ln -s /usr/local/Cellar/qt@5.5/5.5.1/plugins /usr/local/plugins; fi; fi +- if test $TRAVIS_OS_NAME == osx ; then if [[ "$QT_VERSION" == "5.5.1" ]] ; then ln -s /usr/local/Cellar/qt@5.5/5.5.1_1/mkspecs /usr/local/mkspecs; fi; fi +- if test $TRAVIS_OS_NAME == osx ; then if [[ "$QT_VERSION" == "5.5.1" ]] ; then ln -s /usr/local/Cellar/qt@5.5/5.5.1_1/plugins /usr/local/plugins; fi; fi +- if test $TRAVIS_OS_NAME == osx ; then if [[ "$QT_VERSION" == "4.8.7" ]] ; then ln -s /usr/local/Cellar/qt@4/4.8.7_1/mkspecs /usr/local/mkspecs; fi; fi +- if test $TRAVIS_OS_NAME == osx ; then if [[ "$QT_VERSION" == "4.8.7" ]] ; then ln -s /usr/local/Cellar/qt@4/4.8.7_1/plugins /usr/local/plugins; fi; fi - if test $TRAVIS_OS_NAME == osx ; then qmake -v; fi cache: @@ -72,6 +95,7 @@ cache: before_script: - if test $TRAVIS_OS_NAME == linux ; then sudo ln -s /usr/bin/x86_64-linux-gnu/libpq.so /usr/bin/libpq.so; fi +- echo $PATH - $SCRIPTS/travis_build_vtk.sh - $SCRIPTS/travis_build_itk.sh #Install vtk and itk (different version) diff --git a/README.md b/README.md index 5c0673d..e904d36 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,10 @@ VV, a 4D image viewer, see : http://vv.creatis.insa-lyon.fr ### Status -[![Build Status](https://travis-ci.org/open-vv/vv.svg?branch=master)](https://travis-ci.org/open-vv/vv) \ No newline at end of file +[![Build Status](https://travis-ci.org/open-vv/vv.svg?branch=master)](https://travis-ci.org/open-vv/vv) + +### Download +You can download the binaries here: + - [Linux 64bits](https://www.creatis.insa-lyon.fr/rio/vv?action=AttachFile&do=get&target=vv-1.4Qt4-linux64) + - [Windows 32bits](https://www.creatis.insa-lyon.fr/rio/vv?action=AttachFile&do=get&target=vv-1.4Qt4-win32.zip) + - [Windows 64bits](https://www.creatis.insa-lyon.fr/rio/vv?action=AttachFile&do=get&target=vv-1.4Qt4-win64.zip) \ No newline at end of file diff --git a/cluster_tools/CMakeLists.txt b/cluster_tools/CMakeLists.txt index 76a4286..0d2af3b 100644 --- a/cluster_tools/CMakeLists.txt +++ b/cluster_tools/CMakeLists.txt @@ -3,6 +3,7 @@ if(CLITK_BUILD_TOOLS) # Install scripts when running make install set(SCRIPTS gate_job_cluster.job + gate_job_ccin2p3.job gate_make_merge_release.sh gate_make_release.sh gate_power_merge.sh diff --git a/cluster_tools/gate_job_ccin2p3.job b/cluster_tools/gate_job_ccin2p3.job index e443780..c7abaac 100644 --- a/cluster_tools/gate_job_ccin2p3.job +++ b/cluster_tools/gate_job_ccin2p3.job @@ -9,22 +9,32 @@ # PARAM # #$ -P "P_creatis" -#$ -l vmem=2G +#$ -l vmem=4G #$ -l fsize=1G #$ -l ct=30:00:00 #$ -j yes #$ -r no +function transferJobData { + echo "Copying data back" + pwd + echo ${OUTPUTDIR} + mkdir "${OUTPUTDIR}/output.${JOB_ID%%.*}" + rsync -av --remove-source-files output/ "${OUTPUTDIR}/output.${JOB_ID%%.*}" + echo "Cleanup" + rm -r ${LOCALMACRODIR} +} function error { -echo "ERROR: $1" -exit 1 + echo "ERROR: $1" + exit 1 } function warning { -echo "WARNING: $1" + echo "WARNING: $1" } +date test -f ${HOME}/.bashrc && echo "Sourcing bashrc" && source ${HOME}/.bashrc set -u @@ -41,30 +51,30 @@ echo "PARAM=${PARAM}" if test "$RELEASEDIR" = "NONE" then - echo Using $(which Gate) - ldd $(which Gate) + echo Using $(which Gate) + ldd $(which Gate) else - test -d "${RELEASEDIR}" || error "can't find release" - md5sum ${RELEASEDIR}/Gate - test -f ${RELEASEDIR}/libGate.so && md5sum ${RELEASEDIR}/libGate.so + test -d "${RELEASEDIR}" || error "can't find release" + md5sum ${RELEASEDIR}/Gate + test -f ${RELEASEDIR}/libGate.so && md5sum ${RELEASEDIR}/libGate.so - echo "Finding libraries" - ROOTLIBS="${RELEASEDIR}/libCore.so:${RELEASEDIR}/libCint.so:${RELEASEDIR}/libRIO.so:${RELEASEDIR}/libNet.so:${RELEASEDIR}/libHist.so:${RELEASEDIR}/libGraf.so:${RELEASEDIR}/libGraf3d.so:${RELEASEDIR}/libGpad.so:${RELEASEDIR}/libTree.so:${RELEASEDIR}/libRint.so:${RELEASEDIR}/libPostscript.so:${RELEASEDIR}/libMatrix.so:${RELEASEDIR}/libPhysics.so:${RELEASEDIR}/libMathCore.so:${RELEASEDIR}/libThread.so:" - echo "ROOTLIBS=${ROOTLIBS}" - G4LIBS="$(for library in $(find "${RELEASEDIR}" -maxdepth 1 -name 'libG4*.so'); do echo -n "${library}:"; done)" - echo "G4LIBS=${G4LIBS}" - CLHEPLIBS="$(for library in $(find "${RELEASEDIR}" -maxdepth 1 -name 'libCLHEP*.so'); do echo -n "${library}:"; done)" - echo "CLHEPLIBS=${CLHEPLIBS}" - GATELIBS="" - test -f ${RELEASEDIR}/libGate.so && GATELIBS="${RELEASEDIR}/libGate.so:" - echo "GATELIBS=${GATELIBS}" + echo "Finding libraries" + ROOTLIBS="${RELEASEDIR}/libCore.so:${RELEASEDIR}/libCint.so:${RELEASEDIR}/libRIO.so:${RELEASEDIR}/libNet.so:${RELEASEDIR}/libHist.so:${RELEASEDIR}/libGraf.so:${RELEASEDIR}/libGraf3d.so:${RELEASEDIR}/libGpad.so:${RELEASEDIR}/libTree.so:${RELEASEDIR}/libRint.so:${RELEASEDIR}/libPostscript.so:${RELEASEDIR}/libMatrix.so:${RELEASEDIR}/libPhysics.so:${RELEASEDIR}/libMathCore.so:${RELEASEDIR}/libThread.so:" + echo "ROOTLIBS=${ROOTLIBS}" + G4LIBS="$(for library in $(find "${RELEASEDIR}" -maxdepth 1 -name 'libG4*.so'); do echo -n "${library}:"; done)" + echo "G4LIBS=${G4LIBS}" + CLHEPLIBS="$(for library in $(find "${RELEASEDIR}" -maxdepth 1 -name 'libCLHEP*.so'); do echo -n "${library}:"; done)" + echo "CLHEPLIBS=${CLHEPLIBS}" + GATELIBS="" + test -f ${RELEASEDIR}/libGate.so && GATELIBS="${RELEASEDIR}/libGate.so:" + echo "GATELIBS=${GATELIBS}" fi test -d "${MACRODIR}" && test -d "${MACRODIR}/mac" || error "invalid macro" echo "Copying inputs" LOCALMACRODIR=$(mktemp -d) -trap "mv output ${OUTPUTDIR}/output.${JOB_ID%%.*} ; rm -r ${LOCALMACRODIR} ; exit 1" 1 2 3 15 +trap "wait ; transferJobData ; exit 1" 1 2 3 15 cd ${LOCALMACRODIR} cp -r -L "${MACRODIR}"/{data,mac} . mkdir output @@ -76,29 +86,24 @@ echo "Lauching macro" date if test "$RELEASEDIR" = "NONE" then - Gate ${PARAM} ${MACROFILE} || error "gate failed" + Gate ${PARAM} ${MACROFILE} || error "gate failed" else - LD_PRELOAD="${ROOTLIBS}${G4LIBS}${CLHEPLIBS}${GATELIBS}" \ - G4LEVELGAMMADATA="${RELEASEDIR}/PhotonEvaporation2.1" \ - G4RADIOACTIVEDATA="${RELEASEDIR}/RadioactiveDecay3.3" \ - G4LEDATA="${RELEASEDIR}/G4EMLOW6.19" \ - G4NEUTRONHPDATA="${RELEASEDIR}/G4NDL3.14" \ - G4ABLADATA="${RELEASEDIR}/G4ABLA3.0" \ - G4REALSURFACEDATA="${RELEASEDIR}/RealSurface1.0" \ - G4NEUTRONXSDATA="${RELEASEDIR}/G4NEUTRONXS1.0" \ - G4PIIDATA="${RELEASEDIR}/G4PII1.2" \ - /usr/bin/time --format="real %es\nuser %Us\nsys %Ss\nmaxmem %Mk" \ - ${RELEASEDIR}/Gate ${PARAM} ${MACROFILE} \ - || error "gate failed" + LD_PRELOAD="${ROOTLIBS}${G4LIBS}${CLHEPLIBS}${GATELIBS}" \ + G4LEVELGAMMADATA="${RELEASEDIR}/PhotonEvaporation2.1" \ + G4RADIOACTIVEDATA="${RELEASEDIR}/RadioactiveDecay3.3" \ + G4LEDATA="${RELEASEDIR}/G4EMLOW6.19" \ + G4NEUTRONHPDATA="${RELEASEDIR}/G4NDL3.14" \ + G4ABLADATA="${RELEASEDIR}/G4ABLA3.0" \ + G4REALSURFACEDATA="${RELEASEDIR}/RealSurface1.0" \ + G4NEUTRONXSDATA="${RELEASEDIR}/G4NEUTRONXS1.0" \ + G4PIIDATA="${RELEASEDIR}/G4PII1.2" \ + /usr/bin/time --format="real %es\nuser %Us\nsys %Ss\nmaxmem %Mk" \ + ${RELEASEDIR}/Gate ${PARAM} ${MACROFILE} \ + || error "gate failed" fi date -echo "Copying data back" -ssh -i ${HOME}/.ssh/ccin2p3 linux1.dg.creatis.insa-lyon.fr "mkdir cc/$(basename ${OUTPUTDIR})/output.${JOB_ID%%.*}" -rsync -av --remove-source-files -e "ssh -i ${HOME}/.ssh/ccin2p3" output/ "linux1.dg.creatis.insa-lyon.fr:./cc/$(basename ${OUTPUTDIR})/output.${JOB_ID%%.*}" - -echo "Cleanup" -rm -r ${LOCALMACRODIR} +transferJobData date echo "Success!!!" diff --git a/cluster_tools/gate_run_submit_cluster.sh b/cluster_tools/gate_run_submit_cluster.sh index 9112050..edd798b 100755 --- a/cluster_tools/gate_run_submit_cluster.sh +++ b/cluster_tools/gate_run_submit_cluster.sh @@ -1,4 +1,4 @@ -#! /usr/local/bin/bash -lx +#! /bin/bash -lx set -u SCRIPTNAME="$(basename "${0}")" @@ -102,13 +102,14 @@ while test $NJOBS -gt 0; do PARAM=\"${PARAM}\" INDEX=${NJOBS} INDEXMAX=${NJOBSMAX} OUTPUTDIR=${OUTPUTDIR} RELEASEDIR=${RELEASEDIR} MACROFILE=${MACROFILE} MACRODIR=${MACRODIR} PBS_JOBID="local_${NJOBS}" bash "${JOBFILE}" > ${OUTPUTDIR}/gate_${NJOBS}.log & elif test "$(dnsdomainname)" = "in2p3.fr" then - PROJECTGROUP=creatis + PROJECTGROUP=creatis qsub -o "${OUTPUTDIR}" \ + -l sps=1 \ -N "gate.${RUNID}" \ -v "PARAM=\"${PARAM}\",INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \ "${JOBFILE}" || error "submission error" else - qsub -N "gatejob.${RUNID}" -o "${OUTPUTDIR}" \ + qsub -N "gatejob.${RUNID}" -o "${OUTPUTDIR}" \ -v "PARAM=${PARAM},INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \ "${JOBFILE}" || error "submission error" fi @@ -117,7 +118,3 @@ while test $NJOBS -gt 0; do done echo "runid is ${RUNID}" -if test "$(dnsdomainname)" = "in2p3.fr" -then - rsync -av --remove-source-files -e "ssh -i ${HOME}/.ssh/ccin2p3" ${OUTPUTDIR}/ "linux1.dg.creatis.insa-lyon.fr:./cc/$(basename ${OUTPUTDIR})" --exclude '.__afs*' --exclude "${OUTPUTDIR}/gatejob.*.o*" -fi diff --git a/cmake/build_opt.cmake b/cmake/build_opt.cmake index 2331750..54a3531 100644 --- a/cmake/build_opt.cmake +++ b/cmake/build_opt.cmake @@ -20,6 +20,8 @@ endif(BUILD_DOXYGEN) # Compilation options option(CLITK_EXPERIMENTAL "Enable experimental software and features" OFF) mark_as_advanced(CLITK_EXPERIMENTAL) +option(CLITK_MEMORY_INFO "Enable memory info (need libstatgrab >= v.0.90)" OFF) +mark_as_advanced(CLITK_MEMORY_INFO) option(CLITK_BUILD_TOOLS "Build command-line tools" OFF) option(CLITK_BUILD_SEGMENTATION "Build command-line segmentation tools" OFF) option(CLITK_BUILD_REGISTRATION "Build command-line registration tools" OFF) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index bdd6316..a871fec 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -44,15 +44,15 @@ find_package(Gengetopt) #========================================================= # Find libstatgrab is installed, add clitkMemoryUsage.cxx in the library -#if(NOT DEFINED CLITK_MEMORY_INFO OR CLITK_MEMORY_INFO) -# find_library(LIBSTATGRAB NAMES statgrab PATHS) -# if(${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") +if(NOT DEFINED CLITK_MEMORY_INFO OR CLITK_MEMORY_INFO) + find_library(LIBSTATGRAB NAMES statgrab PATHS) + if(${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") # message("Install libstatgrab (http://www.i-scream.org/libstatgrab/) for memory usage information") set(CLITK_MEMORY_INFO OFF) -# else(${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") -# set(CLITK_MEMORY_INFO ON) -# endif(${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") -#endif() + else(${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") + set(CLITK_MEMORY_INFO ON) + endif(${LIBSTATGRAB} MATCHES "LIBSTATGRAB-NOTFOUND") +endif() #========================================================= diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 94d1c60..d7cd460 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -69,6 +69,9 @@ namespace clitk { exit(-3); \ } +#ifndef ITK_OVERRIDE +# define ITK_OVERRIDE +#endif //-------------------------------------------------------------------- // when everything goes wrong diff --git a/common/clitkDicomRTDoseIO.h b/common/clitkDicomRTDoseIO.h index f233f3a..2f08938 100644 --- a/common/clitkDicomRTDoseIO.h +++ b/common/clitkDicomRTDoseIO.h @@ -59,17 +59,17 @@ public: itkTypeMacro(DicomRTDoseIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); - virtual bool CanReadFile( const char* FileNameToRead ); - virtual void Read(void * buffer); + virtual void ReadImageInformation() ITK_OVERRIDE; + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); - virtual void Write(const void* buffer); + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: template void dose_copy_raw (float *img_out, T *img_in, int nvox, float scale); diff --git a/common/clitkDicomRTDoseIOFactory.h b/common/clitkDicomRTDoseIOFactory.h index fc22891..9dae60d 100644 --- a/common/clitkDicomRTDoseIOFactory.h +++ b/common/clitkDicomRTDoseIOFactory.h @@ -41,11 +41,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "Dicom RT Dose IO factory"; } diff --git a/common/clitkEsrfHstImageIO.h b/common/clitkEsrfHstImageIO.h index 9a732be..c35f98f 100644 --- a/common/clitkEsrfHstImageIO.h +++ b/common/clitkEsrfHstImageIO.h @@ -23,6 +23,8 @@ #include #include +#include "clitkCommon.h" + namespace clitk { @@ -45,15 +47,15 @@ public: itkTypeMacro(EsrfHstImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); - virtual bool CanReadFile( const char* FileNameToRead ); - virtual void Read(void * buffer); + virtual void ReadImageInformation() ITK_OVERRIDE; + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); - virtual void Write(const void* buffer); + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: std::string m_XmlFileName; diff --git a/common/clitkEsrfHstImageIOFactory.h b/common/clitkEsrfHstImageIOFactory.h index 0f26584..b63d4ad 100644 --- a/common/clitkEsrfHstImageIOFactory.h +++ b/common/clitkEsrfHstImageIOFactory.h @@ -24,6 +24,8 @@ #include #include +#include "clitkCommon.h" + namespace clitk { @@ -39,11 +41,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "Esrf Hst ImageIO Factory, allows the loading of Esrf Hst images into insight"; } diff --git a/common/clitkEsrfHstXMLFileReader.h b/common/clitkEsrfHstXMLFileReader.h index 1b24a0b..bd2f0a2 100644 --- a/common/clitkEsrfHstXMLFileReader.h +++ b/common/clitkEsrfHstXMLFileReader.h @@ -28,6 +28,8 @@ #include +#include "clitkCommon.h" + namespace clitk { @@ -51,17 +53,17 @@ public: itkNewMacro(Self); /** Determine if a file can be read */ - int CanReadFile(const char* name); + int CanReadFile(const char* name) ITK_OVERRIDE; protected: EsrfHstXMLFileReader() {m_OutputObject = &m_Dictionary;}; virtual ~EsrfHstXMLFileReader() {}; - virtual void StartElement(const char * name,const char **atts); + virtual void StartElement(const char * name,const char **atts) ITK_OVERRIDE; - virtual void EndElement(const char *name); + virtual void EndElement(const char *name) ITK_OVERRIDE; - void CharacterDataHandler(const char *inData, int inLength); + void CharacterDataHandler(const char *inData, int inLength) ITK_OVERRIDE; private: EsrfHstXMLFileReader(const Self&); //purposely not implemented diff --git a/common/clitkGateAsciiImageIO.h b/common/clitkGateAsciiImageIO.h index 7d134de..d5eefc1 100644 --- a/common/clitkGateAsciiImageIO.h +++ b/common/clitkGateAsciiImageIO.h @@ -30,6 +30,8 @@ typedef unsigned int uint32_t; #include #endif +#include "clitkCommon.h" + namespace clitk { @@ -59,16 +61,16 @@ public: itkTypeMacro(GateAsciiImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); - virtual bool CanReadFile( const char* FileNameToRead ); - virtual void Read(void * buffer); + virtual void ReadImageInformation() ITK_OVERRIDE; + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ - virtual void WriteImageInformation(); - virtual bool CanWriteFile(const char* filename); - virtual void Write(const void* buffer); + virtual void WriteImageInformation() ITK_OVERRIDE; + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; + virtual void Write(const void* buffer) ITK_OVERRIDE; - virtual bool SupportsDimension(unsigned long dim); + virtual bool SupportsDimension(unsigned long dim) ITK_OVERRIDE; protected: static bool ReadHeader(FILE* handle, GateAsciiHeader& header); diff --git a/common/clitkGateAsciiImageIOFactory.h b/common/clitkGateAsciiImageIOFactory.h index bae5ac3..90fd97e 100644 --- a/common/clitkGateAsciiImageIOFactory.h +++ b/common/clitkGateAsciiImageIOFactory.h @@ -40,11 +40,11 @@ namespace clitk { typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "GateAscii ImageIO Factory, allows the loading of gate ascii images into insight"; } diff --git a/common/clitkMemoryUsage.cxx b/common/clitkMemoryUsage.cxx index e2a095d..9cc75d0 100644 --- a/common/clitkMemoryUsage.cxx +++ b/common/clitkMemoryUsage.cxx @@ -1,7 +1,7 @@ /*========================================================================= Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Authors belong to: + Authors belong to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr @@ -23,7 +23,7 @@ # include #endif -void clitk::PrintMemory(bool verbose, std::string s) +void clitk::PrintMemory(bool verbose, std::string s) { #if CLITK_MEMORY_INFO == 1 if (verbose) { @@ -38,21 +38,30 @@ void clitk::PrintMemory(bool verbose, std::string s) #endif } -double clitk::GetMemoryUsageInMb() +double clitk::GetMemoryUsageInMb() { #if CLITK_MEMORY_INFO == 1 //sleep(1); // wait to refresh memory ? need to let the system refresh the mem - int * entries = new int; - sg_process_stats * stat = new sg_process_stats; - int i=0; - stat = sg_get_process_stats(entries); + size_t entries; + sg_process_stats *stat; + int i=0; + sg_init(1); + + stat = sg_get_process_stats(&entries); + if(stat == NULL) + return 0.0; + // Search the current pid in the list of processes - while (stat[i].pid != getpid()) i++; - // Display total memory size - double mem = stat[i].proc_resident/1024/1024; // in Mb + while (stat->pid != getpid() && i < entries) + { + ++i; + ++stat; + } + + // Display total memory size + double mem = stat->proc_resident/1000/1000; // in MB return mem; #else return 0.0; #endif } - diff --git a/common/clitkVfImageIO.h b/common/clitkVfImageIO.h index 5bdcf88..fbe6d9c 100644 --- a/common/clitkVfImageIO.h +++ b/common/clitkVfImageIO.h @@ -60,15 +60,15 @@ namespace clitk { itkTypeMacro(VfImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); - virtual bool CanReadFile( const char* FileNameToRead ); - virtual void Read(void * buffer); + virtual void ReadImageInformation() ITK_OVERRIDE; + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); - virtual void Write(const void* buffer); + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: bool mustWriteHeader; diff --git a/common/clitkVfImageIOFactory.h b/common/clitkVfImageIOFactory.h index f00b8d2..6d790f0 100644 --- a/common/clitkVfImageIOFactory.h +++ b/common/clitkVfImageIOFactory.h @@ -50,11 +50,11 @@ namespace clitk { typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "Vf ImageIO Factory, allows the loading of Vf images into insight"; } diff --git a/common/clitkVoxImageIO.h b/common/clitkVoxImageIO.h index 1d0aced..6a4f924 100644 --- a/common/clitkVoxImageIO.h +++ b/common/clitkVoxImageIO.h @@ -58,15 +58,15 @@ namespace clitk { itkTypeMacro(VoxImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); - virtual bool CanReadFile( const char* FileNameToRead ); - virtual void Read(void * buffer); + virtual void ReadImageInformation() ITK_OVERRIDE; + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); - virtual void Write(const void* buffer); + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: bool mustWriteHeader; diff --git a/common/clitkVoxImageIOFactory.h b/common/clitkVoxImageIOFactory.h index 70e00a8..8ca7ccc 100644 --- a/common/clitkVoxImageIOFactory.h +++ b/common/clitkVoxImageIOFactory.h @@ -49,11 +49,11 @@ namespace clitk { typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "Vox ImageIO Factory, allows the loading of Vox images into insight"; } diff --git a/common/clitkXdrImageIO.h b/common/clitkXdrImageIO.h index 98fa739..3458898 100644 --- a/common/clitkXdrImageIO.h +++ b/common/clitkXdrImageIO.h @@ -34,6 +34,8 @@ #define AVSerror(v) itkGenericExceptionMacro(<< "Error in clitk::XdrImageIO. Message:" << v); #define AVSwarning(v) itkWarningMacro(<< "Error in clitk::XdrImageIO. Message:" << v); +#include "clitkCommon.h" + namespace clitk { //==================================================================== @@ -61,15 +63,15 @@ public: /*-------- This part of the interface deals with reading data. ------ */ virtual int ReadImageInformationWithError(); virtual int ReadWithError(void * buffer); - virtual void ReadImageInformation(); - virtual void Read(void * buffer); - virtual bool CanReadFile( const char* FileNameToRead ); + virtual void ReadImageInformation() ITK_OVERRIDE; + virtual void Read(void * buffer) ITK_OVERRIDE; + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream) {;} - virtual void WriteImageInformation() { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* FileNameToWrite); - virtual void Write(const void* buffer); + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } + virtual bool CanWriteFile(const char* FileNameToWrite) ITK_OVERRIDE; + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: void ITKError(std::string funcName, int msgID); diff --git a/common/clitkXdrImageIOFactory.h b/common/clitkXdrImageIOFactory.h index 8cd00b7..47ca942 100644 --- a/common/clitkXdrImageIOFactory.h +++ b/common/clitkXdrImageIOFactory.h @@ -50,11 +50,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "Xdr ImageIO Factory, allows the loading of Xdr images into insight"; } diff --git a/common/rtkEdfImageIO.h b/common/rtkEdfImageIO.h index 83823cb..f88b2b7 100644 --- a/common/rtkEdfImageIO.h +++ b/common/rtkEdfImageIO.h @@ -23,6 +23,8 @@ #include #include +#include "clitkCommon.h" + namespace rtk { /** \class EdfImageIO @@ -51,22 +53,22 @@ public: itkTypeMacro(EdfImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); + virtual void ReadImageInformation() ITK_OVERRIDE; - virtual bool CanReadFile( const char* FileNameToRead ); + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; - virtual void Read(void * buffer); + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; - virtual void Write(const void* buffer); + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: std::string m_BinaryFileName; diff --git a/common/rtkEdfImageIOFactory.h b/common/rtkEdfImageIOFactory.h index 33eb518..f789f48 100644 --- a/common/rtkEdfImageIOFactory.h +++ b/common/rtkEdfImageIOFactory.h @@ -41,11 +41,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "Edf ImageIO Factory, allows the loading of Edf images into insight"; } diff --git a/common/rtkHisImageIO.h b/common/rtkHisImageIO.h index 030711c..9a0e354 100644 --- a/common/rtkHisImageIO.h +++ b/common/rtkHisImageIO.h @@ -22,6 +22,8 @@ // itk include #include +#include "clitkCommon.h" + namespace rtk { @@ -54,24 +56,24 @@ public: itkTypeMacro(HisImageIO, itk::ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); + virtual void ReadImageInformation() ITK_OVERRIDE; - virtual bool CanReadFile( const char* FileNameToRead ); + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; - virtual void Read(void * buffer); + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool /*keepOfStream*/) { ; } - virtual void WriteImageInformation() { + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; - virtual void Write(const void* buffer); + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: int m_HeaderSize; diff --git a/common/rtkHisImageIOFactory.h b/common/rtkHisImageIOFactory.h index fbaccda..bb45d20 100644 --- a/common/rtkHisImageIOFactory.h +++ b/common/rtkHisImageIOFactory.h @@ -44,11 +44,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "His ImageIO Factory, allows the loading of His images into insight"; } diff --git a/common/rtkHndImageIO.h b/common/rtkHndImageIO.h index 6f32ec9..f88e11e 100644 --- a/common/rtkHndImageIO.h +++ b/common/rtkHndImageIO.h @@ -29,6 +29,8 @@ #include #endif +#include "clitkCommon.h" + namespace rtk { /** \class HndImageIO @@ -121,20 +123,20 @@ public: itkTypeMacro(HndImageIO, itk::ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); + virtual void ReadImageInformation() ITK_OVERRIDE; - virtual bool CanReadFile( const char* FileNameToRead ); + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; - virtual void Read(void * buffer); + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool /*keepOfStream*/) { } - virtual void WriteImageInformation() { WriteImageInformation(false); } + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; - virtual void Write(const void* buffer); + virtual void Write(const void* buffer) ITK_OVERRIDE; }; // end class HndImageIO diff --git a/common/rtkHndImageIOFactory.h b/common/rtkHndImageIOFactory.h index a410e62..24ca3a1 100644 --- a/common/rtkHndImageIOFactory.h +++ b/common/rtkHndImageIOFactory.h @@ -47,11 +47,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "His ImageIO Factory, allows the loading of His images into insight"; } diff --git a/common/rtkImagXImageIO.h b/common/rtkImagXImageIO.h index bbdc6a8..387dd68 100644 --- a/common/rtkImagXImageIO.h +++ b/common/rtkImagXImageIO.h @@ -23,6 +23,8 @@ #include #include +#include "clitkCommon.h" + namespace rtk { @@ -48,19 +50,19 @@ public: itkTypeMacro(ImagXImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); + virtual void ReadImageInformation() ITK_OVERRIDE; - virtual bool CanReadFile( const char* FileNameToRead ); + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; - virtual void Read(void * buffer); + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; - virtual void Write(const void* buffer); + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: std::string m_RawFileName; diff --git a/common/rtkImagXImageIOFactory.h b/common/rtkImagXImageIOFactory.h index 2466e9d..da584f7 100644 --- a/common/rtkImagXImageIOFactory.h +++ b/common/rtkImagXImageIOFactory.h @@ -42,11 +42,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "ImagX ImageIO Factory, allows the loading of ImagX images into insight"; } diff --git a/common/rtkImagXXMLFileReader.h b/common/rtkImagXXMLFileReader.h index 1a948e2..e3493c1 100644 --- a/common/rtkImagXXMLFileReader.h +++ b/common/rtkImagXXMLFileReader.h @@ -28,6 +28,8 @@ #include +#include "clitkCommon.h" + namespace rtk { @@ -51,17 +53,17 @@ public: itkNewMacro(Self); /** Determine if a file can be read */ - int CanReadFile(const char* name); + int CanReadFile(const char* name) ITK_OVERRIDE; protected: ImagXXMLFileReader() {m_OutputObject = &m_Dictionary;} virtual ~ImagXXMLFileReader() {} - virtual void StartElement(const char * name,const char **atts); + virtual void StartElement(const char * name,const char **atts) ITK_OVERRIDE; - virtual void EndElement(const char *name); + virtual void EndElement(const char *name) ITK_OVERRIDE; - void CharacterDataHandler(const char *inData, int inLength); + void CharacterDataHandler(const char *inData, int inLength) ITK_OVERRIDE; private: ImagXXMLFileReader(const Self&); //purposely not implemented diff --git a/common/rtkXRadImageIO.h b/common/rtkXRadImageIO.h index 8229455..65d2d11 100644 --- a/common/rtkXRadImageIO.h +++ b/common/rtkXRadImageIO.h @@ -23,6 +23,8 @@ #include #include +#include "clitkCommon.h" + namespace rtk { /** \class XRadImageIO @@ -51,22 +53,22 @@ public: itkTypeMacro(XRadImageIO, ImageIOBase); /*-------- This part of the interface deals with reading data. ------ */ - virtual void ReadImageInformation(); + virtual void ReadImageInformation() ITK_OVERRIDE; - virtual bool CanReadFile( const char* FileNameToRead ); + virtual bool CanReadFile( const char* FileNameToRead ) ITK_OVERRIDE; - virtual void Read(void * buffer); + virtual void Read(void * buffer) ITK_OVERRIDE; /*-------- This part of the interfaces deals with writing data. ----- */ virtual void WriteImageInformation(bool keepOfStream); - virtual void WriteImageInformation() { + virtual void WriteImageInformation() ITK_OVERRIDE { WriteImageInformation(false); } - virtual bool CanWriteFile(const char* filename); + virtual bool CanWriteFile(const char* filename) ITK_OVERRIDE; - virtual void Write(const void* buffer); + virtual void Write(const void* buffer) ITK_OVERRIDE; protected: diff --git a/common/rtkXRadImageIOFactory.h b/common/rtkXRadImageIOFactory.h index 1651918..23cb63e 100644 --- a/common/rtkXRadImageIOFactory.h +++ b/common/rtkXRadImageIOFactory.h @@ -41,11 +41,11 @@ public: typedef itk::SmartPointer ConstPointer; /** Class methods used to interface with the registered factories. */ - const char* GetITKSourceVersion(void) const { + const char* GetITKSourceVersion(void) const ITK_OVERRIDE { return ITK_SOURCE_VERSION; } - const char* GetDescription(void) const { + const char* GetDescription(void) const ITK_OVERRIDE { return "XRad ImageIO Factory, allows the loading of XRad images into insight"; } diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 47a0e34..c7e13cc 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -196,7 +196,7 @@ unsigned long vvImage::GetActualMemorySize() { unsigned long size = 0; for (unsigned int i = 0; i < mVtkImages.size(); i++) { - size += mVtkImages[i]->GetActualMemorySize(); + size += mVtkImages[i]->GetActualMemorySize()*1024; } return size; } diff --git a/common/vvImageReader.txx b/common/vvImageReader.txx index d1fddfb..a9f17ab 100644 --- a/common/vvImageReader.txx +++ b/common/vvImageReader.txx @@ -157,11 +157,17 @@ void vvImageReader::UpdateWithDimAndInputPixelType() spacing.Fill(1); typename OutputImageType::PointType origin; origin.Fill(0); + typename OutputImageType::DirectionType direction; + direction.SetIdentity(); for (unsigned int pixelDim=0; pixelDimGetLargestPossibleRegion().GetSize(pixelDim); spacing[pixelDim]=input->GetSpacing()[pixelDim]; origin[pixelDim]=input->GetOrigin()[pixelDim]; + for (unsigned int pixelDim2=0; pixelDim2GetDirection()[pixelDim][pixelDim2]; + } } typename OutputImageType::RegionType region; region.SetSize(size); @@ -169,6 +175,7 @@ void vvImageReader::UpdateWithDimAndInputPixelType() output->SetRegions(region); output->SetOrigin(origin); output->SetSpacing(spacing); + output->SetDirection(direction); output->Allocate(); //Copy each channel @@ -193,10 +200,10 @@ void vvImageReader::UpdateWithDimAndInputPixelType() } } - if (VImageDimension == 4) +/* if (VImageDimension == 4) mType == VECTORPIXELIMAGEWITHTIME; else - mType == VECTORPIXELIMAGE; + mType == VECTORPIXELIMAGE;*/ try { mImage = vvImageFromITK(output, mType == VECTORPIXELIMAGEWITHTIME); diff --git a/itk/RelativePositionPropImageFilter.h b/itk/RelativePositionPropImageFilter.h index 183f260..c4f0812 100644 --- a/itk/RelativePositionPropImageFilter.h +++ b/itk/RelativePositionPropImageFilter.h @@ -170,8 +170,8 @@ namespace itk } - virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError); - void EnlargeOutputRequestedRegion (DataObject * output); + virtual void GenerateInputRequestedRegion() throw(InvalidRequestedRegionError) ITK_OVERRIDE; + void EnlargeOutputRequestedRegion (DataObject * output) ITK_OVERRIDE; protected: RelativePositionPropImageFilter() @@ -185,10 +185,10 @@ namespace itk m_VerboseProgress = false; } virtual ~RelativePositionPropImageFilter() {} - void PrintSelf(std::ostream& os, Indent indent) const; + void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE; //void GenerateThreadedData(const typename TOutputImage::RegionType& outputRegionForThread, int threadId); - void GenerateData(); + void GenerateData() ITK_OVERRIDE; private: RelativePositionPropImageFilter(const Self&); //purposely not implemented diff --git a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h index 781775f..45f331e 100644 --- a/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h +++ b/itk/clitkAddRelativePositionConstraintToLabelImageFilter.h @@ -85,7 +85,7 @@ namespace clitk { } OrientationTypeEnumeration; /** Input : initial image and object */ - void SetInput(const ImageType * image); + void SetInput(const ImageType * image) ITK_OVERRIDE; void SetInputObject(const ImageType * image); // Options @@ -149,7 +149,7 @@ namespace clitk { typename FloatImageType::Pointer GetFuzzyMap() { return m_FuzzyMap; } // I dont want to verify inputs information - virtual void VerifyInputInformation() { } + virtual void VerifyInputInformation() ITK_OVERRIDE { } // For debug void PrintOptions(); @@ -176,9 +176,9 @@ namespace clitk { double m_Radius; double m_K1; - virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - virtual void GenerateData(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; typedef itk::PasteImageFilter PasteFilterType; typedef itk::PasteImageFilter PasteFloatFilterType; diff --git a/itk/clitkAutoCropFilter.h b/itk/clitkAutoCropFilter.h index 98ab74f..f24aa05 100644 --- a/itk/clitkAutoCropFilter.h +++ b/itk/clitkAutoCropFilter.h @@ -54,7 +54,7 @@ namespace clitk { typedef long LabelType; /** Connect one of the operands for pixel-wise addition */ - void SetInput( const ImageType * image); + void SetInput( const ImageType * image) ITK_OVERRIDE; // LabelImage information (BG) void SetBackgroundValue(ImagePixelType p); @@ -71,8 +71,8 @@ namespace clitk { AutoCropFilter(); virtual ~AutoCropFilter() {} - virtual void GenerateOutputInformation(); - virtual void GenerateData(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; ImagePixelType m_BackgroundValue; ImageRegionType m_Region; diff --git a/itk/clitkBooleanOperatorLabelImageFilter.h b/itk/clitkBooleanOperatorLabelImageFilter.h index adb7116..e7d1b73 100644 --- a/itk/clitkBooleanOperatorLabelImageFilter.h +++ b/itk/clitkBooleanOperatorLabelImageFilter.h @@ -99,18 +99,18 @@ namespace clitk { itkStaticConstMacro(OutputImageDimension, unsigned int, TOutputImage::ImageDimension); // I dont want to verify inputs information - virtual void VerifyInputInformation() { } + virtual void VerifyInputInformation() ITK_OVERRIDE { } protected: BooleanOperatorLabelImageFilter(); virtual ~BooleanOperatorLabelImageFilter() {} - virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - virtual void GenerateData(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; // Do not release date to keep input in memory and continue ... - virtual void ReleaseInputs() { } + virtual void ReleaseInputs() ITK_OVERRIDE { } Input1ImagePixelType mBackgroundValue1; Input2ImagePixelType mBackgroundValue2; diff --git a/itk/clitkCropLikeImageFilter.h b/itk/clitkCropLikeImageFilter.h index cc7623f..47ae445 100644 --- a/itk/clitkCropLikeImageFilter.h +++ b/itk/clitkCropLikeImageFilter.h @@ -71,15 +71,15 @@ namespace clitk { itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension); // I dont want to verify inputs information - virtual void VerifyInputInformation() { } + virtual void VerifyInputInformation() ITK_OVERRIDE { } protected: CropLikeImageFilter(); virtual ~CropLikeImageFilter() {} - virtual void GenerateOutputInformation(); - virtual void GenerateData(); - virtual void GenerateInputRequestedRegion(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; PixelType m_BackgroundValue; RegionType m_OutputRegion; diff --git a/itk/clitkExplosionControlledThresholdConnectedImageFilter.h b/itk/clitkExplosionControlledThresholdConnectedImageFilter.h index 9211418..f7a31dc 100644 --- a/itk/clitkExplosionControlledThresholdConnectedImageFilter.h +++ b/itk/clitkExplosionControlledThresholdConnectedImageFilter.h @@ -62,7 +62,7 @@ public: typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename OutputImageType::PixelType OutputImagePixelType; - void PrintSelf ( std::ostream& os, itk::Indent indent ) const; + void PrintSelf ( std::ostream& os, itk::Indent indent ) const ITK_OVERRIDE; /** Clear the seeds */ void ClearSeeds(); @@ -178,11 +178,11 @@ protected: unsigned int m_MinimumSize; // Override since the filter needs all the data for the algorithm - void GenerateInputRequestedRegion(); + void GenerateInputRequestedRegion() ITK_OVERRIDE; // Override since the filter produces the entire dataset - void EnlargeOutputRequestedRegion(itk::DataObject *output); - void GenerateData(); + void EnlargeOutputRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void GenerateData() ITK_OVERRIDE; private: ExplosionControlledThresholdConnectedImageFilter(const Self&); //purposely not implemented diff --git a/itk/clitkExtractSliceFilter.h b/itk/clitkExtractSliceFilter.h index 2cdabcf..30976ce 100644 --- a/itk/clitkExtractSliceFilter.h +++ b/itk/clitkExtractSliceFilter.h @@ -81,7 +81,7 @@ namespace clitk { FILTERBASE_INIT; /** Input : initial image and object */ - void SetInput(const ImageType * image); + void SetInput(const ImageType * image) ITK_OVERRIDE; // Options itkGetConstMacro(Direction, int); @@ -96,9 +96,9 @@ namespace clitk { int m_Direction; - virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - virtual void GenerateData(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; int m_NumberOfSlices; ImagePointer input; diff --git a/itk/clitkInvertVFFilter.h b/itk/clitkInvertVFFilter.h index 8475241..52edcd9 100644 --- a/itk/clitkInvertVFFilter.h +++ b/itk/clitkInvertVFFilter.h @@ -65,7 +65,7 @@ namespace clitk //Set Methods(inline) itkSetMacro( Verbose, bool); itkSetMacro( EdgePaddingValue, PixelType ); - void SetNumberOfThreads(unsigned int r ) + void SetNumberOfThreads(unsigned int r ) ITK_OVERRIDE { m_NumberOfThreadsIsGiven=true; m_NumberOfThreads=r; @@ -78,7 +78,7 @@ namespace clitk protected: InvertVFFilter(); ~InvertVFFilter() {}; - void GenerateData( ); + void GenerateData( ) ITK_OVERRIDE; bool m_Verbose; bool m_NumberOfThreadsIsGiven; diff --git a/itk/clitkInvertVFFilter.txx b/itk/clitkInvertVFFilter.txx index c32782f..4b98230 100644 --- a/itk/clitkInvertVFFilter.txx +++ b/itk/clitkInvertVFFilter.txx @@ -74,8 +74,8 @@ protected: ~HelperClass1() {}; //the actual processing - void BeforeThreadedGenerateData(); - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); + void BeforeThreadedGenerateData() ITK_OVERRIDE; + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) ITK_OVERRIDE; //member data typename WeightsImageType::Pointer m_Weights; @@ -289,7 +289,7 @@ protected: //the actual processing - void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ); + void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) ITK_OVERRIDE; //member data typename WeightsImageType::Pointer m_Weights; diff --git a/itk/clitkLocallyAdaptiveBinaryThresholdImageFunction.h b/itk/clitkLocallyAdaptiveBinaryThresholdImageFunction.h index 6b32e82..f05c892 100644 --- a/itk/clitkLocallyAdaptiveBinaryThresholdImageFunction.h +++ b/itk/clitkLocallyAdaptiveBinaryThresholdImageFunction.h @@ -71,17 +71,17 @@ public: itkGetConstReferenceMacro(Radius, InputSizeType); /** Evalulate the function at specified index */ - virtual bool EvaluateAtIndex( const IndexType& index ) const; + virtual bool EvaluateAtIndex( const IndexType& index ) const ITK_OVERRIDE; /** Evaluate the function at non-integer positions */ - virtual bool Evaluate( const PointType& point ) const + virtual bool Evaluate( const PointType& point ) const ITK_OVERRIDE { IndexType index; this->ConvertPointToNearestIndex( point, index ); return this->EvaluateAtIndex( index ); } virtual bool EvaluateAtContinuousIndex( - const ContinuousIndexType& cindex ) const + const ContinuousIndexType& cindex ) const ITK_OVERRIDE { IndexType index; this->ConvertContinuousIndexToNearestIndex( cindex, index ); @@ -108,7 +108,7 @@ public: protected: LocallyAdaptiveBinaryThresholdImageFunction(); ~LocallyAdaptiveBinaryThresholdImageFunction(){}; - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: LocallyAdaptiveBinaryThresholdImageFunction( const Self& ); //purposely not implemented diff --git a/itk/clitkLocallyAdaptiveThresholdConnectedImageFilter.h b/itk/clitkLocallyAdaptiveThresholdConnectedImageFilter.h index dc71f7f..2d38caa 100644 --- a/itk/clitkLocallyAdaptiveThresholdConnectedImageFilter.h +++ b/itk/clitkLocallyAdaptiveThresholdConnectedImageFilter.h @@ -61,7 +61,7 @@ public: typedef typename OutputImageType::RegionType OutputImageRegionType; typedef typename OutputImageType::PixelType OutputImagePixelType; - void PrintSelf ( std::ostream& os, itk::Indent indent ) const; + void PrintSelf ( std::ostream& os, itk::Indent indent ) const ITK_OVERRIDE; /** Clear the seeds */ void ClearSeeds(); @@ -145,11 +145,11 @@ protected: double m_MaximumSD; // Override since the filter needs all the data for the algorithm - void GenerateInputRequestedRegion(); + void GenerateInputRequestedRegion() ITK_OVERRIDE; // Override since the filter produces the entire dataset - void EnlargeOutputRequestedRegion(itk::DataObject *output); - void GenerateData(); + void EnlargeOutputRequestedRegion(itk::DataObject *output) ITK_OVERRIDE; + void GenerateData() ITK_OVERRIDE; private: LocallyAdaptiveThresholdConnectedImageFilter(const Self&); //purposely not implemented diff --git a/itk/clitkPasteImageFilter.h b/itk/clitkPasteImageFilter.h index 72550cf..5f286b3 100644 --- a/itk/clitkPasteImageFilter.h +++ b/itk/clitkPasteImageFilter.h @@ -18,7 +18,7 @@ namespace clitk public itk::PasteImageFilter< TInputImage, TSourceImage, TOutputImage > { public: - virtual void VerifyInputInformation() { } + virtual void VerifyInputInformation() ITK_OVERRIDE { } /** Standard class typedefs. */ typedef PasteImageFilter Self; diff --git a/itk/clitkResampleImageWithOptionsFilter.h b/itk/clitkResampleImageWithOptionsFilter.h index 4b6b409..f3de134 100644 --- a/itk/clitkResampleImageWithOptionsFilter.h +++ b/itk/clitkResampleImageWithOptionsFilter.h @@ -22,6 +22,8 @@ #include "itkImageToImageFilter.h" #include "itkAffineTransform.h" +#include "clitkCommon.h" + namespace clitk { //-------------------------------------------------------------------- @@ -84,7 +86,7 @@ namespace clitk { (itk::Concept::SameDimension)); /** Input : image to resample */ - void SetInput(const InputImageType * image); + void SetInput(const InputImageType * image) ITK_OVERRIDE; /** ImageDimension constants */ itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension); @@ -139,9 +141,9 @@ namespace clitk { bool m_VerboseOptions; OutputImageRegionType m_OutputRegion; - virtual void GenerateInputRequestedRegion(); - virtual void GenerateOutputInformation(); - virtual void GenerateData(); + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; private: ResampleImageWithOptionsFilter(const Self&); //purposely not implemented diff --git a/itk/clitkSetBackgroundImageFilter.h b/itk/clitkSetBackgroundImageFilter.h index e5ac118..500ecc4 100644 --- a/itk/clitkSetBackgroundImageFilter.h +++ b/itk/clitkSetBackgroundImageFilter.h @@ -20,6 +20,8 @@ #include "itkFlexibleBinaryFunctorImageFilter.h" #include "itkNumericTraits.h" +#include "clitkCommon.h" + namespace clitk { @@ -211,7 +213,7 @@ protected: SetBackgroundImageFilter() {} virtual ~SetBackgroundImageFilter() {} - void PrintSelf(std::ostream &os, itk::Indent indent) const + void PrintSelf(std::ostream &os, itk::Indent indent) const ITK_OVERRIDE { Superclass::PrintSelf(os, indent); os << indent << "OutsideValue: " << this->GetOutsideValue() << std::endl; diff --git a/itk/clitkSliceBySliceRelativePositionFilter.h b/itk/clitkSliceBySliceRelativePositionFilter.h index ec1246f..42633a9 100644 --- a/itk/clitkSliceBySliceRelativePositionFilter.h +++ b/itk/clitkSliceBySliceRelativePositionFilter.h @@ -67,7 +67,7 @@ namespace clitk { typedef typename RelPosFilterType::OrientationTypeEnumeration OrientationTypeEnumeration; /** Input : initial image and object */ - void SetInput(const ImageType * image); + virtual void SetInput(const ImageType * image) ITK_OVERRIDE; void SetInputObject(const ImageType * image); // Options @@ -106,9 +106,9 @@ namespace clitk { SliceBySliceRelativePositionFilter(); virtual ~SliceBySliceRelativePositionFilter() {} - virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); - virtual void GenerateData(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; + virtual void GenerateData() ITK_OVERRIDE; ImagePointer input; ImagePointer object; diff --git a/itk/itkBSplineInterpolateImageFunctionWithLUT.h b/itk/itkBSplineInterpolateImageFunctionWithLUT.h index 7fd7ab8..5ca614d 100644 --- a/itk/itkBSplineInterpolateImageFunctionWithLUT.h +++ b/itk/itkBSplineInterpolateImageFunctionWithLUT.h @@ -21,6 +21,8 @@ #include "itkBSplineWeightsCalculator.h" #include +#include "clitkCommon.h" + namespace itk { template < @@ -59,19 +61,19 @@ namespace itk { void SetSplineOrders(const SizeType & SplineOrders); /** Set the input image. This must be set by the user. */ - virtual void SetInputImage(const TImageType * inputData); + virtual void SetInputImage(const TImageType * inputData) ITK_OVERRIDE; /** Evaluate the function at a ContinuousIndex position. Overwritten for taking LUT into account (RP: multi-threading-compatible version, the threadID is actually ignored) */ - virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index, unsigned int /* threadID */ ) const + virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index, unsigned int /* threadID */ ) const ITK_OVERRIDE { return this->EvaluateAtContinuousIndex( index ); } /** Evaluate the function at a ContinuousIndex position. Overwritten for taking LUT into account */ - virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const; + virtual OutputType EvaluateAtContinuousIndex(const ContinuousIndexType & index ) const ITK_OVERRIDE; /** Static convenient functions to compute BSpline weights for various order, dimension, sampling ... **/ diff --git a/itk/itkFlexibleBinaryFunctorImageFilter.h b/itk/itkFlexibleBinaryFunctorImageFilter.h index 6b85a09..f8736d7 100644 --- a/itk/itkFlexibleBinaryFunctorImageFilter.h +++ b/itk/itkFlexibleBinaryFunctorImageFilter.h @@ -20,6 +20,8 @@ #include "itkInPlaceImageFilter.h" #include "itkImageRegionIteratorWithIndex.h" +#include "clitkCommon.h" + namespace itk { @@ -109,8 +111,8 @@ public: } } - virtual void GenerateOutputInformation(); - virtual void GenerateInputRequestedRegion(); + virtual void GenerateOutputInformation() ITK_OVERRIDE; + virtual void GenerateInputRequestedRegion() ITK_OVERRIDE; /** ImageDimension constants */ itkStaticConstMacro( @@ -146,7 +148,7 @@ protected: * \sa ImageToImageFilter::ThreadedGenerateData(), * ImageToImageFilter::GenerateData() */ void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, - itk::ThreadIdType threadId ); + itk::ThreadIdType threadId ) ITK_OVERRIDE; private: FlexibleBinaryFunctorImageFilter(const Self&); //purposely not implemented diff --git a/registration/clitkAffineRegistrationGenericFilter.cxx b/registration/clitkAffineRegistrationGenericFilter.cxx index bcf5fd4..f369e05 100644 --- a/registration/clitkAffineRegistrationGenericFilter.cxx +++ b/registration/clitkAffineRegistrationGenericFilter.cxx @@ -45,11 +45,11 @@ public: } // Execute - void Execute(itk::Object *caller, const itk::EventObject & event) { + void Execute(itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE { Execute( (const itk::Object *)caller, event); } - void Execute(const itk::Object * object, const itk::EventObject & event) { + void Execute(const itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE { if ( !(itk::IterationEvent().CheckEvent( &event )) ) { return; } @@ -108,7 +108,7 @@ public: // Two arguments are passed to the Execute() method: the first // is the pointer to the object which invoked the event and the // second is the event that was invoked. - void Execute(itk::Object * object, const itk::EventObject & event) { + void Execute(itk::Object * object, const itk::EventObject & event) ITK_OVERRIDE { if ( !(itk::IterationEvent().CheckEvent( &event )) ) { return; } @@ -138,7 +138,7 @@ public: } } - void Execute(const itk::Object * , const itk::EventObject & ) { + void Execute(const itk::Object * , const itk::EventObject & ) ITK_OVERRIDE { return; } diff --git a/registration/clitkConvertBLUTCoeffsToVFFilter.h b/registration/clitkConvertBLUTCoeffsToVFFilter.h index 40eb129..dc85c7a 100644 --- a/registration/clitkConvertBLUTCoeffsToVFFilter.h +++ b/registration/clitkConvertBLUTCoeffsToVFFilter.h @@ -43,7 +43,11 @@ namespace clitk typedef clitk::BSplineDeformableTransform BLUTTransformType; typedef typename BLUTTransformType::CoefficientImageType BLUTCoefficientImageType; - typedef itk::BSplineDeformableTransform ITKTransformType; + typedef itk::BSplineDeformableTransform ITKTransformType; + typedef itk::BSplineDeformableTransform ITKTransformTypeZero; + typedef itk::BSplineDeformableTransform ITKTransformTypeOne; + typedef itk::BSplineDeformableTransform ITKTransformTypeTwo; + typedef itk::BSplineDeformableTransform ITKTransformTypeFour; typedef itk::Transform< double, TDVFType::ImageDimension, TDVFType::ImageDimension> GenericTransformType; diff --git a/registration/clitkConvertBLUTCoeffsToVFFilter.txx b/registration/clitkConvertBLUTCoeffsToVFFilter.txx index ef63900..9bda80f 100644 --- a/registration/clitkConvertBLUTCoeffsToVFFilter.txx +++ b/registration/clitkConvertBLUTCoeffsToVFFilter.txx @@ -162,23 +162,64 @@ namespace clitk for (unsigned int j=0; j < coefficient_images[i]->GetPixelContainer()->Size(); j++) params[input->GetPixelContainer()->Size() * i + j] = coefficient_images[i]->GetPixelContainer()->GetBufferPointer()[j]; } + typename ITKTransformTypeZero::Pointer zero; + typename ITKTransformTypeOne::Pointer one; + typename ITKTransformTypeTwo::Pointer two; + typename ITKTransformTypeFour::Pointer four; - m_ITKTransform->SetGridOrigin(input->GetOrigin()); - m_ITKTransform->SetGridDirection(input->GetDirection()); - m_ITKTransform->SetGridRegion(input->GetLargestPossibleRegion()); - m_ITKTransform->SetGridSpacing(input->GetSpacing()); - m_ITKTransform->SetParametersByValue(params); - - m_GenericTransform = m_ITKTransform; + switch(m_BLUTSplineOrders[0]) + { + case 0: + zero = ITKTransformTypeZero::New(); + zero->SetGridOrigin(input->GetOrigin()); + zero->SetGridDirection(input->GetDirection()); + zero->SetGridRegion(input->GetLargestPossibleRegion()); + zero->SetGridSpacing(input->GetSpacing()); + m_GenericTransform = zero; + break; + case 1: + one = ITKTransformTypeOne::New(); + one->SetGridOrigin(input->GetOrigin()); + one->SetGridDirection(input->GetDirection()); + one->SetGridRegion(input->GetLargestPossibleRegion()); + one->SetGridSpacing(input->GetSpacing()); + m_GenericTransform = one; + break; + case 2: + two = ITKTransformTypeTwo::New(); + two->SetGridOrigin(input->GetOrigin()); + two->SetGridDirection(input->GetDirection()); + two->SetGridRegion(input->GetLargestPossibleRegion()); + two->SetGridSpacing(input->GetSpacing()); + m_GenericTransform = two; + break; + case 3: + m_ITKTransform = ITKTransformType::New(); + m_ITKTransform->SetGridOrigin(input->GetOrigin()); + m_ITKTransform->SetGridDirection(input->GetDirection()); + m_ITKTransform->SetGridRegion(input->GetLargestPossibleRegion()); + m_ITKTransform->SetGridSpacing(input->GetSpacing()); + m_GenericTransform = m_ITKTransform; + break; + case 4: + four = ITKTransformTypeFour::New(); + four->SetGridOrigin(input->GetOrigin()); + four->SetGridDirection(input->GetDirection()); + four->SetGridRegion(input->GetLargestPossibleRegion()); + four->SetGridSpacing(input->GetSpacing()); + m_GenericTransform = four; + break; + } + m_GenericTransform->SetParametersByValue(params); } #if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6) - m_Filter->SetReferenceImage(output); + m_Filter->SetSize(output->GetLargestPossibleRegion().GetSize()); #else - m_Filter->SetOutputOrigin(output->GetOrigin()); - m_Filter->SetOutputSpacing(output->GetSpacing()); m_Filter->SetOutputSize(output->GetLargestPossibleRegion().GetSize()); #endif + m_Filter->SetOutputOrigin(output->GetOrigin()); + m_Filter->SetOutputSpacing(output->GetSpacing()); m_Filter->SetTransform(m_GenericTransform); m_Filter->Update(); diff --git a/registration/clitkCorrelationRatioImageToImageMetric.h b/registration/clitkCorrelationRatioImageToImageMetric.h index c8f9d21..04a6a37 100644 --- a/registration/clitkCorrelationRatioImageToImageMetric.h +++ b/registration/clitkCorrelationRatioImageToImageMetric.h @@ -105,18 +105,18 @@ public: * (1) making sure that all the components are present and plugged * together correctly, * (3) allocate memory for bin data structures. */ - virtual void Initialize(void) throw ( ExceptionObject ); + virtual void Initialize(void) throw ( ExceptionObject ) ITK_OVERRIDE; /** Get the derivatives of the match measure. */ void GetDerivative( const TransformParametersType & parameters, - DerivativeType & derivative ) const; + DerivativeType & derivative ) const ITK_OVERRIDE; /** Get the value for single valued optimizers. */ - MeasureType GetValue( const TransformParametersType & parameters ) const; + MeasureType GetValue( const TransformParametersType & parameters ) const ITK_OVERRIDE; /** Get value and derivatives for multiple valued optimizers. */ void GetValueAndDerivative( const TransformParametersType & parameters, - MeasureType& Value, DerivativeType& Derivative ) const; + MeasureType& Value, DerivativeType& Derivative ) const ITK_OVERRIDE; /** Number of bins to used in the calculation. Typical value is 50. */ itkSetClampMacro( NumberOfBins, unsigned long, diff --git a/registration/clitkLBFGSBOptimizer.h b/registration/clitkLBFGSBOptimizer.h index 7b4052e..4ea8924 100644 --- a/registration/clitkLBFGSBOptimizer.h +++ b/registration/clitkLBFGSBOptimizer.h @@ -19,6 +19,8 @@ #define __clitkLBFGSBOptimizer_h #include "itkSingleValuedNonLinearVnlOptimizer.h" +#include "clitkCommon.h" + namespace clitk { @@ -93,10 +95,10 @@ public: /** Start optimization with an initial value. */ - void StartOptimization( void ); + virtual void StartOptimization( void ) ITK_OVERRIDE; /** Plug in a Cost Function into the optimizer */ - virtual void SetCostFunction( itk::SingleValuedCostFunction * costFunction ); + virtual void SetCostFunction( itk::SingleValuedCostFunction * costFunction ) ITK_OVERRIDE; /** Set the lower bound value for each variable. */ virtual void SetLowerBound( const BoundValueType & value ); @@ -160,12 +162,12 @@ public: itkGetConstReferenceMacro( InfinityNormOfProjectedGradient, double ); /** Get the reason for termination */ - const std::string GetStopConditionDescription() const; + virtual const std::string GetStopConditionDescription() const ITK_OVERRIDE; protected: LBFGSBOptimizer(); virtual ~LBFGSBOptimizer(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; typedef Superclass::CostFunctionAdaptorType CostFunctionAdaptorType; diff --git a/registration/clitkOptNormalizedCorrelationImageToImageMetric.h b/registration/clitkOptNormalizedCorrelationImageToImageMetric.h index 242a4a1..46dcae9 100644 --- a/registration/clitkOptNormalizedCorrelationImageToImageMetric.h +++ b/registration/clitkOptNormalizedCorrelationImageToImageMetric.h @@ -95,25 +95,25 @@ public: * (2) uniformly select NumberOfSpatialSamples within * the FixedImageRegion, and * (3) allocate memory for pdf data structures. */ - virtual void Initialize(void) throw ( itk::ExceptionObject ); + virtual void Initialize(void) throw ( itk::ExceptionObject ) ITK_OVERRIDE; /** Get the value. */ - MeasureType GetValue( const ParametersType & parameters ) const; + MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE; /** Get the derivatives of the match measure. */ void GetDerivative( const ParametersType & parameters, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; /** Get the value and derivatives for single valued optimizers. */ void GetValueAndDerivative( const ParametersType & parameters, MeasureType & Value, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; protected: NormalizedCorrelationImageToImageMetric(); virtual ~NormalizedCorrelationImageToImageMetric(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: @@ -129,7 +129,7 @@ private: inline bool GetValueThreadProcessSample( unsigned int threadID, unsigned long fixedImageSample, const MovingImagePointType & mappedPoint, - double movingImageValue ) const; + double movingImageValue ) const ITK_OVERRIDE; inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID, @@ -137,7 +137,7 @@ private: const MovingImagePointType & mappedPoint, double movingImageValue, const ImageDerivativesType & - movingImageGradientValue ) const; + movingImageGradientValue ) const ITK_OVERRIDE; AccumulateType *m_ThreaderSFF, *m_ThreaderSMM, *m_ThreaderSFM, *m_ThreaderSF, *m_ThreaderSM; mutable AccumulateType m_SFF, m_SMM, m_SFM, m_SF, m_SM; diff --git a/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h b/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h index dc7ef9f..24afdbe 100644 --- a/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h +++ b/registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h @@ -95,25 +95,25 @@ public: * (2) uniformly select NumberOfSpatialSamples within * the FixedImageRegion, and * (3) allocate memory for pdf data structures. */ - virtual void Initialize(void) throw ( itk::ExceptionObject ); + virtual void Initialize(void) throw ( itk::ExceptionObject ) ITK_OVERRIDE; /** Get the value. */ - MeasureType GetValue( const ParametersType & parameters ) const; + MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE; /** Get the derivatives of the match measure. */ void GetDerivative( const ParametersType & parameters, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; /** Get the value and derivatives for single valued optimizers. */ void GetValueAndDerivative( const ParametersType & parameters, MeasureType & Value, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; protected: NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(); virtual ~NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(); - void PrintSelf(std::ostream& os, itk::Indent indent) const; + void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE; private: @@ -129,7 +129,7 @@ private: inline bool GetValueThreadProcessSample( unsigned int threadID, unsigned long fixedImageSample, const MovingImagePointType & mappedPoint, - double movingImageValue ) const; + double movingImageValue ) const ITK_OVERRIDE; inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID, @@ -137,7 +137,7 @@ private: const MovingImagePointType & mappedPoint, double movingImageValue, const ImageDerivativesType & - movingImageGradientValue ) const; + movingImageGradientValue ) const ITK_OVERRIDE; AccumulateType *m_ThreaderSFF, *m_ThreaderSMM, *m_ThreaderSFM, *m_ThreaderSF, *m_ThreaderSM; mutable AccumulateType m_SFF, m_SMM, m_SFM, m_SF, m_SM; diff --git a/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h b/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h index 1eaa49a..e914c1f 100644 --- a/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h +++ b/registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h @@ -187,19 +187,19 @@ public: * (2) uniformly select NumberOfSpatialSamples within * the FixedImageRegion, and * (3) allocate memory for pdf data structures. */ - virtual void Initialize(void) throw ( ExceptionObject ); + virtual void Initialize(void) throw ( ExceptionObject ) ITK_OVERRIDE; /** Get the value. */ - MeasureType GetValue( const ParametersType & parameters ) const; + MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE; /** Get the derivatives of the match measure. */ void GetDerivative( const ParametersType & parameters, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; /** Get the value and derivatives for single valued optimizers. */ void GetValueAndDerivative( const ParametersType & parameters, MeasureType & Value, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; /** Number of bins to used in the histogram. Typical value is 50. */ itkSetClampMacro( NumberOfHistogramBins, unsigned long, @@ -238,7 +238,7 @@ protected: MattesMutualInformationImageToImageMetricFor3DBLUTFFD(); virtual ~MattesMutualInformationImageToImageMetricFor3DBLUTFFD(); - void PrintSelf(std::ostream& os, Indent indent) const; + void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE; private: @@ -330,26 +330,26 @@ private: virtual inline void GetValueThreadPreProcess( unsigned int threadID, - bool withinSampleThread ) const; + bool withinSampleThread ) const ITK_OVERRIDE; virtual inline bool GetValueThreadProcessSample( unsigned int threadID, unsigned long fixedImageSample, const MovingImagePointType & mappedPoint, - double movingImageValue ) const; + double movingImageValue ) const ITK_OVERRIDE; virtual inline void GetValueThreadPostProcess( unsigned int threadID, - bool withinSampleThread ) const; + bool withinSampleThread ) const ITK_OVERRIDE; virtual inline void GetValueAndDerivativeThreadPreProcess( unsigned int threadID, - bool withinSampleThread ) const; + bool withinSampleThread ) const ITK_OVERRIDE; virtual inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID, unsigned long fixedImageSample, const MovingImagePointType & mappedPoint, double movingImageValue, const ImageDerivativesType & - movingImageGradientValue ) const; + movingImageGradientValue ) const ITK_OVERRIDE; virtual inline void GetValueAndDerivativeThreadPostProcess( unsigned int threadID, - bool withinSampleThread ) const; + bool withinSampleThread ) const ITK_OVERRIDE; }; diff --git a/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h b/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h index 949246d..06ecf29 100644 --- a/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h +++ b/registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h @@ -98,25 +98,25 @@ public: * (2) uniformly select NumberOfSpatialSamples within * the FixedImageRegion, and * (3) allocate memory for pdf data structures. */ - virtual void Initialize(void) throw ( ExceptionObject ); + virtual void Initialize(void) throw ( ExceptionObject ) ITK_OVERRIDE; /** Get the value. */ - MeasureType GetValue( const ParametersType & parameters ) const; + MeasureType GetValue( const ParametersType & parameters ) const ITK_OVERRIDE; /** Get the derivatives of the match measure. */ void GetDerivative( const ParametersType & parameters, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; /** Get the value and derivatives for single valued optimizers. */ void GetValueAndDerivative( const ParametersType & parameters, MeasureType & Value, - DerivativeType & Derivative ) const; + DerivativeType & Derivative ) const ITK_OVERRIDE; protected: MeanSquaresImageToImageMetricFor3DBLUTFFD(); virtual ~MeanSquaresImageToImageMetricFor3DBLUTFFD(); - void PrintSelf(std::ostream& os, Indent indent) const; + void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE; private: @@ -128,14 +128,14 @@ private: inline bool GetValueThreadProcessSample( unsigned int threadID, unsigned long fixedImageSample, const MovingImagePointType & mappedPoint, - double movingImageValue ) const; + double movingImageValue ) const ITK_OVERRIDE; inline bool GetValueAndDerivativeThreadProcessSample( unsigned int threadID, unsigned long fixedImageSample, const MovingImagePointType & mappedPoint, double movingImageValue, const ImageDerivativesType & - movingImageGradientValue ) const; + movingImageGradientValue ) const ITK_OVERRIDE; MeasureType * m_ThreaderMSE; DerivativeType * m_ThreaderMSEDerivatives; diff --git a/superbuild/CMakeLists.txt b/superbuild/CMakeLists.txt index fad0b95..a059e4e 100644 --- a/superbuild/CMakeLists.txt +++ b/superbuild/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 2.8) cmake_policy(VERSION 2.8) + + +message( FATAL_ERROR "This superbuild is not up to date, do not use." ) + + # set a default build type if it is undefined, then make sure it goes in the cache if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 0ca5ca9..515e99a 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -12,6 +12,9 @@ add_library(clitkBinarizeImageLib clitkBinarizeImageGenericFilter.cxx ${clitkBin WRAP_GGO(clitkProfileImage_GGO_C clitkProfileImage.ggo) add_library(clitkProfileImageLib clitkProfileImageGenericFilter.cxx ${clitkProfileImage_GGO_C}) +WRAP_GGO(clitkHistogramImage_GGO_C clitkHistogramImage.ggo) +add_library(clitkHistogramImageLib clitkHistogramImageGenericFilter.cxx ${clitkHistogramImage_GGO_C}) + WRAP_GGO(clitkImageArithm_GGO_C clitkImageArithm.ggo) add_library(clitkImageArithmImageLib clitkImageArithmGenericFilter.cxx ${clitkImageArithm_GGO_C}) diff --git a/tools/clitk4DImageToNVectorImageGenericFilter.txx b/tools/clitk4DImageToNVectorImageGenericFilter.txx index 554cec7..1f8f3eb 100644 --- a/tools/clitk4DImageToNVectorImageGenericFilter.txx +++ b/tools/clitk4DImageToNVectorImageGenericFilter.txx @@ -97,9 +97,15 @@ namespace clitk extractFilter->SetInput(input); typename InputImageType::SizeType size; + typename OutputImageType::DirectionType direction; + direction.SetIdentity(); for (unsigned int nbDimension=0; nbDimensionGetLargestPossibleRegion().GetSize(nbDimension); + for (unsigned int pixelDim2=0; pixelDim2GetDirection()[nbDimension][pixelDim2]; + } } size[Dimension-1] = 0; typename MedianImageType::Pointer tempImage = MedianImageType::New(); @@ -124,7 +130,10 @@ namespace clitk imageToVectorImageFilter->Update(); - // Output + // Copy transform matrix + imageToVectorImageFilter->GetOutput()->SetDirection(direction); + + //Output writer->SetInput(imageToVectorImageFilter->GetOutput()); writer->SetFileName(fileName); writer->Update(); diff --git a/tools/clitkHistogramImage.cxx b/tools/clitkHistogramImage.cxx new file mode 100644 index 0000000..0cb5ac9 --- /dev/null +++ b/tools/clitkHistogramImage.cxx @@ -0,0 +1,41 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ + +// clitk +#include "clitkHistogramImage_ggo.h" +#include "clitkHistogramImageGenericFilter.h" + +//-------------------------------------------------------------------- +int main(int argc, char * argv[]) +{ + + // Init command line + GGO(clitkHistogramImage, args_info); + CLITK_INIT; + + // Filter + typedef clitk::HistogramImageGenericFilter FilterType; + FilterType::Pointer filter = FilterType::New(); + + filter->SetArgsInfo(args_info); + + CLITK_TRY_CATCH_EXIT(filter->Update()); + + return EXIT_SUCCESS; +} // This is the end, my friend +//-------------------------------------------------------------------- diff --git a/tools/clitkHistogramImage.ggo b/tools/clitkHistogramImage.ggo new file mode 100644 index 0000000..6689677 --- /dev/null +++ b/tools/clitkHistogramImage.ggo @@ -0,0 +1,15 @@ +#File clitkHistogramImage.ggo +package "clitkHistogramImage" +version "1.0" +purpose "Save the histogram of the input image in the output text file" + +option "config" - "Config file" string no +option "verbose" v "Verbose" flag off +option "imagetypes" - "Display allowed image types" flag off + +option "input" i "Input image filename" string yes +option "output" o "Output texte filename" string yes +option "size" s "size of the bin" double no + + + diff --git a/tools/clitkHistogramImageGenericFilter.cxx b/tools/clitkHistogramImageGenericFilter.cxx new file mode 100644 index 0000000..49e3fa0 --- /dev/null +++ b/tools/clitkHistogramImageGenericFilter.cxx @@ -0,0 +1,165 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef clitkHistogramImageGenericFilter_cxx +#define clitkHistogramImageGenericFilter_cxx + +/* ================================================= + * @file clitkHistogramImageGenericFilter.cxx + * @author Thomas Baudier + * @date 22 dec 2015 + * + * @brief + * + ===================================================*/ + +#include "clitkHistogramImageGenericFilter.h" + +// itk include +#include +#include + +#include + + + +namespace clitk +{ + +//-------------------------------------------------------------------- +HistogramImageGenericFilter::HistogramImageGenericFilter(): + ImageToImageGenericFilter("HistogramImage") +{ + InitializeImageType<2>(); + InitializeImageType<3>(); + InitializeImageType<4>(); + mBinSize = 100; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void HistogramImageGenericFilter::InitializeImageType() +{ + ADD_DEFAULT_IMAGE_TYPES(Dim); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +vtkFloatArray* HistogramImageGenericFilter::GetArrayX() +{ + return(mArrayX); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +vtkFloatArray* HistogramImageGenericFilter::GetArrayY() +{ + return(mArrayY); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void HistogramImageGenericFilter::SetArgsInfo(const args_info_type & a) +{ + mArgsInfo=a; + if (mArgsInfo.verbose_given) + SetIOVerbose(mArgsInfo.verbose_flag); + if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag) + this->PrintAvailableImageTypes(); + + if (mArgsInfo.input_given) { + SetInputFilename(mArgsInfo.input_arg); + } + if (mArgsInfo.output_given) { + SetOutputFilename(mArgsInfo.output_arg); + } + if (mArgsInfo.size_given) { + SetSizeBin(mArgsInfo.size_arg); + } +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void HistogramImageGenericFilter::SetSizeBin(const double size) +{ + mBinSize = size; +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +// Update with the number of dimensions and the pixeltype +//-------------------------------------------------------------------- +template +void +HistogramImageGenericFilter::UpdateWithInputImageType() +{ + + // Reading input + typename InputImageType::Pointer input = this->template GetInput(0); + typedef typename InputImageType::PixelType PixelType; + typedef typename InputImageType::IndexType IndexType; + typedef typename itk::Statistics::ImageToHistogramFilter HistogramFilterType; + typedef typename itk::StatisticsImageFilter StatisticsImageFilterType; + + //compute range + typename StatisticsImageFilterType::Pointer statisticsImageFilter = StatisticsImageFilterType::New (); + statisticsImageFilter->SetInput(input); + statisticsImageFilter->Update(); + double range = statisticsImageFilter->GetMaximum() - statisticsImageFilter->GetMinimum(); + //compute bin number + typedef typename HistogramFilterType::HistogramSizeType SizeType; + SizeType binNumber(1); + mBinSize = std::log(range); + binNumber[0] = (int)(range/mBinSize); + if (binNumber[0] == 0) + binNumber[0] = 1; + + //compute histogram + typename HistogramFilterType::Pointer histogramFilter = HistogramFilterType::New(); + histogramFilter->SetHistogramSize(binNumber); + histogramFilter->SetAutoMinimumMaximum(true); + typename HistogramFilterType::HistogramMeasurementVectorType lowerBound(1); + typename HistogramFilterType::HistogramMeasurementVectorType upperBound(1); + lowerBound[0] = statisticsImageFilter->GetMinimum(); + upperBound[0] = statisticsImageFilter->GetMaximum(); + histogramFilter->SetHistogramBinMinimum(lowerBound); + histogramFilter->SetHistogramBinMaximum(upperBound); + histogramFilter->SetInput(input); + histogramFilter->Update(); + + mArrayX = vtkSmartPointer::New(); + mArrayY = vtkSmartPointer::New(); + + for(unsigned int i = 0; i < histogramFilter->GetOutput()->GetSize()[0]; ++i) + { + mArrayY->InsertNextTuple1(histogramFilter->GetOutput()->GetFrequency(i)); + mArrayX->InsertNextTuple1(statisticsImageFilter->GetMinimum() + (i+0.5)*mBinSize); + } +} +//-------------------------------------------------------------------- + + +}//end clitk + +#endif //#define clitkHistogramImageGenericFilter_cxx diff --git a/tools/clitkHistogramImageGenericFilter.h b/tools/clitkHistogramImageGenericFilter.h new file mode 100644 index 0000000..d963fbc --- /dev/null +++ b/tools/clitkHistogramImageGenericFilter.h @@ -0,0 +1,79 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ + +#ifndef clitkHistogramImageGenericFilter_h +#define clitkHistogramImageGenericFilter_h + +#include "clitkIO.h" +#include "clitkImageToImageGenericFilter.h" +#include "clitkHistogramImage_ggo.h" + +#include +#include +#include + +//-------------------------------------------------------------------- +namespace clitk +{ + + class ITK_EXPORT HistogramImageGenericFilter: + public ImageToImageGenericFilter + { + + public: + //-------------------------------------------------------------------- + typedef HistogramImageGenericFilter Self; + typedef itk::SmartPointer Pointer; + typedef itk::SmartPointer ConstPointer; + typedef args_info_clitkHistogramImage args_info_type; + + //-------------------------------------------------------------------- + // Method for creation through the object factory + // and Run-time type information (and related methods) + itkNewMacro(Self); + itkTypeMacro(HistogramImageGenericFilter, LightObject); + + //-------------------------------------------------------------------- + void SetArgsInfo(const args_info_type & a); + void SetSizeBin (const double size); + + //-------------------------------------------------------------------- + // Main function called each time the filter is updated + template + void UpdateWithInputImageType(); + + vtkFloatArray* GetArrayX(); + vtkFloatArray* GetArrayY(); + + protected: + HistogramImageGenericFilter(); + template void InitializeImageType(); + args_info_type mArgsInfo; + + double mBinSize; + + vtkSmartPointer mArrayX; + vtkSmartPointer mArrayY; + + }; // end class + //-------------------------------------------------------------------- + +} // end namespace clitk +//-------------------------------------------------------------------- + +#endif // #define clitkHistogramImageGenericFilter_h diff --git a/tools/clitkImageConvert.cxx b/tools/clitkImageConvert.cxx index 8138682..e54c736 100644 --- a/tools/clitkImageConvert.cxx +++ b/tools/clitkImageConvert.cxx @@ -68,6 +68,7 @@ int main(int argc, char * argv[]) filter->SetIOVerbose(args_info.verbose_flag); filter->SetOutputFilename(output); filter->SetVV(args_info.vv_flag); + filter->SetNoNiiMeta(args_info.noniimeta_flag); filter->SetCorrectNegativeSpacingFlag(args_info.correct_flag); filter->EnableWriteCompression(args_info.compression_flag); if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg); diff --git a/tools/clitkImageConvert.ggo b/tools/clitkImageConvert.ggo index 6d74318..2304d50 100644 --- a/tools/clitkImageConvert.ggo +++ b/tools/clitkImageConvert.ggo @@ -3,11 +3,12 @@ package "clitkImageConvert" version "1.0" purpose "Convert an image into another image.\n\tAllow to change the file format and/or the pixel type. \n\tKnown file formats 2D: jpeg png bmp tif mhd hdr vox dcm \n\tKnown file formats 3D: mhd vox hdr dcm\n\tKnown file formats 4D: mhd \n\tKnown images: 2D 3D or 4D, schar, uchar, short, ushort, int, float and double\n\nIf the -o option is not given, the last parameter of the command line is used as output." -option "config" - "Config file" string no -option "input" i "Input image filename" string no -option "output" o "Output image filename" string no -option "type" t "Output type (float, ushort ...)" string no -option "verbose" v "Verbose" flag off -option "compression" c "Compress output" flag off -option "vv" - "Read image as in vv and save transform in meta information" flag off -option "correct" - "Correct dicom with negative Z spacing" flag off +option "config" - "Config file" string no +option "input" i "Input image filename" string no +option "output" o "Output image filename" string no +option "type" t "Output type (float, ushort ...)" string no +option "verbose" v "Verbose" flag off +option "compression" c "Compress output" flag off +option "vv" - "Read image as in vv and save transform in meta information" flag off +option "correct" - "Correct dicom with negative Z spacing" flag off +option "noniimeta" - "Multiply 1st and 2nd coordinate of Direction and Origin by -1" flag off diff --git a/tools/clitkImageConvertGenericFilter.cxx b/tools/clitkImageConvertGenericFilter.cxx index a1b28c2..1e95a7b 100644 --- a/tools/clitkImageConvertGenericFilter.cxx +++ b/tools/clitkImageConvertGenericFilter.cxx @@ -24,6 +24,7 @@ #include "vvImageWriter.h" #include "itkFlipImageFilter.h" #include "itkGDCMImageIO.h" +#include #include "gdcmReader.h" #include "gdcmAttribute.h" @@ -172,8 +173,26 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() itk::MetaDataDictionary dict;// = new itk::MetaDataDictionary; input->SetMetaDataDictionary(dict); } - this->SetNextOutput(input); + typedef itk::ChangeInformationImageFilter CIType; + typename CIType::Pointer changeInfo = CIType::New(); + if(mNoNiiMeta) { + changeInfo->SetInput(input); + typename CIType::PointType o = input->GetOrigin(); + o[0] *= -1.; + o[1] *= -1.; + typename CIType::DirectionType d = input->GetDirection(); + d[0][0] *= -1.; + d[1][1] *= -1.; + changeInfo->ChangeDirectionOn(); + changeInfo->ChangeOriginOn(); + changeInfo->SetOutputOrigin(o); + changeInfo->SetOutputDirection(d); + changeInfo->Update(); + input = changeInfo->GetOutput(); + } + + this->SetNextOutput(input); } else { // "trick" to call independent versions of update according to the diff --git a/tools/clitkImageConvertGenericFilter.h b/tools/clitkImageConvertGenericFilter.h index aa8b2ba..4f1a100 100644 --- a/tools/clitkImageConvertGenericFilter.h +++ b/tools/clitkImageConvertGenericFilter.h @@ -74,6 +74,7 @@ namespace clitk { std::string GetOutputPixelTypeName() { return mOutputPixelTypeName; } void SetOutputPixelType(std::string p) { mOutputPixelTypeName = p; } void SetVV(bool b) { mVV = b; } + void SetNoNiiMeta(bool b) { mNoNiiMeta = b; } bool IsWarningOccur() { return mWarningOccur; } std::string & GetWarning() { return mWarning; } void EnableDisplayWarning(bool b) { mDisplayWarning = b; } @@ -95,6 +96,7 @@ namespace clitk { bool mWarningOccur; bool mDisplayWarning; bool mVV; + bool mNoNiiMeta; bool mCorrectNegativeSpacingFlag; private: diff --git a/tools/clitkImageCreate.cxx b/tools/clitkImageCreate.cxx index ab2bec5..d84bbb5 100644 --- a/tools/clitkImageCreate.cxx +++ b/tools/clitkImageCreate.cxx @@ -31,23 +31,35 @@ #include "clitkIO.h" template -void NewFilledImage(int * size, float * spacing, double * origin, +void NewFilledImage(int * size, float * spacing, double * origin, double * direction, double value,typename ImageType::Pointer output) { static const unsigned int Dim = ImageType::GetImageDimension(); + typename ImageType::SizeType mSize; mSize.Fill (0); for(unsigned int i=0; iSetRegions(mRegion); output->SetSpacing(mSpacing); + output->SetDirection(directionImage); output->Allocate(); + typename ImageType::PointType mOrigin; for(unsigned int i=0; iSetOrigin(mOrigin); + typedef typename ImageType::PixelType PixelType; PixelType p = clitk::PixelTypeDownCast(value); output->FillBuffer(p); @@ -75,11 +87,15 @@ int main(int argc, char * argv[]) args_info.spacing_arg = new float[dim]; args_info.origin_given = dim; args_info.origin_arg = new double[dim]; + args_info.transformMatrix_given = dim*dim; + args_info.transformMatrix_arg = new double[dim*dim]; for(int i=0; iGetDimensions(i); args_info.spacing_arg[i] = header->GetSpacing(i); args_info.origin_arg[i]= header->GetOrigin(i); + for (int j=0; jGetDirection(i)[j]; } } @@ -119,27 +135,50 @@ int main(int argc, char * argv[]) for(int i=0; i direction; + direction.resize(dim*dim); + for(int i=0; i ImageType; ImageType::Pointer output = ImageType::New(); - NewFilledImage(args_info.size_arg, &spacing[0], &origin[0], args_info.value_arg, output); + NewFilledImage(args_info.size_arg, &spacing[0], &origin[0], &direction[0], args_info.value_arg, output); clitk::writeImage(output, args_info.output_arg); } if (dim == 3) { const int Dim=3; typedef itk::Image ImageType; ImageType::Pointer output = ImageType::New(); - NewFilledImage(args_info.size_arg, &spacing[0], &origin[0], args_info.value_arg, output); + NewFilledImage(args_info.size_arg, &spacing[0], &origin[0], &direction[0], args_info.value_arg, output); clitk::writeImage(output, args_info.output_arg); } if (dim == 4) { const int Dim=4; typedef itk::Image ImageType; ImageType::Pointer output = ImageType::New(); - NewFilledImage(args_info.size_arg, &spacing[0], &origin[0], args_info.value_arg, output); + NewFilledImage(args_info.size_arg, &spacing[0], &origin[0], &direction[0], args_info.value_arg, output); clitk::writeImage(output, args_info.output_arg); } diff --git a/tools/clitkImageCreate.ggo b/tools/clitkImageCreate.ggo index f197de7..391801d 100644 --- a/tools/clitkImageCreate.ggo +++ b/tools/clitkImageCreate.ggo @@ -11,6 +11,7 @@ option "like" l "Size/spacing like this other image" string no option "size" - "Number of pixels of each coordinate" int no multiple option "spacing" - "Spacing in mm between pixels" float no multiple option "origin" - "Origin in mm" double no multiple +option "transformMatrix" - "Rotation matrix" double no multiple option "value" - "Value for all voxels" float default="0.0" no option "verbose" v "Verbose" flag off diff --git a/tools/clitkNVectorImageTo4DImageGenericFilter.txx b/tools/clitkNVectorImageTo4DImageGenericFilter.txx index 06d5792..1ea4436 100644 --- a/tools/clitkNVectorImageTo4DImageGenericFilter.txx +++ b/tools/clitkNVectorImageTo4DImageGenericFilter.txx @@ -103,17 +103,24 @@ namespace clitk spacing.Fill(1); typename OutputImageType::PointType origin; origin.Fill(0); + typename OutputImageType::DirectionType direction; + direction.SetIdentity(); for (unsigned int pixelDim=0; pixelDimGetLargestPossibleRegion().GetSize(pixelDim); spacing[pixelDim]=input->GetSpacing()[pixelDim]; origin[pixelDim]=input->GetOrigin()[pixelDim]; + for (unsigned int pixelDim2=0; pixelDim2GetDirection()[pixelDim][pixelDim2]; + } } typename OutputImageType::RegionType region; region.SetSize(size); region.SetIndex(index); output->SetRegions(region); output->SetOrigin(origin); + output->SetDirection(direction); output->SetSpacing(spacing); output->Allocate(); writer->SetInput(output); diff --git a/tools/clitkProfileImage.ggo b/tools/clitkProfileImage.ggo index 773790d..9f3f443 100644 --- a/tools/clitkProfileImage.ggo +++ b/tools/clitkProfileImage.ggo @@ -9,8 +9,8 @@ option "imagetypes" - "Display allowed image types" flag off option "input" i "Input image filename" string yes option "output" o "Output texte filename" string yes -option "point1" f "First point (mm)" double yes multiple(-4) -option "point2" s "Second point (mm)" double yes multiple(-4) +option "point1" f "First point (vox)" double yes multiple(-4) +option "point2" s "Second point (vox)" double yes multiple(-4) diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx index 02394d3..6c81756 100644 --- a/tools/clitkProfileImageGenericFilter.cxx +++ b/tools/clitkProfileImageGenericFilter.cxx @@ -120,6 +120,9 @@ ProfileImageGenericFilter::UpdateWithInputImageType() mArrayY = vtkSmartPointer::New(); mCoord = vtkSmartPointer::New(); mCoord->SetNumberOfComponents(InputImageType::ImageDimension); + mCoordmm = vtkSmartPointer::New(); + mCoordmm->SetNumberOfComponents(InputImageType::ImageDimension); + mDimension = InputImageType::ImageDimension; /*typename InputImageType::Pointer outputImage; outputImage = InputImageType::New(); @@ -162,11 +165,20 @@ ProfileImageGenericFilter::UpdateWithInputImageType() // Fill in the table the distance value mArrayX->InsertNextTuple1(distance); - // Fille in the table the voxel coordinate value - mCoord->InsertNextTuple(tuple); + // Fill in the table the voxel coordinate value + mCoord->InsertNextTuple(tuple); //index + for (int i=0; iInsertNextTuple(tuple); //mm ++lineNumber; ++itProfile; } + + if (mArgsInfo.output_given) { + std::string str(mArgsInfo.output_arg); + this->WriteOutput(str); + } /* itk::LineIterator otProfile(outputImage, pointBegin, pointEnd); @@ -184,6 +196,58 @@ ProfileImageGenericFilter::UpdateWithInputImageType() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void ProfileImageGenericFilter::WriteOutput(std::string outputFilename) +{ + ofstream fileOpen(outputFilename.c_str(), std::ofstream::trunc); + + if(!fileOpen) { + cerr << "Error during saving" << endl; + return; + } + + double *tuple; + tuple = new double[mDimension]; + int i(0); + fileOpen << "The Bresenham algorithm is used to travel along the line. Values represent the center of each crossed voxel (in voxel and mm)" << endl; + fileOpen << "Id" << "\t" << "Value" << "\t" ; + fileOpen << "x(vox)" << "\t" << "y(vox)" << "\t"; + if (mDimension >=3) + fileOpen << "z(vox)" << "\t"; + if (mDimension >=4) + fileOpen << "t" << "\t"; + fileOpen << "x(mm)" << "\t" << "y(mm)" << "\t"; + if (mDimension >=3) + fileOpen << "z(mm)" << "\t"; + if (mDimension >=4) + fileOpen << "t" << "\t"; + fileOpen << endl; + + while (iGetNumberOfTuples()) { + fileOpen << i << "\t" << mArrayY->GetTuple(i)[0] << "\t" ; + + mCoord->GetTuple(i, tuple); + for (int j=0; jGetTuple(i, tuple); + for (int j=0; j #include //-------------------------------------------------------------------- @@ -59,6 +58,9 @@ namespace clitk vtkFloatArray* GetArrayY(); vtkFloatArray* GetCoord(); + //Write the output in the txt file + void WriteOutput(std::string outputFilename); + protected: ProfileImageGenericFilter(); template void InitializeImageType(); @@ -68,6 +70,8 @@ namespace clitk vtkSmartPointer mArrayX; vtkSmartPointer mArrayY; vtkSmartPointer mCoord; + vtkSmartPointer mCoordmm; + int mDimension; }; // end class diff --git a/tools/clitkSplitImageGenericFilter.cxx b/tools/clitkSplitImageGenericFilter.cxx index 4eb00b9..a73d308 100644 --- a/tools/clitkSplitImageGenericFilter.cxx +++ b/tools/clitkSplitImageGenericFilter.cxx @@ -25,6 +25,7 @@ -------------------------------------------------------------------*/ #include "clitkSplitImageGenericFilter.h" +#include "itkChangeInformationImageFilter.h" #include //-------------------------------------------------------------------- clitk::SplitImageGenericFilter::SplitImageGenericFilter(): @@ -109,6 +110,8 @@ void clitk::SplitImageGenericFilter::UpdateWithInputImageType() filter->SetExtractionRegion(extracted_region); filter->Update(); + typedef itk::ChangeInformationImageFilter< OutputImageType > InformationFilterType; + typename ImageType::IndexType index=input->GetLargestPossibleRegion().GetIndex(); std::string base_filename=GetOutputFilename(); unsigned int number_of_output_images=input->GetLargestPossibleRegion().GetSize()[mSplitDimension]; @@ -119,16 +122,44 @@ void clitk::SplitImageGenericFilter::UpdateWithInputImageType() extracted_region.SetIndex(index); filter->SetExtractionRegion(extracted_region); filter->Update(); - if(this->m_Png){ - PngConversion png; - SetOutputFilename(base_filename+"_"+ss.str()+".png"); - typename PngConversion::OutputPngImagePointer output; - output = png.Do(this->m_Window, this->m_Level, filter->GetOutput()); - this->template SetNextOutput::OutputPngImageType>(output); + + if (ImageType::ImageDimension == 4 && mSplitDimension == 3) //Copy the transformation matrix if the original image is a 4D image splitted along the time dimension + { + typename InformationFilterType::Pointer informationFilter = InformationFilterType::New(); + informationFilter->SetInput( filter->GetOutput() ); + typename OutputImageType::DirectionType directionOutput; + for (unsigned j=0; j<3; ++j) + for (unsigned k=0; k<3; ++k) + directionOutput[j][k] = input->GetDirection()[j][k]; + informationFilter->SetOutputDirection( directionOutput ); + informationFilter->ChangeDirectionOn(); + informationFilter->UpdateOutputInformation(); + + if(this->m_Png){ + PngConversion png; + SetOutputFilename(base_filename+"_"+ss.str()+".png"); + typename PngConversion::OutputPngImagePointer output; + output = png.Do(this->m_Window, this->m_Level, informationFilter->GetOutput()); + this->template SetNextOutput::OutputPngImageType>(output); + } + else { + SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); + SetNextOutput(informationFilter->GetOutput()); + } } - else { - SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); - SetNextOutput(filter->GetOutput()); + else + { + if(this->m_Png){ + PngConversion png; + SetOutputFilename(base_filename+"_"+ss.str()+".png"); + typename PngConversion::OutputPngImagePointer output; + output = png.Do(this->m_Window, this->m_Level, filter->GetOutput()); + this->template SetNextOutput::OutputPngImageType>(output); + } + else { + SetOutputFilename(base_filename+"_"+ss.str()+".mhd"); + SetNextOutput(filter->GetOutput()); + } } } } diff --git a/tools/clitkWarpImageGenericFilter.txx b/tools/clitkWarpImageGenericFilter.txx index d1d1f71..84bfbaa 100644 --- a/tools/clitkWarpImageGenericFilter.txx +++ b/tools/clitkWarpImageGenericFilter.txx @@ -132,6 +132,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType() resampler =itk::VectorResampleImageFilter::New(); resampler->SetInput(deformationField); resampler->SetOutputSpacing(deformationField->GetSpacing()); + resampler->SetOutputDirection(deformationField->GetDirection()); resampler->SetSize(newSize); resampler->SetOutputOrigin(input->GetOrigin()); resampler->SetInterpolator(genericInterpolator->GetInterpolatorPointer()); @@ -163,6 +164,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType() resampler =itk::VectorResampleImageFilter::New(); resampler->SetInput(deformationField); resampler->SetOutputSpacing(input->GetSpacing()); + resampler->SetOutputDirection(deformationField->GetDirection()); resampler->SetSize(newSize); resampler->SetOutputOrigin(input->GetOrigin()); resampler->SetInterpolator(genericInterpolator->GetInterpolatorPointer()); @@ -210,6 +212,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType() backwardWarpFilter->SetOutputSpacing( deformationField->GetSpacing() ); backwardWarpFilter->SetOutputOrigin( input->GetOrigin() ); backwardWarpFilter->SetOutputSize( deformationField->GetLargestPossibleRegion().GetSize() ); + backwardWarpFilter->SetOutputDirection( input->GetDirection() ); typename itk::VectorResampleImageFilter::Pointer resampler =itk::VectorResampleImageFilter::New(); backwardWarpFilter->SetInterpolator(genericInterpolator->GetInterpolatorPointer()); diff --git a/travis/travis_build_itk.sh b/travis/travis_build_itk.sh index 5bcc4c0..ee0fc25 100755 --- a/travis/travis_build_itk.sh +++ b/travis/travis_build_itk.sh @@ -3,12 +3,22 @@ set -ev MAKE="make --jobs=$NUM_THREADS --keep-going" #Prepare cmake arguments following the ITK version -if [ "$ITK_VERSION" == "4.5" ]; then -itk_repo_str=" --branch v4.5.0 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1" -cmake_arg_str=" -DModule_ITKVtkGlue=ON -DVTK_DIR=$VTK_DIR -DModule_ITKReview=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF " -elif [ "$ITK_VERSION" == "4.9.1" ]; then -itk_repo_str=" --branch v4.9.1 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1" -cmake_arg_str=" -DModule_ITKVtkGlue=ON -DVTK_DIR=$VTK_DIR -DModule_ITKReview=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF " +if [ "$C11" == "true" ]; then + if [ "$ITK_VERSION" == "4.5" ]; then + itk_repo_str=" --branch v4.5.0 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1" + cmake_arg_str=" -DCMAKE_CXX_FLAGS=-std=c++11 -DModule_ITKVtkGlue=ON -DVTK_DIR=$VTK_DIR -DModule_ITKReview=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF " + elif [ "$ITK_VERSION" == "4.9.1" ]; then + itk_repo_str=" --branch v4.9.1 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1" + cmake_arg_str=" -DCMAKE_CXX_FLAGS=-std=c++11 -DModule_ITKVtkGlue=ON -DVTK_DIR=$VTK_DIR -DModule_ITKReview=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF " + fi +else + if [ "$ITK_VERSION" == "4.5" ]; then + itk_repo_str=" --branch v4.5.0 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1" + cmake_arg_str=" -DModule_ITKVtkGlue=ON -DVTK_DIR=$VTK_DIR -DModule_ITKReview=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF " + elif [ "$ITK_VERSION" == "4.9.1" ]; then + itk_repo_str=" --branch v4.9.1 https://github.com/InsightSoftwareConsortium/ITK.git --depth 1" + cmake_arg_str=" -DModule_ITKVtkGlue=ON -DVTK_DIR=$VTK_DIR -DModule_ITKReview=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF " + fi fi if [ -d $ITK_SOURCE_DIR ]; then diff --git a/travis/travis_build_qt.sh b/travis/travis_build_qt.sh index 455eb73..7b3ef0b 100755 --- a/travis/travis_build_qt.sh +++ b/travis/travis_build_qt.sh @@ -5,8 +5,10 @@ set -ev if [ "$QT_VERSION" == "4.8.7" ]; then if test $TRAVIS_OS_NAME == linux ; then sudo apt-get -y --force-yes install qt4-dev-tools; fi - if test $TRAVIS_OS_NAME == osx ; then brew install cartr/qt4/qt; fi - if test $TRAVIS_OS_NAME == osx ; then brew link qt --force; fi + if test $TRAVIS_OS_NAME == osx ; then brew install cartr/qt4/qt@4; fi + if test $TRAVIS_OS_NAME == osx ; then brew install cartr/qt4/qt-webkit@2.3; fi + if test $TRAVIS_OS_NAME == osx ; then brew link qt@4 --force; fi + if test $TRAVIS_OS_NAME == osx ; then brew link qt-webkit@2.3 --force; fi if test $TRAVIS_OS_NAME == osx ; then qmake -v; fi elif [ "$QT_VERSION" == "5.5.1" ]; then if test $TRAVIS_OS_NAME == linux ; then sudo add-apt-repository --yes ppa:beineri/opt-qt551-trusty; fi diff --git a/travis/travis_build_vtk.sh b/travis/travis_build_vtk.sh index f7b1fce..f4dbf32 100755 --- a/travis/travis_build_vtk.sh +++ b/travis/travis_build_vtk.sh @@ -9,61 +9,123 @@ elif [ "$QT_VERSION" == "5.5.1" ]; then fi #Prepare cmake arguments following the VTK version -if [ "$VTK_VERSION" == "5.10" ]; then -vtk_repo_str=" --branch v5.10.0 https://github.com/Kitware/VTK.git --depth 1" -cmake_arg_str=" $cmake_arg_str - -DBUILD_SHARED_LIBS=1 - -DCMAKE_BUILD_TYPE=Release - -DBUILD_TESTING=0 - -DBUILD_EXAMPLES=0 - -DBUILD_DOCUMENTATION=0 - -DVTK_USE_QT=ON - -DVTK_USE_RENDERING=ON - -DVTK_USE_VIEWS=ON - -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " -elif [ "$VTK_VERSION" == "6.3" ]; then -vtk_repo_str=" --branch v6.3.0 https://github.com/Kitware/VTK.git --depth 1" -cmake_arg_str=" $cmake_arg_str - -DBUILD_SHARED_LIBS=1 - -DCMAKE_BUILD_TYPE=Release - -DBUILD_TESTING=0 - -DBUILD_EXAMPLES=0 - -DBUILD_DOCUMENTATION=0 - -DVTK_Group_StandAlone=ON - -DVTK_Group_Imaging=OFF - -DVTK_Group_MPI=OFF - -DVTK_Group_Rendering=ON - -DVTK_Group_Tk=OFF - -DVTK_Group_Views=OFF - -DVTK_Group_Web=OFF - -DModule_vtkGUISupportQt=ON - -DModule_vtkGUISupportQtOpenGL=ON - -DModule_vtkGUISupportQtSQL=ON - -DModule_vtkRenderingQt=ON - -DModule_vtkViewsQt=ON - -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " -elif [ "$VTK_VERSION" == "7.0.0" ]; then -vtk_repo_str=" --branch v7.0.0 https://github.com/Kitware/VTK.git --depth 1" -cmake_arg_str=" $cmake_arg_str - -DBUILD_SHARED_LIBS=1 - -DCMAKE_BUILD_TYPE=Release - -DBUILD_TESTING=0 - -DBUILD_EXAMPLES=0 - -DBUILD_DOCUMENTATION=0 - -DVTK_Group_StandAlone=ON - -DVTK_Group_Imaging=OFF - -DVTK_Group_MPI=OFF - -DVTK_Group_Rendering=ON - -DVTK_Group_Tk=OFF - -DVTK_Group_Views=OFF - -DVTK_Group_Web=OFF - -DVTK_RENDERING_BACKEND=OpenGL - -DModule_vtkGUISupportQt=ON - -DModule_vtkGUISupportQtOpenGL=ON - -DModule_vtkGUISupportQtSQL=ON - -DModule_vtkRenderingQt=ON - -DModule_vtkViewsQt=ON - -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " +if [ "$C11" == "true" ]; then + if [ "$VTK_VERSION" == "5.10" ]; then + vtk_repo_str=" --branch v5.10.0 https://github.com/Kitware/VTK.git --depth 1" + cmake_arg_str=" $cmake_arg_str + -DCMAKE_CXX_FLAGS=-std=c++11 + -DBUILD_SHARED_LIBS=1 + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=0 + -DBUILD_EXAMPLES=0 + -DBUILD_DOCUMENTATION=0 + -DVTK_USE_QT=ON + -DVTK_USE_RENDERING=ON + -DVTK_USE_VIEWS=ON + -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " + elif [ "$VTK_VERSION" == "6.3" ]; then + vtk_repo_str=" --branch v6.3.0 https://github.com/Kitware/VTK.git --depth 1" + cmake_arg_str=" $cmake_arg_str + -DCMAKE_CXX_FLAGS=-std=c++11 + -DBUILD_SHARED_LIBS=1 + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=0 + -DBUILD_EXAMPLES=0 + -DBUILD_DOCUMENTATION=0 + -DVTK_Group_StandAlone=ON + -DVTK_Group_Imaging=OFF + -DVTK_Group_MPI=OFF + -DVTK_Group_Rendering=ON + -DVTK_Group_Tk=OFF + -DVTK_Group_Views=OFF + -DVTK_Group_Web=OFF + -DModule_vtkGUISupportQt=ON + -DModule_vtkGUISupportQtOpenGL=ON + -DModule_vtkGUISupportQtSQL=ON + -DModule_vtkRenderingQt=ON + -DModule_vtkViewsQt=ON + -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " + elif [ "$VTK_VERSION" == "7.0.0" ]; then + vtk_repo_str=" --branch v7.0.0 https://github.com/Kitware/VTK.git --depth 1" + cmake_arg_str=" $cmake_arg_str + -DCMAKE_CXX_FLAGS=-std=c++11 + -DBUILD_SHARED_LIBS=1 + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=0 + -DBUILD_EXAMPLES=0 + -DBUILD_DOCUMENTATION=0 + -DVTK_Group_StandAlone=ON + -DVTK_Group_Imaging=OFF + -DVTK_Group_MPI=OFF + -DVTK_Group_Rendering=ON + -DVTK_Group_Tk=OFF + -DVTK_Group_Views=OFF + -DVTK_Group_Web=OFF + -DVTK_RENDERING_BACKEND=OpenGL + -DModule_vtkGUISupportQt=ON + -DModule_vtkGUISupportQtOpenGL=ON + -DModule_vtkGUISupportQtSQL=ON + -DModule_vtkRenderingQt=ON + -DModule_vtkViewsQt=ON + -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " + fi +else + if [ "$VTK_VERSION" == "5.10" ]; then + vtk_repo_str=" --branch v5.10.0 https://github.com/Kitware/VTK.git --depth 1" + cmake_arg_str=" $cmake_arg_str + -DBUILD_SHARED_LIBS=1 + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=0 + -DBUILD_EXAMPLES=0 + -DBUILD_DOCUMENTATION=0 + -DVTK_USE_QT=ON + -DVTK_USE_RENDERING=ON + -DVTK_USE_VIEWS=ON + -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " + elif [ "$VTK_VERSION" == "6.3" ]; then + vtk_repo_str=" --branch v6.3.0 https://github.com/Kitware/VTK.git --depth 1" + cmake_arg_str=" $cmake_arg_str + -DBUILD_SHARED_LIBS=1 + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=0 + -DBUILD_EXAMPLES=0 + -DBUILD_DOCUMENTATION=0 + -DVTK_Group_StandAlone=ON + -DVTK_Group_Imaging=OFF + -DVTK_Group_MPI=OFF + -DVTK_Group_Rendering=ON + -DVTK_Group_Tk=OFF + -DVTK_Group_Views=OFF + -DVTK_Group_Web=OFF + -DModule_vtkGUISupportQt=ON + -DModule_vtkGUISupportQtOpenGL=ON + -DModule_vtkGUISupportQtSQL=ON + -DModule_vtkRenderingQt=ON + -DModule_vtkViewsQt=ON + -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " + elif [ "$VTK_VERSION" == "7.0.0" ]; then + vtk_repo_str=" --branch v7.0.0 https://github.com/Kitware/VTK.git --depth 1" + cmake_arg_str=" $cmake_arg_str + -DBUILD_SHARED_LIBS=1 + -DCMAKE_BUILD_TYPE=Release + -DBUILD_TESTING=0 + -DBUILD_EXAMPLES=0 + -DBUILD_DOCUMENTATION=0 + -DVTK_Group_StandAlone=ON + -DVTK_Group_Imaging=OFF + -DVTK_Group_MPI=OFF + -DVTK_Group_Rendering=ON + -DVTK_Group_Tk=OFF + -DVTK_Group_Views=OFF + -DVTK_Group_Web=OFF + -DVTK_RENDERING_BACKEND=OpenGL + -DModule_vtkGUISupportQt=ON + -DModule_vtkGUISupportQtOpenGL=ON + -DModule_vtkGUISupportQtSQL=ON + -DModule_vtkRenderingQt=ON + -DModule_vtkViewsQt=ON + -DVTK_QT_VERSION="$QT_MAJOR_VERSION" " + fi fi if [ -d $VTK_SOURCE_DIR ]; then diff --git a/travis/travis_build_vv.sh b/travis/travis_build_vv.sh index 797b03c..5472076 100755 --- a/travis/travis_build_vv.sh +++ b/travis/travis_build_vv.sh @@ -3,11 +3,20 @@ set -ev MAKE="make --jobs=$NUM_THREADS --keep-going" #Prepare cmake arguments following the vv version -cmake_arg_str=" -DCLITK_BUILD_REGISTRATION=OFF --DCLITK_BUILD_SEGMENTATION=OFF --DCLITK_BUILD_TOOLS=OFF --DCLITK_BUILD_VV=ON --DCLITK_EXPERIMENTAL=OFF" +if [ "$C11" == "true" ]; then + cmake_arg_str=" -DCMAKE_CXX_FLAGS=-std=c++11 + -DCLITK_BUILD_REGISTRATION=OFF + -DCLITK_BUILD_SEGMENTATION=OFF + -DCLITK_BUILD_TOOLS=OFF + -DCLITK_BUILD_VV=ON + -DCLITK_EXPERIMENTAL=OFF" +else + cmake_arg_str=" -DCLITK_BUILD_REGISTRATION=OFF + -DCLITK_BUILD_SEGMENTATION=OFF + -DCLITK_BUILD_TOOLS=OFF + -DCLITK_BUILD_VV=ON + -DCLITK_EXPERIMENTAL=OFF" +fi #CMAKE and MAKE mkdir -p $BUILD_DIR diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 14b441e..436dfc6 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -22,6 +22,7 @@ set(vv_TOOLS vvToolROIManager vvToolSegmentation vvToolProfile + vvToolHistogram ## these ones are for tests (not working) # vvToolTest # vvToolFoo @@ -38,6 +39,7 @@ set(vv_TOOLS # >> add the relevant $_LIBS variable to the tool that has dependencies? set(vvToolBinarize_LIBS clitkBinarizeImageLib) set(vvToolProfile_LIBS clitkProfileImageLib) +set(vvToolHistogram_LIBS clitkHistogramImageLib) set(vvToolResample_LIBS clitkResampleImageLib) set(vvToolConvert_LIBS clitkImageConvertLib) set(vvToolExtractPatient_LIBS clitkSegmentationGgoLib) @@ -89,6 +91,7 @@ set(vv_SRCS vvGlyph2D.cxx vvSlicerManager.cxx vvSlicerManagerCommand.cxx + vvToolHistogramCommand.cxx vvUtils.cxx # vvMaximumIntensityProjection.cxx vvMesh.cxx diff --git a/vv/icons/histogram.png b/vv/icons/histogram.png new file mode 100644 index 0000000..2690413 Binary files /dev/null and b/vv/icons/histogram.png differ diff --git a/vv/qt_ui/vvInfoPanel.ui b/vv/qt_ui/vvInfoPanel.ui index b0b8d39..8eb2d87 100644 --- a/vv/qt_ui/vvInfoPanel.ui +++ b/vv/qt_ui/vvInfoPanel.ui @@ -401,13 +401,6 @@ p, li { white-space: pre-wrap; } 0 - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">in mebibytes (2<span style=" vertical-align:super;">20</span> bytes, not 10<span style=" vertical-align:super;">6</span>)</p></body></html> - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> diff --git a/vv/qt_ui/vvMainWindow.ui b/vv/qt_ui/vvMainWindow.ui index ec4051a..fa205e0 100644 --- a/vv/qt_ui/vvMainWindow.ui +++ b/vv/qt_ui/vvMainWindow.ui @@ -146,7 +146,7 @@ - 3 + 6 -66000.000000000000000 @@ -195,7 +195,7 @@ - 3 + 6 -66000.000000000000000 diff --git a/vv/qt_ui/vvToolHistogram.ui b/vv/qt_ui/vvToolHistogram.ui new file mode 100644 index 0000000..01851e0 --- /dev/null +++ b/vv/qt_ui/vvToolHistogram.ui @@ -0,0 +1,106 @@ + + + vvToolHistogram + + + + 0 + 0 + 506 + 452 + + + + Histogram image + + + + + + + + 6 + + + + + + + + 0 + 0 + + + + Save Histogram + + + + + + + + + + + + 0 + 0 + + + + + 200 + 0 + + + + + + + + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + 0 + 300 + + + + true + + + + + + + + + + QVTKWidget + QWidget +
QVTKWidget.h
+
+
+ + +
diff --git a/vv/vvIcons.qrc b/vv/vvIcons.qrc index a5e31cc..6bb8c93 100644 --- a/vv/vvIcons.qrc +++ b/vv/vvIcons.qrc @@ -13,6 +13,7 @@ icons/1b.png icons/binarize.png icons/profile.png + icons/histogram.png icons/resample.png icons/crop.png icons/splashscreen2.png diff --git a/vv/vvIntensityValueSlider.h b/vv/vvIntensityValueSlider.h index 722e534..b123f40 100644 --- a/vv/vvIntensityValueSlider.h +++ b/vv/vvIntensityValueSlider.h @@ -20,7 +20,11 @@ // qt #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include // clitk diff --git a/vv/vvLabelImageLoaderWidget.h b/vv/vvLabelImageLoaderWidget.h index eadf342..178acb2 100644 --- a/vv/vvLabelImageLoaderWidget.h +++ b/vv/vvLabelImageLoaderWidget.h @@ -24,7 +24,11 @@ // qt #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include #include "ui_vvLabelImageLoaderWidget.h" diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index a3d2000..aa10ded 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -416,7 +416,7 @@ void vvMainWindow::UpdateMemoryUsage() { // clitk::PrintMemory(true); if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA"); - else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB"); + else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MB"); } //------------------------------------------------------------------------------ @@ -1173,7 +1173,7 @@ void vvMainWindow::ImageInfoChanged() sizeMM[i] = inputSize[i]*inputSpacing[i]; NPixel *= inputSize[i]; } - inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()*1000); + inputSizeInBytes = GetSizeInBytes(imageSelected->GetActualMemorySize()); QString dim = QString::number(dimension) + " ("; dim += pixelType + ")"; @@ -1374,15 +1374,15 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size) if (size > 1000000000) { size /= 1000000000; result += QString::number(size); - result += "Gb";//)"; + result += "GB";//)"; } else if (size > 1000000) { size /= 1000000; result += QString::number(size); - result += "Mb";//)"; + result += "MB";//)"; } else if (size > 1000) { size /= 1000; result += QString::number(size); - result += "kb";//)"; + result += "kB";//)"; } return result; } diff --git a/vv/vvQProgressDialogITKCommand.h b/vv/vvQProgressDialogITKCommand.h index 8ac9979..72821b7 100644 --- a/vv/vvQProgressDialogITKCommand.h +++ b/vv/vvQProgressDialogITKCommand.h @@ -22,6 +22,8 @@ // qt include #include +#include "clitkCommon.h" + class vvQProgressDialogITKCommand : public itk::Command { public: @@ -33,8 +35,8 @@ public: void Initialize(QString title, float sec, int max); - void Execute(itk::Object *caller, const itk::EventObject & event); - void Execute(const itk::Object *caller, const itk::EventObject & event); + void Execute(itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE; + void Execute(const itk::Object *caller, const itk::EventObject & event) ITK_OVERRIDE; protected: vvQProgressDialogITKCommand(); diff --git a/vv/vvReadState.h b/vv/vvReadState.h index a34c464..b10a2cb 100644 --- a/vv/vvReadState.h +++ b/vv/vvReadState.h @@ -29,8 +29,13 @@ protected: std::string ReadVector(int index); std::string ReadLink(); +#if __cplusplus > 199711L + std::shared_ptr m_XmlReader; + std::shared_ptr m_File; +#else std::auto_ptr m_XmlReader; std::auto_ptr m_File; +#endif vvMainWindow* m_Window; int m_TreeItemCount; int m_NumImages; diff --git a/vv/vvSaveState.h b/vv/vvSaveState.h index 4f96c06..8085e25 100644 --- a/vv/vvSaveState.h +++ b/vv/vvSaveState.h @@ -30,8 +30,13 @@ protected: void SaveVector(const QTreeWidgetItem* item); void SaveLink(const vvSlicerManager* slicerManager); +#if __cplusplus > 199711L + std::shared_ptr m_XmlWriter; + std::shared_ptr m_File; +#else std::auto_ptr m_XmlWriter; std::auto_ptr m_File; +#endif vvMainWindow* m_Window; }; diff --git a/vv/vvSegmentationDialog.h b/vv/vvSegmentationDialog.h index a3af4a3..f457df5 100644 --- a/vv/vvSegmentationDialog.h +++ b/vv/vvSegmentationDialog.h @@ -32,7 +32,11 @@ #include "vtkPolyData.h" #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include //==================================================================== diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 46139cd..ce6d335 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -150,10 +150,10 @@ vvSlicer::vvSlicer() legend = vtkSmartPointer::New(); //legend->SetTitle("test!"); - legend->SetPosition(0.82,0.18); - legend->SetWidth(0.1); + legend->SetPosition(0.82,0.08); + //legend->SetWidth(0.1); legend->SetVisibility(0); - legend->SetLabelFormat("%.1f"); + legend->SetLabelFormat("%.1e"); this->GetRenderer()->AddActor(legend); showFusionLegend = false; @@ -170,6 +170,7 @@ vvSlicer::vvSlicer() mConcatenatedTransform = vtkSmartPointer::New(); mConcatenatedFusionTransform = vtkSmartPointer::New(); mConcatenatedOverlayTransform = vtkSmartPointer::New(); + mConcatenatedVFTransform = vtkSmartPointer::New(); mFirstSetSliceOrientation = true; } //------------------------------------------------------------------------------ @@ -393,7 +394,7 @@ void vvSlicer::SetImage(vvImage::Pointer image) mImageReslice->GetOutput()->SetUpdateExtent(extent); mImageReslice->GetOutput()->Update(); #else - //mImageReslice->SetUpdateExtent(extent); + mImageReslice->SetUpdateExtent(extent); mImageReslice->Update(); #endif @@ -583,15 +584,31 @@ void vvSlicer::SetVF(vvImage::Pointer vf) mVFVisibility = true; if (!mAAFilter) { + mVFReslice = vtkSmartPointer::New(); + mVFReslice->SetInterpolationModeToLinear(); + mVFReslice->AutoCropOutputOn(); + mVFReslice->SetBackgroundColor(-1000,-1000,-1000,1); mAAFilter= vtkSmartPointer::New(); mVOIFilter = vtkSmartPointer::New(); mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling); } + + mConcatenatedVFTransform->Identity(); + mConcatenatedVFTransform->Concatenate(mVF->GetTransform()[0]); + mConcatenatedVFTransform->Concatenate(mSlicingTransform); + mVFReslice->SetResliceTransform(mConcatenatedVFTransform); #if VTK_MAJOR_VERSION <= 5 - mVOIFilter->SetInput(vf->GetFirstVTKImageData()); + mVFReslice->SetInput(0, mVF->GetFirstVTKImageData()); +#else + mVFReslice->SetInputData(0, mVF->GetFirstVTKImageData()); +#endif + mVFReslice->Update(); + +#if VTK_MAJOR_VERSION <= 5 + mVOIFilter->SetInput(mVFReslice->GetOutput()); mAAFilter->SetInput(mVOIFilter->GetOutput()); #else - mVOIFilter->SetInputData(vf->GetFirstVTKImageData()); + mVOIFilter->SetInputConnection(mVFReslice->GetOutputPort()); mAAFilter->SetInputConnection(mVOIFilter->GetOutputPort()); #endif ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows @@ -846,10 +863,14 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages) if (mVF && mVFActor->GetVisibility()) { if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice) #if VTK_MAJOR_VERSION <= 5 - mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]); + mVFReslice->SetInput(mVF->GetVTKImages()[mCurrentTSlice]); #else - mVOIFilter->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]); + mVFReslice->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]); #endif + // Update overlay transform + mConcatenatedVFTransform->Identity(); + mConcatenatedVFTransform->Concatenate(mVF->GetTransform()[mCurrentTSlice]); + mConcatenatedVFTransform->Concatenate(mSlicingTransform); } //update the overlay if (mOverlay && mOverlayActor->GetVisibility()) { @@ -976,6 +997,9 @@ void vvSlicer::SetSliceOrientation(int orientation) if(mOverlay) AdjustResliceToSliceOrientation(mOverlayReslice); + if(mVF) + AdjustResliceToSliceOrientation(mVFReslice); + // Update the viewer // Go to current cursor position @@ -1193,14 +1217,15 @@ void vvSlicer::UpdateDisplayExtent() offset = -1; if (mVF && mVFVisibility) { + AdjustResliceToSliceOrientation(mVFReslice); int vfExtent[6]; #if VTK_MAJOR_VERSION <= 5 mVF->GetVTKImages()[0]->UpdateInformation(); - this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent); + this->ConvertImageToImageDisplayExtent(input, w_ext, mVFReslice->GetOutput(), vfExtent); bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent()); #else mVOIFilter->Update(); - this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVF->GetVTKImages()[0], vfExtent); + this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVFReslice->GetOutput(), vfExtent); bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())); #endif mVFActor->SetVisibility(!out); diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 23c1959..3beab6e 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -270,6 +270,8 @@ protected: vtkSmartPointer mVFMapper; vtkSmartPointer mVFColorLUT; vtkSmartPointer mVFActor; + vtkSmartPointer mVFReslice; + vtkSmartPointer mConcatenatedVFTransform; vtkSmartPointer mLandGlyph; vtkSmartPointer mCross; vtkSmartPointer mLandClipper; diff --git a/vv/vvSurfaceViewerDialog.h b/vv/vvSurfaceViewerDialog.h index 88a75a6..f53c9bb 100644 --- a/vv/vvSurfaceViewerDialog.h +++ b/vv/vvSurfaceViewerDialog.h @@ -23,7 +23,11 @@ class vtkPolyDataMapper; class vtkActor; class vtkOBJReader; +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include //==================================================================== diff --git a/vv/vvToolBaseBase.cxx b/vv/vvToolBaseBase.cxx index 544bc5e..c71a216 100644 --- a/vv/vvToolBaseBase.cxx +++ b/vv/vvToolBaseBase.cxx @@ -20,7 +20,11 @@ #include "vvToolBaseBase.h" //------------------------------------------------------------------------------ -void vvToolBaseBase::SaveState(std::auto_ptr & m_XmlWriter) +#if __cplusplus > 199711L +void vvToolBaseBase::SaveState(std::shared_ptr & m_XmlWriter) +#else +void vvToolBaseBase::SaveState(std::auto_ptr & m_XmlWriter) +#endif { std::cerr << "SaveState not implemented for this tool." << std::endl; } diff --git a/vv/vvToolBaseBase.h b/vv/vvToolBaseBase.h index fa93d14..9c76bb1 100644 --- a/vv/vvToolBaseBase.h +++ b/vv/vvToolBaseBase.h @@ -32,8 +32,11 @@ public: std::vector & v = mCreator->GetListOfTool(); v.erase(std::find(v.begin(), v.end(), this)); }; - +#if __cplusplus > 199711L + virtual void SaveState(std::shared_ptr & m_XmlWriter); +#else virtual void SaveState(std::auto_ptr & m_XmlWriter); +#endif virtual void InitializeNewTool(bool ReadStateFlag); void SetCreator(vvToolCreatorBase * m) { mCreator = m; } void SetXmlReader(QXmlStreamReader * r, int index) { m_XmlReader = r; mImageIndex = index;} diff --git a/vv/vvToolBinarize.h b/vv/vvToolBinarize.h index 89e001e..4cdaa85 100644 --- a/vv/vvToolBinarize.h +++ b/vv/vvToolBinarize.h @@ -19,7 +19,11 @@ #define VVTOOLBINARIZE_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolCreatorBase.h b/vv/vvToolCreatorBase.h index b2c942f..5ade4a4 100644 --- a/vv/vvToolCreatorBase.h +++ b/vv/vvToolCreatorBase.h @@ -35,7 +35,7 @@ class vvToolCreatorBase: public QObject { public: vvToolCreatorBase(QString name); - virtual ~vvToolCreatorBase() {;} + virtual ~vvToolCreatorBase() {} virtual void InsertToolInMenu(vvMainWindowBase * m); virtual void InsertToolInContextMenu(); template void CreateTool(); @@ -55,7 +55,11 @@ class vvToolCreatorBase: public QObject { bool mUseContextMenu; QMenu * mToolMenu; std::vector mListOfActions; +#if __cplusplus > 199711L + std::shared_ptr m_XmlReader; +#else std::auto_ptr m_XmlReader; +#endif bool mReadStateFlag; int mImageIndex; diff --git a/vv/vvToolCropImage.cxx b/vv/vvToolCropImage.cxx index 736a7d6..0fb3e54 100644 --- a/vv/vvToolCropImage.cxx +++ b/vv/vvToolCropImage.cxx @@ -215,7 +215,7 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer) } // Set initial sliders values - int w_ext[6], imsize[3]; + int w_ext[6], imsize[4]; mCurrentSlicerManager->GetSlicer(0)->GetRegisterExtent(w_ext); for(int dim=0; dimGetDimension() && dim<3; ++dim){ imsize[dim] = w_ext[2*dim+1] - w_ext[2*dim] +1; diff --git a/vv/vvToolCropImage.h b/vv/vvToolCropImage.h index 014fe3d..c5d8ce1 100644 --- a/vv/vvToolCropImage.h +++ b/vv/vvToolCropImage.h @@ -20,7 +20,11 @@ //qt #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include #include // vv diff --git a/vv/vvToolFoo.h b/vv/vvToolFoo.h index 91f7dfe..e3526d6 100644 --- a/vv/vvToolFoo.h +++ b/vv/vvToolFoo.h @@ -17,7 +17,11 @@ ===========================================================================**/ #ifndef VVTOOLFOO_H #define VVTOOLFOO_H +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include #include "vvToolBase.h" diff --git a/vv/vvToolFooWithWidgetBase.h b/vv/vvToolFooWithWidgetBase.h index 0d07efd..3458f92 100644 --- a/vv/vvToolFooWithWidgetBase.h +++ b/vv/vvToolFooWithWidgetBase.h @@ -17,7 +17,11 @@ ===========================================================================**/ #ifndef VVTOOLFOO_H #define VVTOOLFOO_H +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolHistogram.cxx b/vv/vvToolHistogram.cxx new file mode 100644 index 0000000..24b0864 --- /dev/null +++ b/vv/vvToolHistogram.cxx @@ -0,0 +1,472 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ===========================================================================**/ + +#include +#include + +#include + +// vv +#include "vvToolHistogram.h" +#include "vvProgressDialog.h" +#include "vvSlicerManager.h" +#include "vvSlicer.h" +#include "vvToolInputSelectorWidget.h" +#include "vvToolHistogramCommand.h" + +// vtk +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_OSX +# include "vvOSXHelper.h" +#endif + +//------------------------------------------------------------------------------ +// Create the tool and automagically (I like this word) insert it in +// the main window menu. +ADD_TOOL(vvToolHistogram); +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::Initialize() +{ + SetToolName("Histogram"); + SetToolMenuName("Intensity Histogram"); + SetToolIconFilename(":/common/icons/histogram.png"); + SetToolTip("Display the histogram of the image."); + SetToolExperimental(false); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolHistogram::vvToolHistogram(vvMainWindowBase * parent, Qt::WindowFlags f) + :vvToolWidgetBase(parent,f), + vvToolBase(parent), + Ui::vvToolHistogram() +{ + // GUI Initialization + Ui_vvToolHistogram::setupUi(mToolWidget); + + mModificationsDone = false; + + // Connect signals & slots + connect(mSaveHistogramButton, SIGNAL(clicked()), this, SLOT(SaveAs())); + + // Initialize some widget + HistogramWidget->hide(); + + mView = vtkSmartPointer::New(); + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(false); + chart->SetRenderEmpty(true); + mView->GetScene()->AddItem(chart); + mView->GetRenderer()->SetBackground(1.0, 1.0, 1.0); + this->HistogramWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->HistogramWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + HistogramWidget->show(); + +#ifdef Q_OS_OSX + disableGLHiDPI(HistogramWidget->winId()); +#endif + + // Main filter + mFilter = clitk::HistogramImageGenericFilter::New(); + + // Set how many inputs are needed for this tool + AddInputSelector("Select one image", mFilter); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolHistogram::~vvToolHistogram() +{ +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::computeHistogram() +{ + if (!mCurrentSlicerManager) close(); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + GetArgsInfoFromGUI(); + HistogramWidget->hide(); + + // Main filter + mFilter->SetInputVVImage(mCurrentImage); + mFilter->SetArgsInfo(mArgsInfo); + mFilter->Update(); + + //Creation of the XY chart + vtkSmartPointer arrX = vtkSmartPointer::New(); + vtkSmartPointer arrY = vtkSmartPointer::New(); + arrX = mFilter->GetArrayX(); + arrY = mFilter->GetArrayY(); + arrX->SetName("Intensity"); + arrY->SetName("#Voxels"); + mTable->AddColumn(arrX); + mTable->AddColumn(arrY); + + //Upper and Lower lines for window/level + vtkSmartPointer arrXUpperWindowLevel = vtkSmartPointer::New(); + vtkSmartPointer arrXLowerWindowLevel = vtkSmartPointer::New(); + vtkSmartPointer arrYWindowLevel = vtkSmartPointer::New(); + arrXUpperWindowLevel->InsertNextTuple1(mMaxWindowLevel); + arrXUpperWindowLevel->InsertNextTuple1(mMaxWindowLevel); + arrXLowerWindowLevel->InsertNextTuple1(mMinWindowLevel); + arrXLowerWindowLevel->InsertNextTuple1(mMinWindowLevel); + arrYWindowLevel->InsertNextTuple1(0.0); + arrYWindowLevel->InsertNextTuple1(arrY->GetMaxNorm()); + arrXUpperWindowLevel->SetName("IntensityUp"); + arrXLowerWindowLevel->SetName("IntensityLow"); + arrYWindowLevel->SetName("#Voxels"); + mTableWindowLevel->AddColumn(arrXUpperWindowLevel); + mTableWindowLevel->AddColumn(arrXLowerWindowLevel); + mTableWindowLevel->AddColumn(arrYWindowLevel); + + displayHistogram(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::displayHistogram() +{ + if (!mCurrentSlicerManager) close(); + HistogramWidget->hide(); + + + vtkSmartPointer chart = vtkSmartPointer::New(); + chart->SetAutoSize(true); + mView->GetScene()->ClearItems(); + mView->GetScene()->AddItem(chart); + vtkPlot *line = chart->AddPlot(vtkChart::LINE); +#if VTK_MAJOR_VERSION <= 5 + line->SetInput(mTable, 0, 1); +#else + line->SetInputData(mTable, 0, 1); +#endif + line->SetColor(0, 255, 0, 255); + line->SetWidth(1.0); + + + vtkPlot *upperWindowLine = chart->AddPlot(vtkChart::LINE); + vtkPlot *lowerWindowLine = chart->AddPlot(vtkChart::LINE); +#if VTK_MAJOR_VERSION <= 5 + upperWindowLine->SetInput(mTableWindowLevel, 0, 2); + lowerWindowLine->SetInput(mTableWindowLevel, 1, 2); +#else + upperWindowLine->SetInputData(mTableWindowLevel, 0, 2); + lowerWindowLine->SetInputData(mTableWindowLevel, 1, 2); +#endif + upperWindowLine->SetColor(255, 0, 0, 255); + lowerWindowLine->SetColor(255, 0, 0, 255); + upperWindowLine->SetWidth(1.0); + lowerWindowLine->SetWidth(1.0); + + chart->GetAxis(vtkAxis::LEFT)->SetTitle("#Voxels"); + chart->GetAxis(vtkAxis::BOTTOM)->SetTitle("Intensity"); + + this->HistogramWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems(); + this->HistogramWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer()); + HistogramWidget->show(); + + QApplication::restoreOverrideCursor(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::changeWindowLevel() +{ + vtkFloatArray* upperArray = vtkFloatArray::New(); + upperArray = static_cast(mTableWindowLevel->GetColumn(0)); + upperArray->SetTuple1(0, mMaxWindowLevel); + upperArray->SetTuple1(1, mMaxWindowLevel); + vtkFloatArray* lowerArray = vtkFloatArray::New(); + lowerArray = static_cast(mTableWindowLevel->GetColumn(1)); + lowerArray->SetTuple1(0, mMinWindowLevel); + lowerArray->SetTuple1(1, mMinWindowLevel); + displayHistogram(); + mCurrentSlicerManager->UpdateWindowLevel(); + mCurrentSlicerManager->Render(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::windowLevelChanged() +{ + computeMinMax(); + changeWindowLevel(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::RemoveVTKObjects() +{ +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +bool vvToolHistogram::close() +{ + if (!mModificationsDone) + { + mCurrentSlicerManager->SetColorLevel(originalLevel); + mCurrentSlicerManager->SetColorWindow(originalWindow); + mCurrentSlicerManager->UpdateWindowLevel(); + mCurrentSlicerManager->Render(); + } + return vvToolWidgetBase::close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::closeEvent(QCloseEvent *event) +{ + RemoveVTKObjects(); + event->accept(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::reject() +{ + // DD("vvToolHistogram::reject"); + RemoveVTKObjects(); + return vvToolWidgetBase::reject(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::InputIsSelected(vvSlicerManager * m) +{ + mCurrentSlicerManager = m; + + mSaveHistogramButton->setEnabled(true); + mTextFileName = "Histogram.txt"; + + mTableWindowLevel = vtkSmartPointer::New(); + mTable = vtkSmartPointer::New(); + + originalWindow = mCurrentSlicerManager->GetColorWindow(); + originalLevel = mCurrentSlicerManager->GetColorLevel(); + + //Compute Min & Max for Window/Level + computeMinMax(); + + computeHistogram(); + + // Connect signals & slots + vvToolHistogramCommand *smc = vvToolHistogramCommand::New(); + smc->mHist = this; + HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::LeftButtonPressEvent, smc); + HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseMoveEvent, smc); + HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelForwardEvent, smc); + HistogramWidget->GetRenderWindow()->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::MouseWheelBackwardEvent, smc); + smc->Delete(); + +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +QVTKWidget* vvToolHistogram::GetHistogramWidget() +{ + return(HistogramWidget); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::computeMinMax() +{ + mMinWindowLevel = mCurrentSlicerManager->GetColorLevel() - mCurrentSlicerManager->GetColorWindow()/2.0; + mMaxWindowLevel = mCurrentSlicerManager->GetColorLevel() + mCurrentSlicerManager->GetColorWindow()/2.0; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::computeWindowLevel() +{ + double window = mMaxWindowLevel - mMinWindowLevel; + double level = (mMaxWindowLevel + mMinWindowLevel)/2.0; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::expandWindow() +{ + mCurrentSlicerManager->SetColorWindow(mCurrentSlicerManager->GetColorWindow()+10.0); + computeMinMax(); + changeWindowLevel(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::reduceWindow() +{ + mCurrentSlicerManager->SetColorWindow(mCurrentSlicerManager->GetColorWindow()-10.0); + computeMinMax(); + changeWindowLevel(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::translateWindow(double x) +{ + mCurrentSlicerManager->SetColorLevel(mCurrentSlicerManager->GetColorLevel()+10.0*x); + computeMinMax(); + changeWindowLevel(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::GetArgsInfoFromGUI() +{ + + /* //KEEP THIS FOR READING GGO FROM FILE + int argc=1; + std::string a = "toto"; + char * const* argv = new char*; + //a.c_str(); + struct cmdline_parser_params p; + p.check_required = 0; + int good = cmdline_parser_ext(argc, argv, &args_info, &p); + DD(good); + */ + cmdline_parser_clitkHistogramImage_init(&mArgsInfo); // Initialisation to default + + mArgsInfo.verbose_flag = false; + + // Required (even if not used) + mArgsInfo.input_given = 0; + mArgsInfo.output_given = 0; + + mArgsInfo.input_arg = new char; + mArgsInfo.output_arg = new char; + +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::apply() +{ + mModificationsDone = true; + close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolHistogram::SaveAs() +{ + QStringList OutputListeFormat; + OutputListeFormat.clear(); + OutputListeFormat.push_back(".txt"); + + QString Extensions = "AllFiles(*.*)"; + for (int i = 0; i < OutputListeFormat.count(); i++) { + Extensions += ";;Text File ( *"; + Extensions += OutputListeFormat[i]; + Extensions += ")"; + } + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), mTextFileName.c_str(), Extensions); + if (!fileName.isEmpty()) { + std::string fileformat = itksys::SystemTools::GetFilenameLastExtension(fileName.toStdString()); + QString fileQFormat = fileformat.c_str(); + if (OutputListeFormat.contains(fileformat.c_str()) || fileQFormat.isEmpty()) { + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + std::string action = "Saving"; + vvProgressDialog progress("Saving "+fileName.toStdString()); + qApp->processEvents(); + + if (!mCurrentSlicerManager) { + close(); + return; + } + + // Output + mTextFileName = fileName.toStdString(); + if (fileQFormat.isEmpty()) + mTextFileName += ".txt"; + ofstream fileOpen(mTextFileName.c_str(), std::ofstream::trunc); + + if(!fileOpen) { + cerr << "Error during saving" << endl; + QApplication::restoreOverrideCursor(); + close(); + return; + } + + vtkSmartPointer arrX = vtkSmartPointer::New(); + vtkSmartPointer arrY = vtkSmartPointer::New(); + vtkSmartPointer coords = vtkSmartPointer::New(); + arrX = mFilter->GetArrayX(); + arrY = mFilter->GetArrayY(); + int i(0); + fileOpen << "Value represents the number of voxels around the corresponding intensity (by default the windows size around intensity is log(range))" << endl; + fileOpen << "Intensity" << "\t" << "Value" << endl; + + while (iGetNumberOfTuples()) { + fileOpen << arrX->GetTuple(i)[0] << "\t" << arrY->GetTuple(i)[0] << endl; + ++i; + } + + fileOpen.close(); + QApplication::restoreOverrideCursor(); + } else { + QString error = fileformat.c_str(); + error += " format unknown !!!\n"; + QMessageBox::information(this,tr("Saving Problem"),error); + SaveAs(); + } + } +} +//------------------------------------------------------------------------------ diff --git a/vv/vvToolHistogram.h b/vv/vvToolHistogram.h new file mode 100644 index 0000000..437e4e6 --- /dev/null +++ b/vv/vvToolHistogram.h @@ -0,0 +1,103 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef VVTOOLHISTOGRAM_H +#define VVTOOLHISTOGRAM_H + +#include +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif + +#include "vvToolBase.h" +#include "vvToolWidgetBase.h" +#include "ui_vvToolHistogram.h" + +#include "clitkHistogramImage_ggo.h" +#include "clitkHistogramImageGenericFilter.h" +#include +#include +#include +#include +#include + +//------------------------------------------------------------------------------ +class vvToolHistogram: + public vvToolWidgetBase, + public vvToolBase, + private Ui::vvToolHistogram +{ + Q_OBJECT + public: + vvToolHistogram(vvMainWindowBase * parent=0, Qt::WindowFlags f=0); + ~vvToolHistogram(); + + //----------------------------------------------------- + static void Initialize(); + void GetArgsInfoFromGUI(); + virtual void InputIsSelected(vvSlicerManager * m); + + void computeHistogram(); + void changeWindowLevel(); + void computeWindowLevel(); + void computeMinMax(); + void SetPoints(); + + void displayHistogram(); + + QVTKWidget* GetHistogramWidget(); + + //----------------------------------------------------- + public slots: + virtual void apply(); + virtual bool close(); + virtual void reject(); + + void windowLevelChanged(); + void reduceWindow(); + void expandWindow(); + void translateWindow(double x); + + void SaveAs(); + + protected: + void RemoveVTKObjects(); + virtual void closeEvent(QCloseEvent *event); + Ui::vvToolHistogram ui; + args_info_clitkHistogramImage mArgsInfo; + + double mMinWindowLevel; + double mMaxWindowLevel; + double originalWindow; + double originalLevel; + bool mModificationsDone; + + vtkSmartPointer mView; + + vtkSmartPointer mTableWindowLevel; + vtkSmartPointer mTable; + //vtkSmartPointer mView; + clitk::HistogramImageGenericFilter::Pointer mFilter; + std::string mTextFileName; + +}; // end class vvToolHistogram +//------------------------------------------------------------------------------ + +#endif + diff --git a/vv/vvToolHistogramCommand.cxx b/vv/vvToolHistogramCommand.cxx new file mode 100644 index 0000000..585f16c --- /dev/null +++ b/vv/vvToolHistogramCommand.cxx @@ -0,0 +1,73 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#include "vvToolHistogramCommand.h" +#include "vvSlicerManager.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vvSlicer.h" +#include "vvInteractorStyleNavigator.h" +#include "vtkTransform.h" + +#include +//------------------------------------------------------------------------------ +vvToolHistogramCommand::vvToolHistogramCommand() +{ + mFollowMouse = false; +} +//------------------------------------------------------------------------------ + + + + +//------------------------------------------------------------------------------ +void vvToolHistogramCommand::Execute(vtkObject *caller, + unsigned long event, + void *vtkNotUsed(callData)) +{ + if (event == vtkCommand::MouseWheelForwardEvent) { + mHist->expandWindow(); + } + if (event == vtkCommand::MouseWheelBackwardEvent) { + mHist->reduceWindow(); + } + if (event == vtkCommand::LeftButtonPressEvent) { + mFollowMouse = !mFollowMouse; + } + if (event == vtkCommand::MouseMoveEvent) { + if (mFollowMouse) { + vtkSmartPointer interactor = mHist->GetHistogramWidget()->GetRenderWindow()->GetInteractor(); + if (interactor->GetEventPosition()[0] != interactor->GetLastEventPosition()[0]) + mHist->translateWindow(interactor->GetEventPosition()[0] - interactor->GetLastEventPosition()[0]); + } + } +} +//------------------------------------------------------------------------------ diff --git a/vv/vvToolHistogramCommand.h b/vv/vvToolHistogramCommand.h new file mode 100644 index 0000000..0a73dbe --- /dev/null +++ b/vv/vvToolHistogramCommand.h @@ -0,0 +1,56 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef __vvToolHistogramCommand_h +#define __vvToolHistogramCommand_h +#include "vtkCommand.h" +#include "vvSlicerManager.h" +#include "vvToolHistogram.h" +#include "vtkRenderWindow.h" +#include "vtkRenderer.h" +#include "vtkImageData.h" +#include "vtkImageActor.h" +#include "vvInteractorStyleNavigator.h" +#include "vtkRenderWindowInteractor.h" +#include "vtkInteractorStyleImage.h" +#include "vtkPropPicker.h" + +#include +#include +#include + +class vvToolHistogramCommand : public vtkCommand +{ +public: + static vvToolHistogramCommand *New() { + return new vvToolHistogramCommand; + } + + void Execute(vtkObject *caller, + unsigned long event, + void *vtkNotUsed(callData)); + + vvToolHistogram* mHist; + +protected : + vvToolHistogramCommand(); + ~vvToolHistogramCommand() {} + + bool mFollowMouse; +}; + +#endif diff --git a/vv/vvToolImageArithm.h b/vv/vvToolImageArithm.h index 9fe70ce..964b9c8 100644 --- a/vv/vvToolImageArithm.h +++ b/vv/vvToolImageArithm.h @@ -19,7 +19,11 @@ #define VVTOOLImageArithm_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolInputSelectorWidget.h b/vv/vvToolInputSelectorWidget.h index 07dbd48..76e0c34 100644 --- a/vv/vvToolInputSelectorWidget.h +++ b/vv/vvToolInputSelectorWidget.h @@ -20,7 +20,11 @@ // qt #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include // vv diff --git a/vv/vvToolMIP.h b/vv/vvToolMIP.h index e3904a6..e915525 100644 --- a/vv/vvToolMIP.h +++ b/vv/vvToolMIP.h @@ -48,7 +48,11 @@ along with this program. If not, see . #include #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "QWidget" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolMedianFilter.h b/vv/vvToolMedianFilter.h index 9152712..b075ac1 100644 --- a/vv/vvToolMedianFilter.h +++ b/vv/vvToolMedianFilter.h @@ -46,7 +46,11 @@ #define VVTOOLMedianFilter_H #include +#if QT_VERSION >= 0x050000 + #include +#else #include +#endif #include "vvToolBase.h" #include "QWidget" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolPlastimatch.h b/vv/vvToolPlastimatch.h index d808abd..ff56b8a 100644 --- a/vv/vvToolPlastimatch.h +++ b/vv/vvToolPlastimatch.h @@ -18,7 +18,11 @@ #ifndef VVTOOLPLASTIMATCH_H #define VVTOOLPLASTIMATCH_H +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx index e0ebdf1..7ef2310 100644 --- a/vv/vvToolProfile.cxx +++ b/vv/vvToolProfile.cxx @@ -511,50 +511,8 @@ void vvToolProfile::SaveAs() close(); return; } - - vtkSmartPointer arrX = vtkSmartPointer::New(); - vtkSmartPointer arrY = vtkSmartPointer::New(); - vtkSmartPointer coords = vtkSmartPointer::New(); - arrX = mFilter->GetArrayX(); - arrY = mFilter->GetArrayY(); - coords = mFilter->GetCoord(); - double *tuple; - tuple = new double[mCurrentSlicerManager->GetImage()->GetNumberOfDimensions()]; - int i(0); - fileOpen << "The Bresenham algorithm is used to travel along the line. Values represent the center of each crossed voxel (in voxel and mm)" << endl; - fileOpen << "Id" << "\t" << "Value" << "\t" ; - fileOpen << "x(vox)" << "\t" << "y(vox)" << "\t"; - if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=3) - fileOpen << "z(vox)" << "\t"; - if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=4) - fileOpen << "t" << "\t"; - fileOpen << "x(mm)" << "\t" << "y(mm)" << "\t"; - if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=3) - fileOpen << "z(mm)" << "\t"; - if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() >=4) - fileOpen << "t" << "\t"; - fileOpen << endl; - - while (iGetNumberOfTuples()) { - fileOpen << i << "\t" << arrY->GetTuple(i)[0] << "\t" ; - - coords->GetTuple(i, tuple); - for (int j=0; jGetImage()->GetNumberOfDimensions() ; ++j) { - fileOpen << tuple[j] << "\t" ; - } - int j(0); - while (jGetImage()->GetNumberOfDimensions() && j<3) { - fileOpen << tuple[j]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[j]+mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[j] << "\t" ; - ++j; - } - if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) { - fileOpen << tuple[3] << "\t" ; - } - fileOpen << endl; - ++i; - } - - delete [] tuple; + + mFilter->WriteOutput(mTextFileName.c_str()); fileOpen.close(); QApplication::restoreOverrideCursor(); diff --git a/vv/vvToolProfile.h b/vv/vvToolProfile.h index 2f64bb3..0410637 100644 --- a/vv/vvToolProfile.h +++ b/vv/vvToolProfile.h @@ -19,7 +19,11 @@ #define VVTOOLPROFILE_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolROIManager.cxx b/vv/vvToolROIManager.cxx index 791db06..4c2832e 100644 --- a/vv/vvToolROIManager.cxx +++ b/vv/vvToolROIManager.cxx @@ -865,7 +865,11 @@ void vvToolROIManager::ReloadCurrentROI() //------------------------------------------------------------------------------ +#if __cplusplus > 199711L +void vvToolROIManager::SaveState(std::shared_ptr & m_XmlWriter) +#else void vvToolROIManager::SaveState(std::auto_ptr & m_XmlWriter) +#endif { // Get index of the image int n = mMainWindow->GetSlicerManagers().size(); diff --git a/vv/vvToolROIManager.h b/vv/vvToolROIManager.h index 9cb993a..db630c6 100644 --- a/vv/vvToolROIManager.h +++ b/vv/vvToolROIManager.h @@ -20,7 +20,11 @@ #define VVTOOLROIMANAGER_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include #include "vvToolBase.h" @@ -47,7 +51,11 @@ class vvToolROIManager: void AddImage(vvImage * binaryImage, std::string name, std::string filename, double BG, bool m_modeBG=true); void UpdateAllContours(); void UpdateAllROIStatus(); +#if __cplusplus > 199711L + virtual void SaveState(std::shared_ptr & m_XmlWriter); +#else virtual void SaveState(std::auto_ptr & m_XmlWriter); +#endif virtual void InitializeNewTool(bool ReadStateFlag); public slots: diff --git a/vv/vvToolResample.h b/vv/vvToolResample.h index ec56fda..2a4c427 100644 --- a/vv/vvToolResample.h +++ b/vv/vvToolResample.h @@ -31,7 +31,11 @@ #include "vvToolBase.h" // qt +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include //------------------------------------------------------------------------------ diff --git a/vv/vvToolRigidReg.cxx b/vv/vvToolRigidReg.cxx index e50ab7f..5a11c7f 100644 --- a/vv/vvToolRigidReg.cxx +++ b/vv/vvToolRigidReg.cxx @@ -413,7 +413,7 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix) double rad = (checkBoxDegrees->checkState()==Qt::Checked)?180./itk::Math::pi:1.; double angleDiff = euler->GetParameters()[i]-rotSBs[i]->value()/rad+2*itk::Math::pi; angleDiff = angleDiff - 2*itk::Math::pi*itk::Math::Round(angleDiff/(2*itk::Math::pi)); - if(abs(angleDiff)>1.e-4) { + if(std::abs(angleDiff)>1.e-4) { rotSBs[i]->blockSignals(true); rotSBs[i]->setValue( euler->GetParameters()[i]*rad ); rotSBs[i]->blockSignals(false); diff --git a/vv/vvToolSegmentation.h b/vv/vvToolSegmentation.h index 25bf6d0..7e49dc4 100644 --- a/vv/vvToolSegmentation.h +++ b/vv/vvToolSegmentation.h @@ -19,7 +19,11 @@ #define VVTOOLSEGMENTATION_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" diff --git a/vv/vvToolSimpleInputSelectorWidget.h b/vv/vvToolSimpleInputSelectorWidget.h index dfc83b1..4b8028f 100644 --- a/vv/vvToolSimpleInputSelectorWidget.h +++ b/vv/vvToolSimpleInputSelectorWidget.h @@ -19,7 +19,11 @@ #define VVTOOLSIMPLEINPUTSELECTORWIDGET_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include #include "ui_vvToolSimpleInputSelectorWidget.h" diff --git a/vv/vvToolStructureSetManager.h b/vv/vvToolStructureSetManager.h index 0f5ffec..5bc88c2 100644 --- a/vv/vvToolStructureSetManager.h +++ b/vv/vvToolStructureSetManager.h @@ -19,7 +19,11 @@ #ifndef VVTOOLSTRUCTURESETMANAGER_H #define VVTOOLSTRUCTURESETMANAGER_H +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "vvToolBase.h" #include "vvToolWidgetBase.h" #include "clitkDicomRT_StructureSet.h" diff --git a/vv/vvToolWidgetBase.h b/vv/vvToolWidgetBase.h index 8e5405a..7a3a5df 100644 --- a/vv/vvToolWidgetBase.h +++ b/vv/vvToolWidgetBase.h @@ -20,7 +20,11 @@ #define VVTOOLWIDGETBASE_H #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include "ui_vvToolWidgetBase.h" #include "clitkImageToImageGenericFilter.h"