]> Creatis software - clitk.git/commitdiff
Ensure compilation with VTK6/Qt5 and newer version of GDCM
authortbaudier <thomas.baudier@creatis.insa-lyon.fr>
Fri, 22 Jul 2016 12:58:01 +0000 (14:58 +0200)
committertbaudier <thomas.baudier@creatis.insa-lyon.fr>
Fri, 22 Jul 2016 12:58:01 +0000 (14:58 +0200)
286 files changed:
.vimrc [deleted file]
CMakeLists.txt
CTestConfig.cmake
Doxygen/CMakeLists.txt
cluster_tools/CMakeLists.txt [new file with mode: 0644]
cluster_tools/check_tmp_cluster.sh [new file with mode: 0755]
cluster_tools/gate_job_ccin2p3.job [new file with mode: 0644]
cluster_tools/gate_job_cluster.job
cluster_tools/gate_job_cluster_nomove.job [new file with mode: 0644]
cluster_tools/gate_make_merge_release.sh [new file with mode: 0755]
cluster_tools/gate_make_release.sh
cluster_tools/gate_merge_merges.sh [new file with mode: 0755]
cluster_tools/gate_power_merge.sh
cluster_tools/gate_run_submit_cluster.sh
cluster_tools/gate_run_submit_cluster_nomove.sh [new file with mode: 0644]
cluster_tools/mergeStatFile.py
cmake/FindGengetopt.cmake
cmake/FindROOT.cmake
cmake/build_opt.cmake
cmake/common.cmake
cmake/dependencies.cmake
common/CMakeLists.txt
common/clitkCommon.cxx
common/clitkCommon.h
common/clitkCommonGenericFilter.h
common/clitkDD.h
common/clitkDicomRTStruct2ImageFilter.cxx
common/clitkDicomRTStruct2ImageFilter.h
common/clitkDicomRT_ROI.cxx
common/clitkDicomRT_ROI.h
common/clitkDicomRT_StructureSet.cxx
common/clitkElastix.h
common/clitkFilterBase.h
common/clitkIO.cxx
common/clitkImage2DicomRTStructFilter.h
common/clitkImage2DicomRTStructFilter.txx
common/clitkImageCommon.cxx
common/clitkMatrix.cxx
common/clitkMatrix.h
common/clitkTimer.cxx
common/clitkXdrImageIOWriter.cxx
common/rtkEdfImageIO.cxx
common/rtkEdfImageIO.h
common/rtkHisImageIO.cxx
common/rtkHndImageIO.cxx
common/rtkImagXImageIO.cxx
common/rtkImagXImageIO.h
common/rtkImagXImageIOFactory.cxx
common/rtkImagXImageIOFactory.h
common/rtkImagXLookupTableImageFilter.h [deleted file]
common/rtkImagXRawToAttenuationImageFilter.h [deleted file]
common/rtkImagXRawToAttenuationImageFilter.txx [deleted file]
common/rtkImagXXMLFileReader.cxx
common/rtkXRadImageIO.cxx
common/vvFromITK.h
common/vvImage.cxx
common/vvImage.h
common/vvImage.txx
common/vvImageReader.cxx
common/vvImageReader.txx
itk/RelativePositionPropImageFilter.h
itk/clitkAddRelativePositionConstraintToLabelImageFilter.txx
itk/clitkBackProjectImageFilter.h
itk/clitkBackProjectImageFilter.txx
itk/clitkBinaryImageToMeshFilter.h
itk/clitkBinaryImageToMeshFilter.txx
itk/clitkComposeVFFilter.h
itk/clitkComposeVFFilter.txx
itk/clitkCropLikeImageFilter.h
itk/clitkExtractImageFilter.h
itk/clitkExtractImageFilter.txx
itk/clitkExtractSliceFilter.txx
itk/clitkInvertVFFilter.txx
itk/clitkMeshToBinaryImageFilter.txx
itk/clitkReconstructThroughDilationImageFilter.h
itk/clitkReconstructThroughDilationImageFilter.txx
itk/clitkResampleImageWithOptionsFilter.h
itk/clitkResampleImageWithOptionsFilter.txx
itk/clitkVectorBSplineDecompositionImageFilterWithOBD.txx
itk/itkFlexibleBinaryFunctorImageFilter.h
itk/itkFlexibleBinaryFunctorImageFilter.txx
itk/itkVTKImageToImageFilter.txx
make_new_tool.sh [changed mode: 0644->0755]
registration/CMakeLists.txt
registration/clitkAffineRegistrationGenericFilter.cxx
registration/clitkBLUTDIRGenericFilter.cxx
registration/clitkBLUTDIRGenericFilter.h
registration/clitkBSplineDeformableTransform.h
registration/clitkBSplineDeformableTransform.txx
registration/clitkConvertBLUTCoeffsToVFFilter.h
registration/clitkConvertBLUTCoeffsToVFFilter.txx
registration/clitkCorrelationRatioImageToImageMetric.txx
registration/clitkDeformationFieldTransform.h
registration/clitkDeformationFieldTransform.txx
registration/clitkDemonsDeformableRegistrationGenericFilter.txx
registration/clitkGenericMetric.h
registration/clitkGenericMetric.txx
registration/clitkLBFGSBOptimizer.h
registration/clitkMatrixTransformToVFGenericFilter.h
registration/clitkMatrixTransformToVFGenericFilter.txx
registration/clitkMultiResolutionPDEDeformableRegistration.txx
registration/clitkMultipleBSplineDeformableTransform.h
registration/clitkMultipleBSplineDeformableTransform.txx
registration/clitkNormalizedCorrelationImageToImageMetric.h
registration/clitkNormalizedCorrelationImageToImageMetric.txx
registration/clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h
registration/clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx
registration/clitkOptNormalizedCorrelationImageToImageMetric.h
registration/clitkOptNormalizedCorrelationImageToImageMetric.txx
registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h
registration/clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx
registration/clitkPointListTransform.h
registration/clitkPointListTransform.txx
registration/clitkShapedBLUTSpatioTemporalDeformableTransform.h
registration/clitkShapedBLUTSpatioTemporalDeformableTransform.txx
registration/itkMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h
registration/itkMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx
registration/itkMeanSquaresImageToImageMetricFor3DBLUTFFD.h
registration/itkMeanSquaresImageToImageMetricFor3DBLUTFFD.txx
registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h
registration/itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx
registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h
registration/itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx
segmentation/CMakeLists.txt
segmentation/clitkAnatomicalFeatureDatabase.cxx
segmentation/clitkExtractLungFilter.txx
segmentation/clitkFillMaskFilter.txx
segmentation/clitkMorphoMathFilter.h
segmentation/clitkMotionMaskGenericFilter.txx
segmentation/clitkRegionGrowingGenericFilter.txx
superbuild/CMakeLists.txt
tests/CMakeLists.txt
tests/tools/CMakeLists.txt
tools/CMakeLists.txt
tools/clitkAffineTransform.ggo
tools/clitkAffineTransformGenericFilter.txx
tools/clitkAnisotropicDiffusionGenericFilter.cxx
tools/clitkBlurImage.cxx [new file with mode: 0644]
tools/clitkBlurImage.ggo [new file with mode: 0644]
tools/clitkBlurImageGenericFilter.h [new file with mode: 0644]
tools/clitkBlurImageGenericFilter.txx [new file with mode: 0644]
tools/clitkCropImageGenericFilter.cxx
tools/clitkDicom2Image.cxx
tools/clitkDicomRTStruct2Image.cxx
tools/clitkDicomRTStruct2Image.ggo
tools/clitkElastixTransformToMatrix.cxx
tools/clitkFooImage.cxx
tools/clitkFooImage.ggo
tools/clitkFooImageGenericFilter.h
tools/clitkFooImageGenericFilter.txx
tools/clitkGammaIndex.cxx
tools/clitkImageConvert.cxx
tools/clitkImageConvert.ggo
tools/clitkImageConvertGenericFilter.cxx
tools/clitkImageConvertGenericFilter.h
tools/clitkImageGradientMagnitude.cxx [new file with mode: 0644]
tools/clitkImageGradientMagnitude.ggo [new file with mode: 0644]
tools/clitkImageGradientMagnitudeGenericFilter.h [new file with mode: 0644]
tools/clitkImageGradientMagnitudeGenericFilter.txx [new file with mode: 0644]
tools/clitkImageInfo.cxx
tools/clitkImageInfo.ggo
tools/clitkImageIntensityWindowing.cxx [new file with mode: 0644]
tools/clitkImageIntensityWindowing.ggo [new file with mode: 0644]
tools/clitkImageIntensityWindowingGenericFilter.h [new file with mode: 0644]
tools/clitkImageIntensityWindowingGenericFilter.txx [new file with mode: 0644]
tools/clitkImageLaplacian.cxx [new file with mode: 0644]
tools/clitkImageLaplacian.ggo [new file with mode: 0644]
tools/clitkImageLaplacianGenericFilter.h [new file with mode: 0644]
tools/clitkImageLaplacianGenericFilter.txx [new file with mode: 0644]
tools/clitkImageStatistics.ggo
tools/clitkImageStatisticsGenericFilter.cxx
tools/clitkImageStatisticsGenericFilter.txx
tools/clitkImageToVectorImageGenericFilter.txx
tools/clitkImageUncertainty.cxx [new file with mode: 0644]
tools/clitkImageUncertainty.ggo [new file with mode: 0644]
tools/clitkInvertVFGenericFilter.h
tools/clitkInvertVFGenericFilter.txx
tools/clitkJacobianImageGenericFilter.h
tools/clitkMatrixMultiply.cxx [new file with mode: 0644]
tools/clitkMatrixMultiply.ggo [new file with mode: 0644]
tools/clitkMedianImageGenericFilter.h
tools/clitkMedianImageGenericFilter.txx
tools/clitkMergeRootFiles.cxx
tools/clitkNormalizeImageFilter.cxx [new file with mode: 0644]
tools/clitkNormalizeImageFilter.ggo [new file with mode: 0644]
tools/clitkNormalizeImageFilterGenericFilter.h [new file with mode: 0644]
tools/clitkNormalizeImageFilterGenericFilter.txx [new file with mode: 0644]
tools/clitkPadImageGenericFilter.cxx
tools/clitkPadImageGenericFilter.h
tools/clitkPointRigidRegistration.cxx [new file with mode: 0644]
tools/clitkPointRigidRegistration.ggo [new file with mode: 0644]
tools/clitkProfileImage.cxx [new file with mode: 0644]
tools/clitkProfileImage.ggo [new file with mode: 0644]
tools/clitkProfileImageGenericFilter.cxx [new file with mode: 0644]
tools/clitkProfileImageGenericFilter.h [new file with mode: 0644]
tools/clitkResampleImage.cxx
tools/clitkResampleImageGenericFilter.txx
tools/clitkSplitImageGenericFilter.cxx
tools/clitkSum.cxx [new file with mode: 0644]
tools/clitkSum.ggo [new file with mode: 0644]
tools/clitkSumGenericFilter.h [new file with mode: 0644]
tools/clitkSumGenericFilter.txx [new file with mode: 0644]
tools/clitkVectorImageToImageFilter.h
tools/clitkVectorImageToImageFilter.txx
tools/clitkWarpImageGenericFilter.txx
tools/clitkWriteDicomSeries.ggo
tools/clitkWriteDicomSeriesGenericFilter.txx
utilities/CxImage/CMakeLists.txt
utilities/gengetopt/CMakeLists.txt
vv/CMakeLists.txt
vv/QTreePushButton.h
vv/icons/profile.png [new file with mode: 0644]
vv/qt_ui/vvLandmarksPanel.ui
vv/qt_ui/vvMainWindow.ui
vv/qt_ui/vvPacsConnection.ui
vv/qt_ui/vvToolProfile.ui [new file with mode: 0644]
vv/qt_ui/vvToolROIManager.ui
vv/qt_ui/vvToolTest.ui [new file with mode: 0644]
vv/qt_ui/vvToolWidgetBase.ui
vv/vtkVOXImageWriter.cxx
vv/vtkVOXImageWriter.h
vv/vv.cxx
vv/vvAnimatedGIFWriter.cxx
vv/vvBinaryImageOverlayActor.cxx
vv/vvDeformableRegistration.cxx
vv/vvGlyph2D.cxx
vv/vvGlyph2D.h
vv/vvGlyphSource.cxx
vv/vvGlyphSource.h
vv/vvIcons.qrc
vv/vvImageContour.cxx
vv/vvImageWarp.cxx
vv/vvIntensityValueSlider.h
vv/vvInteractorStyleNavigator.cxx
vv/vvInteractorStyleNavigator.h
vv/vvLabelImageLoaderWidget.h
vv/vvLandmarks.cxx
vv/vvLandmarks.h
vv/vvLandmarksGlyph.cxx
vv/vvLandmarksGlyph.h
vv/vvLandmarksPanel.cxx
vv/vvMainWindow.cxx
vv/vvMainWindow.h
vv/vvMesh.cxx
vv/vvMeshActor.cxx
vv/vvMeshReader.cxx
vv/vvMidPosition.cxx
vv/vvOSXHelper.h [new file with mode: 0644]
vv/vvOSXHelper.mm [new file with mode: 0644]
vv/vvOverlayPanel.cxx
vv/vvQDicomSeriesSelector.cxx
vv/vvQPacsConnection.cxx
vv/vvROIActor.cxx
vv/vvROIActor.h
vv/vvRegisterForm.cxx
vv/vvSegmentationDialog.cxx
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx
vv/vvSurfaceViewerDialog.cxx
vv/vvSurfaceViewerDialog.h
vv/vvToolBinarize.cxx
vv/vvToolBinarize.h
vv/vvToolCropImage.cxx
vv/vvToolCropImage.h
vv/vvToolImageArithm.h
vv/vvToolInputSelectorWidget.h
vv/vvToolMIP.h
vv/vvToolMedianFilter.h
vv/vvToolProfile.cxx [new file with mode: 0644]
vv/vvToolProfile.h [new file with mode: 0644]
vv/vvToolROIManager.cxx
vv/vvToolROIManager.h
vv/vvToolResample.cxx
vv/vvToolRigidReg.cxx
vv/vvToolRigidReg.h
vv/vvToolSegmentation.cxx
vv/vvToolSegmentation.h
vv/vvToolSimpleInputSelectorWidget.h
vv/vvToolTest.cxx [new file with mode: 0644]
vv/vvToolTest.h [new file with mode: 0644]
vv/vvToolWidgetBase.cxx
vv/vvToolWidgetBase.h
vv/vvUtils.h

diff --git a/.vimrc b/.vimrc
deleted file mode 100644 (file)
index 97cf20f..0000000
--- a/.vimrc
+++ /dev/null
@@ -1,10 +0,0 @@
-"clitk related standards
-"
-set cindent
-set softtabstop=0 "disable
-set expandtab
-"set cino={.5s,e-.5s,^-.5s
-set shiftwidth=2
-
-set makeprg=${HOME}/workspace/cvs/clitk3/fast_make.sh
-set grepprg=clgrep
index 20e162ee66cd0965463f8b694e2f26a12ca054ad..3bb8fc5b4f63d80204a78078dfe4914b1272f8ce 100644 (file)
@@ -1,32 +1,40 @@
 #=========================================================
 # CLITK = Command Line ITK
-PROJECT(clitk)
+project(clitk)
 cmake_minimum_required(VERSION 2.8)
 cmake_policy(VERSION 2.8)
 if(COMMAND cmake_policy)
     cmake_policy(SET CMP0003 NEW)
+    cmake_policy(SET CMP0007 NEW)
 endif(COMMAND cmake_policy)
-IF(NOT DEFINED CLITK_SOURCE_DIR)
-  SET(CLITK_SOURCE_DIR ${PROJECT_SOURCE_DIR})
-ENDIF(NOT DEFINED CLITK_SOURCE_DIR)
+if(NOT DEFINED CLITK_SOURCE_DIR)
+  set(CLITK_SOURCE_DIR ${PROJECT_SOURCE_DIR})
+endif(NOT DEFINED CLITK_SOURCE_DIR)
+# Default build type
+IF(NOT CMAKE_BUILD_TYPE)
+  SET(CMAKE_BUILD_TYPE Release CACHE STRING
+    "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
+    FORCE)
+ENDIF(NOT CMAKE_BUILD_TYPE)
 #=========================================================
 
-SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 
-IF(MSVC)
-  SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" )
-  SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj" )
-ENDIF(MSVC)
+if(MSVC)
+  set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj" )
+  set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /bigobj" )
+endif(MSVC)
 
 #=========================================================
-INCLUDE(${CLITK_SOURCE_DIR}/cmake/common.cmake)
-INCLUDE(${CLITK_SOURCE_DIR}/cmake/dependencies.cmake)
-INCLUDE(${CLITK_SOURCE_DIR}/cmake/build_opt.cmake)
+include(${CLITK_SOURCE_DIR}/cmake/common.cmake)
+include(${CLITK_SOURCE_DIR}/cmake/dependencies.cmake)
+include(${CLITK_SOURCE_DIR}/cmake/build_opt.cmake)
 #=========================================================
 #=========================================================
 SET(vvPacsConnection true)
 # Select what is compiled
-ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/common ${PROJECT_BINARY_DIR}/common)
-ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/tools ${PROJECT_BINARY_DIR}/tools)
-ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/segmentation ${PROJECT_BINARY_DIR}/segmentation)
-ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/registration ${PROJECT_BINARY_DIR}/registration)
+add_subdirectory(${CLITK_SOURCE_DIR}/common ${PROJECT_BINARY_DIR}/common)
+add_subdirectory(${CLITK_SOURCE_DIR}/tools ${PROJECT_BINARY_DIR}/tools)
+add_subdirectory(${CLITK_SOURCE_DIR}/segmentation ${PROJECT_BINARY_DIR}/segmentation)
+add_subdirectory(${CLITK_SOURCE_DIR}/registration ${PROJECT_BINARY_DIR}/registration)
+add_subdirectory(${CLITK_SOURCE_DIR}/cluster_tools ${PROJECT_BINARY_DIR}/cluster_tools)
index 15bbadd615cfa17269b85c13408d813e1e3237dc..3a20d28372ab8aae7b947179f545767d77a20839 100644 (file)
@@ -1,8 +1,8 @@
-MACRO(SET_IF_NOT_SET var val)
-  IF(NOT DEFINED "${var}")
-    SET("${var}" "${val}")
-  ENDIF(NOT DEFINED "${var}")
-ENDMACRO(SET_IF_NOT_SET)
+macro(SET_IF_NOT_SET var val)
+  if(NOT DEFINED "${var}")
+    set("${var}" "${val}")
+  endif(NOT DEFINED "${var}")
+endmacro(SET_IF_NOT_SET)
 
 # Those are set for running a classical make Experimental
 SET_IF_NOT_SET(CTEST_DROP_METHOD "http")
index 6c57945a532dd7ff80d34dfb756f3cfb64669a63..1e48ba8d2fe5c2dde15e48a581e242c9db1081db 100644 (file)
@@ -1,24 +1,24 @@
 #
 # Build the documentation
 #
-INCLUDE (${CMAKE_ROOT}/Modules/Documentation.cmake)
+include(${CMAKE_ROOT}/Modules/Documentation.cmake)
 
-IF (BUILD_DOXYGEN)
+if(BUILD_DOXYGEN)
 
   #
   # Configure the script and the doxyfile, then add target
   #
-  CONFIGURE_FILE(${CLITK_SOURCE_DIR}/Doxygen/doxygen.config.in
+  configure_file(${CLITK_SOURCE_DIR}/Doxygen/doxygen.config.in
                  ${PROJECT_BINARY_DIR}/Doxygen/doxygen.config)
 
-               CONFIGURE_FILE(${CLITK_SOURCE_DIR}/Doxygen/itkdoxygen.pl.in
+               configure_file(${CLITK_SOURCE_DIR}/Doxygen/itkdoxygen.pl.in
                  ${PROJECT_BINARY_DIR}/Doxygen/itkdoxygen.pl)
 
-  ADD_CUSTOM_TARGET(Documentation 
+  add_custom_target(Documentation
     COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxygen/doxygen.config
     MAIN_DEPENDENCY ${PROJECT_BINARY_DIR}/Doxygen/doxygen.config
     DEPENDS         ${PROJECT_BINARY_DIR}/Doxygen/itkdoxygen.pl
     WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/Doxygen
     )
 
-ENDIF (BUILD_DOXYGEN)
+endif(BUILD_DOXYGEN)
diff --git a/cluster_tools/CMakeLists.txt b/cluster_tools/CMakeLists.txt
new file mode 100644 (file)
index 0000000..76a4286
--- /dev/null
@@ -0,0 +1,21 @@
+if(CLITK_BUILD_TOOLS)
+  #=========================================================
+  # Install scripts when running make install
+  set(SCRIPTS
+    gate_job_cluster.job
+    gate_make_merge_release.sh
+    gate_make_release.sh
+    gate_power_merge.sh
+    gate_run_submit_cluster.sh
+    gate_upload_release.sh
+    mergeDosePerEnergyFile.sh
+    mergeStatFile.py
+    mergeStatFile.sh
+    gate_run_submit_cluster_nomove.sh
+    gate_job_cluster_nomove.job
+    check_tmp_cluster.sh
+    )
+
+  install(FILES ${SCRIPTS} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
+
+endif(CLITK_BUILD_TOOLS)
diff --git a/cluster_tools/check_tmp_cluster.sh b/cluster_tools/check_tmp_cluster.sh
new file mode 100755 (executable)
index 0000000..64f0007
--- /dev/null
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+for i in 1 $(seq 4 20) $(seq 30 36)
+do
+    echo
+    echo "Files on host linux${i}.dg.creatis.insa-lyon.fr "
+    #ssh -o "StrictHostKeyChecking no" linux${i}.dg.creatis.insa-lyon.fr "find /tmp -user $1 -exec rm -fr {} \; "
+    ssh -o "StrictHostKeyChecking no" linux${i}.dg.creatis.insa-lyon.fr "find /tmp -user $1 2>/dev/null"
+#ssh -o "StrictHostKeyChecking no" linux${i}.dg.creatis.insa-lyon.fr "rm -fr /tmp/tmp.*/core* /tmp/tmp.*/mac /tmp/tmp.*/data /tmp/tmp.*/output/*root"
+#ssh -o "StrictHostKeyChecking no" linux${i}.dg.creatis.insa-lyon.fr "mv /tmp/tmp.* data/gate/hybrid_analog_mc/liver/hybrid_emlivermore/rr/rayleigh/run.O6VN"
+done
+
diff --git a/cluster_tools/gate_job_ccin2p3.job b/cluster_tools/gate_job_ccin2p3.job
new file mode 100644 (file)
index 0000000..e443780
--- /dev/null
@@ -0,0 +1,104 @@
+#! /usr/local/bin/bash -lx
+#
+# MACRODIR
+# MACROFILE
+# RELEASEDIR
+# OUTPUTDIR
+# INDEX
+# INDEXMAX
+# PARAM
+#
+#$ -P "P_creatis"
+#$ -l vmem=2G
+#$ -l fsize=1G
+#$ -l ct=30:00:00
+#$ -j yes
+#$ -r no
+
+
+function error {
+echo "ERROR: $1"
+exit 1
+}
+
+function warning {
+echo "WARNING: $1"
+}
+
+test -f ${HOME}/.bashrc && echo "Sourcing bashrc" && source ${HOME}/.bashrc
+set -u
+
+echo "Checking"
+uname -a
+echo "MACRODIR=${MACRODIR:?"unknown MACRODIR"}"
+echo "MACROFILE=${MACROFILE:?"unknown MACROFILE"}"
+echo "RELEASEDIR=${RELEASEDIR:?"unknown RELEASEDIR"}"
+echo "OUTPUTDIR=${OUTPUTDIR:?"unknown OUTPUTDIR"}"
+echo "JOB_ID=${JOB_ID}"
+echo "INDEX=${INDEX}"
+echo "INDEXMAX=${INDEX}"
+echo "PARAM=${PARAM}"
+
+if test "$RELEASEDIR" = "NONE"
+then
+       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
+
+       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
+cd ${LOCALMACRODIR}
+cp -r -L "${MACRODIR}"/{data,mac} .
+mkdir output
+
+# Enforce one thread
+ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
+
+echo "Lauching macro"
+date
+if test "$RELEASEDIR" = "NONE"
+then
+       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"
+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}
+date
+
+echo "Success!!!"
index 1242dfd06fd9ecb32e4fd9c20345f225b8d35354..9401268acb080c8e348d88d288feabf78ab30930 100644 (file)
 #PBS -r n
 #PBS -l walltime=100:00:00
 #PBS -j oe
-
-#env
-#pwd
-#exit 1
+#PBS -l mem=3Gb
 
 
 function error {
@@ -77,7 +74,8 @@ echo "Lauching macro"
 date
 if test "$RELEASEDIR" = "NONE"
 then
-       Gate ${PARAM} ${MACROFILE} || error "gate failed"
+        echo Gate ${PARAM} ${MACROFILE}
+       eval Gate ${PARAM} ${MACROFILE} || error "gate failed"
 else
        LD_PRELOAD="${ROOTLIBS}${G4LIBS}${CLHEPLIBS}${GATELIBS}" \
        G4LEVELGAMMADATA="${RELEASEDIR}/PhotonEvaporation2.1" \
diff --git a/cluster_tools/gate_job_cluster_nomove.job b/cluster_tools/gate_job_cluster_nomove.job
new file mode 100644 (file)
index 0000000..80d5b3d
--- /dev/null
@@ -0,0 +1,102 @@
+#!/bin/bash
+#
+# MACRODIR
+# MACROFILE
+# RELEASEDIR
+# OUTPUTDIR
+# INDEX
+# INDEXMAX
+# PARAM
+#
+#PBS -r n
+#PBS -l walltime=5:00:00
+#PBS -j oe
+#PBS -l mem=5Gb
+
+
+function error {
+echo "ERROR: $1"
+exit 1
+}
+
+function warning {
+echo "WARNING: $1"
+}
+
+test -f ${HOME}/.bashrc && echo "Sourcing bashrc" && source ${HOME}/.bashrc
+set -u
+
+echo "Checking"
+uname -a
+echo "MACRODIR=${MACRODIR:?"unknown MACRODIR"}"
+echo "MACROFILE=${MACROFILE:?"unknown MACROFILE"}"
+echo "RELEASEDIR=${RELEASEDIR:?"unknown RELEASEDIR"}"
+echo "OUTPUTDIR=${OUTPUTDIR:?"unknown OUTPUTDIR"}"
+echo "PBS_JOBID=${PBS_JOBID}"
+echo "INDEX=${INDEX}"
+echo "INDEXMAX=${INDEX}"
+echo "PARAM=${PARAM}"
+
+if test "$RELEASEDIR" = "NONE"
+then
+       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
+
+       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/linking inputs"
+LOCALMACRODIR=$(mktemp -d)
+trap "mv output ${OUTPUTDIR}/output.${PBS_JOBID%%.*} ; rm -rf ${LOCALMACRODIR} ; exit 1" 1 2 3 15
+cd ${LOCALMACRODIR}
+## below line seems not to be trapped correctly
+cp -r -L "${MACRODIR}"/mac .
+ln -s "${MACRODIR}"/data ./data
+mkdir output
+
+# Enforce one thread
+ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS=1
+
+echo "Lauching macro"
+date
+if test "$RELEASEDIR" = "NONE"
+then
+       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"
+fi
+
+echo "Copying data back"
+mv output "${OUTPUTDIR}/output.${PBS_JOBID%%.*}"
+
+echo "Cleanup"
+unlink "${LOCALMACRODIR}"/data
+rm -rf "${LOCALMACRODIR}"
+
+echo "Success!!!"
diff --git a/cluster_tools/gate_make_merge_release.sh b/cluster_tools/gate_make_merge_release.sh
new file mode 100755 (executable)
index 0000000..e506728
--- /dev/null
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+set -u
+set -e
+
+function error {
+echo "ERROR: $1"
+echo "$(basename $0)"
+exit 1
+}
+
+function get_deps {
+targetbinary=${1}
+targetdir=${2}
+test -d ${targetdir} || error "${targetdir} isn't a directory"
+ldd ${targetbinary} | while read library; do
+       libfile="$(echo ${library} | awk -F' ' '/=> \// {print $3}')"
+       test $libfile || continue # didn't macht regex
+       test -f "${targetdir}/$(basename ${libfile})" && continue # already exists
+       cp "${libfile}" "${targetdir}"
+       get_deps "${libfile}" "${targetdir}"
+done
+}
+
+function package_target {
+targetname="${1}"
+which "${targetname}" > /dev/null || error "cant locate ${targetname}"
+targetbin="$(which ${targetname})"
+echo "${targetname} executable is ${targetbin}"
+
+echo "Getting libraries"
+targetdir="$(mktemp -d)"
+get_deps "${targetbin}" "${targetdir}"
+
+echo "Removing unused libraries"
+rm -f ${targetdir}/libdl.so*
+rm -f ${targetdir}/libm.so*
+rm -f ${targetdir}/libstdc++.so*
+rm -f ${targetdir}/libgcc_s.so*
+rm -f ${targetdir}/libpthread.so*
+rm -f ${targetdir}/libc.so*
+
+echo "Copying binary"
+cp "${targetbin}" .
+for filename in $(find ${targetdir} -name '*.so*'); do cp ${filename} . ; done
+
+echo "Cleaning up"
+rm -r "${targetdir}"
+}
+
+filenames=("clitkImageArithm" "clitkMergeRootFiles" "clitkMergeAsciiDoseActor" "clitkImageUncertainty" "mergeStatFile.sh" "gate_power_merge.sh")
+
+for input in "${filenames[@]}"; do
+       package_target "${input}" || error "error while packaging ${input}"
+done
+
+echo "Making release"
+tar -czvf merge_release.tar.gz ** \
+        || usage "can't create release zip"
+
+
+
index 363d583a435b118d214a354b3cf1f30c90ce24d2..ee2e0389576667197d2652a40c26756c4fc056d3 100755 (executable)
@@ -29,12 +29,12 @@ test -d "${G4PIIDATA}" || usage "can't locate pii data. please set G4PIIDATA"
 echo "pii data is ${G4PIIDATA}"
 
 echo "Cleaning previous build"
-rm -fr $(basename ${G4NEUTRONHPDATA})
-rm -fr $(basename ${G4LEVELGAMMADATA})
-rm -fr $(basename ${G4RADIOACTIVEDATA})
-rm -fr $(basename ${G4ABLADATA})
-rm -fr $(basename ${G4LEDATA})
-rm -fr $(basename ${G4REALSURFACEDATA})
+rm -fr $(basename ${G4NEUTRONHPDATA})
+rm -fr $(basename ${G4LEVELGAMMADATA})
+rm -fr $(basename ${G4RADIOACTIVEDATA})
+rm -fr $(basename ${G4ABLADATA})
+rm -fr $(basename ${G4LEDATA})
+rm -fr $(basename ${G4REALSURFACEDATA})
 rm -fr test_libs gate_shared_libs.tar.gz gate_release.tar.gz
 
 echo "Copying libraries"
@@ -93,5 +93,3 @@ tar -czvf gate_release.tar.gz \
     || usage "can't create release zip"
 
 chmod -w gate_release.tar.gz
-
-
diff --git a/cluster_tools/gate_merge_merges.sh b/cluster_tools/gate_merge_merges.sh
new file mode 100755 (executable)
index 0000000..72fcbcc
--- /dev/null
@@ -0,0 +1,7 @@
+mkdir run.merge
+for i in $(ls -d results.????)
+do
+       ln -s ../$i run.merge/output_${i}
+done
+gate_power_merge.sh run.merge
index fc0e6aa3233fe032bf9713b1038e27315f4c9e67..aaf063b18d4f8cc85be856ef0f19df1087c1570d 100755 (executable)
@@ -1,41 +1,41 @@
 #!/usr/bin/env bash
 
-set -u 
+set -u
 
 function error {
-echo "ERROR: $1"
-exit 1
+    echo "ERROR: $1"
+    exit 1
 }
 
 warning_count=0
 function warning {
-let "warning_count++"
-echo "MERGE_WARNING: $1"
+    let "warning_count++"
+    echo "MERGE_WARNING: $1"
 }
 
 function start_bar {
-count_max="${1:?"provide count max"}"
+    count_max="${1:?"provide count max"}"
 }
 
 function update_bar {
-local count="${1:?"provide count"}"
-local message="${2:?"provide message"}"
-local percent=$(echo "100*${count}/${count_max}" | bc)
-#printf "[%03d/%03d] %3d%% %-80.80s\r" ${count} ${count_max} ${percent} "${message}"
-printf "[%03d/%03d] %3d%% %-80.80s\n" ${count} ${count_max} ${percent} "${message}"
+    local count="${1:?"provide count"}"
+    local message="${2:?"provide message"}"
+    local percent=$(echo "100*${count}/${count_max}" | bc)
+    #printf "[%03d/%03d] %3d%% %-80.80s\r" ${count} ${count_max} ${percent} "${message}"
+    printf "[%03d/%03d] %3d%% %-80.80s\n" ${count} ${count_max} ${percent} "${message}"
 }
 
 function end_bar {
-unset count_max
-#echo -ne '\n'
+    unset count_max
+    #echo -ne '\n'
 }
 
 function check_interfile {
-local input_interfile="${1:?"provide input interfile"}"
+    local input_interfile="${1:?"provide input interfile"}"
 
-grep -qs '!INTERFILE :=' "${input_interfile}" || return 1
+    grep -qs '!INTERFILE :=' "${input_interfile}" || return 1
 
-local header_byte_size=$(awk -F' ' '
+    local header_byte_size=$(awk -F' ' '
 BEGIN { zsize = 0; }
 /matrix size/ && $3 == "[1]" { xsize = $5; }
 /matrix size/ && $3 == "[2]" { ysize = $5; }
@@ -43,19 +43,19 @@ BEGIN { zsize = 0; }
 /number of bytes per pixel/ { byte_per_pixel = $7; }
 END { print xsize * ysize * zsize * byte_per_pixel; }' "${input_interfile}")
 
-local raw_interfile="$(dirname "${input_interfile}")/$(awk -F' := ' '/name of data file/ { print $2; }' "${input_interfile}")"
+    local raw_interfile="$(dirname "${input_interfile}")/$(awk -F' := ' '/name of data file/ { print $2; }' "${input_interfile}")"
 
-test -f "${raw_interfile}" || return 1
-test $(stat -c%s "${raw_interfile}") -eq ${header_byte_size} || return 1
+    test -f "${raw_interfile}" || return 1
+    test $(stat -c%s "${raw_interfile}") -eq ${header_byte_size} || return 1
 }
 
 function write_mhd_header {
-local input_interfile="${1:?"provide input interfile"}"
-local output_mhd="$(dirname "${input_interfile}")/$(basename "${input_interfile}" ".hdr").mhd"
+    local input_interfile="${1:?"provide input interfile"}"
+    local output_mhd="$(dirname "${input_interfile}")/$(basename "${input_interfile}" ".hdr").mhd"
 
-check_interfile "${input_interfile}" || error "${input_interfile} isn't an interfile image"
+    check_interfile "${input_interfile}" || error "${input_interfile} isn't an interfile image"
 
-local header_start='ObjectType = Image
+    local header_start='ObjectType = Image
 NDims = 3
 AcquisitionDate = none
 BinaryData = True
@@ -67,21 +67,21 @@ CenterOfRotation = 0 0 0
 DistanceUnits = mm
 AnatomicalOrientation = RIP'
 
-echo "${header_start}" > "${output_mhd}"
+    echo "${header_start}" > "${output_mhd}"
 
-awk -F' ' '
+    awk -F' ' '
 /scaling factor/ && $4 == "[1]" { xspacing = $6; }
 /scaling factor/ && $4 == "[2]" { yspacing = $6; }
 END { print "ElementSpacing = " xspacing " " yspacing " 1"; }' "${input_interfile}" >> "${output_mhd}"
 
-awk -F' ' '
+    awk -F' ' '
 BEGIN { zsize = 0; }
 /matrix size/ && $3 == "[1]" { xsize = $5; }
 /matrix size/ && $3 == "[2]" { ysize = $5; }
 /number of projections/ { zsize += $5; }
 END { print "DimSize = " xsize " " ysize " " zsize; }' "${input_interfile}" >> "${output_mhd}"
 
-awk -F' := ' '
+    awk -F' := ' '
 /number format/ { format = $2; }
 /number of bytes per pixel/ { byte_per_pixel = $2 }
 END {
@@ -98,7 +98,7 @@ if (format == "float" && byte_per_pixel == 4) { print "ElementType = MET_DOUBLE"
 print "ElementType = MET_INT";
 }' "${input_interfile}" >> "${output_mhd}"
 
-awk -F' := ' '
+    awk -F' := ' '
 /name of data file/ { print "ElementDataFile = " $2; }' "${input_interfile}" >> "${output_mhd}"
 }
 
@@ -106,200 +106,207 @@ rootMerger="clitkMergeRootFiles"
 test -x "./clitkMergeRootFiles" && rootMerger="./clitkMergeRootFiles"
 
 function merge_root {
-local merged="$1"
-shift
-echo "  ${indent}entering root merger"
-echo "  ${indent}merger is ${rootMerger}"
-echo "  ${indent}creating ${merged}"
-#echo "######## $#"
-#echo "######## $*"
-
-if test $# -eq 1
-then
-    echo "  ${indent}just one partial file => just copy it"
-    cp "$1" "${merged}"
-    return
-fi
-
-local count=0
-local arguments=" -o ${merged}"
-while test $# -gt 0
-do
-    local partial="$1"
+    local merged="$1"
     shift
-    let count++
-    local arguments=" -i ${partial} ${arguments}"
-done
-${rootMerger} ${arguments} > /dev/null || error "error while calling ${rootMerger}"
-echo "  ${indent}merged ${count} files"
+    echo "  ${indent}entering root merger"
+    echo "  ${indent}merger is ${rootMerger}"
+    echo "  ${indent}creating ${merged}"
+    #echo "######## $#"
+    #echo "######## $*"
+
+    if test $# -eq 1
+    then
+        echo "  ${indent}just one partial file => just copy it"
+        cp "$1" "${merged}"
+        return
+    fi
+
+    local count=0
+    local arguments=" -o ${merged}"
+    while test $# -gt 0
+    do
+        local partial="$1"
+        shift
+        let count++
+        local arguments=" -i ${partial} ${arguments}"
+    done
+    ${rootMerger} ${arguments} > /dev/null || error "error while calling ${rootMerger}"
+    echo "  ${indent}merged ${count} files"
 }
 
 statMerger="mergeStatFile.py"
 test -x "./mergeStatFile.sh" && statMerger="./mergeStatFile.sh"
 
 function merge_stat {
-local merged="$1"
-shift
-echo "  ${indent}entering stat merger"
-echo "  ${indent}merger is ${statMerger}"
-echo "  ${indent}creating ${merged}"
-local count=0
-start_bar $#
-while test $# -gt 0
-do
-    local partial="$1"
+    local merged="$1"
     shift
-    let count++
-
-    if test ! -f "${merged}"
-    then
-        update_bar ${count} "copying first partial result ${partial}"
-        cp "${partial}" "${merged}"
-        continue
-    fi
+    echo "  ${indent}entering stat merger"
+    echo "  ${indent}merger is ${statMerger}"
+    echo "  ${indent}creating ${merged}"
+    local count=0
+    start_bar $#
+    while test $# -gt 0
+    do
+        local partial="$1"
+        shift
+        let count++
+
+        if test ! -f "${merged}"
+        then
+            update_bar ${count} "copying first partial result ${partial}"
+            cp "${partial}" "${merged}"
+            continue
+        fi
 
-    update_bar ${count} "adding ${partial}"
-    ${statMerger} -i "${merged}" -j "${partial}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${statMerger}"
-done
-end_bar
-echo "  ${indent}merged ${count} files"
+        update_bar ${count} "adding ${partial}"
+        ${statMerger} -i "${merged}" -j "${partial}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${statMerger}"
+    done
+    end_bar
+    echo "  ${indent}merged ${count} files"
 }
 
 doseMerger="mergeDosePerEnegryFile.sh"
 test -x "./mergeDosePerEnergyFile.sh" && doseMerger="./mergeDosePerEnergyFile.sh"
 
 function merge_dose {
-local merged="$1"
-shift
-echo "  ${indent}entering dose merger"
-echo "  ${indent}merger is ${doseMerger}"
-echo "  ${indent}creating ${merged}"
-local count=0
-start_bar $#
-while test $# -gt 0
-do
-    local partial="$1"
+    local merged="$1"
     shift
-    let count++
-
-    if test ! -f "${merged}"
-    then
-        update_bar ${count} "copying first partial result ${partial}"
-        cp "${partial}" "${merged}"
-        continue
-    fi
+    echo "  ${indent}entering dose merger"
+    echo "  ${indent}merger is ${doseMerger}"
+    echo "  ${indent}creating ${merged}"
+    local count=0
+    start_bar $#
+    while test $# -gt 0
+    do
+        local partial="$1"
+        shift
+        let count++
+
+        if test ! -f "${merged}"
+        then
+            update_bar ${count} "copying first partial result ${partial}"
+            cp "${partial}" "${merged}"
+            continue
+        fi
 
-    update_bar ${count} "adding ${partial}"
-    ${doseMerger} -i "${merged}" -j "${partial}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${doseMerger}"
-done
-end_bar
-echo "  ${indent}merged ${count} files"
+        update_bar ${count} "adding ${partial}"
+        ${doseMerger} -i "${merged}" -j "${partial}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${doseMerger}"
+    done
+    end_bar
+    echo "  ${indent}merged ${count} files"
 }
 
 txtImageMerger="clitkMergeAsciiDoseActor"
 test -f "./clitkMergeAsciiDoseActor" && txtImageMerger="./clitkMergeAsciiDoseActor"
 
 function merge_txt_image {
-local merged="$1"
-shift
-echo "  ${indent}entering text image merger"
-echo "  ${indent}merger is ${txtImageMerger}"
-echo "  ${indent}creating ${merged}"
-local count=0
-start_bar $#
-while test $# -gt 0
-do
-    local partial="$1"
+    local merged="$1"
     shift
-    let count++
-
-    if test ! -f "${merged}"
-    then
-        update_bar ${count} "copying first partial result ${partial}"
-        cp "${partial}" "${merged}"
-        continue
-    fi
+    echo "  ${indent}entering text image merger"
+    echo "  ${indent}merger is ${txtImageMerger}"
+    echo "  ${indent}creating ${merged}"
+    local count=0
+    start_bar $#
+    while test $# -gt 0
+    do
+        local partial="$1"
+        shift
+        let count++
+
+        if test ! -f "${merged}"
+        then
+            update_bar ${count} "copying first partial result ${partial}"
+            cp "${partial}" "${merged}"
+            continue
+        fi
 
-    update_bar ${count} "adding ${partial}"
-    local header="$(cat "${merged}" | head -n 6)"
-    local tmp="$(mktemp)"
-    ${txtImageMerger} -i "${partial}" -j "${merged}" -o "${tmp}" 2> /dev/null > /dev/null || warning "error while calling ${txtImageMerger}"
-    echo "${header}" > "${merged}"
-    grep -v '## Merge' "${tmp}" >> "${merged}"
-    rm "${tmp}"
-done
-end_bar
-echo "  ${indent}merged ${count} files"
+        update_bar ${count} "adding ${partial}"
+        local header="$(cat "${merged}" | head -n 6)"
+        local tmp="$(mktemp)"
+        ${txtImageMerger} -i "${partial}" -j "${merged}" -o "${tmp}" 2> /dev/null > /dev/null || warning "error while calling ${txtImageMerger}"
+        echo "${header}" > "${merged}"
+        grep -v '## Merge' "${tmp}" >> "${merged}"
+        rm "${tmp}"
+    done
+    end_bar
+    echo "  ${indent}merged ${count} files"
 }
 
 hdrImageMerger="clitkImageArithm"
 test -x "./clitkImageArithm" && hdrImageMerger="./clitkImageArithm"
 
 function merge_hdr_image {
-local merged="$1"
-local merged_bin="${merged%.*}.img"
-shift
-echo "  ${indent}entering hdr image merger"
-echo "  ${indent}merger is ${hdrImageMerger}"
-echo "  ${indent}creating ${merged}"
-local count=0
-start_bar $#
-while test $# -gt 0
-do
-    local partial="$1"
-    local partial_bin="${partial%.*}.img"
+    local merged="$1"
+    local merged_bin="${merged%.*}.img"
     shift
-    let count++
-
-    if test ! -f "${merged}"
-    then
-        update_bar ${count} "copying first partial result ${partial}"
-        cp "${partial}" "${merged}"
-        cp "${partial_bin}" "${merged_bin}"
-        continue
-    fi
+    echo "  ${indent}entering hdr image merger"
+    echo "  ${indent}merger is ${hdrImageMerger}"
+    echo "  ${indent}creating ${merged}"
+    local count=0
+    start_bar $#
+    while test $# -gt 0
+    do
+        local partial="$1"
+        local partial_bin="${partial%.*}.img"
+        shift
+        let count++
+
+        if test ! -f "${merged}"
+        then
+            update_bar ${count} "copying first partial result ${partial}"
+            cp "${partial}" "${merged}"
+            cp "${partial_bin}" "${merged_bin}"
+            continue
+        fi
 
-    update_bar ${count} "adding ${partial}"
-    ${hdrImageMerger} -t 0 -i "${partial}" -j "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${hdrImageMerger}"
-done
-end_bar
-echo "  ${indent}merged ${count} files"
+        update_bar ${count} "adding ${partial}"
+        ${hdrImageMerger} -t 0 -i "${partial}" -j "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${hdrImageMerger}"
+    done
+    end_bar
+    echo "  ${indent}merged ${count} files"
 }
 
 mhdImageMerger="clitkImageArithm"
 test -x "./clitkImageArithm" && mhdImageMerger="./clitkImageArithm"
 
 function merge_mhd_image {
-local merged="$1"
-local merged_bin="${merged%.*}.raw"
-shift
-echo "  ${indent}entering mhd image merger"
-echo "  ${indent}merger is ${mhdImageMerger}"
-echo "  ${indent}creating ${merged}"
-local count=0
-start_bar $#
-while test $# -gt 0
-do
-    local partial="$1"
-    local partial_bin="$(dirname "${partial}")/$(awk -F' = ' '/ElementDataFile/ { print $2; }' "${partial}")"
+    local merged="$1"
+    local merged_bin="${merged%.*}.raw"
+    local last_character=${merged#${merged%?}}
     shift
-    let count++
-
-    if test ! -f "${merged}"
-    then
-        update_bar ${count} "copying first partial result ${partial}"
-        cp "${partial}" "${merged}"
-        cp "${partial_bin}" "${merged_bin%.*}.${partial_bin##*.}"
-        continue
-    fi
+    echo "  ${indent}entering mhd image merger"
+    echo "  ${indent}merger is ${mhdImageMerger}"
+    echo "  ${indent}creating ${merged}"
+    local count=0
+    start_bar $#
+    while test $# -gt 0
+    do
+        local partial="$1"
+        local partial_bin="$(dirname "${partial}")/$(awk -F' = ' '/ElementDataFile/ { print $2; }' "${partial}")"
+        shift
+        let count++
+
+        if test ! -f "${merged}"
+        then
+            update_bar ${count} "copying first partial result ${partial}"
+            cp "${partial}" "${merged}"
+            if test "$last_character" = "d"
+            then
+                cp "${partial_bin}" "${merged_bin%.*}.${partial_bin##*.}"
+            fi
+            continue
+        fi
 
-    update_bar ${count} "adding ${partial}"
-    ${mhdImageMerger} -t 0 -i "${partial}" -j "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${mhdImageMerger}"
-    mv "${merged_bin}" "${merged_bin%.*}.${partial_bin##*.}"
-    sed -i "s/$(basename "${merged_bin}")/$(basename "${merged_bin%.*}.${partial_bin##*.}")/" "${merged}"
-done
-end_bar
-echo "  ${indent}merged ${count} files"
+        update_bar ${count} "adding ${partial}"
+        ${mhdImageMerger} -t 0 -i "${partial}" -j "${merged}" -o "${merged}" 2> /dev/null > /dev/null || warning "error while calling ${mhdImageMerger}"
+        if test "$last_character" = "d" && test "${merged_bin}" != "${merged_bin%.*}.${partial_bin##*.}"
+        then
+            mv "${merged_bin}" "${merged_bin%.*}.${partial_bin##*.}"
+            sed -i "s/$(basename "${merged_bin}")/$(basename "${merged_bin%.*}.${partial_bin##*.}")/" "${merged}"
+        fi
+    done
+    end_bar
+    echo "  ${indent}merged ${count} files"
 }
 
 function merge_dispatcher {
@@ -307,12 +314,15 @@ function merge_dispatcher {
     local outputfile="${1:?"provide output filename"}"
     echo "merging ${outputfile}"
 
-    local partialoutputfiles="$(find "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
+    local partialoutputfiles="$(find -L "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
     local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)"
     if test ${nboutputdirs} -ne ${nboutputfiles}
     then
         warning "missing files"
-        return
+        if ! test "${2}" == "--force"
+        then
+            return
+        fi
     fi
 
     local firstpartialoutputfile="$(echo "${partialoutputfiles}" | head -n 1)"
@@ -343,7 +353,7 @@ function merge_dispatcher {
         return
     fi
 
-    if test "${firstpartialoutputextension}" == "mhd"
+    if test "${firstpartialoutputextension}" == "mhd" || test "${firstpartialoutputextension}" == "mha"
     then
         echo "${indent}this is a mhd image"
         local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")"
@@ -420,11 +430,82 @@ function merge_dispatcher {
     error "unknown file type"
 }
 
+function merge_dispatcher_uncertainty {
+    local indent="  ** "
+    local outputfile="${1:?"provide output filename"}"
+
+    local partialoutputfiles="$(find -L "${rundir}" -mindepth 2 -type f -name "${outputfile}")"
+    local nboutputfiles="$(echo "${partialoutputfiles}" | wc -l)"
+    if test ${nboutputdirs} -ne ${nboutputfiles}
+    then
+        warning "missing files"
+        if ! test "${2}" == "--force"
+        then
+            return
+        fi
+    fi
+
+    local firstpartialoutputfile="$(echo "${partialoutputfiles}" | head -n 1)"
+    local firstpartialoutputextension="${firstpartialoutputfile##*.}"
+
+    if [[ "${firstpartialoutputfile}" == *Uncertainty* ]]
+    then
+       if test "${firstpartialoutputextension}" == "mhd" || test "${firstpartialoutputextension}" == "mha"
+        then
+            echo "${indent}Uncertainty file found: ${firstpartialoutputfile}"
+            ## search for sum
+            local mergedfile="${outputdir}/$(basename "${firstpartialoutputfile}")"
+            summed_merged_file=${mergedfile//-Uncertainty/}
+            if [ ! -f ${summed_merged_file} ];
+            then
+                warning "${summed_merged_file} does not exist. Error, no uncertainty computed"
+                return;
+            fi
+            echo "${indent}${summed_merged_file} found"
+            ## search for Squared
+            squared_merged_file=${mergedfile//-Uncertainty/-Squared}
+            if [ ! -f ${squared_merged_file} ];
+            then
+                warning "${squared_merged_file} does not exist. Error, no uncertainty computed"
+                return;
+            fi
+            echo "${indent}${squared_merged_file} found"
+            ## search for NumberOfEvent
+            totalEvents=0;
+            for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+            do
+                #echo $outputfile
+                if grep -q 'NumberOfEvent' "${outputdir}/${outputfile}"
+                then
+                    totalEvents="$(grep "NumberOfEvents" "${outputdir}/${outputfile}" | cut -d' ' -f4)"
+                    echo "${indent}Find the NumberOfEvent in $outputfile: ${totalEvents}"
+                fi
+            done
+
+            if test ${totalEvents} -gt 0
+            then
+                uncerImageMerger="clitkImageUncertainty"
+                test -x "./clitkImageUncertainty" && uncerImageMerger="./clitkImageUncertainty"
+                ${uncerImageMerger} -i ${summed_merged_file} -s ${squared_merged_file} -o ${mergedfile} -n ${totalEvents}
+            else
+                warning "${totalEvents} not positive. A at least one stat file (SimulationStatisticActor) must be provided. Error, no uncertainty computed"
+                return;
+            fi
+       else
+            error "merge_dispatcher_uncertainty does not handle ${firstpartialoutputfile} files"
+        fi
+    fi
+
+}
+
 echo "!!!! this is $0 v0.3k !!!!"
+echo "Usage: gate_power_merge.sh run.dir [--force]"
+echo "   where --force allows to merge files even if the file is missing in some output directories"
 
 rundir="${1?"provide run dir"}"
+force=${2:-""}
 rundir="$(echo "${rundir}" | sed 's|/*$||')"
-nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -name 'output*' | wc -l)"
+nboutputdirs="$(find "${rundir}" -mindepth 1 -type d -name 'output*' -o -type l -name 'output*' | wc -l)"
 
 test ${nboutputdirs} -gt 0 || error "no output dir found"
 echo "found ${nboutputdirs} partial output dirs"
@@ -436,18 +517,31 @@ then
 fi
 outputdir="$(basename "${outputdir}")"
 echo "output dir is ${outputdir}"
+
 test -d "${outputdir}" && rm -r "${outputdir}"
 mkdir "${outputdir}"
+for outputfile in $(find -L "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+do
+    merge_dispatcher "${outputfile}" "${force}"
+done
 
-for outputfile in $(find "${rundir}" -regextype 'posix-extended' -type f -regex "${rundir}/output.*\.(hdr|mhd|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
+echo ""
+echo "Merging done. Special case for statistical uncertainty"
+for outputfile in $(find -L "${outputdir}" -regextype 'posix-extended' -type f -regex "${outputdir}/.*\.(hdr|mhd|mha|root|txt)" | awk -F '/' '{ print $NF; }' | sort | uniq)
 do
-    merge_dispatcher "${outputfile}"
+    merge_dispatcher_uncertainty "${outputfile}" "${force}"
 done
 
 if [ -f "${rundir}/params.txt" ]
 then
-       echo "copying params file"
-       cp "${rundir}/params.txt" "${outputdir}/params.txt"
+    echo "copying params file"
+    cp "${rundir}/params.txt" "${outputdir}/params.txt"
+fi
+
+if [ -d "${rundir}/mac" ]
+then
+    echo "copying mac folder"
+    cp -r "${rundir}/mac" "${outputdir}/mac"
 fi
 
 echo "these was ${warning_count} warning(s)"
index 0248a1ec007262561431d49f9ccf4db00de59f93..91120500e4ae817ff51e0ef958125c0843a0ba87 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash 
+#! /usr/local/bin/bash -lx
 
 set -u
 SCRIPTNAME="$(basename "${0}")"
@@ -19,15 +19,20 @@ function usage {
     echo "${SCRIPTNAME} mac/main.mac njobs releasesuffix paramtogate"
     echo "default njobs = ${DEFAULTNUMBEROFJOBS}"
     echo "default releasesuffix = ${DEFAULTRELEASESUFFIX} (NONE means use Gate in PATH)"
+    echo "default paramtogate = \"\" (use \"\" around params and \\ in front of commas)"
 }
 # -------------------------------------------------
 
 test $# -eq 0 && usage && exit 0
 
-SCRIPTDIR="${HOME}/git/gate-tests/bin"
 RELEASESUFFIX=${3:-"${DEFAULTRELEASESUFFIX}"}
 RELEASEDIR="${HOME}/releases/grid_release${RELEASESUFFIX}"
-JOBFILE="$(dirname $0)/gate_job_cluster.job"
+if test "$(dnsdomainname)" = "in2p3.fr"
+then
+    JOBFILE="$(dirname $0)/gate_job_ccin2p3.job"
+else
+    JOBFILE="$(dirname $0)/gate_job_cluster.job"
+fi
 
 echo "Checking stuff"
 test -f ${JOBFILE} || error "can't find job file ${JOBFILE}"
@@ -42,12 +47,18 @@ MACRODIR=$(pwd)
 test -d ${MACRODIR}/mac && test -d ${MACRODIR}/data || error "invalid path"
 MACROFILE=${1:?"provide relative macro path"}
 test -f ${MACRODIR}/${MACROFILE} || error "invalid macro"
-OUTPUTDIR=$(mktemp --tmpdir=${MACRODIR} -d run.XXXX || error "can't create temp dir")
+if test "$(dnsdomainname)" = "in2p3.fr"
+then
+    OUTPUTDIR=$(mktemp -d -p "${MACRODIR}" run.XXXX || error "can't create temp dir")
+    ssh -i ${HOME}/.ssh/ccin2p3 linux1.dg.creatis.insa-lyon.fr mkdir -p "cc/$(basename ${OUTPUTDIR})"
+else
+    OUTPUTDIR=$(mktemp --tmpdir=${MACRODIR} -d run.XXXX || error "can't create temp dir")
+fi
 test -d ${OUTPUTDIR} || error "can't locate output dir"
 RUNID=${OUTPUTDIR##*.}
 NJOBS=${2:-"${DEFAULTNUMBEROFJOBS}"}
 NJOBSMAX=${NJOBS}
-PARAM="${4:-""}"
+PARAM="${4:-\"\"}"
 
 echo "Lets roll!!"
 echo "runid is ${RUNID}"
@@ -74,15 +85,31 @@ echo "njobs = ${NJOBS}" >> "${PARAMFILE}"
 echo "macro = ${MACROFILE}" >> "${PARAMFILE}"
 test -z "${PARAM}" || echo "param = ${PARAM}" >> "${PARAMFILE}"
 
+# Copy macros files (for log)
+mkdir ${OUTPUTDIR}/mac
+cp ${MACROFILE} ${OUTPUTDIR}/mac
+files=`grep "control/execute" ${MACROFILE} | cut -d " " -f 2`
+for i in $files
+do
+    cp $i ${OUTPUTDIR}/mac
+done
+
 while test $NJOBS -gt 0; do
 
     if test "${QSUB}" = "noqsub"
-    then 
+    then
         echo "Launching Gate log in ${OUTPUTDIR}/gate_${NJOBS}.log"
-        PARAM=\"${PARAM}\" INDEX=${NJOBS} INDEXMAX=${NJOBSMAX} SCRIPTDIR=${SCRIPTDIR} OUTPUTDIR=${OUTPUTDIR}  RELEASEDIR=${RELEASEDIR} MACROFILE=${MACROFILE} MACRODIR=${MACRODIR} PBS_JOBID="local_${NJOBS}" bash "${JOBFILE}" > ${OUTPUTDIR}/gate_${NJOBS}.log &
+        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 
+        qsub -o "${OUTPUTDIR}" \
+             -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}" \
-           -v "PARAM=\"${PARAM}\",INDEX=${NJOBS},INDEXMAX=${NJOBSMAX},SCRIPTDIR=${SCRIPTDIR},OUTPUTDIR=${OUTPUTDIR},RELEASEDIR=${RELEASEDIR},MACROFILE=${MACROFILE},MACRODIR=${MACRODIR}" \
+       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
 
@@ -90,3 +117,7 @@ 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/cluster_tools/gate_run_submit_cluster_nomove.sh b/cluster_tools/gate_run_submit_cluster_nomove.sh
new file mode 100644 (file)
index 0000000..47ad699
--- /dev/null
@@ -0,0 +1,101 @@
+#! /bin/bash
+
+set -u
+SCRIPTNAME="$(basename "${0}")"
+
+# -------------------------------------------------
+function error {
+    echo "ERROR: $1"
+    usage
+    exit 1
+}
+# -------------------------------------------------
+
+DEFAULTRELEASESUFFIX="NONE"
+DEFAULTNUMBEROFJOBS="10"
+
+# -------------------------------------------------
+function usage {
+    echo "${SCRIPTNAME} mac/main.mac njobs releasesuffix paramtogate"
+    echo "default njobs = ${DEFAULTNUMBEROFJOBS}"
+    echo "default releasesuffix = ${DEFAULTRELEASESUFFIX} (NONE means use Gate in PATH)"
+    echo "default paramtogate = \"\" (use \"\" around params and \\ in front of commas)"
+}
+# -------------------------------------------------
+
+test $# -eq 0 && usage && exit 0
+
+RELEASESUFFIX=${3:-"${DEFAULTRELEASESUFFIX}"}
+RELEASEDIR="${HOME}/releases/grid_release${RELEASESUFFIX}"
+JOBFILE="$(dirname $0)/gate_job_cluster_nomove.job"
+
+echo "Checking stuff"
+test -f ${JOBFILE} || error "can't find job file ${JOBFILE}"
+if test "${RELEASESUFFIX}" = "${DEFAULTRELEASESUFFIX}"
+then
+    RELEASEDIR="NONE"
+    which Gate 2>&1 >/dev/null || error "there is no Gate in the PATH"
+else
+    test -d ${RELEASEDIR} || error "invalid release dir ${RELEASEDIR}"
+fi
+MACRODIR=$(pwd)
+test -d ${MACRODIR}/mac && test -d ${MACRODIR}/data || error "invalid path"
+MACROFILE=${1:?"provide relative macro path"}
+test -f ${MACRODIR}/${MACROFILE} || error "invalid macro"
+OUTPUTDIR=$(mktemp --tmpdir=${MACRODIR} -d run.XXXX || error "can't create temp dir")
+test -d ${OUTPUTDIR} || error "can't locate output dir"
+RUNID=${OUTPUTDIR##*.}
+NJOBS=${2:-"${DEFAULTNUMBEROFJOBS}"}
+NJOBSMAX=${NJOBS}
+PARAM="${4:-\"\"}"
+
+echo "Lets roll!!"
+echo "runid is ${RUNID}"
+
+QSUB=$(which qsub 2> /dev/null)
+# echo "qsub is $(which qsub)"
+test -z "${QSUB}" && QSUB="noqsub"
+if test "${QSUB}" = "noqsub"
+then
+    echo "qsub is not found. Simply run Gate on multiple cores."
+fi
+
+test -z "${PARAM}" && echo "no param" || echo "param is ${PARAM}"
+if test "$RELEASESUFFIX" = "$DEFAULTRELEASESUFFIX"
+then
+    echo "Gate is $(which Gate)"
+else
+    echo "Gate release is $(basename ${RELEASEDIR})"
+fi
+echo "submitting ${NJOBS} jobs"
+
+PARAMFILE="${OUTPUTDIR}/params.txt"
+echo "njobs = ${NJOBS}" >> "${PARAMFILE}"
+echo "macro = ${MACROFILE}" >> "${PARAMFILE}"
+test -z "${PARAM}" || echo "param = ${PARAM}" >> "${PARAMFILE}"
+
+# Copy macros files (for log)
+mkdir ${OUTPUTDIR}/mac
+cp ${MACROFILE} ${OUTPUTDIR}/mac
+files=`grep "control/execute" ${MACROFILE} | cut -d " " -f 2`
+for i in $files
+do
+    cp $i ${OUTPUTDIR}/mac
+done
+
+while test $NJOBS -gt 0; do
+
+    if test "${QSUB}" = "noqsub"
+    then
+        echo "Launching Gate log in ${OUTPUTDIR}/gate_${NJOBS}.log"
+        PARAM=\"${PARAM}\" INDEX=${NJOBS} INDEXMAX=${NJOBSMAX} OUTPUTDIR=${OUTPUTDIR}  RELEASEDIR=${RELEASEDIR} MACROFILE=${MACROFILE} MACRODIR=${MACRODIR} PBS_JOBID="local_${NJOBS}" bash "${JOBFILE}" > ${OUTPUTDIR}/gate_${NJOBS}.log &
+    else
+       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
+
+    let NJOBS--
+done
+
+echo "runid is ${RUNID}"
index a1cd573cdb21e5f23488992c401d029a74d6b17a..ab5028954ce62feeab9953d0baf3af6dc0eb4f49 100755 (executable)
@@ -27,7 +27,9 @@ def parse_stat_file(filename):
     keys = {}
     for line in open(filename,"r").readlines():
         match = linere.match(line)
-        assert(match is not None)
+        #assert(match is not None)
+        if match is None:
+            continue
         groups = match.groups()
         if groups[0] not in mergedlines:
             continue
@@ -88,4 +90,3 @@ jkeys = parse_stat_file(sys.argv[4])
 keys  = merge_keys(ikeys,jkeys)
 output = format_keys(keys)
 open(sys.argv[6],"w").write(output)
-
index 95f2a474897059f2a7248f1b80267c053b84c268..090303cde90177fb391475fb7fe003d77c35c29d 100644 (file)
@@ -1,22 +1,22 @@
 
 # Attempt to find gengetopt. If not found, compile it.
-FIND_PROGRAM(GENGETOPT gengetopt)
-IF (GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
-  GET_FILENAME_COMPONENT(CLITK_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
-  ADD_SUBDIRECTORY(${CLITK_CMAKE_DIR}/../utilities/gengetopt ${CMAKE_CURRENT_BINARY_DIR}/gengetopt)
-ELSE(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
-  ADD_EXECUTABLE(gengetopt IMPORTED)
-  SET_PROPERTY(TARGET gengetopt PROPERTY IMPORTED_LOCATION ${GENGETOPT})
-ENDIF(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
+find_program(GENGETOPT gengetopt)
+if(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
+  get_filename_component(CLITK_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+  add_subdirectory(${CLITK_CMAKE_DIR}/../utilities/gengetopt ${CMAKE_CURRENT_BINARY_DIR}/gengetopt)
+else(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
+  add_executable(gengetopt IMPORTED)
+  set_property(TARGET gengetopt PROPERTY IMPORTED_LOCATION ${GENGETOPT})
+endif(GENGETOPT STREQUAL "GENGETOPT-NOTFOUND")
 
-MACRO (WRAP_GGO GGO_SRCS)
-  FOREACH(GGO_FILE ${ARGN})
-    GET_FILENAME_COMPONENT(GGO_BASEFILENAME ${GGO_FILE} NAME_WE)
-    GET_FILENAME_COMPONENT(GGO_FILE_ABS ${GGO_FILE} ABSOLUTE)
-    SET(GGO_H ${GGO_BASEFILENAME}_ggo.h)
-    SET(GGO_C ${GGO_BASEFILENAME}_ggo.c)
-    SET(GGO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${GGO_H} ${CMAKE_CURRENT_BINARY_DIR}/${GGO_C})
-    ADD_CUSTOM_COMMAND(OUTPUT ${GGO_OUTPUT}
+macro(WRAP_GGO GGO_SRCS)
+  foreach(GGO_FILE ${ARGN})
+    get_filename_component(GGO_BASEFILENAME ${GGO_FILE} NAME_WE)
+    get_filename_component(GGO_FILE_ABS ${GGO_FILE} ABSOLUTE)
+    set(GGO_H ${GGO_BASEFILENAME}_ggo.h)
+    set(GGO_C ${GGO_BASEFILENAME}_ggo.c)
+    set(GGO_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${GGO_H} ${CMAKE_CURRENT_BINARY_DIR}/${GGO_C})
+    add_custom_command(OUTPUT ${GGO_OUTPUT}
                        COMMAND gengetopt
                        ARGS < ${GGO_FILE_ABS}
                               --output-dir=${CMAKE_CURRENT_BINARY_DIR}
@@ -28,15 +28,15 @@ MACRO (WRAP_GGO GGO_SRCS)
                               --include-getopt
                        DEPENDS ${GGO_FILE_ABS}
                       )
-    SET(${GGO_SRCS} ${${GGO_SRCS}} ${GGO_OUTPUT})
-    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
-  ENDFOREACH(GGO_FILE)
-  SET_SOURCE_FILES_PROPERTIES(${${GGO_SRCS}} PROPERTIES GENERATED TRUE)
-  IF(CMAKE_COMPILER_IS_GNUCXX)
-    FIND_PROGRAM(DEFAULT_GCC gcc)
-    EXEC_PROGRAM(${DEFAULT_GCC} ARGS "-dumpversion" OUTPUT_VARIABLE GCCVER)
-    IF("${GCCVER}" VERSION_GREATER "4.5.2")
-      SET_SOURCE_FILES_PROPERTIES(${${GGO_SRCS}} PROPERTIES COMPILE_FLAGS "-Wno-unused-but-set-variable")
-    ENDIF("${GCCVER}" VERSION_GREATER "4.5.2")
-  ENDIF(CMAKE_COMPILER_IS_GNUCXX)
-ENDMACRO (WRAP_GGO)
+    set(${GGO_SRCS} ${${GGO_SRCS}} ${GGO_OUTPUT})
+    include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  endforeach(GGO_FILE)
+  set_source_files_properties(${${GGO_SRCS}} PROPERTIES GENERATED TRUE)
+  if(CMAKE_COMPILER_IS_GNUCXX)
+    find_program(DEFAULT_GCC gcc)
+    exec_program(${DEFAULT_GCC} ARGS "-dumpversion" OUTPUT_VARIABLE GCCVER)
+    if("${GCCVER}" VERSION_GREATER "4.5.2")
+      set_source_files_properties(${${GGO_SRCS}} PROPERTIES COMPILE_FLAGS "-Wno-unused-but-set-variable")
+    endif("${GCCVER}" VERSION_GREATER "4.5.2")
+  endif(CMAKE_COMPILER_IS_GNUCXX)
+endmacro(WRAP_GGO)
index db14f988662d855e6bd8a44129ad86137f2aa6e2..f0482994223dcde4db584e6045f1eb314290cf9e 100644 (file)
 # It tries to find the root-config script which gives you all the needed information.
 # If the system variable ROOTSYS is set this is straight forward.
 # If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH.
-# If you need an other path you should add this path to this varaible.  
+# If you need an other path you should add this path to this varaible.
 # The root-config script is then used to detect basically everything else.
 # This module defines a number of key variables and macros.
 
 
-MESSAGE(STATUS "Looking for Root...")
+message(STATUS "Looking for Root...")
 
-SET(ROOT_DEFINITIONS "")
+set(ROOT_DEFINITIONS "")
 
-SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
+set(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
 
-SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
+set(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
 
-FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS)
-    
-IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-  MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
+find_program(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS)
+
+if(${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+  message( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
  set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the
  subdirectory cmake/modules.")
-ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-               MESSAGE(STATUS "root-config found")
-  STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) 
-  SET( ENV{ROOTSYS} ${test})
+else(${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+               message(STATUS "root-config found")
+  string(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE})
+  set( ENV{ROOTSYS} ${test})
   set( ROOTSYS ${test})
-ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")  
+endif(${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
+
+
+if(ROOT_CONFIG_EXECUTABLE)
 
-IF (ROOT_CONFIG_EXECUTABLE)
-   
-  SET(ROOT_FOUND FALSE)
+  set(ROOT_FOUND FALSE)
 
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
+  exec_program(${ROOT_CONFIG_EXECUTABLE} ARGS "--version" OUTPUT_VARIABLE ROOTVERSION)
 
-  MESSAGE(STATUS "Looking for Root... - found $ENV{ROOTSYS}/bin/root")
-  MESSAGE(STATUS "Looking for Root... - version ${ROOTVERSION} ")   
+  message(STATUS "Looking for Root... - found $ENV{ROOTSYS}/bin/root")
+  message(STATUS "Looking for Root... - version ${ROOTVERSION} ")
 
   # we need at least version 5.00/00
-  IF (NOT ROOT_MIN_VERSION)
-    SET(ROOT_MIN_VERSION "5.00/00")
-  ENDIF (NOT ROOT_MIN_VERSION)
-   
+  if(NOT ROOT_MIN_VERSION)
+    set(ROOT_MIN_VERSION "5.00/00")
+  endif(NOT ROOT_MIN_VERSION)
+
   # now parse the parts of the user given version string into variables
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
-   
+  string(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
+
   # and now the version string given by qmake
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
+  string(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
+  string(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
 
-  IF (found_root_major_vers LESS 5)
-    MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
-  ENDIF (found_root_major_vers LESS 5)
+  if(found_root_major_vers LESS 5)
+    message( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
+  endif(found_root_major_vers LESS 5)
 
   # compute an overall version number which can be compared at once
-  MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
-  MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
-   
-  IF (found_vers LESS req_vers)
-    SET(ROOT_FOUND FALSE)
-    SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
-  ELSE (found_vers LESS req_vers)
-    SET(ROOT_FOUND TRUE)
-  ENDIF (found_vers LESS req_vers)
+  math(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
+  math(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
+
+  if(found_vers LESS req_vers)
+    set(ROOT_FOUND FALSE)
+    set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
+  else(found_vers LESS req_vers)
+    set(ROOT_FOUND TRUE)
+  endif(found_vers LESS req_vers)
 
-ENDIF (ROOT_CONFIG_EXECUTABLE)
+endif(ROOT_CONFIG_EXECUTABLE)
 
-#MESSAGE("root found = "${ROOT_FOUND})
+#message("root found = "${ROOT_FOUND})
 
-IF (ROOT_FOUND)
+if(ROOT_FOUND)
 
   # ask root-config for the library dir
   # Set ROOT_LIBRARY_DIR
 
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
+  exec_program( ${ROOT_CONFIG_EXECUTABLE}
     ARGS "--libdir"
     OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP )
 
-  IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
-  ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
-    MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
-  ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    
+  if(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+    set(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
+  else(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+    message("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
+    message("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
+  endif(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
+
   # ask root-config for the binary dir
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
+  exec_program(${ROOT_CONFIG_EXECUTABLE}
     ARGS "--bindir"
     OUTPUT_VARIABLE root_bins )
-  SET(ROOT_BINARY_DIR ${root_bins})
+  set(ROOT_BINARY_DIR ${root_bins})
 
   # ask root-config for the include dir
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--incdir" 
+  exec_program( ${ROOT_CONFIG_EXECUTABLE}
+    ARGS "--incdir"
     OUTPUT_VARIABLE root_headers )
-  SET(ROOT_INCLUDE_DIR ${root_headers})
+  set(ROOT_INCLUDE_DIR ${root_headers})
       # CACHE INTERNAL "")
 
   # ask root-config for the library varaibles
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-#    ARGS "--noldflags --noauxlibs --libs" 
-    ARGS "--glibs" 
+  exec_program( ${ROOT_CONFIG_EXECUTABLE}
+#    ARGS "--noldflags --noauxlibs --libs"
+    ARGS "--glibs"
     OUTPUT_VARIABLE root_flags )
 
-#  STRING(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
-#  STRING(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
+#  string(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
+#  string(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
 #  REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}")
 
-  SET(ROOT_LIBRARIES ${root_flags})
+  set(ROOT_LIBRARIES ${root_flags})
 
   # Make variables changeble to the advanced user
-  MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
+  mark_as_advanced( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
 
   # Set ROOT_INCLUDES
-  SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
+  set( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
 
-  SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
+  set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
 
   #######################################
   #
-  #       Check the executables of ROOT 
-  #          ( rootcint ) 
+  #       Check the executables of ROOT
+  #          ( rootcint )
   #
   #######################################
 
-  FIND_PROGRAM(ROOT_CINT_EXECUTABLE
+  find_program(ROOT_CINT_EXECUTABLE
     NAMES rootcint
     PATHS ${ROOT_BINARY_DIR}
     NO_DEFAULT_PATH
     )
 
-ENDIF (ROOT_FOUND)
+endif(ROOT_FOUND)
 
 
-#MESSAGE("icici")
+#message("icici")
 
   ###########################################
   #
@@ -146,44 +146,44 @@ ENDIF (ROOT_FOUND)
   #
   ###########################################
 
-MACRO (ROOT_GENERATE_DICTIONARY_OLD )
-   set(INFILES "")    
+macro(ROOT_GENERATE_DICTIONARY_OLD )
+
+   set(INFILES "")
 
    foreach (_current_FILE ${ARGN})
 
-     IF (${_current_FILE} MATCHES "^.*\\.h$")
-       IF (${_current_FILE} MATCHES "^.*Link.*$")
+     if(${_current_FILE} MATCHES "^.*\\.h$")
+       if(${_current_FILE} MATCHES "^.*Link.*$")
          set(LINKDEF_FILE ${_current_FILE})
-       ELSE (${_current_FILE} MATCHES "^.*Link.*$")
+       else(${_current_FILE} MATCHES "^.*Link.*$")
          set(INFILES ${INFILES} ${_current_FILE})
-       ENDIF (${_current_FILE} MATCHES "^.*Link.*$")
-     ELSE (${_current_FILE} MATCHES "^.*\\.h$")
-       IF (${_current_FILE} MATCHES "^.*\\.cxx$")
+       endif(${_current_FILE} MATCHES "^.*Link.*$")
+     else(${_current_FILE} MATCHES "^.*\\.h$")
+       if(${_current_FILE} MATCHES "^.*\\.cxx$")
          set(OUTFILE ${_current_FILE})
-       ELSE (${_current_FILE} MATCHES "^.*\\.cxx$")
-         set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
-       ENDIF (${_current_FILE} MATCHES "^.*\\.cxx$")
-     ENDIF (${_current_FILE} MATCHES "^.*\\.h$")
-     
+       else(${_current_FILE} MATCHES "^.*\\.cxx$")
+         set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
+       endif(${_current_FILE} MATCHES "^.*\\.cxx$")
+     endif(${_current_FILE} MATCHES "^.*\\.h$")
+
    endforeach (_current_FILE ${ARGN})
-   
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
 
-   STRING(REGEX REPLACE "(^.*).cxx" "\\1.h" bla "${OUTFILE}")
-#   MESSAGE("BLA: ${bla}")
-   SET (OUTFILES ${OUTFILE} ${bla})
+#  message("INFILES: ${INFILES}")
+#  message("OutFILE: ${OUTFILE}")
+#  message("LINKDEF_FILE: ${LINKDEF_FILE}")
+#  message("INCLUDE_DIRS: ${INCLUDE_DIRS}")
 
-   ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
+   string(REGEX REPLACE "(^.*).cxx" "\\1.h" bla "${OUTFILE}")
+#   message("BLA: ${bla}")
+   set(OUTFILES ${OUTFILE} ${bla})
+
+   add_custom_command(OUTPUT ${OUTFILES}
       COMMAND ${ROOT_CINT_EXECUTABLE}
       ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES})
 
-#   MESSAGE("ROOT_CINT_EXECUTABLE has created the dictionary ${OUTFILE}")
+#   message("ROOT_CINT_EXECUTABLE has created the dictionary ${OUTFILE}")
 
-ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD)
+endmacro(ROOT_GENERATE_DICTIONARY_OLD)
 
   ###########################################
   #
@@ -191,28 +191,28 @@ ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD)
   #
   ###########################################
 
-MACRO (ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
+macro(ROOT_GENERATE_DICTIONARY INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
+
   set(INCLUDE_DIRS)
 
   foreach (_current_FILE ${INCLUDE_DIRS_IN})
-    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
+    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
   endforeach (_current_FILE ${INCLUDE_DIRS_IN})
 
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
 
-  STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
-#  MESSAGE("BLA: ${bla}")
-  SET (OUTFILES ${OUTFILE} ${bla})
+#  message("INFILES: ${INFILES}")
+#  message("OutFILE: ${OUTFILE}")
+#  message("LINKDEF_FILE: ${LINKDEF_FILE}")
+#  message("INCLUDE_DIRS: ${INCLUDE_DIRS}")
+
+  string(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
+#  message("BLA: ${bla}")
+  set(OUTFILES ${OUTFILE} ${bla})
 
-  ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
+  add_custom_command(OUTPUT ${OUTFILES}
      COMMAND ${ROOT_CINT_EXECUTABLE}
      ARGS -f ${OUTFILE} -c -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES})
 
-ENDMACRO (ROOT_GENERATE_DICTIONARY)
+endmacro(ROOT_GENERATE_DICTIONARY)
 
-#MESSAGE("la")
+#message("la")
index e836147db8578a98ead1f99bc175005b4561068c..2331750a80c279520f69d917f6820cffe4d11911 100644 (file)
@@ -1,37 +1,49 @@
 #=========================================================
 #Support for the CTest dashboard testing system
-OPTION(BUILD_TESTING "Build the testing tree" OFF)
-IF (BUILD_TESTING)
-  OPTION(CLITK_BUILD_TESTING "Test ITK" ON)
-  INCLUDE(CTest)
-ENDIF(BUILD_TESTING)
+option(BUILD_TESTING "Build the testing tree" OFF)
+if(BUILD_TESTING)
+  option(CLITK_BUILD_TESTING "Test ITK" ON)
+  include(CTest)
+endif(BUILD_TESTING)
 #=========================================================
 
 
 #=========================================================
 # If the user choose to build documentation, then search for Doxygen executables.
-OPTION(BUILD_DOXYGEN "Build Doxygen Documentation" OFF)
-IF(BUILD_DOXYGEN)
-  FIND_PACKAGE(Doxygen)
-  ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/Doxygen ${PROJECT_BINARY_DIR}/Doxygen)
-ENDIF(BUILD_DOXYGEN)
+option(BUILD_DOXYGEN "Build Doxygen Documentation" OFF)
+if(BUILD_DOXYGEN)
+  find_package(Doxygen)
+  add_subdirectory(${CLITK_SOURCE_DIR}/Doxygen ${PROJECT_BINARY_DIR}/Doxygen)
+endif(BUILD_DOXYGEN)
 #=========================================================
 
 # Compilation options
-OPTION(CLITK_EXPERIMENTAL "Enable experimental software and features" OFF)
-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)
+option(CLITK_EXPERIMENTAL "Enable experimental software and features" OFF)
+mark_as_advanced(CLITK_EXPERIMENTAL)
+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)
 
-OPTION(CLITK_BUILD_VV "Build vv the 4D visualizer (requires VTK and QT)" ON)
-IF (CLITK_BUILD_VV)
-  ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/vv ${PROJECT_BINARY_DIR}/vv)
-ENDIF(CLITK_BUILD_VV)
+option(CLITK_BUILD_VV "Build vv the 4D visualizer (requires VTK and QT)" ON)
+
+if(CLITK_BUILD_VV)
+ if(VTK_VERSION VERSION_LESS 6.0.0)
+    set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version")
+ else()
+    if(VTK_QT_VERSION VERSION_LESS 5)
+       set(vv_QT_VERSION "4" CACHE INTERNAL "Expected Qt version")
+    else()
+       set(vv_QT_VERSION "5" CACHE INTERNAL "Expected Qt version")
+    endif()
+ endif()
+
+  add_subdirectory(${CLITK_SOURCE_DIR}/vv ${PROJECT_BINARY_DIR}/vv)
+endif(CLITK_BUILD_VV)
 
 #=========================================================
 # Build test when vv has been compiled
-IF(BUILD_TESTING)
-  ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests)
-ENDIF(BUILD_TESTING)
+if(BUILD_TESTING)
+  add_subdirectory(${CLITK_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/tests)
+endif(BUILD_TESTING)
 
 
index 771467b0780a567cae2dd975cf28339560c06685..226064867e3e23cc3563abcc4b5b87c394af33fb 100644 (file)
@@ -1,7 +1,7 @@
 #=========================================================
-MACRO (DD in)
-    MESSAGE(${in}=${${in}})
-ENDMACRO(DD)
+macro(DD in)
+    message(${in}=${${in}})
+endmacro(DD)
 #=========================================================
 
 #=========================================================
@@ -11,32 +11,32 @@ if (NOT CMAKE_BUILD_TYPE)
 endif (NOT CMAKE_BUILD_TYPE)
 
 #=========================================================
-INCLUDE_DIRECTORIES(${CLITK_SOURCE_DIR}/itk
+include_directories(${CLITK_SOURCE_DIR}/itk
   ${CLITK_SOURCE_DIR}/filters
   ${CLITK_SOURCE_DIR}/segmentation
   ${CLITK_SOURCE_DIR}/registration
   ${CLITK_SOURCE_DIR}/tools
   ${CLITK_SOURCE_DIR}/common
   ${PROJECT_BINARY_DIR})
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
-SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-LINK_DIRECTORIES(${PROJECT_BINARY_DIR}/lib)
-INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/tools)         #For _ggo.h includes from other directories
-INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/segmentation)  #For _ggo.h includes from other directories
-INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/registration)  #For _ggo.h includes from other directories
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
+link_directories(${PROJECT_BINARY_DIR}/lib)
+include_directories(${PROJECT_BINARY_DIR}/tools)         #For _ggo.h includes from other directories
+include_directories(${PROJECT_BINARY_DIR}/segmentation)  #For _ggo.h includes from other directories
+include_directories(${PROJECT_BINARY_DIR}/registration)  #For _ggo.h includes from other directories
 #=========================================================
 
 #=========================================================
 # Building in the source tree is forbidden
-IF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
-  MESSAGE(FATAL_ERROR "Building in the source tree is not allowed ! Quit; remove the file 'CMakeCache.txt' and the folder 'CMakeFiles' an
+if(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+  message(FATAL_ERROR "Building in the source tree is not allowed ! Quit; remove the file 'CMakeCache.txt' and the folder 'CMakeFiles' an
 d build outside the sources (for example 'mkdir build ; cmake <CLITK_DIR>'.")
-ENDIF(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
+endif(PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
 #=========================================================
 
 #=========================================================
 # Remove some MS Visual c++ flags
-IF(MSVC)
-  ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
-ENDIF(MSVC)
+if(MSVC)
+  add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS)
+endif(MSVC)
 #=========================================================
index 1ba42ec4568fb48fc16e9525c3e74f16578e6bba..a871fecd0d19523b2fa28823856adcf5637c32ed 100644 (file)
@@ -1,20 +1,20 @@
 #=========================================================
 # Find ITK (required)
-FIND_PACKAGE(ITK)
-IF(ITK_FOUND)
-  INCLUDE("${ITK_USE_FILE}")
-ELSE(ITK_FOUND)
-  MESSAGE(FATAL_ERROR "Cannot build without ITK.  Please set ITK_DIR.")
-ENDIF(ITK_FOUND)
+find_package(ITK)
+if(ITK_FOUND)
+  include("${ITK_USE_FILE}")
+else(ITK_FOUND)
+  message(FATAL_ERROR "Cannot build without ITK.  Please set ITK_DIR.")
+endif(ITK_FOUND)
 #=========================================================
 
 #=========================================================
 # Find VTK (required)
-FIND_PACKAGE(VTK REQUIRED)
-IF(VTK_FOUND)
-  INCLUDE("${VTK_USE_FILE}")
-  IF(VTK_VERSION VERSION_LESS 5.8.0)
-    SET ( VTK_LIBRARIES
+find_package(VTK REQUIRED)
+if(VTK_FOUND)
+  include("${VTK_USE_FILE}")
+  if(VTK_VERSION VERSION_LESS 5.8.0)
+    set( VTK_LIBRARIES
       vtkCommon
       vtkRendering
       vtkIO
@@ -24,52 +24,45 @@ IF(VTK_FOUND)
       vtkImaging
       vtkHybrid
       )
-  ENDIF(VTK_VERSION VERSION_LESS 5.8.0)
-  IF(VTK_VERSION VERSION_LESS 5.6.0)
-    SET ( VTK_LIBRARIES
+  endif(VTK_VERSION VERSION_LESS 5.8.0)
+  if(VTK_VERSION VERSION_LESS 5.6.0)
+    set( VTK_LIBRARIES
       ${VTK_LIBRARIES}
       vtkQVTK
     )
-  ENDIF(VTK_VERSION VERSION_LESS 5.6.0)
-ELSE(VTK_FOUND)
-  MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
-ENDIF(VTK_FOUND)
+  endif(VTK_VERSION VERSION_LESS 5.6.0)
+else(VTK_FOUND)
+  message(FATAL_ERROR "Please set VTK_DIR.")
+endif(VTK_FOUND)
 #=========================================================
 
 #=========================================================
 # Find gengetopt, will create a target exe if not found
-SET(CMAKE_MODULE_PATH "${CLITK_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
-FIND_PACKAGE(Gengetopt)
+set(CMAKE_MODULE_PATH "${CLITK_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
+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")
-#  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()
+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()
 #=========================================================
 
 
 #=========================================================
 ### Check if ITK was compiled with SYSTEM_GDCM = ON
-SET(CLITK_USE_SYSTEM_GDCM FALSE)
-IF(ITK_VERSION_MAJOR LESS "4")
-  IF(ITK_USE_SYSTEM_GDCM)
-    SET(CLITK_USE_SYSTEM_GDCM TRUE) 
-  ENDIF(ITK_USE_SYSTEM_GDCM)
-ELSE(ITK_VERSION_MAJOR LESS "4")
-  SET(GDCM_INCLUDE_INSTALL ".*include/gdcm-.*")
-  SET(GDCM_INCLUDE_BUILD ".*/Source/MediaStorageAndFileFormat")
-  IF(NOT ITKGDCM_INCLUDE_DIRS MATCHES ${GDCM_INCLUDE_BUILD})
-    SET(CLITK_USE_SYSTEM_GDCM TRUE)
-  ENDIF()
-ENDIF(ITK_VERSION_MAJOR LESS "4")
+set(CLITK_USE_SYSTEM_GDCM FALSE)
+# ITK4 creates a target for each gdcm library when it compiles GDCM
+get_target_property(GDCMDICTTARG gdcmDICT TYPE )
+if(NOT GDCMDICTTARG)
+  set(CLITK_USE_SYSTEM_GDCM TRUE)
+endif()
 
-#DD(CLITK_USE_SYSTEM_GDCM)
 
index 28199adfa1f10feba7d7ac7cc37fc7fe4895573d..e17c4dc3e05363b95faab046f6b7997835b65c0f 100644 (file)
@@ -1,9 +1,9 @@
 #=========================================================
 # make clitk libraries*
-CONFIGURE_FILE(clitkConfiguration.h.in ${PROJECT_BINARY_DIR}/clitkConfiguration.h)
+configure_file(clitkConfiguration.h.in ${PROJECT_BINARY_DIR}/clitkConfiguration.h)
 
-SET(clitkCommon_SRC
-  clitkCommon.cxx 
+set(clitkCommon_SRC
+  clitkCommon.cxx
   clitkListOfPair.cxx
   clitkTimer.cxx
   clitkImageCommon.cxx
@@ -11,14 +11,14 @@ SET(clitkCommon_SRC
   clitkIO.cxx
   clitkGateAsciiImageIO.cxx
   clitkGateAsciiImageIOFactory.cxx
-  clitkVoxImageIO.cxx  
+  clitkVoxImageIO.cxx
   clitkVoxImageIOFactory.cxx
-  clitkVfImageIO.cxx  
+  clitkVfImageIO.cxx
   clitkVfImageIOFactory.cxx
-  clitkXdrImageIOReader.cxx  
-  clitkXdrImageIOWriter.cxx  
+  clitkXdrImageIOReader.cxx
+  clitkXdrImageIOWriter.cxx
   clitkXdrImageIOFactory.cxx
-  rtkHisImageIO.cxx  
+  rtkHisImageIO.cxx
   rtkHisImageIOFactory.cxx
   rtkHndImageIO.cxx
   rtkHndImageIOFactory.cxx
@@ -29,7 +29,7 @@ SET(clitkCommon_SRC
   rtkImagXImageIO.cxx
   rtkImagXImageIOFactory.cxx
   rtkImagXXMLFileReader.cxx
-  clitkEsrfHstImageIO.cxx  
+  clitkEsrfHstImageIO.cxx
   clitkEsrfHstImageIOFactory.cxx
   clitkEsrfHstXMLFileReader.cxx
   clitkDicomRTDoseIO.cxx
@@ -44,8 +44,8 @@ SET(clitkCommon_SRC
   vvImageReader.cxx
   vvImageWriter.cxx
 )
-IF(CLITK_PRIVATE_FEATURES)
-  SET(clitkCommon_SRC ${clitkCommon_SRC}
+if(CLITK_PRIVATE_FEATURES)
+  set(clitkCommon_SRC ${clitkCommon_SRC}
     ${PROJECT_SOURCE_DIR}/private_features/clitkUsfImageIO.cxx
     ${PROJECT_SOURCE_DIR}/private_features/clitkUsfImageIOFactory.cxx
     ${PROJECT_SOURCE_DIR}/private_features/clitkUSVoxImageIO.cxx
@@ -53,35 +53,35 @@ IF(CLITK_PRIVATE_FEATURES)
     ${PROJECT_SOURCE_DIR}/private_features/clitkSvlImageIO.cxx
     ${PROJECT_SOURCE_DIR}/private_features/clitkSvlImageIOFactory.cxx
     )
-ENDIF(CLITK_PRIVATE_FEATURES)
+endif(CLITK_PRIVATE_FEATURES)
 
 ### Declare clitkCommon library
-ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC})
+add_library(clitkCommon STATIC ${clitkCommon_SRC})
 
-IF(CLITK_MEMORY_INFO)
-  TARGET_LINK_LIBRARIES(clitkCommon statgrab)
-ENDIF(CLITK_MEMORY_INFO)
+if(CLITK_MEMORY_INFO)
+  target_link_libraries(clitkCommon statgrab)
+endif(CLITK_MEMORY_INFO)
 
 
 #=========================================================
-IF (CLITK_USE_SYSTEM_GDCM)
-  FIND_PACKAGE(GDCM REQUIRED)
+if(CLITK_USE_SYSTEM_GDCM)
+  find_package(GDCM REQUIRED)
   include(${GDCM_USE_FILE})
-  TARGET_LINK_LIBRARIES(clitkCommon vtkgdcm gdcmDICT gdcmMSFF gdcmMEXD)
-ENDIF()
+  target_link_libraries(clitkCommon vtkgdcm gdcmDICT gdcmMSFF gdcmMEXD)
+endif()
 #=========================================================
 
-TARGET_LINK_LIBRARIES(clitkCommon ${VTK_LIBRARIES} ${ITK_LIBRARIES})
+target_link_libraries(clitkCommon ${VTK_LIBRARIES} ${ITK_LIBRARIES})
 
-ADD_LIBRARY(clitkDicomRTStruct STATIC
+add_library(clitkDicomRTStruct STATIC
   clitkDicomRT_Contour.cxx
   clitkDicomRT_ROI.cxx
   clitkDicomRT_StructureSet.cxx
   clitkDicomRTStruct2ImageFilter.cxx
   )
 
-TARGET_LINK_LIBRARIES(clitkDicomRTStruct clitkCommon)
+target_link_libraries(clitkDicomRTStruct clitkCommon)
 
-#ADD_LIBRARY(clitkCommonShared SHARED ${clitkCommon_SRC})
-#SET_TARGET_PROPERTIES(clitkCommonShared PROPERTIES COMPILE_FLAGS -fPIC)
+#add_library(clitkCommonShared SHARED ${clitkCommon_SRC})
+#set_target_properties(clitkCommonShared PROPERTIES COMPILE_FLAGS -fPIC)
 
index 10f608e6ce8b7ba7c92d6085f4d1b1588a047e3d..57be29e5297f833d53769818b0aa097cb3d93a6c 100644 (file)
@@ -104,6 +104,15 @@ float clitk::PixelTypeDownCast(const double & x)
 }
 //------------------------------------------------------------------
 
+//------------------------------------------------------------------
+// Convert a pixel type without casting
+template<>
+double clitk::PixelTypeDownCast(const double & x)
+{
+  return x;
+}
+//------------------------------------------------------------------
+
 //------------------------------------------------------------------
 double clitk::rad2deg(const double anglerad)
 {
index 2f5b26f1173b3e5e94999816031695c13cb2afc4..94d1c607b6049e7d353e1209a4e31b6ba39b5d77 100644 (file)
@@ -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
@@ -34,7 +34,7 @@
 #include <fstream>
 
 // Include for "rusage"
-#include <ctime> 
+#include <ctime>
 #if defined(unix) || defined(__APPLE__)
 #  include <sys/time.h>
 #  include <sys/resource.h>
@@ -51,7 +51,7 @@ namespace clitk {
   typedef unsigned char uchar;
   typedef unsigned short ushort;
   typedef unsigned int uint;
-  
+
 #define CLITK_TRY_CATCH_EXIT(func) \
   try { \
     func; \
@@ -68,13 +68,13 @@ namespace clitk {
     std::cout << "Unknown excpetion" << std::endl; \
     exit(-3); \
   }
-    
+
 
   //--------------------------------------------------------------------
   // when everything goes wrong
 #define WHEREAMI "[ " << __FILE__  << " ] line " << __LINE__
-#define FATAL(a) std::cerr << "ERROR in " << WHEREAMI << ": " << a; exit(0);
-  
+#define FATAL(a) { std::cerr << "ERROR in " << WHEREAMI << ": " << a; exit(0); }
+
   //--------------------------------------------------------------------
   // GGO with modified struct name
 #define GGO(ggo_filename, args_info)                                    \
@@ -82,7 +82,7 @@ namespace clitk {
   cmdline_parser_##ggo_filename##2(argc, argv, &args_info, 1, 1, 0);                   \
   if (args_info.config_given)                                          \
     cmdline_parser_##ggo_filename##_configfile (args_info.config_arg, &args_info, 0, 0, 1); \
-  else cmdline_parser_##ggo_filename(argc, argv, &args_info);  
+  else cmdline_parser_##ggo_filename(argc, argv, &args_info);
 
   //--------------------------------------------------------------------
   // skip line with #
@@ -95,15 +95,15 @@ namespace clitk {
   //--------------------------------------------------------------------
   // Return filename extension
   std::string GetExtension(const std::string& filename);
-  
+
   //--------------------------------------------------------------------
   // Convert float, double ... to string
   template<class T> std::string toString(const T & t);
   template<class T> std::string toStringVector(const T * t, const int n);
   template<class T> std::string toStringVector(const T & t, const int n);
   template<class T> std::string toStringVector(const std::vector<T> & t);
-  template <class T> bool fromString(T& t, 
-                                     const std::string& s, 
+  template <class T> bool fromString(T& t,
+                                     const std::string& s,
                                      std::ios_base& (*f)(std::ios_base&)=std::dec);
 
   //--------------------------------------------------------------------
@@ -117,6 +117,8 @@ namespace clitk {
   TPixelDown PixelTypeDownCast(const TPixelUp & x);
   template<>
   float PixelTypeDownCast(const double & x);
+  template<>
+  double PixelTypeDownCast(const double & x);
 
   //--------------------------------------------------------------------
   // Return the indexes of sorted values in a vector
@@ -129,7 +131,7 @@ namespace clitk {
   // Return the name of a type as a string
   template<class TPixel>
   std::string GetTypeAsString();
-  
+
   //--------------------------------------------------------------------
   // Convert radian / degree
   double rad2deg(double anglerad);
@@ -152,13 +154,13 @@ namespace clitk {
   std::string CreateListOfTypes(bool last=true) {
     return GetTypeAsString<T1>();
   }
-  
+
   template<class T1, class T2>
   std::string CreateListOfTypes(bool last=true) {
     if (last) return CreateListOfTypes<T1>()+" and "+CreateListOfTypes<T2>();
     else return CreateListOfTypes<T1>()+", "+CreateListOfTypes<T2>();
   }
-  
+
   template<class T1, class T2, class T3>
   std::string CreateListOfTypes(bool last=true) {
     if (last) return CreateListOfTypes<T1,T2>(false)+" and "+CreateListOfTypes<T3>();
@@ -195,7 +197,7 @@ namespace clitk {
     else return CreateListOfTypes<T1,T2,T3,T4,T5,T6,T7>(false)+", "+CreateListOfTypes<T8>();
   }
   //--------------------------------------------------------------------
-  
+
   //--------------------------------------------------------------------
   void FindAndReplace(std::string & line, const std::string & tofind, const std::string & replacement);
   void FindAndReplace(std::string & line, const std::vector<std::string> & tofind, const std::vector<std::string> & toreplace);
@@ -203,8 +205,8 @@ namespace clitk {
   //--------------------------------------------------------------------
 
   //--------------------------------------------------------------------
-  double ComputeEuclideanDistanceFromPointToPlane(const itk::ContinuousIndex<double, 3> point, 
-                                                 const itk::ContinuousIndex<double, 3> pointInPlane, 
+  double ComputeEuclideanDistanceFromPointToPlane(const itk::ContinuousIndex<double, 3> point,
+                                                 const itk::ContinuousIndex<double, 3> pointInPlane,
                                                  const itk::ContinuousIndex<double, 3> normalPlane);
 
   //--------------------------------------------------------------------
@@ -232,9 +234,9 @@ namespace clitk {
 
   //--------------------------------------------------------------------
   // Convert a map to a vector
-  template <typename M, typename V> 
+  template <typename M, typename V>
   void MapToVecFirst(const M & m, V & v);
-  template <typename M, typename V> 
+  template <typename M, typename V>
   void MapToVecSecond(const M & m, V & v);
 
   //--------------------------------------------------------------------
@@ -247,4 +249,3 @@ namespace clitk {
 } // end namespace
 
 #endif /* end #define CLITKCOMMON_H */
-
index fe04c5dafb821b312681c6f1ddff5cb1bf184392..13491f7f3722ab41d905b7b5ae8e419466ab85fb 100644 (file)
@@ -61,7 +61,7 @@ namespace clitk {
 
     ImageTypesManager(FilterType * f) { mFilter = f;  }
     virtual void DoIt(int dim, int ncomp, std::string pixelname) {
-      // std::cout << "ImageTypesManager DoIt " << dim << " " << pixelname << std::endl;
+      //std::cout << "ImageTypesManager DoIt " << dim << " " << pixelname << std::endl;
       if (mMapOfImageTypeToFunction[dim][ncomp][pixelname])
         mMapOfImageTypeToFunction[dim][ncomp][pixelname]->Execute();
     }
index 97ba4437b07e5f5207faf55bfee180ac63f1cd2b..c5a999629358e06be28d4f6232f047d8dc4f909c 100644 (file)
@@ -38,6 +38,6 @@
   template<class T>
     void _print_container(T const& a)
     { for(typename T::const_iterator i=a.begin();i!=a.end();++i) { std::cout << *i << " "; };}
-#define DDS(a) { std::cout << #a " = [ "; _print_container(a) ; std::cout << " ]" << std::endl;std::cout.flush():}
+#define DDS(a) { std::cout << #a " = [ "; _print_container(a) ; std::cout << " ]" << std::endl;std::cout.flush();}
 
 #endif
index ad90bef4d56220dfff44e3f7dda190c75a0f9e87..fcc9e2be26da9c02cfdcb1a94f10e5ff67874745 100644 (file)
@@ -25,6 +25,7 @@
 #include "clitkImageCommon.h"
 
 // vtk
+#include <vtkVersion.h>
 #include <vtkPolyDataToImageStencil.h>
 #include <vtkSmartPointer.h>
 #include <vtkImageStencil.h>
@@ -199,20 +200,30 @@ void clitk::DicomRTStruct2ImageFilter::Update()
 
   // Create new output image
   mBinaryImage = vtkSmartPointer<vtkImageData>::New();
+#if VTK_MAJOR_VERSION <= 5
   mBinaryImage->SetScalarTypeToUnsignedChar();
+#endif
   mBinaryImage->SetOrigin(&origin[0]);
   mBinaryImage->SetSpacing(&mSpacing[0]);
   mBinaryImage->SetExtent(0, extend[0],
                           0, extend[1],
                           0, extend[2]);
+#if VTK_MAJOR_VERSION <= 5
   mBinaryImage->AllocateScalars();
+#else
+  mBinaryImage->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
+#endif
 
   memset(mBinaryImage->GetScalarPointer(), 0,
          mBinaryImage->GetDimensions()[0]*mBinaryImage->GetDimensions()[1]*mBinaryImage->GetDimensions()[2]*sizeof(unsigned char));
 
   // Extrude
   vtkSmartPointer<vtkLinearExtrusionFilter> extrude=vtkSmartPointer<vtkLinearExtrusionFilter>::New();
+#if VTK_MAJOR_VERSION <= 5
   extrude->SetInput(mesh);
+#else
+  extrude->SetInputData(mesh);
+#endif
   ///We extrude in the -slice_spacing direction to respect the FOCAL convention (NEEDED !)
   extrude->SetVector(0, 0, -mSpacing[2]);
 
@@ -222,12 +233,24 @@ void clitk::DicomRTStruct2ImageFilter::Update()
   //http://www.nabble.com/Bug-in-vtkPolyDataToImageStencil--td23368312.html#a23370933
   sts->SetTolerance(0);
   sts->SetInformationInput(mBinaryImage);
+#if VTK_MAJOR_VERSION <= 5
   sts->SetInput(extrude->GetOutput());
+#else
+  sts->SetInputConnection(extrude->GetOutputPort(0));
+#endif
   //sts->SetInput(mesh);
 
   vtkSmartPointer<vtkImageStencil> stencil=vtkSmartPointer<vtkImageStencil>::New();
+#if VTK_MAJOR_VERSION <= 5
   stencil->SetStencil(sts->GetOutput());
+#else
+  stencil->SetStencilConnection(sts->GetOutputPort(0));
+#endif
+#if VTK_MAJOR_VERSION <= 5
   stencil->SetInput(mBinaryImage);
+#else
+  stencil->SetInputData(mBinaryImage);
+#endif
   stencil->ReverseStencilOn();
   stencil->Update();
 
index 8f6045ae1e2b7100524464a6ee85c1faccde2a94..0df00dd46fcfca8a0bf86647487b26156b462eaf 100644 (file)
@@ -18,7 +18,7 @@
   =========================================================================*/
 
 #ifndef CLITKDICOMRTSTRUCT2IMAGEFILTER_H
-#define CLITKDICOMRT_TRUCT2IMAGEFILTER_H
+#define CLITKDICOMRTSTRUCT2IMAGEFILTER_H
 
 #include "clitkDicomRT_ROI.h"
 #include "clitkImageCommon.h"
index 1fd9fe1f1c6b806bd0f08be65c15d32d47a42f7f..b6af9c321d5d2a2921cc3e65b352d872b16cde48 100644 (file)
@@ -23,6 +23,7 @@
 #include <vtkImageClip.h>
 #include <vtkMarchingSquares.h>
 #include <vtkPolyDataWriter.h>
+#include <vtkVersion.h>
 
 #if GDCM_MAJOR_VERSION == 2
 #include "gdcmAttribute.h"
@@ -72,6 +73,14 @@ int clitk::DicomRT_ROI::GetROINumber() const
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+void clitk::DicomRT_ROI::SetROINumber(int number)
+{
+  mNumber = number;
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 const std::string & clitk::DicomRT_ROI::GetName() const
 {
@@ -142,7 +151,7 @@ double clitk::DicomRT_ROI::GetForegroundValueLabelImage() const
 #if GDCM_MAJOR_VERSION == 2
 bool clitk::DicomRT_ROI::Read(gdcm::Item * itemInfo, gdcm::Item * itemContour)
 {
-  FATAL("Error : compile vv with itk4 + external gdcm");
+  //FATAL("Error : compile vv with itk4 + external gdcm");
   // Keep dicom item
   mItemInfo = itemInfo;
   mItemContour = itemContour;
@@ -276,7 +285,11 @@ void clitk::DicomRT_ROI::ComputeMeshFromContour()
 {
   vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
   for(unsigned int i=0; i<mListOfContours.size(); i++) {
-    append->AddInput(mListOfContours[i]->GetMesh());
+#if VTK_MAJOR_VERSION <= 5
+       append->AddInput(mListOfContours[i]->GetMesh());
+#else
+       append->AddInputData(mListOfContours[i]->GetMesh());
+#endif
   }
   append->Update();
  
@@ -394,7 +407,12 @@ void clitk::DicomRT_ROI::ComputeContoursFromImage()
   
   // Get initial extend for the clipping
   vtkSmartPointer<vtkImageClip> clipper = vtkSmartPointer<vtkImageClip>::New();
+#if VTK_MAJOR_VERSION <= 5
   clipper->SetInput(image);
+#else
+  clipper->SetInputData(image);
+#endif
+  
   int* extent = image->GetExtent();
   DDV(extent, 6);
   //  std::vector<int> extend;
@@ -414,7 +432,11 @@ void clitk::DicomRT_ROI::ComputeContoursFromImage()
 
 
     vtkSmartPointer<vtkMarchingSquares> squares = vtkSmartPointer<vtkMarchingSquares>::New();
+#if VTK_MAJOR_VERSION <= 5
     squares->SetInput(image);
+#else
+    squares->SetInputData(image);
+#endif
     squares->SetImageRange(extent[0], extent[1], extent[2], extent[3], i, i);
     squares->SetValue(1, 1.0);
     squares->Update();
@@ -446,7 +468,11 @@ void clitk::DicomRT_ROI::ComputeContoursFromImage()
  
   vtkSmartPointer<vtkAppendPolyData> append = vtkSmartPointer<vtkAppendPolyData>::New();
   for(unsigned int i=0; i<n; i++) {
+#if VTK_MAJOR_VERSION <= 5
     append->AddInput(contours[i]);
+#else
+    append->AddInputData(contours[i]);
+#endif
   }
   append->Update();
  
@@ -455,7 +481,11 @@ void clitk::DicomRT_ROI::ComputeContoursFromImage()
   
   // Write vtk
   vtkPolyDataWriter * w = vtkPolyDataWriter::New();
+#if VTK_MAJOR_VERSION <= 5
   w->SetInput(mMesh);
+#else
+  w->SetInputData(mMesh);
+#endif
   w->SetFileName("toto.vtk");
   w->Write();
 
index 31d9db4d44849c2586fdbd30ab1be190cdd2fe53..80cbacc03c2ed00c13a3605cd30df9adba5244ca 100644 (file)
@@ -47,6 +47,7 @@ public:
         std::string filename);
 
   int GetROINumber() const;
+  void SetROINumber(int);
   const std::string & GetName() const;
   const std::string & GetFilename() const;
   const std::vector<double> & GetDisplayColor() const;
index 4945693f8694beaf84dd6ac39ef047dfaf9b12db..9fa96b39f2a55c0e25f9b0e97bfd64dca2718a8a 100644 (file)
@@ -311,66 +311,51 @@ void clitk::DicomRT_StructureSet::Write(const std::string & filename)
 //--------------------------------------------------------------------
 void clitk::DicomRT_StructureSet::Read(const std::string & filename)
 {
-#if CLITK_USE_SYSTEM_GDCM == 1
-  vtkSmartPointer<vtkGDCMPolyDataReader> reader = vtkGDCMPolyDataReader::New();
-  reader->SetFileName(filename.c_str());
-  reader->Update();
-  
-  // Get global information
-  vtkRTStructSetProperties * p = reader->GetRTStructSetProperties();  
-  mStudyID   = p->GetStudyInstanceUID();
-  mStudyDate = p->GetStructureSetDate();
-  mLabel     = p->GetStructureSetLabel();
-  mName      = p->GetStructureSetName();
-  mTime      = p->GetStructureSetTime();
-
-  int n = p->GetNumberOfStructureSetROIs();
-  for(unsigned int i=0; i<n; i++) {
-    // Get the roi number
-    int roinumber = p->GetStructureSetROINumber(i);
-    // Create the roi
-    DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
-    roi->Read(reader, i);
-    // Insert in the map
-    mROIs[roinumber] = roi;
-  }
-  return;
-#endif // END version with system gdcm (vtkGDCMPolyDataReader)
-
 
-  // Open DICOM
-#if GDCM_MAJOR_VERSION == 2
-  FATAL("Error : compile vv with itk4 + external gdcm");
-
-  // Read gdcm file
-  mReader = new gdcm::Reader;
-  mReader->SetFileName(filename.c_str());
-  mReader->Read();
-  mFile = &(mReader->GetFile());
-  const gdcm::DataSet & ds = mFile->GetDataSet();
+//Try to avoid to use extern GDCM library
+    
+  //check the RS file is available before conversion
+  gdcm::Reader RTreader;
+  RTreader.SetFileName( filename.c_str() );
+  if( !RTreader.Read() ) 
+  {
+    std::cout << "Problem reading file: " << filename << std::endl;
+    return;
+  }
+  
+  const gdcm::DataSet& ds = RTreader.GetFile().GetDataSet();
   
-  // Check file type
-  //Verify if the file is a RT-Structure-Set dicom file
   gdcm::MediaStorage ms;
-  ms.SetFromFile(*mFile);
-  if( ms != gdcm::MediaStorage::RTStructureSetStorage )
-    {
-    std::cerr << "Error. the file " << filename
-              << " is not a Dicom Struct ? (must have a SOP Class UID [0008|0016] = 1.2.840.10008.5.1.4.1.1.481.3 ==> [RT Structure Set Storage])"
-              << std::endl;
-    exit(0);
-    }
+  ms.SetFromFile( RTreader.GetFile() );
+    
+  // (3006,0020) SQ (Sequence with explicit length #=4)      # 370, 1 StructureSetROISequence  
+  gdcm::Tag tssroisq(0x3006,0x0020);
+  if( !ds.FindDataElement( tssroisq ) )
+  {
+    std::cout << "Problem locating 0x3006,0x0020 - Is this a valid RT Struct file?" << std::endl;
+    return;
+  }
+  gdcm::Tag troicsq(0x3006,0x0039);
+  if( !ds.FindDataElement( troicsq ) )
+  {
+    std::cout << "Problem locating 0x3006,0x0039 - Is this a valid RT Struct file?" << std::endl;
+    return;
+  }
 
-  gdcm::Attribute<0x8,0x60> modality;
-  modality.SetFromDataSet( ds );
-  if( modality.GetValue() != "RTSTRUCT" )
-    {
-    std::cerr << "Error. the file " << filename
-              << " is not a Dicom Struct ? (must have 0x0008,0x0060 = RTSTRUCT [RT Structure Set Storage])"
-              << std::endl;
-    exit(0);
-    }
+  const gdcm::DataElement &roicsq = ds.GetDataElement( troicsq );
 
+  gdcm::SmartPointer<gdcm::SequenceOfItems> sqi = roicsq.GetValueAsSQ();
+  if( !sqi || !sqi->GetNumberOfItems() )
+  {
+    return;
+  }
+  const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq );
+  gdcm::SmartPointer<gdcm::SequenceOfItems> ssqi = ssroisq.GetValueAsSQ();
+  if( !ssqi || !ssqi->GetNumberOfItems() )
+  {
+    return;
+  }
+  
   // Read global info
   gdcm::Attribute<0x20,0x10> studyid;
   studyid.SetFromDataSet( ds );
@@ -395,22 +380,13 @@ void clitk::DicomRT_StructureSet::Read(const std::string & filename)
   // Temporary store the list of items
   std::map<int, gdcm::Item*> mMapOfROIInfo;
   std::map<int, gdcm::Item*> mMapOfROIContours;
-std::map<int, clitk::DicomRT_ROI::Pointer> mROIs;
-  std::map<int, std::string> mMapOfROIName;
-#if GDCM_MAJOR_VERSION == 2
-  gdcm::Reader * mReader;
-  gdcm::SmartPointer<gdcm::SequenceOfItems> mROIInfoSequenceOfItems;
-  gdcm::SmartPointer<gdcm::SequenceOfItems> mROIContoursSequenceOfItems;  
-#endif
-  gdcm::File * mFile;
-
+  
 
   //----------------------------------
   // Read all ROI Names and number
   // 0x3006,0x0020 = [ Structure Set ROI Sequence ]
-  gdcm::Tag tssroisq(0x3006,0x0020);
-  const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq );
+  //gdcm::Tag tssroisq(0x3006,0x0020);
+  //const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq );
   mROIInfoSequenceOfItems = ssroisq.GetValueAsSQ();
   gdcm::SmartPointer<gdcm::SequenceOfItems> & roi_seq = mROIInfoSequenceOfItems;
   assert(roi_seq); // TODO error message
@@ -441,8 +417,8 @@ std::map<int, clitk::DicomRT_ROI::Pointer> mROIs;
   //----------------------------------
   // Read all ROI item
   // 0x3006,0x0039 = [ ROI Contour Sequence ]
-  gdcm::Tag troicsq(0x3006,0x0039);
-  const gdcm::DataElement &roicsq = ds.GetDataElement( troicsq );
+  //gdcm::Tag troicsq(0x3006,0x0039);
+  //const gdcm::DataElement &roicsq = ds.GetDataElement( troicsq );
   gdcm::SmartPointer<gdcm::SequenceOfItems> roi_contour_seq = roicsq.GetValueAsSQ();
   mROIContoursSequenceOfItems = roi_contour_seq;
   assert(roi_contour_seq); // TODO error message
@@ -462,82 +438,12 @@ std::map<int, clitk::DicomRT_ROI::Pointer> mROIs;
   for(std::map<int, gdcm::Item*>::iterator i = mMapOfROIInfo.begin(); i != mMapOfROIInfo.end(); i++) {
     int nb = i->first;//ReadROINumber(i);//mROIIndex[i];
     // Create the roi
-    DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
-    roi->Read(mMapOfROIInfo[nb], mMapOfROIContours[nb]);
-    //    mListOfROI.push_back(roi);
-    //    mMapOfROIIndex[nb] = i;
-    mROIs[nb] = roi;
-  }
-
-  //----------------------------------------------------------------------------------------
-  //----------------------------------------------------------------------------------------
-  //----------------------------------------------------------------------------------------
-#else
-  mFile = new gdcm::File;
-  mFile->SetFileName(filename.c_str());
-  mFile->SetMaxSizeLoadEntry(16384); // Needed ...
-  mFile->SetLoadMode(gdcm::LD_NOSHADOW); // don't load shadow tags (in order to save memory)
-  mFile->Load();
-  
-  // Check file type
-  //Verify if the file is a RT-Structure-Set dicom file
-  if (!gdcm::Util::DicomStringEqual(mFile->GetEntryValue(0x0008,0x0016),"1.2.840.10008.5.1.4.1.1.481.3")) {  //SOP clas UID
-    std::cerr << "Error. the file " << filename
-              << " is not a Dicom Struct ? (must have a SOP Class UID [0008|0016] = 1.2.840.10008.5.1.4.1.1.481.3 ==> [RT Structure Set Storage])"
-              << std::endl;
-    exit(0);
-  }
-  if (!gdcm::Util::DicomStringEqual(mFile->GetEntryValue(0x0008,0x0060),"RTSTRUCT")) {  //SOP clas UID
-    std::cerr << "Error. the file " << filename
-              << " is not a Dicom Struct ? (must have 0x0008,0x0060 = RTSTRUCT [RT Structure Set Storage])"
-              << std::endl;
-    exit(0);
-  }
-
-  // Read global info
-  mStudyID   = mFile->GetValEntry(0x0020,0x0010)->GetValue();
-  mStudyTime = mFile->GetValEntry(0x008,0x0020)->GetValue();
-  mStudyDate = mFile->GetValEntry(0x008,0x0030)->GetValue();
-  mLabel     = mFile->GetValEntry(0x3006,0x002)->GetValue();
-  if (!mFile->GetValEntry(0x3006,0x004)) {
-    mName = "Anonymous";
-  }
-  else {
-    mName = mFile->GetValEntry(0x3006,0x004)->GetValue();
-  }
-  mTime      = mFile->GetValEntry(0x3006,0x009)->GetValue();
-
-  //----------------------------------
-  // Read all ROI Names and number
-  // 0x3006,0x0020 = [ Structure Set ROI Sequence ]
-  gdcm::SeqEntry * roi_seq=mFile->GetSeqEntry(0x3006,0x0020);
-  assert(roi_seq); // TODO error message
-  for (gdcm::SQItem* r=roi_seq->GetFirstSQItem(); r!=0; r=roi_seq->GetNextSQItem()) {
-    std::string name = r->GetEntryValue(0x3006,0x0026);      // 0x3006,0x0026 = [ROI Name]
-    int nb = atoi(r->GetEntryValue(0x3006,0x0022).c_str());  // 0x3006,0x0022 = [ROI Number]
-    // Check if such a number already exist
-    if (mMapOfROIName.find(nb) != mMapOfROIName.end()) {
-      std::cerr << "WARNING. A Roi already exist with the number "
-                << nb << ". I replace." << std::endl;
-    }
-    // Add in map
-    mMapOfROIName[nb] = name;
-  }
-
-  //----------------------------------
-  // Read all ROI
-  // 0x3006,0x0039 = [ ROI Contour Sequence ]
-  gdcm::SeqEntry * roi_contour_seq=mFile->GetSeqEntry(0x3006,0x0039);
-  assert(roi_contour_seq); // TODO error message
-  int n=0;
-  for (gdcm::SQItem* r=roi_contour_seq->GetFirstSQItem(); r!=0; r=roi_contour_seq->GetNextSQItem()) {
-    DicomRT_ROI::Pointer roi = DicomRT_ROI::New();
-    roi->Read(mMapOfROIName, r);
-    mROIs[roi->GetROINumber()] = roi;
-    n++;
+    mROIs[nb] = DicomRT_ROI::New();
+    mROIs[nb]->Read(mMapOfROIInfo[nb], mMapOfROIContours[nb]);
   }
+    
+  return;
 
-#endif
 }
 //--------------------------------------------------------------------
 
index 738181fd6b9595f0951f6ff7bdf213436701b5c2..bc333caef5d48d4c3f681a1cc0788ef5e394579b 100644 (file)
@@ -66,88 +66,80 @@ GetValuesFromValue(const std::string & s,
 //-------------------------------------------------------------------
 template<unsigned int Dimension>
 typename itk::Matrix<double, Dimension+1, Dimension+1>
-createMatrixFromElastixFile(std::vector<std::string> & filename, bool verbose=true) {
+createMatrixFromElastixFile(std::string& filename, bool verbose=true) {
   if (Dimension != 3) {
     FATAL("Only 3D yet" << std::endl);
   }
-  typename itk::Matrix<double, Dimension+1, Dimension+1> matrix;
+  typename itk::Matrix<double, Dimension+1, Dimension+1> matrix, init;
 
   itk::Euler3DTransform<double>::Pointer mat = itk::Euler3DTransform<double>::New();
   itk::Euler3DTransform<double>::Pointer previous;
-  for(uint j=0; j<filename.size(); j++) {
-
-    // Open file
-    if (verbose) std::cout << "Read elastix parameters in " << filename[j] << std::endl;
-    std::ifstream is;
-    clitk::openFileForReading(is, filename[j]);
-
-    // Check Transform
-    std::string s;
-    bool b = GetElastixValueFromTag(is, "Transform ", s);
-    if (!b) {
-      FATAL("Error must read 'Transform' in " << filename[j] << std::endl);
-    }
-    if (s != "EulerTransform") {
-      FATAL("Sorry only 'EulerTransform'" << std::endl);
-    }
 
-    // FIXME check
-    //    (InitialTransformParametersFilename[j] "NoInitialTransform")
+  // Open file
+  if (verbose) std::cout << "Read elastix parameters in " << filename << std::endl;
+  std::ifstream is;
+  clitk::openFileForReading(is, filename);
 
-    // Get CenterOfRotationPoint
-    GetElastixValueFromTag(is, "CenterOfRotationPoint ", s); // space is needed
-    if (!b) {
-      FATAL("Error must read 'CenterOfRotationPoint' in " << filename[j] << std::endl);
-    }
-    std::vector<std::string> cor;
-    GetValuesFromValue(s, cor);
-    itk::Euler3DTransform<double>::CenterType c;
-    for(uint i=0; i<3; i++)
-      c[i] = atof(cor[i].c_str());
-    mat->SetCenter(c);
-
-    // Get Transformparameters
-    GetElastixValueFromTag(is, "ComputeZYX ", s); // space is needed
-    mat->SetComputeZYX( s==std::string("true") );
-
-    // Get Transformparameters
-    GetElastixValueFromTag(is, "TransformParameters ", s); // space is needed
-    if (!b) {
-      FATAL("Error must read 'TransformParameters' in " << filename[j] << std::endl);
-    }
-    std::vector<std::string> results;
-    GetValuesFromValue(s, results);
-
-    // construct a stream from the string
-    itk::Euler3DTransform<double>::ParametersType p;
-    p.SetSize(6);
-    for(uint i=0; i<3; i++)
-      p[i] = atof(results[i].c_str()); // Rotation
-    for(uint i=0; i<3; i++)
-      p[i+3] = atof(results[i+3].c_str()); // Translation
-    mat->SetParameters(p);
-
-    if (verbose) {
-      std::cout << "Rotation      (deg) : " << rad2deg(p[0]) << " " << rad2deg(p[1]) << " " << rad2deg(p[2]) << std::endl;
-      std::cout << "Center of rot (phy) : " << c[0] << " " << c[1] << " " << c[2] << std::endl;
-      std::cout << "Translation   (phy) : " << p[3] << " " << p[4] << " " << p[5] << std::endl;
-    }
+  // Check Transform
+  std::string s;
+  bool b = GetElastixValueFromTag(is, "Transform ", s);
+  if (!b) {
+    FATAL("Error must read 'Transform' in " << filename << std::endl);
+  }
+  if (s != "EulerTransform") {
+    FATAL("Sorry only 'EulerTransform'" << std::endl);
+  }
 
-    // Compose with previous if needed
-    if (j!=0) {
-      mat->Compose(previous);
-      if (verbose) {
-        std::cout << "Composed rotation      (deg) : " << rad2deg(mat->GetAngleX()) << " " << rad2deg(mat->GetAngleY()) << " " << rad2deg(mat->GetAngleZ()) << std::endl;
-        std::cout << "Composed center of rot (phy) : " << mat->GetCenter() << std::endl;
-        std::cout << "Compsoed translation   (phy) : " << mat->GetTranslation() << std::endl;
-      }
-    }
-    // previous = mat->Clone(); // ITK4
-    previous = itk::Euler3DTransform<double>::New();
-    previous->SetParameters(mat->GetParameters());
-    previous->SetCenter(c);
-    previous->SetComputeZYX(mat->GetComputeZYX());
+  // Get previous
+  b = GetElastixValueFromTag(is, "InitialTransformParametersFileName ", s);
+  if(s == "NoInitialTransform")
+    init.SetIdentity();
+  else
+    init = createMatrixFromElastixFile<Dimension>(s, verbose);
+
+  // Get CenterOfRotationPoint
+  GetElastixValueFromTag(is, "CenterOfRotationPoint ", s); // space is needed
+  if (!b) {
+    FATAL("Error must read 'CenterOfRotationPoint' in " << filename << std::endl);
+  }
+  std::vector<std::string> cor;
+  GetValuesFromValue(s, cor);
+  itk::Euler3DTransform<double>::CenterType c;
+  for(uint i=0; i<3; i++)
+    c[i] = atof(cor[i].c_str());
+  mat->SetCenter(c);
+
+  // Get Transformparameters
+  GetElastixValueFromTag(is, "ComputeZYX ", s); // space is needed
+  mat->SetComputeZYX( s==std::string("true") );
+
+  // Get Transformparameters
+  GetElastixValueFromTag(is, "TransformParameters ", s); // space is needed
+  if (!b) {
+    FATAL("Error must read 'TransformParameters' in " << filename << std::endl);
   }
+  std::vector<std::string> results;
+  GetValuesFromValue(s, results);
+
+  // construct a stream from the string
+  itk::Euler3DTransform<double>::ParametersType p;
+  p.SetSize(6);
+  for(uint i=0; i<3; i++)
+    p[i] = atof(results[i].c_str()); // Rotation
+  for(uint i=0; i<3; i++)
+    p[i+3] = atof(results[i+3].c_str()); // Translation
+  mat->SetParameters(p);
+
+  if (verbose) {
+    std::cout << "Rotation      (deg) : " << rad2deg(p[0]) << " " << rad2deg(p[1]) << " " << rad2deg(p[2]) << std::endl;
+    std::cout << "Center of rot (phy) : " << c[0] << " " << c[1] << " " << c[2] << std::endl;
+    std::cout << "Translation   (phy) : " << p[3] << " " << p[4] << " " << p[5] << std::endl;
+  }
+
+  previous = itk::Euler3DTransform<double>::New();
+  previous->SetParameters(mat->GetParameters());
+  previous->SetCenter(c);
+  previous->SetComputeZYX(mat->GetComputeZYX());
 
   mat = previous;
   for(uint i=0; i<3; i++)
@@ -159,7 +151,7 @@ createMatrixFromElastixFile(std::vector<std::string> & filename, bool verbose=tr
   matrix[2][3] = mat->GetOffset()[2];
   matrix[3][3] = 1;
 
-  return matrix;
+  return matrix*init;
 }
 }
 //-------------------------------------------------------------------
index 7403f37fe0a041fa6a1b0ea85c696b65e1a302f7..1019b7b76aa49f9b28e8796151a2e60c7c89672b 100644 (file)
@@ -42,7 +42,10 @@ namespace clitk {
     typedef FilterBase  Self;
     
     // Run-time type information (and related methods)
-    itkTypeMacro(FilterBase, Object);
+    virtual const char *GetNameOfClass() const
+      {
+      return "FilterBase";
+      }
 
     // Needed by itkSetMacro (cannot inherit from itkObject because of
     // multiple inheritance)
index 5c5977baa4fb7326da551a662a1ab44c1cf35459..9f3fa11a34b6f02934ea0dc89c3d9ef32650ca0b 100644 (file)
   #include "clitkUSVoxImageIOFactory.h"
   #include "clitkSvlImageIOFactory.h"
 #endif
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkGDCMImageIOFactory.h"
-#endif
+#include <itkBMPImageIOFactory.h>
+#include <itkGDCMImageIOFactory.h>
+#include <itkGiplImageIOFactory.h>
+#include <itkJPEGImageIOFactory.h>
+#include <itkMetaImageIOFactory.h>
+#include <itkPNGImageIOFactory.h>
+#include <itkStimulateImageIOFactory.h>
+#include <itkTIFFImageIOFactory.h>
+#include <itkVTKImageIOFactory.h>
 
 //--------------------------------------------------------------------
 // Register factories
 void clitk::RegisterClitkFactories()
 {
-#if ITK_VERSION_MAJOR >= 4
   std::list< itk::ObjectFactoryBase * > fl = itk::GDCMImageIOFactory::GetRegisteredFactories();
   for (std::list< itk::ObjectFactoryBase * >::iterator it = fl.begin(); it != fl.end(); ++it)
     if (dynamic_cast<itk::GDCMImageIOFactory *>(*it))
@@ -59,7 +64,14 @@ void clitk::RegisterClitkFactories()
       itk::GDCMImageIOFactory::UnRegisterFactory(*it);
       break;
     }
-#endif
+
+  std::list< itk::ObjectFactoryBase * > flpng = itk::PNGImageIOFactory::GetRegisteredFactories();
+  for (std::list< itk::ObjectFactoryBase * >::iterator it = flpng.begin(); it != flpng.end(); ++it)
+    if (dynamic_cast<itk::PNGImageIOFactory *>(*it))
+    {
+      itk::PNGImageIOFactory::UnRegisterFactory(*it);
+      break;
+    }
 #if CLITK_PRIVATE_FEATURES
   clitk::UsfImageIOFactory::RegisterOneFactory();
   clitk::USVoxImageIOFactory::RegisterOneFactory();
@@ -67,9 +79,6 @@ void clitk::RegisterClitkFactories()
 #endif
   clitk::GateAsciiImageIOFactory::RegisterOneFactory();
   clitk::DicomRTDoseIOFactory::RegisterOneFactory();
-#if ITK_VERSION_MAJOR <= 3
-  itk::ImageIOFactory::RegisterBuiltInFactories();
-#endif
   clitk::VoxImageIOFactory::RegisterOneFactory();
   clitk::VfImageIOFactory::RegisterOneFactory();
   clitk::XdrImageIOFactory::RegisterOneFactory();
@@ -79,8 +88,14 @@ void clitk::RegisterClitkFactories()
   rtk::ImagXImageIOFactory::RegisterOneFactory();
   rtk::XRadImageIOFactory::RegisterOneFactory();
   clitk::EsrfHstImageIOFactory::RegisterOneFactory();
-#if ITK_VERSION_MAJOR >= 4
+  itk::BMPImageIOFactory::RegisterOneFactory();
   itk::GDCMImageIOFactory::RegisterOneFactory();
-#endif
+  itk::GiplImageIOFactory::RegisterOneFactory();
+  itk::JPEGImageIOFactory::RegisterOneFactory();
+  itk::MetaImageIOFactory::RegisterOneFactory();
+  itk::PNGImageIOFactory::RegisterOneFactory();
+  itk::StimulateImageIOFactory::RegisterOneFactory();
+  itk::TIFFImageIOFactory::RegisterOneFactory();
+  itk::VTKImageIOFactory::RegisterOneFactory();
 } ////
 
index b6a74b2fe7829ff7fb59b7cce19b0c343f0427a1..9455eabb8ba3a65fb74c1879ac6679c34bf371b0 100644 (file)
@@ -2,7 +2,7 @@
   Program:         vv http://www.creatis.insa-lyon.fr/rio/vv
   Main authors :   XX XX XX
 
-  Authors belongs to: 
+  Authors belongs 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
@@ -31,7 +31,7 @@ namespace clitk {
   //--------------------------------------------------------------------
   template<class PixelType>
   class Image2DicomRTStructFilter: public clitk::FilterBase {
-    
+
   public:
     Image2DicomRTStructFilter();
     ~Image2DicomRTStructFilter();
@@ -41,17 +41,24 @@ namespace clitk {
     typedef typename clitk::DicomRT_StructureSet::Pointer DicomRTStructPointer;
 
     // Set inputs
-    itkSetMacro(InputFilenames, std::vector<std::string> );
+    virtual void SetInputFilenames (const std::vector<std::string> _arg)
+    {
+      if ( this->m_InputFilenames != _arg )
+      {
+        this->m_InputFilenames = _arg;
+        this->Modified();
+      }
+    }
     itkSetMacro(StructureSetFilename, std::string);
     itkSetMacro(DicomFolder, std::string);
     itkSetMacro(OutputFilename, std::string);
     void SetROIType(std::string type);
     itkSetMacro(ThresholdValue, PixelType);
     itkSetMacro(SkipInitialStructuresFlag, bool);
-    
+
     // Run filter
-    void Update();    
-    
+    void Update();
+
   protected:
     std::string m_StructureSetFilename;
     std::string m_DicomFolder;
index 77c5e07044f1684b502021b8196c13ec15c5c975..9ebde04d0c878cd8dac885da978c7e9ea332af67 100644 (file)
@@ -52,6 +52,8 @@
 #include <itkVTKImageToImageFilter.h>
 
 // gdcm
+#include <vtkRTStructSetProperties.h>
+#include <vtkGDCMPolyDataReader.h>
 #include <vtkGDCMPolyDataWriter.h>
 
 //--------------------------------------------------------------------
@@ -178,7 +180,11 @@ void clitk::Image2DicomRTStructFilter<PixelType>::Update()
     
   // Copy previous contours
   for (unsigned int i = 0; i < numMasks-m; ++i) {
+#if VTK_MAJOR_VERSION <= 5
     writer->SetInput(i, reader->GetOutput(i));
+#else
+    writer->SetInputData(i, reader->GetOutput(i));
+#endif
     std::string theString = reader->GetRTStructSetProperties()->GetStructureSetROIName(i);
     roiNames->InsertValue(i, theString);
     theString = reader->GetRTStructSetProperties()->GetStructureSetROIGenerationAlgorithm(i);
@@ -189,7 +195,11 @@ void clitk::Image2DicomRTStructFilter<PixelType>::Update()
 
   // Add new ones
   for (unsigned int i = numMasks-m; i < numMasks; ++i) {
+#if VTK_MAJOR_VERSION <= 5
     writer->SetInput(i, meshes[i-numMasks+m]);
+#else
+    writer->SetInputData(i, meshes[i-numMasks+m]);
+#endif
     roiNames->InsertValue(i, m_ROINames[i-numMasks+m]);
     roiAlgorithms->InsertValue(i, "CLITK_CREATED");
     roiTypes->InsertValue(i, m_ROIType);
index 40298452e5430218a3952fbf30a88398d17dc5f3..83b9435854ef3f7bec71e764ccee787ba314e0f9 100644 (file)
@@ -101,11 +101,11 @@ void clitk::printImageHeader(itk::ImageIOBase::Pointer header, std::ostream & os
     for(unsigned int i=0; i< dim-1; i++)
       os << inputSize[i] << "x";
     os << inputSize[dim-1]
-       << "  ";
+       << " ";
     for(unsigned int i=0; i< dim-1; i++)
       os << inputSpacing[i] << "x";
     os << inputSpacing[dim-1]
-       << "  ";
+       << " ";
     for(unsigned int i=0; i< dim-1; i++)
       os << inputOrigin[i] << "x";
     os << inputOrigin[dim-1] << " ";
index c911f55b0f452d4e6e5b8df0af3ab1dfd0869878..2c09f311dd523416720c3496e890de46eaf1397b 100644 (file)
@@ -17,6 +17,7 @@
 ===========================================================================**/
 
 #include "clitkMatrix.h"
+#include <algorithm>
 
 //--------------------------------------------------------------------
 namespace clitk {
index 1e497ea6d372d2aad2a56ab46e2452910ac1c73a..25b0fa1c52598c354060ce0aa813c8fdde3c97d1 100644 (file)
@@ -20,6 +20,7 @@
 #define clitkMatrix_h
 
 #include <itkMatrix.h>
+#define VTK_EXCLUDE_STRSTREAM_HEADERS
 #include <vtkMatrix4x4.h>
 #include <vtkSmartPointer.h>
 
index cd74428832f4505df7edd11028b359030ab064c5..329ca13f04272d44104a3f0926e54e3b0e5b0aa8 100644 (file)
@@ -64,13 +64,15 @@ void clitk::Timer::Stop(bool accumulate)
     mElapsed += (mEnd.ru_utime.tv_usec - mBegin.ru_utime.tv_usec)+
                 (mEnd.ru_utime.tv_sec - mBegin.ru_utime.tv_sec)*1000000;
   }
+  else
 #elif defined(_WIN32)
   QueryPerformanceCounter((LARGE_INTEGER*)&mEnd);
   if (accumulate) {
     mElapsed += ((mEnd-mBegin)*1000000)/(long double)mFrequency;
   }
+  else
 #endif
-  else {
+  {
     mNumberOfCall--;
   }
 }
@@ -114,4 +116,3 @@ void clitk::Timer::Reset()
 
 // #endif // If UNIX
 #endif /* end #define CLITKTIMER_CXX */
-
index fc75976b7feff9dfd92ed58e2f6008b1a0d7d709..6eae6a595f529f45a76286370010b25710a30a61 100644 (file)
@@ -41,7 +41,7 @@
 //From portdefs.h
 #if defined(unix) || defined(__APPLE__)
 #define O_BINARY 0
-#define setmode(a,b) 0
+//#define setmode(a,b) 0 // comment by ds
 #endif
 
 #ifndef __LARGE__
@@ -100,8 +100,8 @@ void clitk::XdrImageIO::Write(const void* buffer)
 #ifndef _WIN32
 #  include <unistd.h>
 #endif
-#if !defined(unix) && !defined(__APPLE__)
-#include <io.h>
+#ifdef _WIN32
+#  include <io.h>
 #endif
 #include <fcntl.h>
 #include <errno.h>
@@ -957,7 +957,7 @@ void clitk::XdrImageIO::WriteImage(const char* file, char* headerinfo, char* hea
 
   for (i=0; i<GetNumberOfDimensions(); i++) {
     if (!raw) {
-      sprintf(temp, "dim%d=%d\n", i+1, GetDimensions(i));
+      sprintf(temp, "dim%d=%lu\n", i+1, GetDimensions(i));
       slen = strlen(temp);
       if (!checked_write(f, temp, slen, buffer)) {
         free(pCompressed);
index ed3cf10c0c82d5acf43fdd49cf36426c06d4ad8b..48acefbb961a2fd3b46af1a464771d033eb5dbdb 100644 (file)
@@ -128,7 +128,7 @@ void rtk::EdfImageIO::ReadImageInformation()
                                 << "\"");
       }
     datalen = edf_datatype_table[k].sajzof;
-    switch(k) {
+    switch(edf_datatype_table[k].value) {
       case U_CHAR_DATATYPE:
         SetComponentType(itk::ImageIOBase::UCHAR);
         break;
@@ -148,10 +148,10 @@ void rtk::EdfImageIO::ReadImageInformation()
         SetComponentType(itk::ImageIOBase::INT);
         break;
       case U_L_INT_DATATYPE:
-        SetComponentType(itk::ImageIOBase::ULONG);
+        SetComponentType(itk::ImageIOBase::UINT);
         break;
       case L_INT_DATATYPE:
-        SetComponentType(itk::ImageIOBase::LONG);
+        SetComponentType(itk::ImageIOBase::INT);
         break;
       case FLOAT_DATATYPE:
         SetComponentType(itk::ImageIOBase::FLOAT);
@@ -203,7 +203,12 @@ void rtk::EdfImageIO::ReadImageInformation()
 
   double spacing = 1.;
   if ( (p = edf_findInHeader(header, "optic_used") ) )
+    {
     spacing = atof(p);
+    if(spacing == 0.)
+      spacing = 1.;
+    }
+
 
   free(header);
   gzclose(inp);
@@ -259,8 +264,8 @@ void rtk::EdfImageIO::Read(void * buffer)
     else if itkReadRawBytesAfterSwappingMacro( unsigned char, UCHAR )
     else if itkReadRawBytesAfterSwappingMacro( unsigned int, UINT )
     else if itkReadRawBytesAfterSwappingMacro( int, INT )
-    else if itkReadRawBytesAfterSwappingMacro( unsigned int, ULONG )
-    else if itkReadRawBytesAfterSwappingMacro( int, LONG )
+    else if itkReadRawBytesAfterSwappingMacro( unsigned int, UINT )
+    else if itkReadRawBytesAfterSwappingMacro( int, INT )
     else if itkReadRawBytesAfterSwappingMacro( float, FLOAT )
     else if itkReadRawBytesAfterSwappingMacro( double, DOUBLE );
     }
@@ -268,19 +273,19 @@ void rtk::EdfImageIO::Read(void * buffer)
 
 //--------------------------------------------------------------------
 // Write Image Information
-void rtk::EdfImageIO::WriteImageInformation(bool keepOfStream)
+void rtk::EdfImageIO::WriteImageInformation( bool itkNotUsed(keepOfStream) )
 {
 }
 
 //--------------------------------------------------------------------
 // Write Image Information
-bool rtk::EdfImageIO::CanWriteFile(const char* FileNameToWrite)
+bool rtk::EdfImageIO::CanWriteFile( const char* itkNotUsed(FileNameToWrite) )
 {
   return false;
 }
 
 //--------------------------------------------------------------------
 // Write Image
-void rtk::EdfImageIO::Write(const void * buffer)
+void rtk::EdfImageIO::Write( const void * itkNotUsed(buffer) )
 {
 } ////
index e86501433884ce92ade5d956a109755f5284f1b7..83823cb427030353c13479815a8eb1935aed640f 100644 (file)
@@ -86,9 +86,9 @@ protected:
     };
 
   /* Note - compatibility:
-    Unsigned8 = 1,     Signed8,        Unsigned16,     Signed16,
-    Unsigned32,        Signed32,       Unsigned64,     Signed64,
-    FloatIEEE32,       DoubleIEEE64
+    Unsigned8 = 1,Signed8,  Unsigned16, Signed16,
+    Unsigned32,   Signed32, Unsigned64, Signed64,
+    FloatIEEE32,  DoubleIEEE64
   */
 
   /***************************************************************************
@@ -138,8 +138,8 @@ protected:
   // * of the matrix in the data file.)
   // */
   //enum EdfRasterAxes {
-  //    RASTER_AXES_XrightYdown,       // matricial format: rows, columns
-  //    RASTER_AXES_XrightYup  // cartesian coordinate system
+  //RASTER_AXES_XrightYdown, // matricial format: rows, columns
+  //RASTER_AXES_XrightYup    // cartesian coordinate system
   //    // other 6 combinations not available (not needed until now)
   //};
 
index 6f9aa227c96b4c406c1adad2f236ba91a7b1f22c..af0cc585ad79dcc5735eb7c9b3efefa23ac280e9 100644 (file)
@@ -128,66 +128,13 @@ void rtk::HisImageIO::Read(void * buffer)
 }
 
 //--------------------------------------------------------------------
-bool rtk::HisImageIO::CanWriteFile(const char* FileNameToWrite)
+bool rtk::HisImageIO::CanWriteFile( const char* itkNotUsed(FileNameToWrite) )
 {
-  return CanReadFile(FileNameToWrite);
+  return false;
 }
 
 //--------------------------------------------------------------------
 // Write Image
-void rtk::HisImageIO::Write(const void* buffer)
+void rtk::HisImageIO::Write( const void* itkNotUsed(buffer) )
 {
-  std::ofstream file(m_FileName.c_str(), std::ios::out | std::ios::binary);
-
-  if ( file.fail() )
-    itkGenericExceptionMacro(<< "Could not open file (for writing): " << m_FileName);
-
-  m_HeaderSize = HEADER_INFO_SIZE + 32;
-  char szHeader[HEADER_INFO_SIZE + 32] = {
-    0x00, 0x70, 0x44, 0x00, 0x64, 0x00, 0x64, 0x00, 0x20, 0x00, 0x20, 0x00, 0x01, 0x00, 0x01, 0x00,
-    0x00, 0x04, 0x00, 0x04, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6A, 0x18, 0x41,
-    0x04, 0x00, 0x40, 0x5F, 0x48, 0x01, 0x40, 0x00, 0x86, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x08, 0x63, 0x13, 0x00, 0xE8, 0x51, 0x13, 0x00, 0x5C, 0xE7, 0x12, 0x00,
-    0xFE, 0x2A, 0x49, 0x5F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-    0x00, 0x00, 0x00, 0x00
-    };
-
-  /* Fill into the header the essentials
-     The 'iheader' in previous module is fixed to 0x20, and is included in szHeader.
-     The 'ulx' and 'uly' are fixed to 0x01, so that 'brx' and 'bry' reflect the dimensions of
-     the image.
-  */
-  const unsigned int ndim = GetNumberOfDimensions();
-  if ( (ndim < 2) || (ndim > 3) )
-    itkExceptionMacro( <<"Only 2D or 3D support");
-
-  szHeader[16] = (char)(GetDimensions(0) % 256);  // X-size    lsb
-  szHeader[17] = (char)(GetDimensions(0) / 256);  // X-size    msb
-  szHeader[18] = (char)(GetDimensions(1) % 256);  // Y-size    lsb
-  szHeader[19] = (char)(GetDimensions(1) / 256);  // Y-size    msb
-  if (ndim == 3) {
-    szHeader[20] = (char)(GetDimensions(0) % 256);  // NbFrames    lsb
-    szHeader[21] = (char)(GetDimensions(0) / 256);  // NbFrames    msb
-    }
-
-  switch (GetComponentType())
-    {
-    case itk::ImageIOBase::USHORT:
-      szHeader[32] = 4;
-      break;
-    //case AVS_TYPE_INTEGER:
-    //  szHeader[32] = 8;
-    //  break;
-    //case AVS_TYPE_REAL:
-    //  szHeader[32] = 16;
-    //  break;
-    default:
-      itkExceptionMacro(<< "Unsupported field type");
-      break;
-    }
-
-  file.write(szHeader, m_HeaderSize);
-  file.write( (const char *)buffer, GetImageSizeInBytes() );
-  file.close();
 } ////
index 4791fd7920a56386435ae34accab7f578ace8631..61152b0844f96445ea4aa28af0468e114815aa73 100644 (file)
@@ -133,16 +133,16 @@ void rtk::HndImageIO::Read(void * buffer)
 {
   FILE *fp;
 
-  itk::uint32_t*      buf = (itk::uint32_t*)buffer;
+  itk::uint32_t *buf = (itk::uint32_t*)buffer;
   unsigned char *pt_lut;
-  itk::uint32_t       a;
+  itk::uint32_t  a;
   unsigned char  v;
   int            lut_idx, lut_off;
   size_t         num_read;
   char           dc;
   short          ds;
   long           dl, diff=0;
-  itk::uint32_t       i;
+  itk::uint32_t  i;
 
   fp = fopen (m_FileName.c_str(), "rb");
   if (fp == NULL)
index d197ed7d122c9a702befd5b0fd33bac2cd14a8fc..09cb910558dc9e9eabedfb81be6c23b0bee42bef 100644 (file)
@@ -57,7 +57,7 @@ void rtk::ImagXImageIO::ReadImageInformation()
   if(pixelType=="Type_float")
     SetComponentType(itk::ImageIOBase::FLOAT);
 
-  if(dic["dimensions"].GetPointer()==NULL)
+  if( dic["dimensions"].GetPointer() == NULL )
     SetNumberOfDimensions(3);
   else
     SetNumberOfDimensions( ( dynamic_cast<MetaDataIntType *>(dic["dimensions"].GetPointer() )->GetMetaDataObjectValue() ) );
@@ -73,15 +73,22 @@ void rtk::ImagXImageIO::ReadImageInformation()
     {
     SetDimensions(2, dynamic_cast<MetaDataIntType *>(dic["z"].GetPointer() )->GetMetaDataObjectValue() );
     SetSpacing(2, dynamic_cast<MetaDataDoubleType *>(dic["spacing_z"].GetPointer() )->GetMetaDataObjectValue() );
+    if(GetSpacing(2) == 0)
+      SetSpacing(2, 1);
     }
 
-  std::istringstream iss(
-    dynamic_cast<MetaDataStringType*>(dic["matrixTransform"].GetPointer() )->GetMetaDataObjectValue() );
   itk::Matrix<double, 4, 4> matrix;
-  for(unsigned int j=0; j<4; j++)
-    for(unsigned int i=0; i<4; i++)
-      iss >> matrix[j][i];
-  matrix /= matrix[3][3];
+  if(dic["matrixTransform"].GetPointer() == NULL)
+    matrix.SetIdentity();
+  else
+    {
+    std::istringstream iss(
+      dynamic_cast<MetaDataStringType*>(dic["matrixTransform"].GetPointer() )->GetMetaDataObjectValue() );
+    for(unsigned int j=0; j<4; j++)
+      for(unsigned int i=0; i<4; i++)
+        iss >> matrix[j][i];
+    matrix /= matrix[3][3];
+    }
 
   std::vector<double> direction;
   for(unsigned int i=0; i<GetNumberOfDimensions(); i++)
@@ -173,20 +180,19 @@ void rtk::ImagXImageIO::Read(void * buffer)
 
 //--------------------------------------------------------------------
 // Write Image Information
-void rtk::ImagXImageIO::WriteImageInformation(bool keepOfStream)
+void rtk::ImagXImageIO::WriteImageInformation( bool itkNotUsed(keepOfStream) )
 {
 }
 
 //--------------------------------------------------------------------
 // Write Image Information
-bool rtk::ImagXImageIO::CanWriteFile(const char* FileNameToWrite)
+bool rtk::ImagXImageIO::CanWriteFile( const char* itkNotUsed(FileNameToWrite) )
 {
   return false;
 }
 
 //--------------------------------------------------------------------
 // Write Image
-void rtk::ImagXImageIO::Write(const void * buffer)
+void rtk::ImagXImageIO::Write( const void * itkNotUsed(buffer) )
 {
 } ////
-
index 8188b04908e44608d45d4f3ccc8fafe2db9cb99f..bbdc6a855ca6ca0f7b88bab08d505ec00449322d 100644 (file)
@@ -69,4 +69,3 @@ protected:
 } // end namespace
 
 #endif
-
index 47520a963bf020660edda6e169985628e73b33b2..fd6fcc0b39e2c90d0b5aeac69242b78e320f847b 100644 (file)
@@ -27,4 +27,3 @@ rtk::ImagXImageIOFactory::ImagXImageIOFactory()
                          1,
                          itk::CreateObjectFunction<ImagXImageIO>::New() );
 }
-
index 5170d45719356466302e7c4dff5e4bebc5cd2921..2466e9d9607bbf7bd18ebb19840341115edcc925 100644 (file)
@@ -54,7 +54,7 @@ public:
   itkFactorylessNewMacro(Self);
 
   /** Run-time type information (and related methods). */
-  itkTypeMacro(EsrfHstImageIOFactory, ObjectFactoryBase);
+  itkTypeMacro(ImagXImageIOFactory, ObjectFactoryBase);
 
   /** Register one factory of this type  */
   static void RegisterOneFactory(void) {
@@ -75,4 +75,3 @@ private:
 } // end namespace
 
 #endif
-
diff --git a/common/rtkImagXLookupTableImageFilter.h b/common/rtkImagXLookupTableImageFilter.h
deleted file mode 100644 (file)
index c6271cc..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*=========================================================================
- *
- *  Copyright RTK Consortium
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0.txt
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *=========================================================================*/
-
-#ifndef __rtkImagXLookupTableImageFilter_h
-#define __rtkImagXLookupTableImageFilter_h
-
-#include "rtkLookupTableImageFilter.h"
-#include <itkNumericTraits.h>
-
-namespace rtk
-{
-
-/** \class ImagXLookupTableImageFilter
- * \brief Lookup table for ImagX data.
- *
- * The lookup table converts the raw values measured by the panel to the
- * logarithm of the value divided by the maximum numerical value. This could
- * be improved with a calibration of the air value.
- *
- * \author Simon Rit
- *
- * \ingroup ImageToImageFilter
- */
-template <class TInputImage, class TOutputImage>
-class ITK_EXPORT ImagXLookupTableImageFilter : public LookupTableImageFilter<TInputImage, TOutputImage>
-{
-
-public:
-  /** Standard class typedefs. */
-  typedef ImagXLookupTableImageFilter                       Self;
-  typedef LookupTableImageFilter<TInputImage, TOutputImage> Superclass;
-  typedef itk::SmartPointer<Self>                           Pointer;
-  typedef itk::SmartPointer<const Self>                     ConstPointer;
-
-  typedef typename TInputImage::PixelType                   InputImagePixelType;
-  typedef typename TOutputImage::PixelType                  OutputImagePixelType;
-  typedef typename Superclass::FunctorType::LookupTableType LookupTableType;
-
-  /** Method for creation through the object factory. */
-  itkNewMacro(Self);
-
-  /** Runtime information support. */
-  itkTypeMacro(ImagXLookupTableImageFilter, LookupTableImageFilter);
-protected:
-  ImagXLookupTableImageFilter();
-  virtual ~ImagXLookupTableImageFilter() {
-  }
-
-private:
-  ImagXLookupTableImageFilter(const Self&); //purposely not implemented
-  void operator=(const Self&);              //purposely not implemented
-
-};
-
-} // end namespace rtk
-
-template <class TInputImage, class TOutputImage>
-rtk::ImagXLookupTableImageFilter<TInputImage, TOutputImage>::ImagXLookupTableImageFilter()
-{
-  // Create the lut
-  typename LookupTableType::Pointer lut = LookupTableType::New();
-  typename LookupTableType::SizeType size;
-  size[0] = itk::NumericTraits<InputImagePixelType>::max()-itk::NumericTraits<InputImagePixelType>::min()+1;
-  lut->SetRegions( size );
-  lut->Allocate();
-
-  OutputImagePixelType logRef = log(OutputImagePixelType(size[0]) );
-
-  // Iterate and set lut
-  itk::ImageRegionIteratorWithIndex<LookupTableType> it( lut, lut->GetBufferedRegion() );
-  it.GoToBegin();
-  while( !it.IsAtEnd() )
-    {
-    it.Set( logRef - log(it.GetIndex()[0]+1.) );
-    ++it;
-    }
-
-  // Set the lut to member and functor
-  this->SetLookupTable(lut);
-}
-
-#endif
diff --git a/common/rtkImagXRawToAttenuationImageFilter.h b/common/rtkImagXRawToAttenuationImageFilter.h
deleted file mode 100644 (file)
index 6ee663a..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*=========================================================================
- *
- *  Copyright RTK Consortium
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0.txt
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *=========================================================================*/
-
-#ifndef __rtkImagXRawToAttenuationImageFilter_h
-#define __rtkImagXRawToAttenuationImageFilter_h
-
-#include <itkImageToImageFilter.h>
-#include <itkCropImageFilter.h>
-
-#include "rtkImagXLookupTableImageFilter.h"
-#include "rtkBoellaardScatterCorrectionImageFilter.h"
-
-/** \class ImagXRawToAttenuationImageFilter
- * \brief Convert raw ImagX data to attenuation images
- *
- * TODO
- *
- * \author Simon Rit
- *
- * \ingroup ImageToImageFilter
- */
-namespace rtk
-{
-
-template<class TInputImage, class TOutputImage=TInputImage>
-class ITK_EXPORT ImagXRawToAttenuationImageFilter :
-  public itk::ImageToImageFilter<TInputImage, TOutputImage>
-{
-public:
-  /** Standard class typedefs. */
-  typedef ImagXRawToAttenuationImageFilter                   Self;
-  typedef itk::ImageToImageFilter<TInputImage, TOutputImage> Superclass;
-  typedef itk::SmartPointer<Self>                            Pointer;
-  typedef itk::SmartPointer<const Self>                      ConstPointer;
-
-  /** Some convenient typedefs. */
-  typedef TInputImage  InputImageType;
-  typedef TOutputImage OutputImageType;
-
-  /** Standard New method. */
-  itkNewMacro(Self);
-
-  /** Runtime information support. */
-  itkTypeMacro(ImagXRawToAttenuationImageFilter, itk::ImageToImageFilter);
-protected:
-  ImagXRawToAttenuationImageFilter();
-  ~ImagXRawToAttenuationImageFilter(){
-  }
-
-  /** Apply changes to the input image requested region. */
-  virtual void GenerateInputRequestedRegion();
-
-  void GenerateOutputInformation();
-
-  /** Single-threaded version of GenerateData.  This filter delegates
-   * to other filters. */
-  void GenerateData();
-
-private:
-  //purposely not implemented
-  ImagXRawToAttenuationImageFilter(const Self&);
-  void operator=(const Self&);
-
-  typedef itk::CropImageFilter<InputImageType, InputImageType>                       CropFilterType;
-  typedef rtk::BoellaardScatterCorrectionImageFilter<InputImageType, InputImageType> ScatterFilterType;
-  typedef rtk::ImagXLookupTableImageFilter<InputImageType, OutputImageType>          LookupTableFilterType;
-
-  typename LookupTableFilterType::Pointer m_LookupTableFilter;
-  typename CropFilterType::Pointer        m_CropFilter;
-  typename ScatterFilterType::Pointer     m_ScatterFilter;
-}; // end of class
-
-} // end namespace rtk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "rtkImagXRawToAttenuationImageFilter.txx"
-#endif
-
-#endif
diff --git a/common/rtkImagXRawToAttenuationImageFilter.txx b/common/rtkImagXRawToAttenuationImageFilter.txx
deleted file mode 100644 (file)
index 5e02cee..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*=========================================================================
- *
- *  Copyright RTK Consortium
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- *
- *         http://www.apache.org/licenses/LICENSE-2.0.txt
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- *=========================================================================*/
-
-#ifndef __rtkImagXRawToAttenuationImageFilter_txx
-#define __rtkImagXRawToAttenuationImageFilter_txx
-
-#include <itkImageFileWriter.h>
-
-namespace rtk
-{
-
-template<class TInputImage, class TOutputImage>
-void
-ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
-::GenerateInputRequestedRegion()
-{
-  typename Superclass::InputImagePointer inputPtr =
-    const_cast< TInputImage * >( this->GetInput() );
-  if ( !inputPtr )
-    return;
-
-  m_CropFilter->SetInput(inputPtr); //SR: this is most likely useless
-  m_LookupTableFilter->GetOutput()->SetRequestedRegion(this->GetOutput()->GetRequestedRegion() );
-  m_LookupTableFilter->GetOutput()->PropagateRequestedRegion();
-}
-
-template <class TInputImage, class TOutputImage>
-ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
-::ImagXRawToAttenuationImageFilter()
-{
-  m_CropFilter = CropFilterType::New();
-  m_ScatterFilter = ScatterFilterType::New();
-  m_LookupTableFilter = LookupTableFilterType::New();
-
-  //Permanent internal connections
-  m_ScatterFilter->SetInput( m_CropFilter->GetOutput() );
-  m_LookupTableFilter->SetInput( m_ScatterFilter->GetOutput() );
-
-  //Default filter parameters
-  typename CropFilterType::SizeType border = m_CropFilter->GetLowerBoundaryCropSize();
-  border[0] = 4;
-  border[1] = 4;
-  m_CropFilter->SetBoundaryCropSize(border);
-}
-
-template<class TInputImage, class TOutputImage>
-void
-ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
-::GenerateOutputInformation()
-{
-  m_CropFilter->SetInput(this->GetInput() );
-  m_LookupTableFilter->UpdateOutputInformation();
-  this->GetOutput()->SetOrigin( m_LookupTableFilter->GetOutput()->GetOrigin() );
-  this->GetOutput()->SetSpacing( m_LookupTableFilter->GetOutput()->GetSpacing() );
-  this->GetOutput()->SetDirection( m_LookupTableFilter->GetOutput()->GetDirection() );
-  this->GetOutput()->SetLargestPossibleRegion( m_LookupTableFilter->GetOutput()->GetLargestPossibleRegion() );
-}
-
-template<class TInputImage, class TOutputImage>
-void
-ImagXRawToAttenuationImageFilter<TInputImage, TOutputImage>
-::GenerateData()
-{
-  m_CropFilter->SetInput(this->GetInput() );
-  m_LookupTableFilter->Update();
-  this->GraftOutput( m_LookupTableFilter->GetOutput() );
-}
-
-} // end namespace rtk
-#endif
index f415f0dfd65dc7894a4b2a2981fbfae7622af886..551dee1d861c7c90c528a05ae81c69f2aaf3b369 100644 (file)
@@ -94,7 +94,7 @@ StartElement(const char * name, const char ** atts)
 
 void
 ImagXXMLFileReader::
-EndElement(const char *name)
+EndElement( const char *itkNotUsed(name) )
 {
 }
 
index db5eb72fe6861c24c22759f155e1ae12d749a81b..fb02952016ed37ce421de70ea8dd312694974167 100644 (file)
@@ -37,13 +37,13 @@ void rtk::XRadImageIO::ReadImageInformation()
     {
     std::string line;
     std::getline(is, line);
-    if(line.find('[')!=std::string::npos)
+    if(line.find('[') != std::string::npos)
       {
       unsigned int pos1 = line.find('[');
       unsigned int pos2 = line.find(']');
       section = line.substr(pos1+1, pos2-pos1-1);
       }
-    if(line.find('=')!=std::string::npos)
+    if(line.find('=') != std::string::npos)
       {
       unsigned int pos       = line.find('=');
       std::string paramName  = line.substr(0,pos);
@@ -57,9 +57,9 @@ void rtk::XRadImageIO::ReadImageInformation()
         SetDimensions(2, atoi(paramValue.c_str()));
       else if(paramName == std::string("CBCT.DimensionalAttributes.DataSize"))
         {
-        if(atoi(paramValue.c_str())==3)
+        if(atoi(paramValue.c_str()) == 3)
           SetComponentType(itk::ImageIOBase::FLOAT);
-        if(atoi(paramValue.c_str())==6)
+        if(atoi(paramValue.c_str()) == 6)
           SetComponentType(itk::ImageIOBase::USHORT);
         }
       else if(paramName == std::string("CBCT.DimensionalAttributes.PixelDimension_I_cm"))
@@ -143,19 +143,19 @@ void rtk::XRadImageIO::Read(void * buffer)
 
 //--------------------------------------------------------------------
 // Write Image Information
-void rtk::XRadImageIO::WriteImageInformation(bool keepOfStream)
+void rtk::XRadImageIO::WriteImageInformation(bool itkNotUsed(keepOfStream))
 {
 }
 
 //--------------------------------------------------------------------
 // Write Image Information
-bool rtk::XRadImageIO::CanWriteFile(const char* FileNameToWrite)
+bool rtk::XRadImageIO::CanWriteFile(const char* itkNotUsed(FileNameToWrite))
 {
   return false;
 }
 
 //--------------------------------------------------------------------
 // Write Image
-void rtk::XRadImageIO::Write(const void * buffer)
+void rtk::XRadImageIO::Write(const void * itkNotUsed(buffer))
 {
 } ////
index 30e1bfe6325c3205a6cb47dee118483ce8c120a0..a51cfe2d7c150caaf78f862b2ee0cda325d3e739 100644 (file)
@@ -51,13 +51,12 @@ static inline void ReadTimeSequence (vvImage::Pointer& vv_image, typename itk::I
     extractedRegion.SetIndex(start);
 
     typename FilterType::Pointer filter = FilterType::New();
-#if ITK_VERSION_MAJOR == 4
     filter->SetDirectionCollapseToSubmatrix();
-#endif
     filter->SetExtractionRegion(extractedRegion);
     filter->SetInput(input);
     filter->ReleaseDataFlagOn();
     vv_image->AddItkImage<ItkImageType>(filter->GetOutput());
+    vv_image->ComputeScalarRangeBase<PixelType, Dim-1>(filter->GetOutput());
   }
   vv_image->SetTimeSpacing(input->GetSpacing()[Dim-1]);
   vv_image->SetTimeOrigin(input->GetOrigin()[Dim-1]);
@@ -73,9 +72,10 @@ struct vvImageFromITK_Impl
 
     if (time_sequence) //The time sequence case: create a series of VTK images
       ReadTimeSequence<Dim,PixelType>(vv_image, input, time_sequence);
-    else //Dim == 1,2,3 and not time_sequence
+    else //Dim == 1,2,3 and not time_sequence
       vv_image->AddItkImage<InputImageType>(input);
-
+      vv_image->ComputeScalarRangeBase<PixelType, Dim>(input);
+    }
     return vv_image;
   }
 };
index 9842d4a7f2f64945580c53a6779b82957f561e55..47a0e3464bd1d6e995b8a3103bab742566a5459b 100644 (file)
 // vtk
 #include <vtkImageData.h>
 #include <vtkTransform.h>
+#include <vtkDataObject.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
+#include <vtkVersion.h>
 
 // std
 #include <cassert>
@@ -45,6 +49,8 @@ void vvImage::Init()
   mTimeSpacing = 1;
   mTimeOrigin = 0;
   mImageDimension = 0;
+  mrange[0] = std::numeric_limits<int>::max();;//min
+  mrange[1] = std::numeric_limits<int>::min();;//max
 }
 //--------------------------------------------------------------------
 
@@ -71,7 +77,11 @@ void vvImage::AddVtkImage(vtkImageData* input)
   // mItkToVtkConverters is therefore not being updated, but 
   // up to here it's not being used anyway...
   mImageDimension = 0;
+#if VTK_MAJOR_VERSION <= 5
   int* extent = input->GetWholeExtent();
+#else
+  int* extent = input->GetInformation()->Get(vtkDataObject::DATA_EXTENT());
+#endif
   if (extent[4] != extent[5])
     mImageDimension = 3;
   else if (extent[3] != extent[4])
@@ -107,15 +117,8 @@ int vvImage::GetNumberOfDimensions() const
 //--------------------------------------------------------------------
 void vvImage::GetScalarRange(double* range)
 {
-  assert(mVtkImages.size());
-  double * temp = mVtkImages[0]->GetScalarRange();
-  range[0]=temp[0];
-  range[1]=temp[1];
-  for (unsigned int i=1; i<mVtkImages.size(); i++) {
-    temp = mVtkImages[i]->GetScalarRange();
-    if (temp[0] < range[0]) range[0]=temp[0];
-    if (temp[1] > range[1]) range[1]=temp[1];
-  }
+  range[0]=mrange[0];
+  range[1]=mrange[1];
 }
 //--------------------------------------------------------------------
 
index 10ffc865fa2ed353605e4844abd6c456e5e678ee..d18ee9865303e217099ba4c40b5247c437ed66e7 100644 (file)
@@ -22,6 +22,8 @@
 #include <vector>
 #include <itkObjectFactory.h>
 #include <itkProcessObject.h>
+#include <itkMinimumMaximumImageCalculator.h>
+#include <itkCastImageFilter.h>
 
 #define VTK_EXCLUDE_STRSTREAM_HEADERS
 #include <vtkSmartPointer.h>
@@ -37,6 +39,10 @@ public :
   typedef itk::SmartPointer<Self> Pointer;
   typedef itk::ProcessObject::Pointer ConverterPointer;
   itkNewMacro(Self);
+  
+  struct DimensionDispatchBase {};
+  template< unsigned int VDimension >
+  struct DimensionDispatch:public DimensionDispatchBase {};
 
   void Init();
   void Reset();
@@ -47,6 +53,9 @@ public :
   int GetNumberOfDimensions() const;
   int GetNumberOfSpatialDimensions();
   void GetScalarRange(double* range);
+  template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRangeBase(itk::Image<TPixelType,VImageDimension> *input);
+  template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRange(DimensionDispatchBase, itk::Image<TPixelType,VImageDimension> *input);
+  template<class TPixelType, unsigned int VImageDimension> void ComputeScalarRange(DimensionDispatch< 1 >, itk::Image<TPixelType,VImageDimension> *input);
   unsigned long GetActualMemorySize();
   std::vector<double> GetSpacing();
   std::vector<double> GetOrigin() const;
@@ -77,6 +86,7 @@ private:
   double mTimeOrigin;
   double mTimeSpacing;
   unsigned int mImageDimension;
+  double mrange[2];
 };
 //------------------------------------------------------------------------------
 
index a6d37c8cbbd8f0447f69c990235fa0963afedb53..cc047bb1caf9c69bb187b52ab94311a14c81751f 100644 (file)
@@ -16,6 +16,7 @@
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================*/
 #include <itkImageToVTKImageFilter.h>
+#include <itkPixelTraits.h>
 
 //--------------------------------------------------------------------
 template<class TItkImageType>
@@ -24,7 +25,7 @@ void vvImage::AddItkImage(TItkImageType *input)
   // Update input before conversion to enable exceptions thrown by the ITK pipeline.
   // Otherwise, vtkImageImport catches the exception for us.
   input->Update();
-
+  
   // Convert from ITK object to VTK object
   mImageDimension = TItkImageType::ImageDimension;
   typedef itk::ImageToVTKImageFilter <TItkImageType> ConverterType;
@@ -40,11 +41,21 @@ void vvImage::AddItkImage(TItkImageType *input)
   matrix->Identity();
   for(unsigned int i=0; i<input->GetImageDimension(); i++) {
     for(unsigned int j=0; j<input->GetImageDimension(); j++) {
+#if VTK_MAJOR_VERSION <= 6
       (*matrix)[i][j] = input->GetDirection()[i][j];
       // Direction is used around the image origin in ITK
       (*matrix)[i][3] -= (*matrix)[i][j] * input->GetOrigin()[j];
+#else
+      (*matrix).SetElement(i, j, input->GetDirection()[i][j]);
+      // Direction is used around the image origin in ITK
+      (*matrix).SetElement(i, 3, (*matrix).GetElement(i,3) - (*matrix).GetElement(i,j) * input->GetOrigin()[j]);
+#endif
     }
+#if VTK_MAJOR_VERSION <= 6
     (*matrix)[i][3] += input->GetOrigin()[i];
+#else
+    (*matrix).SetElement(i, 3, (*matrix).GetElement(i,3) + input->GetOrigin()[i]);
+#endif
   }
 
   // GetDirection provides the forward transform, vtkImageReslice wants the inverse
@@ -56,4 +67,44 @@ void vvImage::AddItkImage(TItkImageType *input)
   mDictionary.push_back(&(input->GetMetaDataDictionary()));
 }
 //--------------------------------------------------------------------
+/** Dispatch the computation of scalar range between vector and scalar image */
+template<class TPixelType, unsigned int VImageDimension>
+void vvImage::ComputeScalarRangeBase(itk::Image<TPixelType,VImageDimension> *input)
+{ 
+ itkStaticConstMacro(Dimension1, unsigned int, itk::PixelTraits< TPixelType >::Dimension);
+ ComputeScalarRange(DimensionDispatch< Dimension1 >(), input);
+}
+
+//--------------------------------------------------------------------
+/** Compute the scalar range for a vector pixel type */
+/** TO DO*/
+template<class TPixelType, unsigned int VImageDimension>
+void vvImage::ComputeScalarRange(DimensionDispatchBase, itk::Image<TPixelType,VImageDimension> *input)
+{
+}
+
+//--------------------------------------------------------------------
+/** Compute the scalar range for a scalar pixel type */
+template<class TPixelType, unsigned int VImageDimension>
+void vvImage::ComputeScalarRange(DimensionDispatch< 1 >, itk::Image<TPixelType,VImageDimension> *input)
+{  
+  typedef typename itk::Image<TPixelType,VImageDimension> TItkImageType;
+  typedef itk::MinimumMaximumImageCalculator <TItkImageType> ImageCalculatorFilterType;
+  
+  typename ImageCalculatorFilterType::Pointer imageCalculatorFilter = ImageCalculatorFilterType::New ();
+  TPixelType tempMin, tempMax;
+  double tempRange[2];
+  imageCalculatorFilter->SetImage(input);
+  imageCalculatorFilter->Compute();
+  tempMin= imageCalculatorFilter->GetMinimum();
+  tempMax= imageCalculatorFilter->GetMaximum();
+
+  tempRange[0] = (double) tempMin;
+  tempRange[1] = (double) tempMax;
+
+  if (tempRange[0] < mrange[0]) mrange[0]=tempRange[0];
+  if (tempRange[1] > mrange[1]) mrange[1]=tempRange[1];
+}
+//--------------------------------------------------------------------
 
index 23c78f155dd9e4c51ddad251cf87c549e6d7b70c..2c094a8c3eda3cfb67e85acddafb9cceb1bf562c 100644 (file)
@@ -188,9 +188,7 @@ void vvImageReader::ReadMatImageTransform()
   f.open(filename.c_str());
   if(!itkMatRead && f.is_open()) {
     itkMatRead = true;
-    std::vector<std::string> l;
-    l.push_back(filename);
-    itkMat = clitk::createMatrixFromElastixFile<3>(l, true);
+    itkMat = clitk::createMatrixFromElastixFile<3>(filename, true);
   }
   f.close();
 
index 3ef04c6e0487f9b6bcec51e294e4f3075a6032e0..551e42626ba7313a84bb687f2fe8322c78d93962 100644 (file)
@@ -60,7 +60,7 @@ void vvImageReader::UpdateWithDim(std::string InputPixelType)
   else
     std::cerr << "Error, input pixel type : " << InputPixelType << " unknown !" << std::endl;
 
-  if (CLITK_EXPERIMENTAL && mLastError.size()==0) {
+  if (mLastError.size()==0) {
     //ReadNkiImageTransform();
     ReadMatImageTransform();
   }
@@ -86,6 +86,7 @@ void vvImageReader::UpdateWithDimAndInputPixelType()
       reader->SetFileName(*i);
       try {
         mImage->AddItkImage<InputImageType>(reader->GetOutput());
+        mImage->ComputeScalarRangeBase<InputPixelType, VImageDimension-1>(reader->GetOutput());
       } catch ( itk::ExceptionObject & err ) {
         std::cerr << "Error while reading " << mInputFilenames[0].c_str()
                   << " " << err << std::endl;
@@ -120,11 +121,10 @@ void vvImageReader::UpdateWithDimAndInputPixelType()
     filter->SetExtractionRegion(extractedRegion);
     filter->SetInput(reader->GetOutput());
     filter->ReleaseDataFlagOn();
-#if ITK_VERSION_MAJOR == 4
     filter->SetDirectionCollapseToSubmatrix();
-#endif
     try {
       mImage->AddItkImage<SlicedImageType>(filter->GetOutput());
+      mImage->ComputeScalarRangeBase<InputPixelType, VImageDimension-1>(filter->GetOutput());
     } catch ( itk::ExceptionObject & err ) {
       std::cerr << "Error while slicing " << mInputFilenames[0].c_str()
                 << "(slice #" << mSlice << ") " << err << std::endl;
index 11797e78d72ed449edddafc67d1873f7b2a1a3d1..183f260e0bee422f9a632a668f42fc6c91317274 100644 (file)
@@ -81,17 +81,10 @@ namespace itk
    *   This filter is implemented using the propagation algorithm
    */
 
-#if ITK_VERSION_MAJOR == 4
   template <class TInputImage, class TOutputImage, class TtNorm=Functor::Minimum<
                                                      typename TOutputImage::PixelType,
                                                      typename TOutputImage::PixelType,
                                                      typename TOutputImage::PixelType>  >
-#else
-  template <class TInputImage, class TOutputImage, class TtNorm=Function::Minimum<
-                                                     typename TOutputImage::PixelType,
-                                                     typename TOutputImage::PixelType,
-                                                     typename TOutputImage::PixelType>  >
-#endif
   class ITK_EXPORT RelativePositionPropImageFilter :
     public ImageToImageFilter< TInputImage, TOutputImage > 
   {
index a3759f49fa2f69606401d0d5289faaf96c70f3d3..c97ba0ea915b4aef1bfd79c3b5611906c9d1f1cc 100644 (file)
 #include <itkBinaryErodeImageFilter.h>
 #include <itkBinaryBallStructuringElement.h>
 #include <itkAddImageFilter.h>
-#if ITK_VERSION_MAJOR >= 4
-  #include <itkDivideImageFilter.h>
-#else
-  #include <itkDivideByConstantImageFilter.h>
-#endif
+#include <itkDivideImageFilter.h>
 
 // itk [Bloch et al] 
 #include "RelativePositionPropImageFilter.h"
@@ -414,15 +410,9 @@ GenerateData()
 
   // Divide by the number of relpos
   if (GetNumberOfAngles() != 1) {
-#if ITK_VERSION_MAJOR >= 4
     typedef itk::DivideImageFilter<FloatImageType, FloatImageType, FloatImageType> DivideFilter;
     typename DivideFilter::Pointer divideFilter = DivideFilter::New();
     divideFilter->SetConstant2(GetNumberOfAngles());
-#else
-    typedef itk::DivideByConstantImageFilter<FloatImageType, float, FloatImageType> DivideFilter;
-    typename DivideFilter::Pointer divideFilter = DivideFilter::New();
-    divideFilter->SetConstant(GetNumberOfAngles());
-#endif
     divideFilter->SetInput(m_FuzzyMap);
     divideFilter->Update();
     m_FuzzyMap = divideFilter->GetOutput();
index 689e67852d0bf3fd5bd93d32ff0493dbc6d42ab7..8ff8def40ec2cbf344ee7d4bd643d20d4f680623 100644 (file)
@@ -242,12 +242,7 @@ namespace clitk
     void BeforeThreadedGenerateData(void );
   
     // Threaded Generate Data
-#if ITK_VERSION_MAJOR >= 4
     void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId );
-#else
-    void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId );
-#endif
-
  
     //------------------------------------------------
     //Member data
index b1f84e260426db6becc2a0261be699742ee759da..f98129145b95fcbc31c794f89618881df80f5cf7 100644 (file)
@@ -302,12 +302,7 @@ namespace clitk
   //-----------------------------------------------------------------------
   template <class InputImageType, class OutputImageType>
   void 
-  BackProjectImageFilter<InputImageType, OutputImageType>
-#if ITK_VERSION_MAJOR >= 4
-  ::ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread,  itk::ThreadIdType threadId )
-#else
-  ::ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread,  int threadId )
-#endif
+  BackProjectImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData( const OutputImageRegionType & outputRegionForThread,  itk::ThreadIdType threadId )
   {
     //Projection pointer
     InputImageConstPointer inputPtr=this->GetInput();
index e2b2198bedd2d7c8e5f4bb5526065f4c3ec5610e..f0d041638e5c50a26de43f18e8f28cbc8a9dabfd 100644 (file)
@@ -17,7 +17,7 @@
   ======================================================================-====*/
 
 #ifndef CLITKBINARYIMAGETOMESHFILTER_H
-#define CLITKMESHTOBINARYIMAGEFILTER_H
+#define CLITKBINARYIMAGETOMESHFILTER_H
 
 // clitk
 #include "clitkCommon.h"
index 8a14edc7f193d2c2125a7c0a87d4605b54f6e7a6..b242dcf81d744ae675762389bdb45594b63edcc3 100644 (file)
@@ -43,7 +43,11 @@ Update()
   
   // Get extend
   vtkSmartPointer<vtkImageClip> clipper = vtkSmartPointer<vtkImageClip>::New();
+#if VTK_MAJOR_VERSION <= 5
   clipper->SetInput(input_vtk);
+#else
+  clipper->SetInputData(input_vtk);
+#endif
   int* extent = input_vtk->GetExtent();
 
   // Loop on slices
@@ -52,7 +56,11 @@ Update()
   // std::vector<vtkSmartPointer<vtkPolyData> > contours;
   for(uint i=0; i<n; i++) {
     vtkSmartPointer<vtkMarchingSquares> squares = vtkSmartPointer<vtkMarchingSquares>::New();
+#if VTK_MAJOR_VERSION <= 5
     squares->SetInput(input_vtk);
+#else
+    squares->SetInputData(input_vtk);
+#endif
     squares->SetImageRange(extent[0], extent[1], extent[2], extent[3], i, i);
     squares->SetNumberOfContours(1);
     squares->SetValue(0, m_ThresholdValue);
@@ -61,7 +69,11 @@ Update()
 
     // Strip (needed)
     vtkSmartPointer<vtkStripper> vs = vtkSmartPointer<vtkStripper>::New();
+#if VTK_MAJOR_VERSION <= 5
     vs->SetInput(squares->GetOutput());
+#else
+    vs->SetInputData(squares->GetOutput());
+#endif
     vs->Update();
     m = vs->GetOutput();
 
@@ -76,7 +88,11 @@ Update()
 
     // only add if lines>0
     if (m->GetNumberOfLines() > 0) {
+#if VTK_MAJOR_VERSION <= 5
       append->AddInput(m);//contours[i]);
+#else
+      append->AddInputData(m);//contours[i]);
+#endif
     }
   }
   append->Update();
index cf1ada2c77678ea0336d8f0662bd6fceec5ad88e..d043c1af00492abd7114946b28232a47e630e0a2 100644 (file)
@@ -75,11 +75,7 @@ namespace clitk
 
     //========================================================================================
     //Threaded execution should implement generate threaded data
-#if ITK_VERSION_MAJOR >= 4
-  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
-#else
-  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
-#endif
+    void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
   
     bool m_Verbose;
     PixelType m_EdgePaddingValue;
index a50ca26a38ee2556751e7af18c7a8913e852546a..5cc5db123bc505a9a77836b7160d00058d309e7c 100644 (file)
@@ -35,13 +35,8 @@ namespace clitk
 
   //=========================================================================================================================
   //update the output for the outputRegionForThread
-#if ITK_VERSION_MAJOR >= 4
   template<class InputImageType, class OutputImageType> 
   void ComposeVFFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId )
-#else
-  template<class InputImageType, class OutputImageType> 
-  void ComposeVFFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId )
-#endif
   {
  
     //Get pointer to the output
index c8fae32891eef1c3a7b1f305fcf4e3fbb716cb06..cc7623f5741a49a2d4e0efc735e95ecd8a9311a5 100644 (file)
@@ -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
 
 // clitk
 #include "clitkBoundingBoxUtils.h"
+#include "clitkImageCommon.h"
 
 // itk
 #include <itkImageToImageFilter.h>
 
 namespace clitk {
-  
+
   //--------------------------------------------------------------------
   /*
     Perform various cropping operation on a image
   */
   //--------------------------------------------------------------------
-  
+
   template <class ImageType>
   class ITK_EXPORT CropLikeImageFilter: public itk::ImageToImageFilter<ImageType, ImageType> {
   public:
@@ -41,10 +42,10 @@ namespace clitk {
     typedef itk::ImageToImageFilter<ImageType, ImageType>  Superclass;
     typedef itk::SmartPointer<Self>                        Pointer;
     typedef itk::SmartPointer<const Self>                  ConstPointer;
-    
+
     /** Method for creation through the object factory. */
     itkNewMacro(Self);
-    
+
     /** Run-time type information (and related methods). */
     itkTypeMacro(CropLikeImageFilter, ImageToImageFilter);
 
@@ -64,7 +65,7 @@ namespace clitk {
 
     // Set Background if 'like' is greater than input
     itkSetMacro(BackgroundValue, PixelType);
-    itkGetConstMacro(BackgroundValue, PixelType); 
+    itkGetConstMacro(BackgroundValue, PixelType);
 
     /** ImageDimension constants */
     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
@@ -75,11 +76,11 @@ namespace clitk {
   protected:
     CropLikeImageFilter();
     virtual ~CropLikeImageFilter() {}
-    
+
     virtual void GenerateOutputInformation();
     virtual void GenerateData();
     virtual void GenerateInputRequestedRegion();
-    
+
     PixelType m_BackgroundValue;
     RegionType m_OutputRegion;
     RegionType m_Region;
@@ -88,41 +89,41 @@ namespace clitk {
     PointType m_Origin;
     const itk::ImageBase<ImageDimension> * m_LikeImage;
     std::vector<bool> m_CropAlongThisDimension;
-    
+
     PointType m_StartPoint;         // start point in physical world
-    IndexType m_StartSourceIndex;   // start index in "source" image 
-    IndexType m_StartDestIndex;     // start index in "destination" image 
-    
+    IndexType m_StartSourceIndex;   // start index in "source" image
+    IndexType m_StartDestIndex;     // start index in "destination" image
+
     PointType m_StopPoint;         // stop point in physical world
-    IndexType m_StopSourceIndex;   // stop index in "source" image 
-    IndexType m_StopDestIndex;     // stop index in "destination" image 
-    
+    IndexType m_StopSourceIndex;   // stop index in "source" image
+    IndexType m_StopDestIndex;     // stop index in "destination" image
+
   private:
     CropLikeImageFilter(const Self&); //purposely not implemented
     void operator=(const Self&); //purposely not implemented
-    
+
   }; // end class
   //--------------------------------------------------------------------
 
 
   //--------------------------------------------------------------------
-  // Convenient function 
+  // Convenient function
   template<class ImageType>
   typename ImageType::Pointer
   ResizeImageLike(const ImageType * input,
-                  const itk::ImageBase<ImageType::ImageDimension> * like, 
+                  const itk::ImageBase<ImageType::ImageDimension> * like,
                   typename ImageType::PixelType BG);
 
   template<class ImageType>
   typename ImageType::Pointer
   ResizeImageLike(const ImageType * input,
-                  typename itk::ImageBase<ImageType::ImageDimension>::RegionType * like, 
+                  typename itk::ImageBase<ImageType::ImageDimension>::RegionType * like,
                   typename ImageType::PixelType BG);
 
   template<class ImageType>
   typename ImageType::Pointer
-  ResizeImageLike(const ImageType * input, 
-                  typename itk::BoundingBox<unsigned long, ImageType::ImageDimension>::Pointer bb, 
+  ResizeImageLike(const ImageType * input,
+                  typename itk::BoundingBox<unsigned long, ImageType::ImageDimension>::Pointer bb,
                   typename ImageType::PixelType BG);
 
 
index ce31fd9c915ebdb12f552f8e58809b312ba26463..98a40a65f8a2159cd338e7b30c5b0ef6c5a1aee6 100644 (file)
@@ -94,11 +94,7 @@ protected:
                                                  const OutputImageRegionType &srcRegion);
 
 
-#if ITK_VERSION_MAJOR >= 4
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
-#else
-  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
-#endif
 
   InputImageRegionType m_ExtractionRegion;
   OutputImageRegionType m_OutputImageRegion;
index 90fee3bbd49f312a120373da966ae0bbc845b5cf..5872469765a28fd71d2ab83a141caef233912cc9 100644 (file)
@@ -235,12 +235,7 @@ ExtractImageFilter<TInputImage,TOutputImage>
    */
 template <class TInputImage, class TOutputImage>
 void 
-ExtractImageFilter<TInputImage,TOutputImage>
-#if ITK_VERSION_MAJOR >= 4
-::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId)
-#else
-::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId)
-#endif
+ExtractImageFilter<TInputImage,TOutputImage>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId)
 {
   itkDebugMacro(<<"Actually executing");
 
index e983be7c4dd3e96b28527c9d3ce13fabdc2c1f2f..af008ec3e9379e6d8f60bfd8cc51123285e26a64 100644 (file)
@@ -105,11 +105,7 @@ GenerateData() {
   m_size[GetDirection()] = 0;
   m_region.SetSize(m_size);
   int start = m_index[GetDirection()];
-#if ITK_VERSION_MAJOR >= 4
   this->SetNumberOfIndexedInputs(m_NumberOfSlices);
-#else
-  this->SetNumberOfOutputs(m_NumberOfSlices);
-#endif
 
   //--------------------------------------------------------------------
   // loop ExtractImageFilter with region updated, push_back
@@ -122,9 +118,7 @@ GenerateData() {
     m_index[GetDirection()] = start + i;
     m_region.SetIndex(m_index);
     extract->SetExtractionRegion(m_region);
-#if ITK_VERSION_MAJOR == 4
     extract->SetDirectionCollapseToSubmatrix();
-#endif
     extract->Update();
     this->SetNthOutput(i, extract->GetOutput());
   }
index 34500a3897e058db1247afc3f1a174526cb5862e..c32782f08b84558f1bcf2cc4fa6f59976f94bd4f 100644 (file)
@@ -75,11 +75,7 @@ protected:
 
   //the actual processing
   void BeforeThreadedGenerateData();
-#if ITK_VERSION_MAJOR >= 4
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
-#else
-  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
-#endif
 
   //member data
   typename  WeightsImageType::Pointer m_Weights;
@@ -117,11 +113,7 @@ void HelperClass1<InputImageType, OutputImageType>::BeforeThreadedGenerateData()
 //=========================================================================================================================
 //update the output for the outputRegionForThread
 template<class InputImageType, class OutputImageType>
-#if ITK_VERSION_MAJOR >= 4
 void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId )
-#else
-void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId )
-#endif
 {
 //   std::cout << "HelperClass1::ThreadedGenerateData - IN " << threadId << std::endl;
   //Get pointer to the input
@@ -145,7 +137,7 @@ void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const O
   typedef typename OutputImageType::PixelType DisplacementType;
   DisplacementType displacement;
   inputIt.GoToBegin();
-  
+
   typename OutputImageType::SizeType size = outputPtr->GetLargestPossibleRegion().GetSize();
 
   //define some temp variables
@@ -199,7 +191,7 @@ void HelperClass1<InputImageType, OutputImageType>::ThreadedGenerateData(const O
             overlap *= 1.0 - distance[dim];
           }
           upper >>= 1;
-          
+
           if (neighIndex[dim] >= size[dim])
             neighIndex[dim] = size[dim] - 1;
         }
@@ -297,11 +289,7 @@ protected:
 
 
   //the actual processing
-#if ITK_VERSION_MAJOR >= 4
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId );
-#else
-  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId );
-#endif
 
   //member data
   typename     WeightsImageType::Pointer m_Weights;
@@ -320,20 +308,19 @@ protected:
 //Empty constructor
 template<class InputImageType, class OutputImageType > HelperClass2<InputImageType, OutputImageType>::HelperClass2()
 {
-  m_EdgePaddingValue=itk::NumericTraits<PixelType>::Zero;
+  PixelType zero;
+  for(unsigned int i=0;i <PixelType::Dimension; i++) zero[i] = 0.0;
+  m_EdgePaddingValue=zero;
+  //m_EdgePaddingValue=itk::NumericTraits<PixelType>::Zero;
 }
 
 
 //=========================================================================================================================
 //update the output for the outputRegionForThread
-#if ITK_VERSION_MAJOR >= 4
 template<class InputImageType, class OutputImageType > void HelperClass2<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId )
-#else
-template<class InputImageType, class OutputImageType > void HelperClass2<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread, int threadId )
-#endif
 {
 //   std::cout << "HelperClass2::ThreadedGenerateData - IN " << threadId << std::endl;
-  
+
   //Get pointer to the input
   typename InputImageType::ConstPointer inputPtr = this->GetInput();
 
@@ -383,9 +370,9 @@ template<class InputImageType, class OutputImageType > void HelperClass2<InputIm
     ++inputIt;
 
   }//end while
-  
+
 //   std::cout << "HelperClass2::ThreadedGenerateData - OUT " << threadId << std::endl;
-  
+
 }//end member
 
 
@@ -405,7 +392,12 @@ namespace clitk
 template <class InputImageType, class OutputImageType>
 InvertVFFilter<InputImageType, OutputImageType>::InvertVFFilter()
 {
-  m_EdgePaddingValue=itk::NumericTraits<PixelType>::Zero; //no other reasonable value?
+
+  //m_EdgePaddingValue=itk::NumericTraits<PixelType>::Zero; //no other reasonable value?
+  PixelType zero;
+  for(unsigned int i=0;i <PixelType::Dimension; i++) zero[i] = 0.0;
+  m_EdgePaddingValue=zero; //no other reasonable value?
+
   m_ThreadSafe=false;
   m_Verbose=false;
 }
@@ -487,7 +479,7 @@ template <class InputImageType, class OutputImageType> void InvertVFFilter<Input
 
   //Set the output
   this->SetNthOutput(0, helper2->GetOutput());
-  
+
   //std::cout << "InvertVFFilter::GenerateData - OUT" << std::endl;
 }
 
index cd9a3bafbbc2a421b780a7f837df371429345b98..3c3ccdb23d28337b838f71ebe9b4f71df765d46d 100644 (file)
@@ -20,6 +20,7 @@
 #include <vtkLinearExtrusionFilter.h>
 #include <vtkImageStencil.h>
 #include <vtkMetaImageWriter.h>
+#include <vtkVersion.h>
 
 #include "itkVTKImageImport.h"
 #include "vtkImageExport.h"
@@ -68,6 +69,7 @@ GenerateData()
 {
   // GO
   vtkSmartPointer<vtkImageData> binary_image=vtkSmartPointer<vtkImageData>::New();
+#if VTK_MAJOR_VERSION <= 5
   binary_image->SetScalarTypeToUnsignedChar();
 
   // Set spacing
@@ -91,6 +93,29 @@ GenerateData()
   
   // Allocate data
   binary_image->AllocateScalars();
+#else
+  // Set spacing
+  PointType samp_origin = m_LikeImage->GetOrigin();
+  SpacingType spacing=m_LikeImage->GetSpacing();
+  double * spacing2 = new double[3];
+  spacing2[0] = spacing[0];
+  spacing2[1] = spacing[1];
+  spacing2[2] = spacing[2];
+  binary_image->SetSpacing(spacing2);
+
+  // Set origin
+  /// Put the origin on a voxel to avoid small skips
+  binary_image->SetOrigin(samp_origin[0], samp_origin[1], samp_origin[2]);
+
+  // Compute image bounds
+  binary_image->SetExtent(0,m_LikeImage->GetLargestPossibleRegion().GetSize()[0],
+                          0,m_LikeImage->GetLargestPossibleRegion().GetSize()[1],
+                          0,m_LikeImage->GetLargestPossibleRegion().GetSize()[2] 
+                          );
+  
+  // Allocate data
+  binary_image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
+#endif
   memset(binary_image->GetScalarPointer(),0,
          binary_image->GetDimensions()[0]*binary_image->GetDimensions()[1]*binary_image->GetDimensions()[2]*sizeof(unsigned char));
 
@@ -105,10 +130,18 @@ GenerateData()
   if (m_Extrude)
   {
     vtkSmartPointer<vtkLinearExtrusionFilter> extrude=vtkSmartPointer<vtkLinearExtrusionFilter>::New();
+#if VTK_MAJOR_VERSION <= 5
     extrude->SetInput(m_Mesh);
+#else
+    extrude->SetInputData(m_Mesh);
+#endif
     // We extrude in the -slice_spacing direction to respect the FOCAL convention 
     extrude->SetVector(0, 0, -m_LikeImage->GetSpacing()[2]);
+#if VTK_MAJOR_VERSION <= 5
     sts->SetInput(extrude->GetOutput());
+#else
+    sts->SetInputConnection(extrude->GetOutputPort());
+#endif
     
     // When extrude ScaleFactor indicate the extrusion scaling (default = 1)
     /*
@@ -118,12 +151,21 @@ GenerateData()
     */ 
   }
   else
+#if VTK_MAJOR_VERSION <= 5
     sts->SetInput(m_Mesh);
+#else
+    sts->SetInputData(m_Mesh);
+#endif
 
   // Stencil
   vtkSmartPointer<vtkImageStencil> stencil=vtkSmartPointer<vtkImageStencil>::New();
+#if VTK_MAJOR_VERSION <= 5
   stencil->SetStencil(sts->GetOutput());
   stencil->SetInput(binary_image);
+#else
+  stencil->SetStencilData(sts->GetOutput());
+  stencil->SetInputData(binary_image);
+#endif
 
   // Convert VTK to ITK
   vtkImageExport * m_Exporter = vtkImageExport::New();
@@ -143,7 +185,11 @@ GenerateData()
   m_Importer->SetBufferPointerCallback( m_Exporter->GetBufferPointerCallback());
   m_Importer->SetCallbackUserData( m_Exporter->GetCallbackUserData());
 
+#if VTK_MAJOR_VERSION <= 5
   m_Exporter->SetInput( stencil->GetOutput() );
+#else
+  m_Exporter->SetInputData( stencil->GetOutput() );
+#endif
   m_Importer->Update();
 
   // writeImage<ImageType>(m_Importer->GetOutput(), "f.mhd");
index 32d31fe51075bf235a8256d9d8066f38d7bf509a..4c7f5eb95945b02cd61b2455d82f74ea5ddf4471 100644 (file)
 #include "itkConnectedComponentImageFilter.h"
 #include "itkStatisticsImageFilter.h"
 #include "itkCastImageFilter.h"
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkTestingComparisonImageFilter.h"
-#else
-  #include "itkDifferenceImageFilter.h"
-#endif
+#include "itkTestingComparisonImageFilter.h"
 #include "itkThresholdImageFilter.h"
 
 namespace clitk 
index 8e30eb39e6dbb4efeae79b8a6493d1094a4d22d0..de290f96c1ae05f534a1a7e3e13603ab66e0a9c8 100644 (file)
@@ -68,11 +68,7 @@ namespace clitk
     typedef itk::StatisticsImageFilter<InternalImageType> StatisticsImageFilterType;
     typedef itk::BinaryBallStructuringElement<InternalPixelType,InputImageDimension > KernelType;
     typedef clitk::ConditionalBinaryDilateImageFilter<InternalImageType, InternalImageType , KernelType> ConditionalBinaryDilateImageFilterType;
-#if ITK_VERSION_MAJOR >= 4
     typedef itk::Testing::ComparisonImageFilter<InternalImageType, InternalImageType> DifferenceImageFilterType;
-#else
-    typedef itk::DifferenceImageFilter<InternalImageType, InternalImageType> DifferenceImageFilterType;
-#endif
     typedef itk::CastImageFilter<InternalImageType, OutputImageType> OutputCastImageFilterType;
     typedef clitk::SetBackgroundImageFilter<InternalImageType, InternalImageType, InternalImageType> SetBackgroundImageFilterType;
 
index b526207be8f9784869a3af0c79394e3c94201124..4b6b409d37caaa492ef14769dc4f45b127898323 100644 (file)
@@ -60,6 +60,8 @@ namespace clitk {
   typedef typename OutputImageType::PixelType    OutputImagePixelType;
   typedef typename OutputImageType::SpacingType  OutputImageSpacingType;
   typedef typename OutputImageType::SizeType     OutputImageSizeType;
+  typedef typename OutputImageType::PointType    OutputImageOriginType;
+  typedef typename OutputImageType::DirectionType        OutputImageDirectionType;
     
   typedef itk::AffineTransform<double, InputImageType::ImageDimension> TransformType;
   typedef typename InputImageType::SpacingType                         GaussianSigmaType;
@@ -96,6 +98,10 @@ namespace clitk {
   itkGetMacro(OutputSpacing, OutputImageSpacingType);
   itkSetMacro(OutputSize, OutputImageSizeType);
   itkGetMacro(OutputSize, OutputImageSizeType);
+  itkSetMacro(OutputOrigin, OutputImageOriginType);
+  itkGetMacro(OutputOrigin, OutputImageOriginType);
+  itkSetMacro(OutputDirection, OutputImageDirectionType);
+  itkGetMacro(OutputDirection, OutputImageDirectionType);
   itkGetMacro(InterpolationType, InterpolationTypeEnumeration);
   itkSetMacro(InterpolationType, InterpolationTypeEnumeration);    
   itkGetMacro(GaussianFilteringEnabled, bool);
@@ -124,7 +130,9 @@ namespace clitk {
   int m_BSplineOrder;
   int m_BLUTSamplingFactor;    
   OutputImageSizeType m_OutputSize;
-  OutputImageSpacingType m_OutputSpacing;  
+  OutputImageSpacingType m_OutputSpacing;
+  OutputImageOriginType    m_OutputOrigin;
+  OutputImageDirectionType m_OutputDirection;
   typename TransformType::Pointer m_Transform;
   GaussianSigmaType m_GaussianSigma;
   OutputImagePixelType m_DefaultPixelValue;
index ddaa8a077b41f2ffcf2456836c2eeb7a4f0119fc..4c949cec33eff1ade7b4fe43cfac3f4bf313a1fe 100644 (file)
@@ -37,7 +37,7 @@
 //--------------------------------------------------------------------
 template <class InputImageType, class OutputImageType>
 clitk::ResampleImageWithOptionsFilter<InputImageType, OutputImageType>::
-ResampleImageWithOptionsFilter():itk::ImageToImageFilter<InputImageType, OutputImageType>() 
+ResampleImageWithOptionsFilter():itk::ImageToImageFilter<InputImageType, OutputImageType>()
 {
   static const unsigned int dim = InputImageType::ImageDimension;
   this->SetNumberOfRequiredInputs(1);
@@ -54,6 +54,8 @@ ResampleImageWithOptionsFilter():itk::ImageToImageFilter<InputImageType, OutputI
     m_OutputSpacing[i] = -1;
     m_GaussianSigma[i] = -1;
   }
+  m_OutputOrigin.Fill(0);
+  m_OutputDirection.SetIdentity();
   m_VerboseOptions = false;
   SetDefaultPixelValue(0);
 }
@@ -64,7 +66,7 @@ ResampleImageWithOptionsFilter():itk::ImageToImageFilter<InputImageType, OutputI
 template <class InputImageType, class OutputImageType>
 void
 clitk::ResampleImageWithOptionsFilter<InputImageType, OutputImageType>::
-SetInput(const InputImageType * image) 
+SetInput(const InputImageType * image)
 {
   // Process object is not const-correct so the const casting is required.
   this->SetNthInput(0, const_cast<InputImageType *>(image));
@@ -76,7 +78,7 @@ SetInput(const InputImageType * image)
 template <class InputImageType, class OutputImageType>
 void
 clitk::ResampleImageWithOptionsFilter<InputImageType, OutputImageType>::
-GenerateInputRequestedRegion() 
+GenerateInputRequestedRegion()
 {
   // call the superclass's implementation of this method
   Superclass::GenerateInputRequestedRegion();
@@ -97,7 +99,7 @@ GenerateInputRequestedRegion()
 template <class InputImageType, class OutputImageType>
 void
 clitk::ResampleImageWithOptionsFilter<InputImageType, OutputImageType>::
-GenerateOutputInformation() 
+GenerateOutputInformation()
 {
   static const unsigned int dim = InputImageType::ImageDimension;
 
@@ -122,27 +124,31 @@ GenerateOutputInformation()
   if (m_OutputIsoSpacing != -1) { // apply isoSpacing
     for(unsigned int i=0; i<dim; i++) {
       m_OutputSpacing[i] = m_OutputIsoSpacing;
-      // floor() is used to intentionally reduce the number of slices 
-      // because, from a clinical point of view, it's better to 
+      // floor() is used to intentionally reduce the number of slices
+      // because, from a clinical point of view, it's better to
       // remove data than to add data that privously didn't exist.
       if(inputSpacing[i]*m_OutputSpacing[i]<0)
         itkExceptionMacro( << "Input and output spacings don't have the same signs, can't cope with that" );
       m_OutputSize[i] = (int)floor(inputSize[i]*inputSpacing[i]/m_OutputSpacing[i]);
     }
-  } else {
+  }
+  else if(m_OutputSpacing[0]==-1 ||  m_OutputSize[0]==0){
     if (m_OutputSpacing[0] != -1) { // apply spacing, compute size
       for(unsigned int i=0; i<dim; i++) {
-        if(inputSpacing[i]*m_OutputSpacing[i]<0)
+        if(inputSpacing[i]*m_OutputSpacing[i]<0) {
           itkExceptionMacro( << "Input and output spacings don't have the same signs, can't cope with that" );
-       // see comment above for the use of floor()
-       m_OutputSize[i] = (int)floor(inputSize[i]*inputSpacing[i]/m_OutputSpacing[i]);
+        }
+        // see comment above for the use of floor()
+        m_OutputSize[i] = (int)floor(inputSize[i]*inputSpacing[i]/m_OutputSpacing[i]);
       }
-    } else {
+    }
+    else {
       if (m_OutputSize[0] != 0) { // apply size, compute spacing
         for(unsigned int i=0; i<dim; i++) {
           m_OutputSpacing[i] = (double)inputSize[i]*inputSpacing[i]/(double)m_OutputSize[i];
         }
-      } else { // copy input size/spacing ... (no resampling)
+      }
+      else { // copy input size/spacing ... (no resampling)
         m_OutputSize = inputSize;
         m_OutputSpacing = inputSpacing;
       }
@@ -188,11 +194,11 @@ GenerateOutputInformation()
 
 //--------------------------------------------------------------------
 template <class InputImageType, class OutputImageType>
-void 
+void
 clitk::ResampleImageWithOptionsFilter<InputImageType, OutputImageType>::
-GenerateData() 
+GenerateData()
 {
-   
+
   // Get input pointer
   InputImagePointer input = dynamic_cast<InputImageType*>(itk::ProcessObject::GetInput(0));
   static const unsigned int dim = InputImageType::ImageDimension;
@@ -223,10 +229,9 @@ GenerateData()
   }
 
   // Compute origin based on image corner
-  typename FilterType::OriginPointType origin = input->GetOrigin();
   for(unsigned int i=0; i<OutputImageType::ImageDimension; i++) {
-    origin[i] -= 0.5 * input->GetSpacing()[i];
-    origin[i] += 0.5 * m_OutputSpacing[i];
+    m_OutputOrigin[i] -= 0.5 * input->GetSpacing()[i];
+    m_OutputOrigin[i] += 0.5 * m_OutputSpacing[i];
   }
 
   // Instance of the transform object to be passed to the resample
@@ -234,10 +239,10 @@ GenerateData()
   filter->SetTransform(m_Transform);
   filter->SetSize(m_OutputSize);
   filter->SetOutputSpacing(m_OutputSpacing);
-  filter->SetOutputOrigin(origin);
+  filter->SetOutputOrigin(m_OutputOrigin);
   filter->SetDefaultPixelValue(m_DefaultPixelValue);
-  filter->SetNumberOfThreads(this->GetNumberOfThreads()); 
-  filter->SetOutputDirection(input->GetDirection()); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example)
+  filter->SetNumberOfThreads(this->GetNumberOfThreads());
+  filter->SetOutputDirection(m_OutputDirection); // <-- NEEDED if we want to keep orientation (in case of PermutAxes for example)
 
   // Select interpolator
   switch (m_InterpolationType) {
@@ -304,21 +309,16 @@ GenerateData()
   filter->Update();
 
   // Set output
-  // DD("before Graft");
-
-  //this->GraftOutput(filter->GetOutput());
-  this->SetNthOutput(0, filter->GetOutput());
-
-  // DD("after Graft");
+  this->GraftOutput(filter->GetOutput());
 }
 //--------------------------------------------------------------------
 
 
 //--------------------------------------------------------------------
 template<class InputImageType>
-typename InputImageType::Pointer 
-clitk::ResampleImageSpacing(typename InputImageType::Pointer input, 
-                            typename InputImageType::SpacingType spacing, 
+typename InputImageType::Pointer
+clitk::ResampleImageSpacing(typename InputImageType::Pointer input,
+                            typename InputImageType::SpacingType spacing,
                             int interpolationType)
 {
   typedef clitk::ResampleImageWithOptionsFilter<InputImageType> ResampleFilterType;
index c29c6ef888be4d9cbc6c5416754d93ab6ed03100..7bc316527ff3c360e840729ecc9cf88bd2c220d2 100644 (file)
@@ -291,8 +291,8 @@ VectorBSplineDecompositionImageFilterWithOBD<TInputImage, TOutputImage>
   InputIterator inIt( this->GetInput(), this->GetInput()->GetBufferedRegion() );
   OutputIterator outIt( this->GetOutput(), this->GetOutput()->GetBufferedRegion() );
 
-  inIt = inIt.Begin();
-  outIt = outIt.Begin();
+  inIt.GoToBegin();
+  outIt.GoToBegin();
   OutputPixelType v;
   while ( !outIt.IsAtEnd() ) {
     for (unsigned int i=0; i< VectorDimension; i++) {
index 18062a2296302fbebc2f922cbc65e920e652d1bc..6b85a096a3c0dcdd83dc9cdc9a8f9d4e18785805 100644 (file)
@@ -145,13 +145,8 @@ protected:
    *
    * \sa ImageToImageFilter::ThreadedGenerateData(),
    *     ImageToImageFilter::GenerateData()  */
-#if ITK_VERSION_MAJOR >= 4  
   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
                             itk::ThreadIdType threadId );
-#else
-  void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
-                            int threadId );
-#endif
 
 private:
   FlexibleBinaryFunctorImageFilter(const Self&); //purposely not implemented
index d8258ccf7859bc352ab8517cf5b2efe29a1f521d..d7c80e20049cb6cb16973ac3f53f2e5415452046 100644 (file)
@@ -97,12 +97,7 @@ FlexibleBinaryFunctorImageFilter<TInputImage1,TInputImage2,TOutputImage,TFunctio
 template <class TInputImage1, class TInputImage2, class TOutputImage, class TFunction  >
 void
 FlexibleBinaryFunctorImageFilter<TInputImage1, TInputImage2, TOutputImage, TFunction>
-::ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread,
-#if ITK_VERSION_MAJOR >= 4  
-                        itk::ThreadIdType threadId )
-#else
-                        int threadId)
-#endif
+::ThreadedGenerateData( const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId )
 {
   const unsigned int dim = Input1ImageType::ImageDimension;
   
index 27a6595385a3fc2ef2daf2b8d36b318c0edc07e9..5fddba28f6d49f17db81cd18ae91f8435a234e88 100644 (file)
@@ -77,7 +77,11 @@ void
 VTKImageToImageFilter<TOutputImage>
 ::SetInput( vtkImageData * inputImage )
 {
+#if VTK_MAJOR_VERSION <= 5
   m_Exporter->SetInput( inputImage );
+#else
+  m_Exporter->SetInputData( inputImage );
+#endif
 }
 
 
old mode 100644 (file)
new mode 100755 (executable)
index 29ca0ee..24f914e
@@ -12,7 +12,9 @@ do
     cp $i ${i/FooImage/$1}
     if test "$(uname)" = "Darwin"
     then
-        sed -i "" "s/FooImage/$1/ig" ${i/FooImage/$1}
+        echo $(pwd)
+        echo sed -i "" "s/FooImage/$1/g" ${i/FooImage/$1}
+        sed -i "" "s/FooImage/$1/g" ${i/FooImage/$1}
     else
         sed -i "s/FooImage/$1/ig" ${i/FooImage/$1}
     fi
index 9c8d36254665a1e0f1cc28e6d15ae2f01ec50a04..1c7d3c003ca417a670be4f5703017aa48845f979 100644 (file)
@@ -2,7 +2,7 @@
 
 # Add Libraries used in vv and clitk to avoid recompilation
 WRAP_GGO(clitkAffineRegistration_GGO_C clitkAffineRegistration.ggo)
-ADD_LIBRARY(clitkAffineRegistrationLib 
+add_library(clitkAffineRegistrationLib
             clitkAffineRegistrationGenericFilter.cxx
             ${clitkAffineRegistration_GGO_C}
             clitkLBFGSBOptimizer.cxx
@@ -10,40 +10,40 @@ ADD_LIBRARY(clitkAffineRegistrationLib
 
 #=========================================================
 
-IF(CLITK_BUILD_REGISTRATION)
+if(CLITK_BUILD_REGISTRATION)
     ############################## registration algorithms
-    ADD_EXECUTABLE(clitkAffineRegistration clitkAffineRegistration.cxx)
-    TARGET_LINK_LIBRARIES(clitkAffineRegistration  clitkAffineRegistrationLib clitkCommon)
-    SET(REGISTRATION_INSTALL clitkAffineRegistration)
+    add_executable(clitkAffineRegistration clitkAffineRegistration.cxx)
+    target_link_libraries(clitkAffineRegistration  clitkAffineRegistrationLib clitkCommon)
+    set(REGISTRATION_INSTALL clitkAffineRegistration)
 
     WRAP_GGO(clitkDemonsDeformableRegistration_GGO_C clitkDemonsDeformableRegistration.ggo)
-    ADD_EXECUTABLE(clitkDemonsDeformableRegistration clitkDemonsDeformableRegistration.cxx ${clitkDemonsDeformableRegistration_GGO_C} clitkDemonsDeformableRegistrationGenericFilter.cxx)
-    TARGET_LINK_LIBRARIES(clitkDemonsDeformableRegistration clitkCommon)
-    SET(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkDemonsDeformableRegistration)
+    add_executable(clitkDemonsDeformableRegistration clitkDemonsDeformableRegistration.cxx ${clitkDemonsDeformableRegistration_GGO_C} clitkDemonsDeformableRegistrationGenericFilter.cxx)
+    target_link_libraries(clitkDemonsDeformableRegistration clitkCommon)
+    set(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkDemonsDeformableRegistration)
 
     WRAP_GGO(clitkBLUTDIR_GGO_C clitkBLUTDIR.ggo)
-    ADD_EXECUTABLE(clitkBLUTDIR  clitkBLUTDIR.cxx clitkBLUTDIRGenericFilter.cxx ${clitkBLUTDIR_GGO_C} clitkLBFGSBOptimizer.cxx )
-    TARGET_LINK_LIBRARIES(clitkBLUTDIR clitkCommon)
-    SET(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkBLUTDIR)
+    add_executable(clitkBLUTDIR  clitkBLUTDIR.cxx clitkBLUTDIRGenericFilter.cxx ${clitkBLUTDIR_GGO_C} clitkLBFGSBOptimizer.cxx )
+    target_link_libraries(clitkBLUTDIR clitkCommon)
+    set(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkBLUTDIR)
 
 
     ############################## registration-related tools to process points, bsplines, vf and image pyramids
     WRAP_GGO(clitkCalculateTRE_GGO_C clitkCalculateTRE.ggo)
-    ADD_EXECUTABLE(clitkCalculateTRE clitkCalculateTRE.cxx clitkCalculateTREGenericFilter.cxx ${clitkCalculateTRE_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkCalculateTRE clitkCommon)
-    SET(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkCalculateTRE)
+    add_executable(clitkCalculateTRE clitkCalculateTRE.cxx clitkCalculateTREGenericFilter.cxx ${clitkCalculateTRE_GGO_C})
+    target_link_libraries(clitkCalculateTRE clitkCommon)
+    set(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkCalculateTRE)
 
     WRAP_GGO(clitkMatrixTransformToVF_GGO_C clitkMatrixTransformToVF.ggo)
-    ADD_EXECUTABLE(clitkMatrixTransformToVF clitkMatrixTransformToVF.cxx clitkMatrixTransformToVFGenericFilter.cxx  ${clitkMatrixTransformToVF_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMatrixTransformToVF clitkCommon)
-    SET(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkMatrixTransformToVF)
+    add_executable(clitkMatrixTransformToVF clitkMatrixTransformToVF.cxx clitkMatrixTransformToVFGenericFilter.cxx  ${clitkMatrixTransformToVF_GGO_C})
+    target_link_libraries(clitkMatrixTransformToVF clitkCommon)
+    set(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkMatrixTransformToVF)
 
     WRAP_GGO(clitkConvertBSplineDeformableTransformToVF_GGO_C clitkConvertBSplineDeformableTransformToVF.ggo)
-    ADD_EXECUTABLE(clitkConvertBSplineDeformableTransformToVF  clitkConvertBSplineDeformableTransformToVF.cxx clitkConvertBSplineDeformableTransformToVFGenericFilter.cxx  ${clitkConvertBSplineDeformableTransformToVF_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkConvertBSplineDeformableTransformToVF clitkCommon)
-    SET(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkConvertBSplineDeformableTransformToVF)
+    add_executable(clitkConvertBSplineDeformableTransformToVF  clitkConvertBSplineDeformableTransformToVF.cxx clitkConvertBSplineDeformableTransformToVFGenericFilter.cxx  ${clitkConvertBSplineDeformableTransformToVF_GGO_C})
+    target_link_libraries(clitkConvertBSplineDeformableTransformToVF clitkCommon)
+    set(REGISTRATION_INSTALL ${REGISTRATION_INSTALL} clitkConvertBSplineDeformableTransformToVF)
 
-    INSTALL (TARGETS ${REGISTRATION_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
+    install(TARGETS ${REGISTRATION_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
 
-ENDIF(CLITK_BUILD_REGISTRATION)
+endif(CLITK_BUILD_REGISTRATION)
 
index 6b0ecffbfdba87541e128945fceae0b13a0fcd5d..bcf5fd4cb05a0d29e8630b398f2577a0e35cec2c 100644 (file)
@@ -175,11 +175,8 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   typedef typename  InputImageType::PixelType PixelType;
 //typedef typename InputImageType::ImageDimension Dimension;
 
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
   bool threadsGiven=m_ArgsInfo.threads_given;
   int threads=m_ArgsInfo.threads_arg;
-#endif
 
   //Coordinate Representation
   typedef double TCoordRep;
@@ -396,11 +393,7 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   typename  MetricType::Pointer metric=genericMetric->GetMetricPointer();
   if (movingMask) metric->SetMovingImageMask(movingMask);
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
   if (threadsGiven) metric->SetNumberOfThreads( threads );
-#else
-  if (m_Verbose) std::cout<<"Not setting the number of threads (not compiled with USE_OPTIMIZED_REGISTRATION_METHODS)..."<<std::endl;
-#endif
 
   //============================================================================
   // Initialize using image moments.
@@ -541,11 +534,7 @@ void AffineRegistrationGenericFilter::UpdateWithInputImageType()
   if (m_Verbose) std::cout << "Starting the registration now..." << std::endl;
 
   try {
-#if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
-    registration->StartRegistration();
-#else
     registration->Update();
-#endif
   } catch ( itk::ExceptionObject & err ) {
     std::cerr << "ExceptionObject caught !" << std::endl;
     std::cerr << err << std::endl;
index c786eeb59dedbd6e1c50d48799e632af63dd126f..9f7b84f456f36496f1be156400a0c43441dd2983 100644 (file)
@@ -30,7 +30,16 @@ It is distributed under dual licence
 #include "clitkBLUTDIRGenericFilter.h"
 #include "clitkBLUTDIRCommandIterationUpdateDVF.h"
 #include "itkCenteredTransformInitializer.h"
-  
+#if ITK_VERSION_MAJOR >= 4
+#  if ITK_VERSION_MINOR < 6
+#    include "itkTransformToDisplacementFieldSource.h"
+#  else
+#    include "itkTransformToDisplacementFieldFilter.h"
+#  endif
+#else
+#  include "itkTransformToDeformationFieldSource.h"
+#endif
+
 namespace clitk
 {
 
@@ -387,9 +396,7 @@ namespace clitk
         // Crop the fixedImage to the bounding box to facilitate multi-resolution
         typedef itk::ExtractImageFilter<FixedImageType,FixedImageType> ExtractImageFilterType;
         typename ExtractImageFilterType::Pointer extractImageFilter=ExtractImageFilterType::New();
-#if ITK_VERSION_MAJOR == 4
         extractImageFilter->SetDirectionCollapseToSubmatrix();
-#endif
         extractImageFilter->SetInput(fixedImage);
         extractImageFilter->SetExtractionRegion(transformRegion);
         extractImageFilter->Update();
@@ -643,16 +650,10 @@ namespace clitk
       typedef itk::ImageToImageMetric< FixedImageType, MovingImageType >  MetricType;
       typename  MetricType::Pointer metric=genericMetric->GetMetricPointer();
       if (movingMask) metric->SetMovingImageMask(movingMask);
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
       if (threadsGiven) {
         metric->SetNumberOfThreads( threads );
         if (m_Verbose) std::cout<< "Using " << threads << " threads." << std::endl;
       }
-#else
-      if (m_Verbose) std::cout<<"Not setting the number of threads (not compiled with USE_OPTIMIZED_REGISTRATION_METHODS)..."<<std::endl;
-#endif
-
 
       //=======================================================
       // Optimizer
@@ -733,11 +734,7 @@ namespace clitk
 
       try
       {
-#if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
-        registration->StartRegistration();
-#else
         registration->Update();
-#endif
       }
       catch( itk::ExceptionObject & err )
       {
@@ -793,9 +790,11 @@ namespace clitk
       typedef itk::Vector< float, SpaceDimension >  DisplacementType;
       typedef itk::Image< DisplacementType, InputImageType::ImageDimension >  DisplacementFieldType;
 #if ITK_VERSION_MAJOR >= 4
+#  if ITK_VERSION_MINOR < 6
       typedef itk::TransformToDisplacementFieldSource<DisplacementFieldType, double> ConvertorType;
-#else
-      typedef itk::TransformToDeformationFieldSource<DisplacementFieldType, double> ConvertorType;
+#  else
+      typedef itk::TransformToDisplacementFieldFilter<DisplacementFieldType, double> ConvertorType;
+#  endif
 #endif
       typename ConvertorType::Pointer filter= ConvertorType::New();
       filter->SetNumberOfThreads(1);
@@ -804,7 +803,11 @@ namespace clitk
       else
         transform->SetBulkTransform(NULL);
       filter->SetTransform(regTransform);
+#if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6)
+      filter->SetReferenceImage(fixedImage);
+#else
       filter->SetOutputParametersFromImage(fixedImage);
+#endif
       filter->Update();
       typename DisplacementFieldType::Pointer field = filter->GetOutput();
 
index eda242f5b4d7d843a91cb2809dbbe319536d06db..18e1600ee9f12827730873a177325ebb3d00a338 100644 (file)
 #include "itkLabelGeometryImageFilter.h"
 #include "itkImageDuplicator.h"
 #include "itkExtractImageFilter.h"
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkTransformToDisplacementFieldSource.h"
-#else
-  #include "itkTransformToDeformationFieldSource.h"
-#endif
 
 namespace clitk
 {
index f5b269828fffb20b5759ae061d8390e3f8698908..8f5a278c6ad0930115070ddc4ae6463a2a5ffa4d 100644 (file)
@@ -65,9 +65,7 @@ namespace clitk
 
     /** Standard parameters container. */
     typedef typename Superclass::ParametersType ParametersType;
-#if ITK_VERSION_MAJOR >= 4
     typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
-#endif
 
     /** Standard Jacobian container. */
     typedef typename Superclass::JacobianType JacobianType;
@@ -257,22 +255,14 @@ namespace clitk
     } 
     
     /** Compute the Jacobian Matrix of the transformation at one point */
-#if ITK_VERSION_MAJOR >= 4
     virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const;
     virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
     {
       itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented for " << this->GetNameOfClass() );
     }
-#else
-    virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
-#endif
 
     /** Return the number of parameters that completely define the Transfom */
-#if ITK_VERSION_MAJOR >= 4
     virtual NumberOfParametersType GetNumberOfParameters(void) const;
-#else
-    virtual unsigned int GetNumberOfParameters(void) const;
-#endif
 
     /** Return the number of parameters per dimension */
     unsigned int GetNumberOfParametersPerDimension(void) const;
@@ -378,16 +368,13 @@ namespace clitk
 
     // VD Add MultipleBSplineDeformableTransform as friend to facilitate wrapping
     friend class MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>;
-#if ITK_VERSION_MAJOR >= 4
     mutable JacobianType                            m_SharedDataBSplineJacobian;
-#endif
-
   }; //class BSplineDeformableTransform
 
 
 }  // namespace itk
 
-#if ITK_TEMPLATE_TXX
+#ifndef ITK_MANUAL_INSTANTIATION
 # include "clitkBSplineDeformableTransform.txx"
 #endif
 
index 9d7cc6b8e2427d195544854ce540d75390a0789b..60a2136d7160c9bbfce3431e376bd2d9232dd08c 100644 (file)
@@ -16,7 +16,7 @@
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
 #ifndef __clitkBSplineDeformableTransform_txx
-#define __clitkBSplineDeformableTransform_tx
+#define __clitkBSplineDeformableTransform_txx
 #include "clitkBSplineDeformableTransform.h"
 
 //itk
@@ -31,12 +31,7 @@ namespace clitk
 
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-  BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
-  ::BSplineDeformableTransform():Superclass(0)
-#else
-  ::BSplineDeformableTransform():Superclass(OutputDimension,0)
-#endif
+  BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::BSplineDeformableTransform():Superclass(0)
   {
     unsigned int i;
     
@@ -255,11 +250,7 @@ namespace clitk
 
   // Get the number of parameters
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
   typename BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::NumberOfParametersType
-#else
-  unsigned int
-#endif
   BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetNumberOfParameters(void) const
   {
@@ -584,18 +575,11 @@ namespace clitk
     m_CoefficientImage = m_WrappedImage;
     
     //JV Wrap jacobian into OutputDimension X Vectorial images
-#if ITK_VERSION_MAJOR >= 4
     this->m_SharedDataBSplineJacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
-#else
-    this->m_Jacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
-#endif
 
     // Use memset to set the memory
-#if ITK_VERSION_MAJOR >= 4
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
-#else
-    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
-#endif
+
     memset(jacobianDataPointer, 0,  OutputDimension*numberOfPixels*sizeof(JacobianPixelType));
     m_LastJacobianIndex = m_ValidRegion.GetIndex();
     m_NeedResetJacobian = false;
@@ -920,7 +904,6 @@ namespace clitk
 
   // JV weights are identical as for transformpoint, could be done simultaneously in metric!!!!
   // Compute the Jacobian in one position 
-#if ITK_VERSION_MAJOR >= 4
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   void
   BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
@@ -982,76 +965,7 @@ namespace clitk
     jacobian = m_SharedDataBSplineJacobian;
 
   }
-#else
-  template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-  const 
-  typename BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-  ::JacobianType & 
-  BSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-  ::GetJacobian( const InputPointType & point ) const
-  {
-    // Can only compute Jacobian if parameters are set via
-    // SetParameters or SetParametersByValue
-    //     if( m_InputParametersPointer == NULL )
-    //       {
-    //         itkExceptionMacro( <<"Cannot compute Jacobian: parameters not set" );
-    //       }
-
-    if (m_NeedResetJacobian)
-      ResetJacobian();
 
-    //========================================================
-    // For each dimension, copy the weight to the support region
-    //========================================================
-
-    // Check if inside mask
-    if(m_Mask &&  !(m_Mask->IsInside(point) ) )
-      {
-       // Outside: no (deformable) displacement
-       return this->m_Jacobian;
-      }        
-
-    //Get index   
-    this->TransformPointToContinuousIndex( point, m_Index );
-
-    // NOTE: if the support region does not lie totally within the grid
-    // we assume zero displacement and return the input point
-    if ( !this->InsideValidRegion( m_Index ) )
-      {
-       return this->m_Jacobian;
-      }
-
-    //Compute interpolation weights
-    const WeightsDataType *weights=NULL;
-    m_VectorInterpolator->EvaluateWeightsAtContinuousIndex( m_Index, &weights, m_LastJacobianIndex);
-    m_SupportRegion.SetIndex( m_LastJacobianIndex );
-
-    //Reset the iterators
-    unsigned int j = 0;
-    for ( j = 0; j < OutputDimension; j++ ) 
-      m_Iterator[j] = IteratorType( m_JacobianImage[j], m_SupportRegion);
-
-    // For each dimension, copy the weight to the support region
-    while ( ! (m_Iterator[0]).IsAtEnd() )
-      {
-       //copy weight to jacobian image
-       for ( j = 0; j < OutputDimension; j++ )
-         {
-           m_ZeroVector[j]=*weights;
-           (m_Iterator[j]).Set( m_ZeroVector);
-           m_ZeroVector[j]=itk::NumericTraits<JacobianValueType>::Zero;
-           ++(m_Iterator[j]);
-         }
-       // go to next coefficient in the support region
-       weights++;
-      }
-    m_NeedResetJacobian = true;
-
-    // Return the result
-    return this->m_Jacobian;
-
-  }
-#endif
 
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
index 3cd1e676b0acdf9d23c37f194fd09f5363cbc227..40eb129d084e3c8bec1f0dabfcd8e9681c5f9477 100644 (file)
@@ -8,9 +8,11 @@
 #include "clitkBSplineDeformableTransform.h"
 #include "itkBSplineDeformableTransform.h"
 #if ITK_VERSION_MAJOR >= 4
-#include "itkTransformToDisplacementFieldSource.h"
-#else
-#include "itkTransformToDeformationFieldSource.h"
+#  if ITK_VERSION_MINOR < 6
+#    include "itkTransformToDisplacementFieldSource.h"
+#  else
+#    include "itkTransformToDisplacementFieldFilter.h"
+#  endif
 #endif
 
 namespace clitk 
@@ -46,9 +48,11 @@ namespace clitk
     typedef itk::Transform< double, TDVFType::ImageDimension, TDVFType::ImageDimension> GenericTransformType;
     
 #if ITK_VERSION_MAJOR >= 4
+#  if ITK_VERSION_MINOR < 6
     typedef itk::TransformToDisplacementFieldSource<OutputImageType, double> ConvertorType;
-#else
-    typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
+#  else
+    typedef itk::TransformToDisplacementFieldFilter<OutputImageType, double> ConvertorType;
+#  endif
 #endif
 
     itkNewMacro(Self);
@@ -90,4 +94,4 @@ namespace clitk
 
 #include "clitkConvertBLUTCoeffsToVFFilter.txx"
 
-#endif // clitkConvertBLUTCoeffsToVFFilter_h
\ No newline at end of file
+#endif // clitkConvertBLUTCoeffsToVFFilter_h
index ae1f9d539bd70d9425efbab1a760e324ba93771a..ef63900717289f73c0fc3b71969c8a7a0c44ec6c 100644 (file)
@@ -7,11 +7,6 @@
 
 //#include "clitkConvertBSplineDeformableTransformToVFGenericFilter.h"
 #include "clitkVectorImageToImageFilter.h"
-#if ITK_VERSION_MAJOR >= 4
-#include "itkTransformToDisplacementFieldSource.h"
-#else
-#include "itkTransformToDeformationFieldSource.h"
-#endif
 #include "itkBSplineDeformableTransform.h"
 
 namespace clitk 
@@ -148,12 +143,7 @@ namespace clitk
         
       typedef clitk::VectorImageToImageFilter<BLUTCoefficientImageType, typename ITKTransformType::ImageType> FilterType;
       typename FilterType::Pointer component_filter[BLUTCoefficientImageType::ImageDimension];
-
-#if ITK_VERSION_MAJOR >= 4
       typename ITKTransformType::CoefficientImageArray coefficient_images;
-#else
-      typename ITKTransformType::ImagePointer coefficient_images[BLUTCoefficientImageType::ImageDimension];
-#endif
 
       for (unsigned int i=0; i < BLUTCoefficientImageType::ImageDimension; i++) {
           component_filter[i] = FilterType::New();
@@ -163,7 +153,6 @@ namespace clitk
           coefficient_images[i] = component_filter[i]->GetOutput();
       }
 
-#if ITK_VERSION_MAJOR >= 4
       // RP: 16/01/2013
       // ATTENTION: Apparently, there's a bug in the SetCoefficientImages function of ITK 4.x
       // I needed to use SetParametersByValue instead.
@@ -179,16 +168,17 @@ namespace clitk
       m_ITKTransform->SetGridRegion(input->GetLargestPossibleRegion());
       m_ITKTransform->SetGridSpacing(input->GetSpacing());
       m_ITKTransform->SetParametersByValue(params);
-#else
-      m_ITKTransform->SetCoefficientImage(coefficient_images);
-#endif
 
       m_GenericTransform = m_ITKTransform;
     }
 
+#if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6)
+    m_Filter->SetReferenceImage(output);
+#else
     m_Filter->SetOutputOrigin(output->GetOrigin());
     m_Filter->SetOutputSpacing(output->GetSpacing());
     m_Filter->SetOutputSize(output->GetLargestPossibleRegion().GetSize());
+#endif
     m_Filter->SetTransform(m_GenericTransform);
 
     m_Filter->Update();
index a400e5100c0819fb46bc8c9bd20f93fdbe35666b..b52c077c95ac352de10509a02ac53dcfa44d4d9f 100644 (file)
@@ -266,14 +266,8 @@ CorrelationRatioImageToImageMetric<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
-#if ITK_VERSION_MAJOR >= 4
       TransformJacobianType jacobian;
       this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint , jacobian);
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
-
 
       const RealType fixedValue     = ti.Value();
       this->m_NumberOfPixelsCounted++;
@@ -389,14 +383,8 @@ CorrelationRatioImageToImageMetric<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
-#if ITK_VERSION_MAJOR >= 4
       TransformJacobianType jacobian;
         this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
-
 
       const RealType fixedValue     = ti.Value();
       this->m_NumberOfPixelsCounted++;
index 06c528855cdd8fb4ec09b24b8a97c164e8c9614d..a997d862a83ded735080ddbf5d8597f10c3d459c 100644 (file)
@@ -109,7 +109,6 @@ namespace clitk
       return OutputCovariantVectorType();
     }
 
-#if ITK_VERSION_MAJOR >= 4
     virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const
     {
       itkExceptionMacro( << "DeformationFieldTransform doesn't declare ComputeJacobianWithRespectToParameters" );
@@ -118,13 +117,6 @@ namespace clitk
     {
       itkExceptionMacro( << "DeformationFieldTransform doesn't declare ComputeJacobianWithRespectToPosition" );
     }
-#else
-    virtual const JacobianType& GetJacobian(const InputPointType  &point ) const
-    {
-      itkExceptionMacro( << "DeformationFieldTransform doesn't declare GetJacobian" );
-      return this->m_Jacobian;
-    }
-#endif
 
   protected:
     DeformationFieldTransform();
index 049f270bd25a5ebc797646ba1135b891d04cefdf..c93b456579337f3a241f13e566adad5f9523a38d 100644 (file)
@@ -25,12 +25,8 @@ namespace clitk
 
   // Constructor
   template<class TScalarType, unsigned int InputDimension, unsigned int OutputDimension, unsigned int SpaceDimension>
-  DeformationFieldTransform<TScalarType, InputDimension, OutputDimension, SpaceDimension>
-#if ITK_VERSION_MAJOR >= 4
-  ::DeformationFieldTransform():Superclass(1)
-#else
-  ::DeformationFieldTransform():Superclass(OutputDimension,1)
-#endif
+  DeformationFieldTransform<TScalarType, InputDimension, OutputDimension, SpaceDimension>::DeformationFieldTransform():Superclass(1)
+
   {
      m_DeformationField=NULL;
      m_Interpolator=DefaultInterpolatorType::New();
index 6132dc5897ae115d57fd9117e93cfd954a024307..d4b0cb238c55665da8b57e9d9cc52f57bd0e1090 100644 (file)
@@ -151,11 +151,7 @@ namespace clitk
     //find the multiresolution filter
     //     typedef typename  RegistrationFilterType::FixedImageType InternalImageType;
     //     typedef typename  RegistrationFilterType::MovingImageType MovingImageType;
-#if ITK_VERSION_MAJOR >= 4
     typedef typename  RegistrationFilterType::DisplacementFieldType DisplacementFieldType;
-#else
-    typedef typename  RegistrationFilterType::DeformationFieldType DisplacementFieldType;
-#endif
     typedef clitk::MultiResolutionPDEDeformableRegistration<FixedImageType, MovingImageType, DisplacementFieldType> MultiResolutionRegistrationType;
     typedef CommandResolutionLevelUpdate<MultiResolutionRegistrationType> LevelObserver;
     
@@ -537,11 +533,7 @@ namespace clitk
     //JV TODO
     // pdeFilter->SetMaximumError(m_ArgsInfo.maxError_arg);
     // pdeFilter->SetMaximumKernelWidth(m_ArgsInfo.maxError_arg);
-#if ITK_VERSION_MAJOR >= 4
     pdeFilter->SetSmoothDisplacementField(!m_ArgsInfo.fluid_flag);
-#else
-    pdeFilter->SetSmoothDeformationField(!m_ArgsInfo.fluid_flag);
-#endif
     pdeFilter->SetSmoothUpdateField(m_ArgsInfo.fluid_flag);
     pdeFilter->SetUseImageSpacing( m_ArgsInfo.spacing_flag );
 
@@ -607,11 +599,7 @@ namespace clitk
     typedef itk::WarpImageFilter< MovingImageType, FixedImageType, DeformationFieldType >    WarpFilterType;
     typename WarpFilterType::Pointer warp = WarpFilterType::New();
 
-#if ITK_VERSION_MAJOR >= 4
     warp->SetDisplacementField( deformationField );
-#else
-    warp->SetDeformationField( deformationField );
-#endif
     warp->SetInput( movingImageReader->GetOutput() );
     warp->SetOutputOrigin(  fixedImage->GetOrigin() );
     warp->SetOutputSpacing( fixedImage->GetSpacing() );
index ad03c7144f5611ac493007b2d2242eb2f278798e..7b84008426a9aeca89ccde56858106b22c96f30c 100644 (file)
@@ -143,11 +143,8 @@ private:
   typename FixedImageType::Pointer m_FixedImage;
   typename FixedImageMaskType::ConstPointer m_FixedImageMask;
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
   FixedImagePixelType m_FixedImageSamplesIntensityThreshold;
   bool m_UseFixedImageSamplesIntensityThreshold;
-#endif
-
 };
 
 } // end namespace clitk
index cbbcaa04a81ed6a02e088a4f364a7f7c0292c36f..852c19f858b833fef34d584642e6b14ff52e50ae 100644 (file)
@@ -35,10 +35,8 @@ GenericMetric<args_info_type, FixedImageType, MovingImageType>::GenericMetric()
   m_Maximize=false;
   m_Verbose=false;
   m_FixedImageRegionGiven=false;
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
   m_FixedImageSamplesIntensityThreshold=0;
   m_UseFixedImageSamplesIntensityThreshold=false;
-#endif
   m_FixedImageMask=NULL;
 }
 
@@ -273,9 +271,6 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
   m_Metric->SetFixedImageRegion(m_FixedImageRegion);
   //m_Metric->SetFixedImageRegion(mask_region);
 
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
-
   //============================================================================
   // Set the lower intensity threshold
   if (m_ArgsInfo.intThreshold_given) {
@@ -436,12 +431,6 @@ GenericMetric<args_info_type,FixedImageType, MovingImageType>::GetMetricPointer(
     if (m_Verbose) std::cout<<"number of mask pixels "<<totalNumberOfMaskPixels<<std::endl;
 
   }
-
-#else
-  if (m_Verbose) std::cout<<"Not setting the fixed image intensity threshold or the fraction of samples to use (not compiled with USE_OPTIMIZED_REGISTRATION_METHODS)..."<<std::endl;
-
-
-#endif
   //============================================================================
   //return the pointer
   return m_Metric;
index 8eec63a1f32046891728d3cfc7c29cad4e3666b7..7b4052eab10708bc38d6cd7c65f7d330b2f0cd3a 100644 (file)
@@ -179,11 +179,7 @@ private:
 
   bool                     m_OptimizerInitialized;
   InternalOptimizerType  * m_VnlOptimizer;
-#if ITK_VERSION_MAJOR > 3
   mutable std::ostringstream    m_StopConditionDescription;
-#else
-  mutable itk::OStringStream    m_StopConditionDescription;
-#endif
   BoundValueType           m_LowerBound;
   BoundValueType           m_UpperBound;
   BoundSelectionType       m_BoundSelection;
index 717e938a4b667b86dfaebc3eea570d578789e222..9aa54895d3fb409b4144843b4e607e56c8ef2298 100644 (file)
 //itk include
 #include "itkLightObject.h"
 #if ITK_VERSION_MAJOR >= 4
-  #include "itkTransformToDisplacementFieldSource.h"
-#else
-  #include "itkTransformToDeformationFieldSource.h"
+#  if ITK_VERSION_MINOR < 6
+#    include "itkTransformToDisplacementFieldSource.h"
+#  else
+#    include "itkTransformToDisplacementFieldFilter.h"
+#  endif
 #endif
 #include "itkAffineTransform.h"
 
index ebc0e45c3ba6ba0beaf9d30dd05b5a954444ebad..8a36a882b91017a7c4d1e69cc1f34cd73cdcedd7 100644 (file)
@@ -79,10 +79,13 @@ namespace clitk
     
     // Filter
 #if ITK_VERSION_MAJOR >= 4
+#  if ITK_VERSION_MINOR < 6
     typedef itk::TransformToDisplacementFieldSource<OutputImageType, double> ConvertorType;
-#else
-    typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
+#  else
+    typedef itk::TransformToDisplacementFieldFilter<OutputImageType, double> ConvertorType;
+#  endif
 #endif
+
     typename   ConvertorType::Pointer filter= ConvertorType::New();
 
     // Output image info
@@ -94,7 +97,12 @@ namespace clitk
        reader2->Update();
 
        typename OutputImageType::Pointer image=reader2->GetOutput();
-       filter->SetOutputParametersFromImage(image);
+#if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6)
+    filter->SetReferenceImage(image);
+    filter->UseReferenceImageOn();
+#else
+    filter->SetOutputParametersFromImage(image);
+#endif
       }
     else
       {
@@ -118,8 +126,12 @@ namespace clitk
            typename OutputImageType::SizeType size;
            for(i=0;i<Dimension;i++)
              size[i]=m_ArgsInfo.size_arg[i];
-           filter->SetOutputSize(size);
-         }
+#if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6)
+        filter->SetSize(size);
+#else
+        filter->SetOutputSize(size);
+#endif
+      }
       }
     
     // Transform
index 5c6b0aeaf55c38e2e3361f2d683a15a4c7d1b927..43fd978b92e8e39bcc8020a30ef33ded70c86855 100644 (file)
@@ -335,11 +335,7 @@ MultiResolutionPDEDeformableRegistration<TFixedImage,TMovingImage,TDeformationFi
       
       if( tempField.IsNull() )
        {
-#if ITK_VERSION_MAJOR >= 4
          m_RegistrationFilter->SetInitialDisplacementField( NULL );
-#else
-         m_RegistrationFilter->SetInitialDeformationField( NULL );
-#endif
        }
       else
        {
@@ -361,12 +357,7 @@ MultiResolutionPDEDeformableRegistration<TFixedImage,TMovingImage,TDeformationFi
       tempField = m_FieldExpander->GetOutput();
       tempField->DisconnectPipeline();
 
-#if ITK_VERSION_MAJOR >= 4
       m_RegistrationFilter->SetInitialDisplacementField( tempField );
-#else
-      m_RegistrationFilter->SetInitialDeformationField( tempField );
-#endif
-
       }
 
     // setup registration filter and pyramids 
index 5b2ee9eb35686933603bb10b4f22796e1be100b7..ae9f16ff420def695c58a909f2903af05f4d56ac 100644 (file)
@@ -59,9 +59,7 @@ namespace clitk
 
     /** Standard parameters container. */
     typedef typename Superclass::ParametersType ParametersType;
-#if ITK_VERSION_MAJOR >= 4
     typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
-#endif
 
     /** Standard Jacobian container. */
     typedef typename Superclass::JacobianType JacobianType;
@@ -216,22 +214,14 @@ namespace clitk
     }
 
     /** Compute the Jacobian Matrix of the transformation at one point */
-#if ITK_VERSION_MAJOR >= 4
     virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const;
     virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
     {
       itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented for " << this->GetNameOfClass() );
     }
-#else
-    virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
-#endif
 
     /** Return the number of parameters that completely define the Transfom */
-#if ITK_VERSION_MAJOR >= 4
     virtual NumberOfParametersType GetNumberOfParameters(void) const;
-#else
-    virtual unsigned int GetNumberOfParameters(void) const;
-#endif
 
     /** Return the number of parameters per dimension */
     unsigned int GetNumberOfParametersPerDimension(void) const;
@@ -278,9 +268,7 @@ namespace clitk
     std::vector<ParametersType>                     m_parameters;
     mutable std::vector<CoefficientImagePointer>    m_CoefficientImages;
     mutable int                                     m_LastJacobian;
-#if ITK_VERSION_MAJOR >= 4
     mutable JacobianType                            m_SharedDataBSplineJacobian;
-#endif
 
     void InitJacobian();
     // FIXME it seems not used
@@ -289,7 +277,7 @@ namespace clitk
 
 }  // namespace clitk
 
-#if ITK_TEMPLATE_TXX
+#ifndef ITK_MANUAL_INSTANTIATION
 # include "clitkMultipleBSplineDeformableTransform.txx"
 #endif
 
index 8df270661409bf8c8ed4939fa34c017db445f0f7..ebcfae976bd89ac3a5e28bbb37e5807f8bfede47 100644 (file)
@@ -28,12 +28,7 @@ namespace clitk
 {
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-  MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
-  ::MultipleBSplineDeformableTransform() : Superclass(0)
-#else
-  ::MultipleBSplineDeformableTransform() : Superclass(OutputDimension, 0)
-#endif
+  MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::MultipleBSplineDeformableTransform() : Superclass(0)
   {
     m_nLabels = 1;
     m_labels = 0;
@@ -329,11 +324,7 @@ namespace clitk
 #undef LOOP_ON_LABELS
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
   inline typename MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::NumberOfParametersType
-#else
-  inline unsigned int
-#endif
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetNumberOfParameters(void) const
   {
@@ -433,7 +424,6 @@ namespace clitk
     return m_trans[lidx]->DeformablyTransformPoint(inputPoint);
   }
 
-#if ITK_VERSION_MAJOR >= 4
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   inline void
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
@@ -459,30 +449,6 @@ namespace clitk
     jacobian = this->m_SharedDataBSplineJacobian;
   }
 
-#else
-  template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-  inline const typename MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::JacobianType &
-  MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-  ::GetJacobian( const InputPointType & point ) const
-  {
-    if (m_LastJacobian != -1)
-      m_trans[m_LastJacobian]->ResetJacobian();
-
-    int lidx = 0;
-    if (m_labels)
-      lidx = m_labelInterpolator->Evaluate(point) - 1;
-    if (lidx == -1)
-    {
-      m_LastJacobian = lidx;
-      return this->m_Jacobian;
-    }
-
-    m_trans[lidx]->GetJacobian(point);
-    m_LastJacobian = lidx;
-
-    return this->m_Jacobian;
-  }
-#endif
 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
   inline void
@@ -497,13 +463,8 @@ namespace clitk
   MultipleBSplineDeformableTransform<TCoordRep, NInputDimensions,NOutputDimensions>::InitJacobian()
   {
     unsigned numberOfParameters = this->GetNumberOfParameters();
-#if ITK_VERSION_MAJOR >= 4
     this->m_SharedDataBSplineJacobian.set_size(OutputDimension, numberOfParameters);
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
-#else
-    this->m_Jacobian.set_size(OutputDimension, numberOfParameters);
-    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
-#endif
     memset(jacobianDataPointer, 0,  numberOfParameters * sizeof (JacobianPixelType));
 
     unsigned tot = 0;
index e6b704b39967fa9744e26e12b5fe1211226c164c..0dd921bdf63c0c355dfdfb7908ad4b0a33c80e43 100644 (file)
 // This line can be removed once the optimized versions
 // gets integrated into the main directories.
 #include "itkConfigure.h"
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "clitkOptNormalizedCorrelationImageToImageMetric.h"
-#else
-
-#include "itkImageToImageMetric.h"
-#include "itkCovariantVector.h"
-#include "itkPoint.h"
-
-
-namespace clitk
-{
-
-template < class TFixedImage, class TMovingImage >
-class ITK_EXPORT NormalizedCorrelationImageToImageMetric :
-  public itk::ImageToImageMetric< TFixedImage, TMovingImage>
-{
-public:
-
-  /** Standard class typedefs. */
-  typedef NormalizedCorrelationImageToImageMetric    Self;
-  typedef itk::ImageToImageMetric<TFixedImage, TMovingImage >  Superclass;
-
-  typedef itk::SmartPointer<Self>         Pointer;
-  typedef itk::SmartPointer<const Self>   ConstPointer;
-
-  /** Method for creation through the object factory. */
-  itkNewMacro(Self);
-
-  /** Run-time type information (and related methods). */
-  itkTypeMacro(NormalizedCorrelationImageToImageMetric, itk::Object);
-
-
-  /** Types transferred from the base class */
-  typedef typename Superclass::RealType                 RealType;
-  typedef typename Superclass::TransformType            TransformType;
-  typedef typename Superclass::TransformPointer         TransformPointer;
-  typedef typename Superclass::TransformParametersType  TransformParametersType;
-  typedef typename Superclass::TransformJacobianType    TransformJacobianType;
-  typedef typename Superclass::GradientPixelType        GradientPixelType;
-  typedef typename Superclass::OutputPointType          OutputPointType;
-  typedef typename Superclass::InputPointType           InputPointType;
-
-  typedef typename Superclass::MeasureType              MeasureType;
-  typedef typename Superclass::DerivativeType           DerivativeType;
-  typedef typename Superclass::FixedImageType           FixedImageType;
-  typedef typename Superclass::MovingImageType          MovingImageType;
-  typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
-  typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
-
-
-  /** Get the derivatives of the match measure. */
-  void GetDerivative( const TransformParametersType & parameters,
-                      DerivativeType & Derivative ) const;
-
-  /**  Get the value for single valued optimizers. */
-  MeasureType GetValue( const TransformParametersType & parameters ) const;
-
-  /**  Get value and derivatives for multiple valued optimizers. */
-  void GetValueAndDerivative( const TransformParametersType & parameters,
-                              MeasureType& Value, DerivativeType& Derivative ) const;
-
-  /** Set/Get SubtractMean boolean. If true, the sample mean is subtracted
-   * from the sample values in the cross-correlation formula and
-   * typically results in narrower valleys in the cost fucntion.
-   * Default value is false. */
-  itkSetMacro( SubtractMean, bool );
-  itkGetConstReferenceMacro( SubtractMean, bool );
-  itkBooleanMacro( SubtractMean );
-
-protected:
-  NormalizedCorrelationImageToImageMetric();
-  virtual ~NormalizedCorrelationImageToImageMetric() {};
-  void PrintSelf(std::ostream& os, itk::Indent indent) const;
-
-private:
-  NormalizedCorrelationImageToImageMetric(const Self&); //purposely not implemented
-  void operator=(const Self&); //purposely not implemented
-
-  bool    m_SubtractMean;
-
-};
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkNormalizedCorrelationImageToImageMetric.txx"
-#endif
-
-#endif // opt
 
 #endif // _clitkNormalizedCorrelationImageToImageMetric.txx
 
index 69aa81fc2a1e282e4ed0e261905cd9c0e7ec0376..19286f6d59b46a95baed841f917ff04168164467 100644 (file)
 // gets integrated into the main directories.
 #include "itkConfigure.h"
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "clitkOptNormalizedCorrelationImageToImageMetric.txx"
-#else
-
-
-#include "clitkNormalizedCorrelationImageToImageMetric.h"
-
-#include "itkImageRegionConstIteratorWithIndex.h"
-
-
-namespace clitk
-{
-
-/*
- * Constructor
- */
-template <class TFixedImage, class TMovingImage>
-NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
-::NormalizedCorrelationImageToImageMetric()
-{
-  m_SubtractMean = false;
-}
-
-/*
- * Get the match Measure
- */
-template <class TFixedImage, class TMovingImage>
-typename NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>::MeasureType
-NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
-::GetValue( const TransformParametersType & parameters ) const
-{
-
-  FixedImageConstPointer fixedImage = this->m_FixedImage;
-
-  if( !fixedImage ) {
-    itkExceptionMacro( << "Fixed image has not been assigned" );
-  }
-
-  typedef  itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
-
-  FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
-
-  typename FixedImageType::IndexType index;
-
-  MeasureType measure;
-
-  this->m_NumberOfPixelsCounted = 0;
-
-  this->SetTransformParameters( parameters );
-
-  typedef  typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
-
-  AccumulateType sff = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType smm = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sfm = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sf  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sm  = itk::NumericTraits< AccumulateType >::Zero;
-
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-      sff += fixedValue  * fixedValue;
-      smm += movingValue * movingValue;
-      sfm += fixedValue  * movingValue;
-      if ( this->m_SubtractMean ) {
-        sf += fixedValue;
-        sm += movingValue;
-      }
-      this->m_NumberOfPixelsCounted++;
-    }
-
-    ++ti;
-  }
-
-  if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-    sff -= ( sf * sf / this->m_NumberOfPixelsCounted );
-    smm -= ( sm * sm / this->m_NumberOfPixelsCounted );
-    sfm -= ( sf * sm / this->m_NumberOfPixelsCounted );
-  }
-
-  const RealType denom = -1.0 * vcl_sqrt(sff * smm );
-
-  if( this->m_NumberOfPixelsCounted > 0 && denom != 0.0) {
-    measure = sfm / denom;
-  } else {
-    measure = itk::NumericTraits< MeasureType >::Zero;
-  }
-
-  return measure;
-
-}
-
-
-
-
-
-/*
- * Get the Derivative Measure
- */
-template < class TFixedImage, class TMovingImage>
-void
-NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
-::GetDerivative( const TransformParametersType & parameters,
-                 DerivativeType & derivative ) const
-{
-
-  if( !this->GetGradientImage() ) {
-    itkExceptionMacro(<<"The gradient image is null, maybe you forgot to call Initialize()");
-  }
-
-  FixedImageConstPointer fixedImage = this->m_FixedImage;
-
-  if( !fixedImage ) {
-    itkExceptionMacro( << "Fixed image has not been assigned" );
-  }
-
-  const unsigned int dimension = FixedImageType::ImageDimension;
-
-  typedef  itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
-
-  FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
-
-  typename FixedImageType::IndexType index;
-
-  this->m_NumberOfPixelsCounted = 0;
-
-  this->SetTransformParameters( parameters );
-
-  typedef  typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
-
-  AccumulateType sff  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType smm  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sfm = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sf  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sm  = itk::NumericTraits< AccumulateType >::Zero;
-
-  const unsigned int ParametersDimension = this->GetNumberOfParameters();
-  derivative = DerivativeType( ParametersDimension );
-  derivative.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeF = DerivativeType( ParametersDimension );
-  derivativeF.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeM = DerivativeType( ParametersDimension );
-  derivativeM.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  ti.GoToBegin();
-  // First compute the sums
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-      sff += fixedValue  * fixedValue;
-      smm += movingValue * movingValue;
-      sfm += fixedValue  * movingValue;
-      if ( this->m_SubtractMean ) {
-        sf += fixedValue;
-        sm += movingValue;
-      }
-      this->m_NumberOfPixelsCounted++;
-    }
-
-    ++ti;
-  }
-
-  // Compute contributions to derivatives
-  ti.GoToBegin();
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if ( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if ( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-
-#if ITK_VERSION_MAJOR >= 4
-      TransformJacobianType jacobian;
-      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
-
-      // Get the gradient by NearestNeighboorInterpolation:
-      // which is equivalent to round up the point components.
-      typedef typename OutputPointType::CoordRepType CoordRepType;
-      typedef itk::ContinuousIndex<CoordRepType,MovingImageType::ImageDimension>
-      MovingImageContinuousIndexType;
-
-      MovingImageContinuousIndexType tempIndex;
-      this->m_MovingImage->TransformPhysicalPointToContinuousIndex( transformedPoint, tempIndex );
-
-      typename MovingImageType::IndexType mappedIndex;
-      mappedIndex.CopyWithRound( tempIndex );
-
-      const GradientPixelType gradient =
-        this->GetGradientImage()->GetPixel( mappedIndex );
-
-      for(unsigned int par=0; par<ParametersDimension; par++) {
-        RealType sumF = itk::NumericTraits< RealType >::Zero;
-        RealType sumM = itk::NumericTraits< RealType >::Zero;
-        for(unsigned int dim=0; dim<dimension; dim++) {
-          const RealType differential = jacobian( dim, par ) * gradient[dim];
-          sumF += fixedValue  * differential;
-          sumM += movingValue * differential;
-          if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-            sumF -= differential * sf / this->m_NumberOfPixelsCounted;
-            sumM -= differential * sm / this->m_NumberOfPixelsCounted;
-          }
-        }
-        derivativeF[par] += sumF;
-        derivativeM[par] += sumM;
-      }
-    }
-
-    ++ti;
-  }
-
-  if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-    sff -= ( sf * sf / this->m_NumberOfPixelsCounted );
-    smm -= ( sm * sm / this->m_NumberOfPixelsCounted );
-    sfm -= ( sf * sm / this->m_NumberOfPixelsCounted );
-  }
-
-  const RealType denom = -1.0 * vcl_sqrt(sff * smm );
-
-  if( this->m_NumberOfPixelsCounted > 0 && denom != 0.0) {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = ( derivativeF[i] - (sfm/smm)* derivativeM[i] ) / denom;
-    }
-  } else {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = itk::NumericTraits< MeasureType >::Zero;
-    }
-  }
-
-}
-
-
-/*
- * Get both the match Measure and theDerivative Measure
- */
-template <class TFixedImage, class TMovingImage>
-void
-NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
-::GetValueAndDerivative(const TransformParametersType & parameters,
-                        MeasureType & value, DerivativeType  & derivative) const
-{
-
-
-  if( !this->GetGradientImage() ) {
-    itkExceptionMacro(<<"The gradient image is null, maybe you forgot to call Initialize()");
-  }
-
-  FixedImageConstPointer fixedImage = this->m_FixedImage;
-
-  if( !fixedImage ) {
-    itkExceptionMacro( << "Fixed image has not been assigned" );
-  }
-
-  const unsigned int dimension = FixedImageType::ImageDimension;
-
-  typedef  itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
-
-  FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
-
-  typename FixedImageType::IndexType index;
-
-  this->m_NumberOfPixelsCounted = 0;
-
-  this->SetTransformParameters( parameters );
-
-  typedef  typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
-
-  AccumulateType sff  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType smm  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sfm  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sf   = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sm   = itk::NumericTraits< AccumulateType >::Zero;
-
-  const unsigned int ParametersDimension = this->GetNumberOfParameters();
-  derivative = DerivativeType( ParametersDimension );
-  derivative.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeF = DerivativeType( ParametersDimension );
-  derivativeF.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeM = DerivativeType( ParametersDimension );
-  derivativeM.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeM1 = DerivativeType( ParametersDimension );
-  derivativeM1.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  ti.GoToBegin();
-  // First compute the sums
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-      sff += fixedValue  * fixedValue;
-      smm += movingValue * movingValue;
-      sfm += fixedValue  * movingValue;
-      if ( this->m_SubtractMean ) {
-        sf += fixedValue;
-        sm += movingValue;
-      }
-      this->m_NumberOfPixelsCounted++;
-    }
-
-    ++ti;
-  }
-
-
-  // Compute contributions to derivatives
-  ti.GoToBegin();
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue     = ti.Get();
-
-#if ITK_VERSION_MAJOR >= 4
-      TransformJacobianType jacobian;
-      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
-
-      // Get the gradient by NearestNeighboorInterpolation:
-      // which is equivalent to round up the point components.
-      typedef typename OutputPointType::CoordRepType CoordRepType;
-      typedef itk::ContinuousIndex<CoordRepType,MovingImageType::ImageDimension>
-      MovingImageContinuousIndexType;
-
-      MovingImageContinuousIndexType tempIndex;
-      this->m_MovingImage->TransformPhysicalPointToContinuousIndex( transformedPoint, tempIndex );
-
-      typename MovingImageType::IndexType mappedIndex;
-      mappedIndex.CopyWithRound( tempIndex );
-
-      const GradientPixelType gradient =
-        this->GetGradientImage()->GetPixel( mappedIndex );
-
-      for(unsigned int par=0; par<ParametersDimension; par++) {
-        RealType sumF = itk::NumericTraits< RealType >::Zero;
-        RealType sumM = itk::NumericTraits< RealType >::Zero;
-        for(unsigned int dim=0; dim<dimension; dim++) {
-          const RealType differential = jacobian( dim, par ) * gradient[dim];
-          sumF += fixedValue  * differential;
-          sumM += movingValue * differential;
-          if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-            sumF -= differential * sf / this->m_NumberOfPixelsCounted;
-            sumM -= differential * sm / this->m_NumberOfPixelsCounted;
-          }
-        }
-        derivativeF[par] += sumF;
-        derivativeM[par] += sumM;
-      }
-    }
-    ++ti;
-  }
-
-  if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-    sff -= ( sf * sf / this->m_NumberOfPixelsCounted );
-    smm -= ( sm * sm / this->m_NumberOfPixelsCounted );
-    sfm -= ( sf * sm / this->m_NumberOfPixelsCounted );
-  }
-
-  const RealType denom = -1.0 * vcl_sqrt(sff * smm );
-
-  if( this->m_NumberOfPixelsCounted > 0 && denom != 0.0) {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = ( derivativeF[i] - (sfm/smm)* derivativeM[i] ) / denom;
-    }
-    value = sfm / denom;
-  } else {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = itk::NumericTraits< MeasureType >::Zero;
-    }
-    value = itk::NumericTraits< MeasureType >::Zero;
-  }
-
-
-
-}
-
-template < class TFixedImage, class TMovingImage>
-void
-NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
-::PrintSelf(std::ostream& os, itk::Indent indent) const
-{
-  Superclass::PrintSelf(os, indent);
-  os << indent << "SubtractMean: " << m_SubtractMean << std::endl;
-}
-
-} // end namespace itk
-
-
-#endif // opt
-
 #endif // _clitkNormalizedCorrelationImageToImageMetric.txx
index 7a7d2b18e99d276f76dabf5d08dc61b8a0e109c4..ad4a118a0c159495ebf7c24509a75638fa5d37bd 100644 (file)
 // gets integrated into the main directories.
 #include "itkConfigure.h"
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h"
-#else
-
-#include "itkImageToImageMetric.h"
-#include "itkCovariantVector.h"
-#include "itkPoint.h"
-
-
-namespace clitk
-{
-
-template < class TFixedImage, class TMovingImage >
-class ITK_EXPORT NormalizedCorrelationImageToImageMetricFor3DBLUTFFD :
-  public itk::ImageToImageMetric< TFixedImage, TMovingImage>
-{
-public:
-
-  /** Standard class typedefs. */
-  typedef NormalizedCorrelationImageToImageMetricFor3DBLUTFFD    Self;
-  typedef itk::ImageToImageMetric<TFixedImage, TMovingImage >  Superclass;
-
-  typedef itk::SmartPointer<Self>         Pointer;
-  typedef itk::SmartPointer<const Self>   ConstPointer;
-
-  /** Method for creation through the object factory. */
-  itkNewMacro(Self);
-
-  /** Run-time type information (and related methods). */
-  itkTypeMacro(NormalizedCorrelationImageToImageMetricFor3DBLUTFFD, itk::Object);
-
-
-  /** Types transferred from the base class */
-  typedef typename Superclass::RealType                 RealType;
-  typedef typename Superclass::TransformType            TransformType;
-  typedef typename Superclass::TransformPointer         TransformPointer;
-  typedef typename Superclass::TransformParametersType  TransformParametersType;
-  typedef typename Superclass::TransformJacobianType    TransformJacobianType;
-  typedef typename Superclass::GradientPixelType        GradientPixelType;
-  typedef typename Superclass::OutputPointType          OutputPointType;
-  typedef typename Superclass::InputPointType           InputPointType;
-
-  typedef typename Superclass::MeasureType              MeasureType;
-  typedef typename Superclass::DerivativeType           DerivativeType;
-  typedef typename Superclass::FixedImageType           FixedImageType;
-  typedef typename Superclass::MovingImageType          MovingImageType;
-  typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
-  typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
-
-
-  /** Get the derivatives of the match measure. */
-  void GetDerivative( const TransformParametersType & parameters,
-                      DerivativeType & Derivative ) const;
-
-  /**  Get the value for single valued optimizers. */
-  MeasureType GetValue( const TransformParametersType & parameters ) const;
-
-  /**  Get value and derivatives for multiple valued optimizers. */
-  void GetValueAndDerivative( const TransformParametersType & parameters,
-                              MeasureType& Value, DerivativeType& Derivative ) const;
-
-  /** Set/Get SubtractMean boolean. If true, the sample mean is subtracted
-   * from the sample values in the cross-correlation formula and
-   * typically results in narrower valleys in the cost fucntion.
-   * Default value is false. */
-  itkSetMacro( SubtractMean, bool );
-  itkGetConstReferenceMacro( SubtractMean, bool );
-  itkBooleanMacro( SubtractMean );
-
-protected:
-  NormalizedCorrelationImageToImageMetricFor3DBLUTFFD();
-  virtual ~NormalizedCorrelationImageToImageMetricFor3DBLUTFFD() {};
-  void PrintSelf(std::ostream& os, itk::Indent indent) const;
-
-private:
-  NormalizedCorrelationImageToImageMetricFor3DBLUTFFD(const Self&); //purposely not implemented
-  void operator=(const Self&); //purposely not implemented
-
-  bool    m_SubtractMean;
-
-};
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx"
-#endif
-
-#endif // opt
-
 #endif // _clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx
 
 
index 16ecec4ee09fb9dbe0075ffb11b5d672b2f12cab..9dd366ab6b32134836d1e361db59d4a15d70a4d9 100644 (file)
 // This line can be removed once the optimized versions
 // gets integrated into the main directories.
 #include "itkConfigure.h"
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx"
-#else
-
-
-#include "clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.h"
-
-#include "itkImageRegionConstIteratorWithIndex.h"
-
-
-namespace clitk
-{
-
-/*
- * Constructor
- */
-template <class TFixedImage, class TMovingImage>
-NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::NormalizedCorrelationImageToImageMetricFor3DBLUTFFD()
-{
-  m_SubtractMean = false;
-}
-
-/*
- * Get the match Measure
- */
-template <class TFixedImage, class TMovingImage>
-typename NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>::MeasureType
-NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::GetValue( const TransformParametersType & parameters ) const
-{
-
-  FixedImageConstPointer fixedImage = this->m_FixedImage;
-
-  if( !fixedImage ) {
-    itkExceptionMacro( << "Fixed image has not been assigned" );
-  }
-
-  typedef  itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
-
-  FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
-
-  typename FixedImageType::IndexType index;
-
-  MeasureType measure;
-
-  this->m_NumberOfPixelsCounted = 0;
-
-  this->SetTransformParameters( parameters );
-
-  typedef  typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
-
-  AccumulateType sff = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType smm = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sfm = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sf  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sm  = itk::NumericTraits< AccumulateType >::Zero;
-
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-      sff += fixedValue  * fixedValue;
-      smm += movingValue * movingValue;
-      sfm += fixedValue  * movingValue;
-      if ( this->m_SubtractMean ) {
-        sf += fixedValue;
-        sm += movingValue;
-      }
-      this->m_NumberOfPixelsCounted++;
-    }
-
-    ++ti;
-  }
-
-  if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-    sff -= ( sf * sf / this->m_NumberOfPixelsCounted );
-    smm -= ( sm * sm / this->m_NumberOfPixelsCounted );
-    sfm -= ( sf * sm / this->m_NumberOfPixelsCounted );
-  }
-
-  const RealType denom = -1.0 * vcl_sqrt(sff * smm );
-
-  if( this->m_NumberOfPixelsCounted > 0 && denom != 0.0) {
-    measure = sfm / denom;
-  } else {
-    measure = itk::NumericTraits< MeasureType >::Zero;
-  }
-
-  return measure;
-
-}
-
-
-
-
-
-/*
- * Get the Derivative Measure
- */
-template < class TFixedImage, class TMovingImage>
-void
-NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::GetDerivative( const TransformParametersType & parameters,
-                 DerivativeType & derivative ) const
-{
-
-  if( !this->GetGradientImage() ) {
-    itkExceptionMacro(<<"The gradient image is null, maybe you forgot to call Initialize()");
-  }
-
-  FixedImageConstPointer fixedImage = this->m_FixedImage;
-
-  if( !fixedImage ) {
-    itkExceptionMacro( << "Fixed image has not been assigned" );
-  }
-
-  const unsigned int dimension = FixedImageType::ImageDimension;
-
-  typedef  itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
-
-  FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
-
-  typename FixedImageType::IndexType index;
-
-  this->m_NumberOfPixelsCounted = 0;
-
-  this->SetTransformParameters( parameters );
-
-  typedef  typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
-
-  AccumulateType sff  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType smm  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sfm = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sf  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sm  = itk::NumericTraits< AccumulateType >::Zero;
-
-  const unsigned int ParametersDimension = this->GetNumberOfParameters();
-  derivative = DerivativeType( ParametersDimension );
-  derivative.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeF = DerivativeType( ParametersDimension );
-  derivativeF.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeM = DerivativeType( ParametersDimension );
-  derivativeM.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  ti.GoToBegin();
-  // First compute the sums
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-      sff += fixedValue  * fixedValue;
-      smm += movingValue * movingValue;
-      sfm += fixedValue  * movingValue;
-      if ( this->m_SubtractMean ) {
-        sf += fixedValue;
-        sm += movingValue;
-      }
-      this->m_NumberOfPixelsCounted++;
-    }
-
-    ++ti;
-  }
-
-  // Compute contributions to derivatives
-  ti.GoToBegin();
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if ( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if ( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-
-#if ITK_VERSION_MAJOR >= 4
-      TransformJacobianType jacobian;
-      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
-
-      // Get the gradient by NearestNeighboorInterpolation:
-      // which is equivalent to round up the point components.
-      typedef typename OutputPointType::CoordRepType CoordRepType;
-      typedef itk::ContinuousIndex<CoordRepType,MovingImageType::ImageDimension>
-      MovingImageContinuousIndexType;
-
-      MovingImageContinuousIndexType tempIndex;
-      this->m_MovingImage->TransformPhysicalPointToContinuousIndex( transformedPoint, tempIndex );
-
-      typename MovingImageType::IndexType mappedIndex;
-      mappedIndex.CopyWithRound( tempIndex );
-
-      const GradientPixelType gradient =
-        this->GetGradientImage()->GetPixel( mappedIndex );
-
-      for(unsigned int par=0; par<ParametersDimension; par++) {
-        RealType sumF = itk::NumericTraits< RealType >::Zero;
-        RealType sumM = itk::NumericTraits< RealType >::Zero;
-        for(unsigned int dim=0; dim<dimension; dim++) {
-          const RealType differential = jacobian( dim, par ) * gradient[dim];
-          sumF += fixedValue  * differential;
-          sumM += movingValue * differential;
-          if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-            sumF -= differential * sf / this->m_NumberOfPixelsCounted;
-            sumM -= differential * sm / this->m_NumberOfPixelsCounted;
-          }
-        }
-        derivativeF[par] += sumF;
-        derivativeM[par] += sumM;
-      }
-    }
-
-    ++ti;
-  }
-
-  if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-    sff -= ( sf * sf / this->m_NumberOfPixelsCounted );
-    smm -= ( sm * sm / this->m_NumberOfPixelsCounted );
-    sfm -= ( sf * sm / this->m_NumberOfPixelsCounted );
-  }
-
-  const RealType denom = -1.0 * vcl_sqrt(sff * smm );
-
-  if( this->m_NumberOfPixelsCounted > 0 && denom != 0.0) {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = ( derivativeF[i] - (sfm/smm)* derivativeM[i] ) / denom;
-    }
-  } else {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = itk::NumericTraits< MeasureType >::Zero;
-    }
-  }
-
-}
-
-
-/*
- * Get both the match Measure and theDerivative Measure
- */
-template <class TFixedImage, class TMovingImage>
-void
-NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::GetValueAndDerivative(const TransformParametersType & parameters,
-                        MeasureType & value, DerivativeType  & derivative) const
-{
-
-
-  if( !this->GetGradientImage() ) {
-    itkExceptionMacro(<<"The gradient image is null, maybe you forgot to call Initialize()");
-  }
-
-  FixedImageConstPointer fixedImage = this->m_FixedImage;
-
-  if( !fixedImage ) {
-    itkExceptionMacro( << "Fixed image has not been assigned" );
-  }
-
-  const unsigned int dimension = FixedImageType::ImageDimension;
-
-  typedef  itk::ImageRegionConstIteratorWithIndex<FixedImageType> FixedIteratorType;
-
-  FixedIteratorType ti( fixedImage, this->GetFixedImageRegion() );
-
-  typename FixedImageType::IndexType index;
-
-  this->m_NumberOfPixelsCounted = 0;
-
-  this->SetTransformParameters( parameters );
-
-  typedef  typename itk::NumericTraits< MeasureType >::AccumulateType AccumulateType;
-
-  AccumulateType sff  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType smm  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sfm  = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sf   = itk::NumericTraits< AccumulateType >::Zero;
-  AccumulateType sm   = itk::NumericTraits< AccumulateType >::Zero;
-
-  const unsigned int ParametersDimension = this->GetNumberOfParameters();
-  derivative = DerivativeType( ParametersDimension );
-  derivative.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeF = DerivativeType( ParametersDimension );
-  derivativeF.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeM = DerivativeType( ParametersDimension );
-  derivativeM.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  DerivativeType derivativeM1 = DerivativeType( ParametersDimension );
-  derivativeM1.Fill( itk::NumericTraits<typename DerivativeType::ValueType>::Zero );
-
-  ti.GoToBegin();
-  // First compute the sums
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue   = ti.Get();
-      sff += fixedValue  * fixedValue;
-      smm += movingValue * movingValue;
-      sfm += fixedValue  * movingValue;
-      if ( this->m_SubtractMean ) {
-        sf += fixedValue;
-        sm += movingValue;
-      }
-      this->m_NumberOfPixelsCounted++;
-    }
-
-    ++ti;
-  }
-
-
-  // Compute contributions to derivatives
-  ti.GoToBegin();
-  while(!ti.IsAtEnd()) {
-
-    index = ti.GetIndex();
-
-    InputPointType inputPoint;
-    fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-    if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );
-
-    if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) ) {
-      ++ti;
-      continue;
-    }
-
-    if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
-      const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
-      const RealType fixedValue     = ti.Get();
-
-#if ITK_VERSION_MAJOR >= 4
-      TransformJacobianType jacobian;
-      this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
-
-      // Get the gradient by NearestNeighboorInterpolation:
-      // which is equivalent to round up the point components.
-      typedef typename OutputPointType::CoordRepType CoordRepType;
-      typedef itk::ContinuousIndex<CoordRepType,MovingImageType::ImageDimension>
-      MovingImageContinuousIndexType;
-
-      MovingImageContinuousIndexType tempIndex;
-      this->m_MovingImage->TransformPhysicalPointToContinuousIndex( transformedPoint, tempIndex );
-
-      typename MovingImageType::IndexType mappedIndex;
-      mappedIndex.CopyWithRound( tempIndex );
-
-      const GradientPixelType gradient =
-        this->GetGradientImage()->GetPixel( mappedIndex );
-
-      for(unsigned int par=0; par<ParametersDimension; par++) {
-        RealType sumF = itk::NumericTraits< RealType >::Zero;
-        RealType sumM = itk::NumericTraits< RealType >::Zero;
-        for(unsigned int dim=0; dim<dimension; dim++) {
-          const RealType differential = jacobian( dim, par ) * gradient[dim];
-          sumF += fixedValue  * differential;
-          sumM += movingValue * differential;
-          if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-            sumF -= differential * sf / this->m_NumberOfPixelsCounted;
-            sumM -= differential * sm / this->m_NumberOfPixelsCounted;
-          }
-        }
-        derivativeF[par] += sumF;
-        derivativeM[par] += sumM;
-      }
-    }
-    ++ti;
-  }
-
-  if ( this->m_SubtractMean && this->m_NumberOfPixelsCounted > 0 ) {
-    sff -= ( sf * sf / this->m_NumberOfPixelsCounted );
-    smm -= ( sm * sm / this->m_NumberOfPixelsCounted );
-    sfm -= ( sf * sm / this->m_NumberOfPixelsCounted );
-  }
-
-  const RealType denom = -1.0 * vcl_sqrt(sff * smm );
-
-  if( this->m_NumberOfPixelsCounted > 0 && denom != 0.0) {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = ( derivativeF[i] - (sfm/smm)* derivativeM[i] ) / denom;
-    }
-    value = sfm / denom;
-  } else {
-    for(unsigned int i=0; i<ParametersDimension; i++) {
-      derivative[i] = itk::NumericTraits< MeasureType >::Zero;
-    }
-    value = itk::NumericTraits< MeasureType >::Zero;
-  }
-
-
-
-}
-
-template < class TFixedImage, class TMovingImage>
-void
-NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::PrintSelf(std::ostream& os, itk::Indent indent) const
-{
-  Superclass::PrintSelf(os, indent);
-  os << indent << "SubtractMean: " << m_SubtractMean << std::endl;
-}
-
-} // end namespace itk
-
-
-#endif // opt
-
 #endif // _clitkNormalizedCorrelationImageToImageMetricFor3DBLUTFFD.txx
index 83448afee1ea403bda7ba1dbe83553f5272d89c5..242a4a1934b48ad6089e1927a2fffb77f3f273d0 100644 (file)
 #ifndef __clitkOptNormalizedCorrelationImageToImageMetric_h
 #define __clitkOptNormalizedCorrelationImageToImageMetric_h
 
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkImageToImageMetric.h"
-#else
-  #include "itkOptImageToImageMetric.h"
-#endif
+#include "itkImageToImageMetric.h"
 #include "itkCovariantVector.h"
 #include "itkPoint.h"
 #include "itkIndex.h"
index 3c0dfab48791b392a2b64087e6ee568eb44e3641..0f8fa64c5d975dbb3c4083e6699e2dd7bc91bc2d 100644 (file)
@@ -219,9 +219,6 @@ NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING
   this->GetValueMultiThreadedInitiate();
@@ -296,9 +293,6 @@ NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING
   this->GetValueMultiThreadedInitiate();
@@ -385,13 +379,8 @@ NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
   }
 
   // Jacobian should be evaluated at the unmapped (fixed image) point.
-#if ITK_VERSION_MAJOR >= 4
   TransformJacobianType jacobian;
   transform->ComputeJacobianWithRespectToParameters(fixedImagePoint, jacobian);
-#else
-  const TransformJacobianType & jacobian = transform
-      ->GetJacobian( fixedImagePoint );
-#endif
 
   for(unsigned int par=0; par<this->m_NumberOfParameters; par++) {
     RealType sumF = itk::NumericTraits< RealType >::Zero;
@@ -431,9 +420,6 @@ NormalizedCorrelationImageToImageMetric<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   //We need the sums and the value to be calculated first
   value=this->ComputeSums(parameters);
index 65559c2fcbb9d94b705ed7eb5c87c1bc234875df..dc7ef9feb294aeba79a8f0860284af692b447ec0 100644 (file)
 #ifndef __clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD_h
 #define __clitkOptNormalizedCorrelationImageToImageMetricFor3DBLUTFFD_h
 
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkImageToImageMetric.h"
-#else
-  #include "itkOptImageToImageMetric.h"
-#endif
+#include "itkImageToImageMetric.h"
 #include "itkCovariantVector.h"
 #include "itkPoint.h"
 #include "itkIndex.h"
index d7c777742981f51e1b2234cf3004bcc49ecfbffe..959bfed1afd56d50dca9a3ec725c8f2f306873c6 100644 (file)
@@ -219,9 +219,6 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING
   this->GetValueMultiThreadedInitiate();
@@ -296,9 +293,6 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING
   this->GetValueMultiThreadedInitiate();
@@ -385,12 +379,8 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
   }
 
   // Jacobian should be evaluated at the unmapped (fixed image) point.
-#if ITK_VERSION_MAJOR >= 4
   TransformJacobianType jacobian;
   transform->ComputeJacobianWithRespectToParameters( fixedImagePoint, jacobian );
-#else
-  const TransformJacobianType & jacobian = transform->GetJacobian( fixedImagePoint );
-#endif
 
 //          for(unsigned int par=0; par<this->m_NumberOfParameters; par++)
 //            {
@@ -455,9 +445,6 @@ NormalizedCorrelationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   //We need the sums and the value to be calculated first
   value=this->ComputeSums(parameters);
index d98c525d6abd3c114454c6e4fccba22dfeec968e..b897f1250a8ca8ba2f4370ea5f6fac82b6f496ce 100644 (file)
@@ -117,7 +117,6 @@ namespace clitk
       return OutputCovariantVectorType();
     }
 
-#if ITK_VERSION_MAJOR >= 4
     virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const
     {
       itkExceptionMacro( << "PointListTransform doesn't declare ComputeJacobianWithRespectToParameters" );
@@ -126,13 +125,6 @@ namespace clitk
     {
       itkExceptionMacro( << "PointListTransform doesn't declare ComputeJacobianWithRespectToPosition" );
     }
-#else
-    virtual const JacobianType& GetJacobian(const InputPointType  &point ) const
-    {
-      itkExceptionMacro( << "PointListTransform doesn't declare GetJacobian" );
-      return this->m_Jacobian;
-    }
-#endif
 
   protected:
     PointListTransform();
index a93a309b589284139d8154b33e5d2c97796674d2..d82759385f79df5e3ea0de667d6753d687fb38cd 100644 (file)
@@ -25,12 +25,7 @@ namespace clitk
 
   // Constructor
   template<class TScalarType, unsigned int NDimensions, unsigned int NOutputDimensions>
-  PointListTransform<TScalarType, NDimensions, NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
-  ::PointListTransform():Superclass(1)
-#else
-  ::PointListTransform():Superclass(NOutputDimensions,1)
-#endif
+  PointListTransform<TScalarType, NDimensions, NOutputDimensions>::PointListTransform():Superclass(1)
   {
     m_PointLists.resize(0);
     m_PointList.resize(1);
index c9fb588e30f83641260459a16e9d57e0cd684a66..309b867f75336539ec5a1a9a24286d5f42e2bcbe 100644 (file)
@@ -68,9 +68,7 @@ namespace clitk
 
     /** Standard parameters container. */
     typedef typename Superclass::ParametersType ParametersType;
-#if ITK_VERSION_MAJOR >= 4
     typedef typename Superclass::NumberOfParametersType NumberOfParametersType;
-#endif
 
     /** Standard Jacobian container. */
     typedef typename Superclass::JacobianType JacobianType;
@@ -266,22 +264,14 @@ namespace clitk
     } 
     
     /** Compute the Jacobian Matrix of the transformation at one point */
-#if ITK_VERSION_MAJOR >= 4
     virtual void ComputeJacobianWithRespectToParameters (const InputPointType &p, JacobianType &jacobian) const;
     virtual void ComputeJacobianWithRespectToPosition (const InputPointType &p, JacobianType &jacobian) const
     {
       itkExceptionMacro( "ComputeJacobianWithRespectToPosition not yet implemented for " << this->GetNameOfClass() );
     }
-#else
-    virtual const JacobianType& GetJacobian(const InputPointType  &point ) const;
-#endif
 
     /** Return the number of parameters that completely define the Transfom */
-#if ITK_VERSION_MAJOR >= 4
     virtual NumberOfParametersType GetNumberOfParameters(void) const;
-#else
-    virtual unsigned int GetNumberOfParameters(void) const;
-#endif
 
     //JV Return the padded number of parameters
     virtual unsigned int GetPaddedNumberOfParameters(void) const;
@@ -445,16 +435,14 @@ namespace clitk
     // JV Shape
     unsigned int m_TransformShape;
 
-#if ITK_VERSION_MAJOR >= 4
     mutable JacobianType                            m_SharedDataBSplineJacobian;
-#endif
 
   }; //class ShapedBLUTSpatioTemporalDeformableTransform
 
 
 }  // namespace itk
 
-#if ITK_TEMPLATE_TXX
+#ifndef ITK_MANUAL_INSTANTIATION
 # include "clitkShapedBLUTSpatioTemporalDeformableTransform.txx"
 #endif
 
index a5db85a10c61aebc96cde60414a7412dcd05aa17..7cc0107ec1a58facfdbe91ef6d72dfb9bbf641dd 100644 (file)
@@ -31,12 +31,7 @@ namespace clitk
 
   // Constructor with default arguments
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-  ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
-  ::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(0)
-#else
-  ::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(OutputDimension,0)
-#endif
+  ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::ShapedBLUTSpatioTemporalDeformableTransform():Superclass(0)
   {
     unsigned int i;
     
@@ -383,11 +378,7 @@ namespace clitk
 
   // Get the number of parameters
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
   typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>::NumberOfParametersType
-#else
-  unsigned int
-#endif
   ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::GetNumberOfParameters(void) const
   {
@@ -810,19 +801,11 @@ namespace clitk
     //=====================================
     //JV Wrap jacobian into OutputDimension X Vectorial images
     //=====================================
-#if ITK_VERSION_MAJOR >= 4
     this->m_SharedDataBSplineJacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
-#else
-    this->m_Jacobian.set_size( OutputDimension, this->GetNumberOfParameters() );
-#endif
 
     // Use memset to set the memory
     // JV four rows of three comps of parameters
-#if ITK_VERSION_MAJOR >= 4
     JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_SharedDataBSplineJacobian.data_block());
-#else
-    JacobianPixelType * jacobianDataPointer = reinterpret_cast<JacobianPixelType *>(this->m_Jacobian.data_block());
-#endif
     memset(jacobianDataPointer, 0,  OutputDimension*numberOfPixels*sizeof(JacobianPixelType));
 
     for (unsigned int j=0; j<OutputDimension; j++)
@@ -2390,17 +2373,9 @@ namespace clitk
   // JV weights are identical as for transformpoint, could be done simultaneously in metric!!!!
   // Compute the Jacobian in one position 
   template<class TCoordRep, unsigned int NInputDimensions, unsigned int NOutputDimensions>
-#if ITK_VERSION_MAJOR >= 4
   void
   ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
   ::ComputeJacobianWithRespectToParameters( const InputPointType & point, JacobianType & jacobian) const
-#else
-  const 
-  typename ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-  ::JacobianType & 
-  ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep, NInputDimensions, NOutputDimensions>
-  ::GetJacobian( const InputPointType & point ) const
-#endif
   {
   
     //========================================================
@@ -2496,12 +2471,8 @@ namespace clitk
     if(m_Mask &&  !(m_Mask->IsInside(point) ) )
       {
        // Outside: no (deformable) displacement
-#if ITK_VERSION_MAJOR >= 4
         jacobian = m_SharedDataBSplineJacobian;
         return;
-#else
-       return this->m_Jacobian;
-#endif
       }        
 
     // Get index   
@@ -2511,12 +2482,8 @@ namespace clitk
     // we assume zero displacement and return the input point
     if ( !this->InsideValidRegion( m_Index ) )
       {
-#if ITK_VERSION_MAJOR >= 4
         jacobian = m_SharedDataBSplineJacobian;
         return;
-#else
-       return this->m_Jacobian;
-#endif
       }
 
     // Compute interpolation weights
@@ -2684,11 +2651,7 @@ namespace clitk
       }
 
     // Return the result
-#if ITK_VERSION_MAJOR >= 4
     jacobian = m_SharedDataBSplineJacobian;
-#else
-    return this->m_Jacobian;
-#endif
   }
 
  
index c941b05d37e366de82e192eead7dfc4ccc323963..5342fea88784ff665a45c30be9abfb53ac662994 100644 (file)
 // This line can be removed once the optimized versions
 // gets integrated into the main directories.
 #include "itkConfigure.h"
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h"
-#else
-
-#include "itkImageToImageMetric.h"
-#include "itkCovariantVector.h"
-#include "itkPoint.h"
-#include "itkIndex.h"
-#include "itkBSplineKernelFunction.h"
-#include "itkBSplineDerivativeKernelFunction.h"
-#include "itkCentralDifferenceImageFunction.h"
-#include "itkBSplineInterpolateImageFunction.h"
-#include "itkBSplineDeformableTransform.h"
-#include "itkArray2D.h"
-
-namespace itk
-{
-
-/** \class MattesMutualInformationImageToImageMetricFor3DBLUTFFD
- * \brief Computes the mutual information between two images to be
- * registered using the method of Mattes et al.
- *
- * MattesMutualInformationImageToImageMetricFor3DBLUTFFD computes the mutual
- * information between a fixed and moving image to be registered.
- *
- * This class is templated over the FixedImage type and the MovingImage
- * type.
- *
- * The fixed and moving images are set via methods SetFixedImage() and
- * SetMovingImage(). This metric makes use of user specified Transform and
- * Interpolator. The Transform is used to map points from the fixed image to
- * the moving image domain. The Interpolator is used to evaluate the image
- * intensity at user specified geometric points in the moving image.
- * The Transform and Interpolator are set via methods SetTransform() and
- * SetInterpolator().
- *
- * If a BSplineInterpolationFunction is used, this class obtain
- * image derivatives from the BSpline interpolator. Otherwise,
- * image derivatives are computed using central differencing.
- *
- * \warning This metric assumes that the moving image has already been
- * connected to the interpolator outside of this class.
- *
- * The method GetValue() computes of the mutual information
- * while method GetValueAndDerivative() computes
- * both the mutual information and its derivatives with respect to the
- * transform parameters.
- *
- * The calculations are based on the method of Mattes et al [1,2]
- * where the probability density distribution are estimated using
- * Parzen histograms. Since the fixed image PDF does not contribute
- * to the derivatives, it does not need to be smooth. Hence,
- * a zero order (box car) BSpline kernel is used
- * for the fixed image intensity PDF. On the other hand, to ensure
- * smoothness a third order BSpline kernel is used for the
- * moving image intensity PDF.
- *
- * On Initialize(), the FixedImage is uniformly sampled within
- * the FixedImageRegion. The number of samples used can be set
- * via SetNumberOfSpatialSamples(). Typically, the number of
- * spatial samples used should increase with the image size.
- *
- * The option UseAllPixelOn() disables the random sampling and uses
- * all the pixels of the FixedImageRegion in order to estimate the
- * joint intensity PDF.
- *
- * During each call of GetValue(), GetDerivatives(),
- * GetValueAndDerivatives(), marginal and joint intensity PDF's
- * values are estimated at discrete position or bins.
- * The number of bins used can be set via SetNumberOfHistogramBins().
- * To handle data with arbitray magnitude and dynamic range,
- * the image intensity is scale such that any contribution to the
- * histogram will fall into a valid bin.
- *
- * One the PDF's have been contructed, the mutual information
- * is obtained by doubling summing over the discrete PDF values.
- *
- *
- * Notes:
- * 1. This class returns the negative mutual information value.
- * 2. This class in not thread safe due the private data structures
- *     used to the store the sampled points and the marginal and joint pdfs.
- *
- * References:
- * [1] "Nonrigid multimodality image registration"
- *      D. Mattes, D. R. Haynor, H. Vesselle, T. Lewellen and W. Eubank
- *      Medical Imaging 2001: Image Processing, 2001, pp. 1609-1620.
- * [2] "PET-CT Image Registration in the Chest Using Free-form Deformations"
- *      D. Mattes, D. R. Haynor, H. Vesselle, T. Lewellen and W. Eubank
- *      IEEE Transactions in Medical Imaging. Vol.22, No.1,
-        January 2003. pp.120-128.
- * [3] "Optimization of Mutual Information for MultiResolution Image
- *      Registration"
- *      P. Thevenaz and M. Unser
- *      IEEE Transactions in Image Processing, 9(12) December 2000.
- *
- * \ingroup RegistrationMetrics
- * \ingroup ThreadUnSafe
- */
-template <class TFixedImage,class TMovingImage >
-class ITK_EXPORT MattesMutualInformationImageToImageMetricFor3DBLUTFFD :
-  public ImageToImageMetric< TFixedImage, TMovingImage >
-{
-public:
-
-  /** Standard class typedefs. */
-  typedef MattesMutualInformationImageToImageMetricFor3DBLUTFFD           Self;
-  typedef ImageToImageMetric< TFixedImage, TMovingImage >     Superclass;
-  typedef SmartPointer<Self>                                  Pointer;
-  typedef SmartPointer<const Self>                            ConstPointer;
-
-  /** Method for creation through the object factory. */
-  itkNewMacro(Self);
-
-  /** Run-time type information (and related methods). */
-  itkTypeMacro(MattesMutualInformationImageToImageMetricFor3DBLUTFFD, ImageToImageMetric);
-
-  /** Types inherited from Superclass. */
-  typedef typename Superclass::TransformType            TransformType;
-  typedef typename Superclass::TransformPointer         TransformPointer;
-  typedef typename Superclass::TransformJacobianType    TransformJacobianType;
-  typedef typename Superclass::InterpolatorType         InterpolatorType;
-  typedef typename Superclass::MeasureType              MeasureType;
-  typedef typename Superclass::DerivativeType           DerivativeType;
-  typedef typename Superclass::ParametersType           ParametersType;
-  typedef typename Superclass::FixedImageType           FixedImageType;
-  typedef typename Superclass::MovingImageType          MovingImageType;
-  typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
-  typedef typename Superclass::MovingImageConstPointer  MovingImageCosntPointer;
-  typedef typename Superclass::InputPointType           InputPointType;
-  typedef typename Superclass::OutputPointType          OutputPointType;
-
-  typedef typename Superclass::CoordinateRepresentationType
-  CoordinateRepresentationType;
-
-  /** Index and Point typedef support. */
-  typedef typename FixedImageType::IndexType           FixedImageIndexType;
-  typedef typename FixedImageIndexType::IndexValueType FixedImageIndexValueType;
-  typedef typename MovingImageType::IndexType          MovingImageIndexType;
-  typedef typename TransformType::InputPointType       FixedImagePointType;
-  typedef typename TransformType::OutputPointType      MovingImagePointType;
-
-  /** The moving image dimension. */
-  itkStaticConstMacro( MovingImageDimension, unsigned int,
-                       MovingImageType::ImageDimension );
-
-  /**
-   *  Initialize the Metric by
-   *  (1) making sure that all the components are present and plugged
-   *      together correctly,
-   *  (2) uniformly select NumberOfSpatialSamples within
-   *      the FixedImageRegion, and
-   *  (3) allocate memory for pdf data structures. */
-  virtual void Initialize(void) throw ( ExceptionObject );
-
-  /** Get the derivatives of the match measure. */
-  void GetDerivative( const ParametersType& parameters,
-                      DerivativeType & Derivative ) const;
-
-  /**  Get the value. */
-  MeasureType GetValue( const ParametersType& parameters ) const;
-
-  /**  Get the value and derivatives for single valued optimizers. */
-  void GetValueAndDerivative( const ParametersType& parameters,
-                              MeasureType& Value,
-                              DerivativeType& Derivative ) const;
-
-  /** Number of spatial samples to used to compute metric */
-  itkSetClampMacro( NumberOfSpatialSamples, unsigned long,
-                    1, NumericTraits<unsigned long>::max() );
-  itkGetConstReferenceMacro( NumberOfSpatialSamples, unsigned long);
-
-  /** Number of bins to used in the histogram. Typical value is 50. */
-  itkSetClampMacro( NumberOfHistogramBins, unsigned long,
-                    1, NumericTraits<unsigned long>::max() );
-  itkGetConstReferenceMacro( NumberOfHistogramBins, unsigned long);
-
-  /** Reinitialize the seed of the random number generator that selects the
-   * sample of pixels used for estimating the image histograms and the joint
-   * histogram. By nature, this metric is not deterministic, since at each run
-   * it may select a different set of pixels. By initializing the random number
-   * generator seed to the same value you can restore determinism. On the other
-   * hand, calling the method ReinitializeSeed() without arguments will use the
-   * clock from your machine in order to have a very random initialization of
-   * the seed. This will indeed increase the non-deterministic behavior of the
-   * metric. */
-  void ReinitializeSeed();
-  void ReinitializeSeed(int);
-
-  /** Select whether the metric will be computed using all the pixels on the
-   * fixed image region, or only using a set of randomly selected pixels. */
-  itkSetMacro(UseAllPixels,bool);
-  itkGetConstReferenceMacro(UseAllPixels,bool);
-  itkBooleanMacro(UseAllPixels);
-
-  /** This variable selects the method to be used for computing the Metric
-   * derivatives with respect to the Transform parameters. Two modes of
-   * computation are available. The choice between one and the other is a
-   * trade-off between computation speed and memory allocations. The two modes
-   * are described in detail below:
-   *
-   * UseExplicitPDFDerivatives = True
-   * will compute the Metric derivative by first calculating the derivatives of
-   * each one of the Joint PDF bins with respect to each one of the Transform
-   * parameters and then accumulating these contributions in the final metric
-   * derivative array by using a bin-specific weight.  The memory required for
-   * storing the intermediate derivatives is a 3D array of doubles with size
-   * equals to the product of (number of histogram bins)^2 times number of
-   * transform parameters. This method is well suited for Transform with a small
-   * number of parameters.
-   *
-   * UseExplicitPDFDerivatives = False will compute the Metric derivative by
-   * first computing the weights for each one of the Joint PDF bins and caching
-   * them into an array. Then it will revisit each one of the PDF bins for
-   * computing its weighted contribution to the full derivative array. In this
-   * method an extra 2D array is used for storing the weights of each one of
-   * the PDF bins. This is an array of doubles with size equals to (number of
-   * histogram bins)^2. This method is well suited for Transforms with a large
-   * number of parameters, such as, BSplineDeformableTransforms. */
-  itkSetMacro(UseExplicitPDFDerivatives,bool);
-  itkGetConstReferenceMacro(UseExplicitPDFDerivatives,bool);
-  itkBooleanMacro(UseExplicitPDFDerivatives);
-
-  /** This boolean flag is only relevant when this metric is used along
-   * with a BSplineDeformableTransform. The flag enables/disables the
-   * caching of values computed when a physical point is mapped through
-   * the BSplineDeformableTransform. In particular it will cache the
-   * values of the BSpline weights for that points, and the indexes
-   * indicating what BSpline-grid nodes are relevant for that specific
-   * point. This caching is made optional due to the fact that the
-   * memory arrays used for the caching can reach large sizes even for
-   * moderate image size problems. For example, for a 3D image of
-   * 256^3, using 20% of pixels, these arrays will take about 1
-   * Gigabyte of RAM for storage. The ratio of computing time between
-   * using the cache or not using the cache can reach 1:5, meaning that
-   * using the caching can provide a five times speed up. It is
-   * therefore, interesting to enable the caching, if enough memory is
-   * available for it. The caching is enabled by default, in order to
-   * preserve backward compatibility with previous versions of ITK. */
-  itkSetMacro(UseCachingOfBSplineWeights,bool);
-  itkGetConstReferenceMacro(UseCachingOfBSplineWeights,bool);
-  itkBooleanMacro(UseCachingOfBSplineWeights);
-
-protected:
-
-  MattesMutualInformationImageToImageMetricFor3DBLUTFFD();
-  virtual ~MattesMutualInformationImageToImageMetricFor3DBLUTFFD() {};
-  void PrintSelf(std::ostream& os, Indent indent) const;
-
-  /** \class FixedImageSpatialSample
-   * A fixed image spatial sample consists of the fixed domain point
-   * and the fixed image value at that point. */
-  /// @cond
-  class FixedImageSpatialSample
-  {
-  public:
-    FixedImageSpatialSample():FixedImageValue(0.0) {
-      FixedImagePointValue.Fill(0.0);
-    }
-    ~FixedImageSpatialSample() {};
-
-    FixedImagePointType           FixedImagePointValue;
-    double                        FixedImageValue;
-    unsigned int                  FixedImageParzenWindowIndex;
-  };
-  /// @endcond
-
-  /** FixedImageSpatialSample typedef support. */
-  typedef std::vector<FixedImageSpatialSample>
-  FixedImageSpatialSampleContainer;
-
-  /** Container to store a set of points and fixed image values. */
-  FixedImageSpatialSampleContainer    m_FixedImageSamples;
-
-  /** Uniformly select a sample set from the fixed image domain. */
-  virtual void SampleFixedImageDomain(
-    FixedImageSpatialSampleContainer& samples);
-
-  /** Gather all the pixels from the fixed image domain. */
-  virtual void SampleFullFixedImageDomain(
-    FixedImageSpatialSampleContainer& samples);
-
-  /** Transform a point from FixedImage domain to MovingImage domain.
-   * This function also checks if mapped point is within support region. */
-  virtual void TransformPoint( unsigned int sampleNumber,
-                               const ParametersType& parameters,
-                               MovingImagePointType& mappedPoint,
-                               bool& sampleWithinSupportRegion,
-                               double& movingImageValue ) const;
-
-private:
-
-  //purposely not implemented
-  MattesMutualInformationImageToImageMetricFor3DBLUTFFD(const Self&);
-  //purposely not implemented
-  void operator=(const Self&);
-
-
-  /** The marginal PDFs are stored as std::vector. */
-  typedef float                       PDFValueType;
-  typedef std::vector<PDFValueType>   MarginalPDFType;
-
-  /** The fixed image marginal PDF. */
-  mutable MarginalPDFType             m_FixedImageMarginalPDF;
-
-  /** The moving image marginal PDF. */
-  mutable MarginalPDFType             m_MovingImageMarginalPDF;
-
-  /** Helper array for storing the values of the JointPDF ratios. */
-  typedef double                      PRatioType;
-  typedef Array2D< PRatioType >       PRatioArrayType;
-  mutable PRatioArrayType             m_PRatioArray;
-
-  /** Helper variable for accumulating the derivative of the metric. */
-  mutable DerivativeType              m_MetricDerivative;
-
-  /** Typedef for the joint PDF and PDF derivatives are stored as ITK Images. */
-  typedef Image<PDFValueType,2>                 JointPDFType;
-  typedef JointPDFType::IndexType               JointPDFIndexType;
-  typedef JointPDFType::PixelType               JointPDFValueType;
-  typedef JointPDFType::RegionType              JointPDFRegionType;
-  typedef JointPDFType::SizeType                JointPDFSizeType;
-  typedef Image<PDFValueType,3>                 JointPDFDerivativesType;
-  typedef JointPDFDerivativesType::IndexType    JointPDFDerivativesIndexType;
-  typedef JointPDFDerivativesType::PixelType    JointPDFDerivativesValueType;
-  typedef JointPDFDerivativesType::RegionType   JointPDFDerivativesRegionType;
-  typedef JointPDFDerivativesType::SizeType     JointPDFDerivativesSizeType;
-
-  /** The joint PDF and PDF derivatives. */
-  typename JointPDFType::Pointer                m_JointPDF;
-  typename JointPDFDerivativesType::Pointer     m_JointPDFDerivatives;
-
-  unsigned long                                 m_NumberOfSpatialSamples;
-  unsigned long                                 m_NumberOfParameters;
-
-  /** Variables to define the marginal and joint histograms. */
-  unsigned long  m_NumberOfHistogramBins;
-  double         m_MovingImageNormalizedMin;
-  double         m_FixedImageNormalizedMin;
-  double         m_MovingImageTrueMin;
-  double         m_MovingImageTrueMax;
-  double         m_FixedImageBinSize;
-  double         m_MovingImageBinSize;
-
-  /** Typedefs for BSpline kernel and derivative functions. */
-  typedef BSplineKernelFunction<3>           CubicBSplineFunctionType;
-  typedef BSplineDerivativeKernelFunction<3> CubicBSplineDerivativeFunctionType;
-
-  /** Cubic BSpline kernel for computing Parzen histograms. */
-  typename CubicBSplineFunctionType::Pointer   m_CubicBSplineKernel;
-  typename CubicBSplineDerivativeFunctionType::Pointer
-  m_CubicBSplineDerivativeKernel;
-
-  /** Precompute fixed image parzen window indices. */
-  virtual void ComputeFixedImageParzenWindowIndices(
-    FixedImageSpatialSampleContainer& samples );
-
-  /**
-   * Types and variables related to image derivative calculations.
-   * If a BSplineInterpolationFunction is used, this class obtain
-   * image derivatives from the BSpline interpolator. Otherwise,
-   * image derivatives are computed using central differencing.
-   */
-  typedef CovariantVector< double,
-          itkGetStaticConstMacro(MovingImageDimension) >
-          ImageDerivativesType;
-
-  /** Compute image derivatives at a point. */
-  virtual void ComputeImageDerivatives( const MovingImagePointType& mappedPoint,
-                                        ImageDerivativesType& gradient ) const;
-
-  /** Boolean to indicate if the interpolator BSpline. */
-  bool m_InterpolatorIsBSpline;
-
-  /** Typedefs for using BSpline interpolator. */
-  typedef
-  BSplineInterpolateImageFunction<MovingImageType,
-                                  CoordinateRepresentationType>
-                                  BSplineInterpolatorType;
-
-  /** Pointer to BSplineInterpolator. */
-  typename BSplineInterpolatorType::Pointer m_BSplineInterpolator;
-
-  /** Typedefs for using central difference calculator. */
-  typedef CentralDifferenceImageFunction<MovingImageType,
-          CoordinateRepresentationType>
-          DerivativeFunctionType;
-
-  /** Pointer to central difference calculator. */
-  typename DerivativeFunctionType::Pointer m_DerivativeCalculator;
-
-
-  /** Compute PDF derivative contribution for each parameter. */
-  virtual void ComputePDFDerivatives( unsigned int sampleNumber,
-                                      int movingImageParzenWindowIndex,
-                                      const ImageDerivativesType&
-                                      movingImageGradientValue,
-                                      double cubicBSplineDerivativeValue
-                                    ) const;
-
-  /**
-   * Types and variables related to BSpline deformable transforms.
-   * If the transform is of type third order BSplineDeformableTransform,
-   * then we can speed up the metric derivative calculation by
-   * only inspecting the parameters within the support region
-   * of a mapped point.
-   */
-
-  /** Boolean to indicate if the transform is BSpline deformable. */
-  bool m_TransformIsBSpline;
-
-  /** The number of BSpline parameters per image dimension. */
-  long m_NumParametersPerDim;
-
-  /**
-   * The number of BSpline transform weights is the number of
-   * of parameter in the support region (per dimension ). */
-  unsigned long m_NumBSplineWeights;
-
-  /** The fixed image dimension. */
-  itkStaticConstMacro( FixedImageDimension, unsigned int,
-                       FixedImageType::ImageDimension );
-
-  /**
-   * Enum of the deformabtion field spline order.
-   */
-  enum { DeformationSplineOrder = 3 };
-
-  /**
-   * Typedefs for the BSplineDeformableTransform.
-   */
-  typedef BSplineDeformableTransform<
-  CoordinateRepresentationType,
-  ::itk::GetImageDimension<FixedImageType>::ImageDimension,
-  DeformationSplineOrder> BSplineTransformType;
-  typedef typename BSplineTransformType::WeightsType
-  BSplineTransformWeightsType;
-  typedef typename BSplineTransformType::ParameterIndexArrayType
-  BSplineTransformIndexArrayType;
-
-  /**
-   * Variables used when transform is of type BSpline deformable.
-   */
-  typename BSplineTransformType::Pointer m_BSplineTransform;
-
-  /**
-   * Cache pre-transformed points, weights, indices and
-   * within support region flag.
-   */
-  typedef typename BSplineTransformWeightsType::ValueType    WeightsValueType;
-  typedef          Array2D<WeightsValueType>                 BSplineTransformWeightsArrayType;
-  typedef typename BSplineTransformIndexArrayType::ValueType IndexValueType;
-  typedef          Array2D<IndexValueType>                   BSplineTransformIndicesArrayType;
-  typedef          std::vector<MovingImagePointType>         MovingImagePointArrayType;
-  typedef          std::vector<bool>                         BooleanArrayType;
-
-  BSplineTransformWeightsArrayType      m_BSplineTransformWeightsArray;
-  BSplineTransformIndicesArrayType      m_BSplineTransformIndicesArray;
-  MovingImagePointArrayType             m_PreTransformPointsArray;
-  BooleanArrayType                      m_WithinSupportRegionArray;
-
-  typedef FixedArray<unsigned long,
-          ::itk::GetImageDimension<FixedImageType>::ImageDimension>
-          ParametersOffsetType;
-  ParametersOffsetType                  m_ParametersOffset;
-
-  bool             m_UseAllPixels;
-
-  virtual void PreComputeTransformValues();
-
-  bool             m_ReseedIterator;
-  int              m_RandomSeed;
-
-  // Selection of explicit or implicit computation of PDF derivatives
-  // with respect to Transform parameters.
-  bool             m_UseExplicitPDFDerivatives;
-
-  // Variables needed for optionally caching values when using a BSpline transform.
-  bool                                    m_UseCachingOfBSplineWeights;
-  mutable BSplineTransformWeightsType     m_Weights;
-  mutable BSplineTransformIndexArrayType  m_Indices;
-
-};
-
-} // end namespace itk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "itkMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx"
-#endif
-
-#endif
-
 #endif
index 9391dc23898a7045fec8c1c55475695c9399dc6e..929d53452645837eb6cd70058b45de2b57248386 100644 (file)
 // gets integrated into the main directories.
 #include "itkConfigure.h"
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD.txx"
-#else
-
-
-#include "itkMattesMutualInformationImageToImageMetricFor3DBLUTFFD.h"
-#include "itkBSplineInterpolateImageFunction.h"
-#include "itkCovariantVector.h"
-#include "itkImageRandomConstIteratorWithIndex.h"
-#include "itkImageRegionConstIterator.h"
-#include "itkImageRegionIterator.h"
-#include "itkImageIterator.h"
-#include "vnl/vnl_math.h"
-#include "itkBSplineDeformableTransform.h"
-
-namespace itk
-{
-
-
-/**
- * Constructor
- */
-template < class TFixedImage, class TMovingImage >
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::MattesMutualInformationImageToImageMetricFor3DBLUTFFD()
-{
-
-  m_NumberOfSpatialSamples = 500;
-  m_NumberOfHistogramBins = 50;
-
-  this->SetComputeGradient(false); // don't use the default gradient for now
-
-  m_InterpolatorIsBSpline = false;
-  m_TransformIsBSpline    = false;
-
-  // Initialize PDFs to NULL
-  m_JointPDF = NULL;
-  m_JointPDFDerivatives = NULL;
-
-  m_UseExplicitPDFDerivatives = true;
-
-  typename BSplineTransformType::Pointer transformer =
-    BSplineTransformType::New();
-  this->SetTransform (transformer);
-
-  typename BSplineInterpolatorType::Pointer interpolator =
-    BSplineInterpolatorType::New();
-  this->SetInterpolator (interpolator);
-
-  // Initialize memory
-  m_MovingImageNormalizedMin = 0.0;
-  m_FixedImageNormalizedMin = 0.0;
-  m_MovingImageTrueMin = 0.0;
-  m_MovingImageTrueMax = 0.0;
-  m_FixedImageBinSize = 0.0;
-  m_MovingImageBinSize = 0.0;
-  m_CubicBSplineDerivativeKernel = NULL;
-  m_BSplineInterpolator = NULL;
-  m_DerivativeCalculator = NULL;
-  m_NumParametersPerDim = 0;
-  m_NumBSplineWeights = 0;
-  m_BSplineTransform = NULL;
-  m_NumberOfParameters = 0;
-  m_UseAllPixels = false;
-  m_ReseedIterator = false;
-  m_RandomSeed = -1;
-  m_UseCachingOfBSplineWeights = true;
-}
-
-
-/**
- * Print out internal information about this class
- */
-template < class TFixedImage, class TMovingImage  >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::PrintSelf(std::ostream& os, Indent indent) const
-{
-
-  Superclass::PrintSelf(os, indent);
-
-  os << indent << "NumberOfSpatialSamples: ";
-  os << m_NumberOfSpatialSamples << std::endl;
-  os << indent << "NumberOfHistogramBins: ";
-  os << m_NumberOfHistogramBins << std::endl;
-  os << indent << "UseAllPixels: ";
-  os << m_UseAllPixels << std::endl;
-
-  // Debugging information
-  os << indent << "NumberOfParameters: ";
-  os << m_NumberOfParameters << std::endl;
-  os << indent << "FixedImageNormalizedMin: ";
-  os << m_FixedImageNormalizedMin << std::endl;
-  os << indent << "MovingImageNormalizedMin: ";
-  os << m_MovingImageNormalizedMin << std::endl;
-  os << indent << "MovingImageTrueMin: ";
-  os << m_MovingImageTrueMin << std::endl;
-  os << indent << "MovingImageTrueMax: ";
-  os << m_MovingImageTrueMax << std::endl;
-  os << indent << "FixedImageBinSize: ";
-  os << m_FixedImageBinSize << std::endl;
-  os << indent << "MovingImageBinSize: ";
-  os << m_MovingImageBinSize << std::endl;
-  os << indent << "InterpolatorIsBSpline: ";
-  os << m_InterpolatorIsBSpline << std::endl;
-  os << indent << "TransformIsBSpline: ";
-  os << m_TransformIsBSpline << std::endl;
-  os << indent << "UseCachingOfBSplineWeights: ";
-  os << m_UseCachingOfBSplineWeights << std::endl;
-  os << indent << "UseExplicitPDFDerivatives: ";
-  os << m_UseExplicitPDFDerivatives << std::endl;
-
-}
-
-
-/**
- * Initialize
- */
-template <class TFixedImage, class TMovingImage>
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::Initialize(void) throw ( ExceptionObject )
-{
-  this->Superclass::Initialize();
-
-  // Cache the number of transformation parameters
-  m_NumberOfParameters = this->m_Transform->GetNumberOfParameters();
-
-  /**
-   * Compute the minimum and maximum for the FixedImage over
-   * the FixedImageRegion.
-   *
-   * NB: We can't use StatisticsImageFilter to do this because
-   * the filter computes the min/max for the largest possible region
-   */
-  double fixedImageMin = NumericTraits<double>::max();
-  double fixedImageMax = NumericTraits<double>::NonpositiveMin();
-
-  typedef ImageRegionConstIterator<FixedImageType> FixedIteratorType;
-  FixedIteratorType fixedImageIterator(
-    this->m_FixedImage, this->GetFixedImageRegion() );
-
-  for ( fixedImageIterator.GoToBegin();
-        !fixedImageIterator.IsAtEnd(); ++fixedImageIterator ) {
-
-    double sample = static_cast<double>( fixedImageIterator.Get() );
-
-    if ( sample < fixedImageMin ) {
-      fixedImageMin = sample;
-    }
-
-    if ( sample > fixedImageMax ) {
-      fixedImageMax = sample;
-    }
-  }
-
-
-  /**
-   * Compute the minimum and maximum for the entire moving image
-   * in the buffer.
-   */
-  double movingImageMin = NumericTraits<double>::max();
-  double movingImageMax = NumericTraits<double>::NonpositiveMin();
-
-  typedef ImageRegionConstIterator<MovingImageType> MovingIteratorType;
-  MovingIteratorType movingImageIterator(
-    this->m_MovingImage, this->m_MovingImage->GetBufferedRegion() );
-
-  for ( movingImageIterator.GoToBegin();
-        !movingImageIterator.IsAtEnd(); ++movingImageIterator) {
-    double sample = static_cast<double>( movingImageIterator.Get() );
-
-    if ( sample < movingImageMin ) {
-      movingImageMin = sample;
-    }
-
-    if ( sample > movingImageMax ) {
-      movingImageMax = sample;
-    }
-  }
-
-  m_MovingImageTrueMin = movingImageMin;
-  m_MovingImageTrueMax = movingImageMax;
-
-  itkDebugMacro( " FixedImageMin: " << fixedImageMin <<
-                 " FixedImageMax: " << fixedImageMax << std::endl );
-  itkDebugMacro( " MovingImageMin: " << movingImageMin <<
-                 " MovingImageMax: " << movingImageMax << std::endl );
-
-
-  /**
-   * Compute binsize for the histograms.
-   *
-   * The binsize for the image intensities needs to be adjusted so that
-   * we can avoid dealing with boundary conditions using the cubic
-   * spline as the Parzen window.  We do this by increasing the size
-   * of the bins so that the joint histogram becomes "padded" at the
-   * borders. Because we are changing the binsize,
-   * we also need to shift the minimum by the padded amount in order to
-   * avoid minimum values filling in our padded region.
-   *
-   * Note that there can still be non-zero bin values in the padded region,
-   * it's just that these bins will never be a central bin for the Parzen
-   * window.
-   *
-   */
-  const int padding = 2;  // this will pad by 2 bins
-
-  m_FixedImageBinSize = ( fixedImageMax - fixedImageMin ) /
-                        static_cast<double>( m_NumberOfHistogramBins - 2 * padding );
-  m_FixedImageNormalizedMin = fixedImageMin / m_FixedImageBinSize -
-                              static_cast<double>( padding );
-
-  m_MovingImageBinSize = ( movingImageMax - movingImageMin ) /
-                         static_cast<double>( m_NumberOfHistogramBins - 2 * padding );
-  m_MovingImageNormalizedMin = movingImageMin / m_MovingImageBinSize -
-                               static_cast<double>( padding );
-
-
-  itkDebugMacro( "FixedImageNormalizedMin: " << m_FixedImageNormalizedMin );
-  itkDebugMacro( "MovingImageNormalizedMin: " << m_MovingImageNormalizedMin );
-  itkDebugMacro( "FixedImageBinSize: " << m_FixedImageBinSize );
-  itkDebugMacro( "MovingImageBinSize; " << m_MovingImageBinSize );
-
-  if( m_UseAllPixels ) {
-    m_NumberOfSpatialSamples =
-      this->GetFixedImageRegion().GetNumberOfPixels();
-  }
-
-  /**
-   * Allocate memory for the fixed image sample container.
-   */
-  m_FixedImageSamples.resize( m_NumberOfSpatialSamples );
-
-
-  /**
-   * Allocate memory for the marginal PDF and initialize values
-   * to zero. The marginal PDFs are stored as std::vector.
-   */
-  m_FixedImageMarginalPDF.resize( m_NumberOfHistogramBins, 0.0 );
-  m_MovingImageMarginalPDF.resize( m_NumberOfHistogramBins, 0.0 );
-
-  /**
-   * Allocate memory for the joint PDF and joint PDF derivatives.
-   * The joint PDF and joint PDF derivatives are store as itk::Image.
-   */
-  m_JointPDF = JointPDFType::New();
-
-  // Instantiate a region, index, size
-  JointPDFRegionType            jointPDFRegion;
-  JointPDFIndexType              jointPDFIndex;
-  JointPDFSizeType              jointPDFSize;
-
-  // Deallocate the memory that may have been allocated for
-  // previous runs of the metric.
-  this->m_JointPDFDerivatives = NULL;  // by destroying the dynamic array
-  this->m_PRatioArray.SetSize( 1, 1 ); // and by allocating very small the static ones
-  this->m_MetricDerivative = DerivativeType( 1 );
-
-  //
-  // Now allocate memory according to the user-selected method.
-  //
-  if( this->m_UseExplicitPDFDerivatives ) {
-    this->m_JointPDFDerivatives = JointPDFDerivativesType::New();
-    JointPDFDerivativesRegionType  jointPDFDerivativesRegion;
-    JointPDFDerivativesIndexType  jointPDFDerivativesIndex;
-    JointPDFDerivativesSizeType    jointPDFDerivativesSize;
-
-    // For the derivatives of the joint PDF define a region starting from {0,0,0}
-    // with size {m_NumberOfParameters,m_NumberOfHistogramBins,
-    // m_NumberOfHistogramBins}. The dimension represents transform parameters,
-    // fixed image parzen window index and moving image parzen window index,
-    // respectively.
-    jointPDFDerivativesIndex.Fill( 0 );
-    jointPDFDerivativesSize[0] = m_NumberOfParameters;
-    jointPDFDerivativesSize[1] = m_NumberOfHistogramBins;
-    jointPDFDerivativesSize[2] = m_NumberOfHistogramBins;
-
-    jointPDFDerivativesRegion.SetIndex( jointPDFDerivativesIndex );
-    jointPDFDerivativesRegion.SetSize( jointPDFDerivativesSize );
-
-    // Set the regions and allocate
-    m_JointPDFDerivatives->SetRegions( jointPDFDerivativesRegion );
-    m_JointPDFDerivatives->Allocate();
-  } else {
-    /** Allocate memory for helper array that will contain the pRatios
-     *  for each bin of the joint histogram. This is part of the effort
-     *  for flattening the computation of the PDF Jacobians.
-     */
-    this->m_PRatioArray.SetSize( this->m_NumberOfHistogramBins, this->m_NumberOfHistogramBins );
-    this->m_MetricDerivative = DerivativeType( this->GetNumberOfParameters() );
-  }
-
-  // For the joint PDF define a region starting from {0,0}
-  // with size {m_NumberOfHistogramBins, m_NumberOfHistogramBins}.
-  // The dimension represents fixed image parzen window index
-  // and moving image parzen window index, respectively.
-  jointPDFIndex.Fill( 0 );
-  jointPDFSize.Fill( m_NumberOfHistogramBins );
-
-  jointPDFRegion.SetIndex( jointPDFIndex );
-  jointPDFRegion.SetSize( jointPDFSize );
-
-  // Set the regions and allocate
-  m_JointPDF->SetRegions( jointPDFRegion );
-  m_JointPDF->Allocate();
-
-
-  /**
-   * Setup the kernels used for the Parzen windows.
-   */
-  m_CubicBSplineKernel = CubicBSplineFunctionType::New();
-  m_CubicBSplineDerivativeKernel = CubicBSplineDerivativeFunctionType::New();
-
-
-  if( m_UseAllPixels ) {
-    /**
-     * Take all the pixels within the fixed image region)
-     * to create the sample points list.
-     */
-    this->SampleFullFixedImageDomain( m_FixedImageSamples );
-  } else {
-    /**
-     * Uniformly sample the fixed image (within the fixed image region)
-     * to create the sample points list.
-     */
-    this->SampleFixedImageDomain( m_FixedImageSamples );
-  }
-
-  /**
-   * Pre-compute the fixed image parzen window index for
-   * each point of the fixed image sample points list.
-   */
-  this->ComputeFixedImageParzenWindowIndices( m_FixedImageSamples );
-
-  /**
-   * Check if the interpolator is of type BSplineInterpolateImageFunction.
-   * If so, we can make use of its EvaluateDerivatives method.
-   * Otherwise, we instantiate an external central difference
-   * derivative calculator.
-   *
-   * TODO: Also add it the possibility of using the default gradient
-   * provided by the superclass.
-   *
-   */
-  m_InterpolatorIsBSpline = true;
-
-  BSplineInterpolatorType * testPtr = dynamic_cast<BSplineInterpolatorType *>(
-                                        this->m_Interpolator.GetPointer() );
-  if ( !testPtr ) {
-    m_InterpolatorIsBSpline = false;
-
-    m_DerivativeCalculator = DerivativeFunctionType::New();
-
-#ifdef ITK_USE_ORIENTED_IMAGE_DIRECTION
-    m_DerivativeCalculator->UseImageDirectionOn();
-#endif
-
-    m_DerivativeCalculator->SetInputImage( this->m_MovingImage );
-
-    m_BSplineInterpolator = NULL;
-    itkDebugMacro( "Interpolator is not BSpline" );
-  } else {
-    m_BSplineInterpolator = testPtr;
-
-#ifdef ITK_USE_ORIENTED_IMAGE_DIRECTION
-    m_BSplineInterpolator->UseImageDirectionOn();
-#endif
-
-    m_DerivativeCalculator = NULL;
-    itkDebugMacro( "Interpolator is BSpline" );
-  }
-
-  /**
-   * Check if the transform is of type BSplineDeformableTransform.
-   *
-   * If so, several speed up features are implemented.
-   * [1] Precomputing the results of bulk transform for each sample point.
-   * [2] Precomputing the BSpline weights for each sample point,
-   *     to be used later to directly compute the deformation vector
-   * [3] Precomputing the indices of the parameters within the
-   *     the support region of each sample point.
-   */
-  m_TransformIsBSpline = true;
-
-  BSplineTransformType * testPtr2 = dynamic_cast<BSplineTransformType *>(
-                                      this->m_Transform.GetPointer() );
-  if( !testPtr2 ) {
-    m_TransformIsBSpline = false;
-    m_BSplineTransform = NULL;
-    itkDebugMacro( "Transform is not BSplineDeformable" );
-  } else {
-    m_BSplineTransform = testPtr2;
-    m_NumParametersPerDim =
-      m_BSplineTransform->GetNumberOfParametersPerDimension();
-    m_NumBSplineWeights = m_BSplineTransform->GetNumberOfWeights();
-    itkDebugMacro( "Transform is BSplineDeformable" );
-  }
-
-  if( this->m_TransformIsBSpline ) {
-    // First, deallocate memory that may have been used from previous run of the Metric
-    this->m_BSplineTransformWeightsArray.SetSize( 1, 1 );
-    this->m_BSplineTransformIndicesArray.SetSize( 1, 1 );
-    this->m_PreTransformPointsArray.resize( 1 );
-    this->m_WithinSupportRegionArray.resize( 1 );
-    this->m_Weights.SetSize( 1 );
-    this->m_Indices.SetSize( 1 );
-
-
-    if( this->m_UseCachingOfBSplineWeights ) {
-      m_BSplineTransformWeightsArray.SetSize(
-        m_NumberOfSpatialSamples, m_NumBSplineWeights );
-      m_BSplineTransformIndicesArray.SetSize(
-        m_NumberOfSpatialSamples, m_NumBSplineWeights );
-      m_PreTransformPointsArray.resize( m_NumberOfSpatialSamples );
-      m_WithinSupportRegionArray.resize( m_NumberOfSpatialSamples );
-
-      this->PreComputeTransformValues();
-    } else {
-      this->m_Weights.SetSize( this->m_NumBSplineWeights );
-      this->m_Indices.SetSize( this->m_NumBSplineWeights );
-    }
-
-    for ( unsigned int j = 0; j < FixedImageDimension; j++ ) {
-      m_ParametersOffset[j] = j *
-                              m_BSplineTransform->GetNumberOfParametersPerDimension();
-    }
-  }
-
-}
-
-
-/**
- * Uniformly sample the fixed image domain using a random walk
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::SampleFixedImageDomain( FixedImageSpatialSampleContainer& samples )
-{
-
-  // Set up a random interator within the user specified fixed image region.
-  typedef ImageRandomConstIteratorWithIndex<FixedImageType> RandomIterator;
-  RandomIterator randIter( this->m_FixedImage, this->GetFixedImageRegion() );
-
-  randIter.SetNumberOfSamples( m_NumberOfSpatialSamples );
-  randIter.GoToBegin();
-
-  typename FixedImageSpatialSampleContainer::iterator iter;
-  typename FixedImageSpatialSampleContainer::const_iterator end=samples.end();
-
-  if( this->m_FixedImageMask ) {
-
-    InputPointType inputPoint;
-
-    iter=samples.begin();
-    int count = 0;
-    int samples_found = 0;
-    int maxcount = m_NumberOfSpatialSamples * 10;
-    while( iter != end ) {
-
-      if ( count > maxcount ) {
-#if 0
-        itkExceptionMacro(
-          "Drew too many samples from the mask (is it too small?): "
-          << maxcount << std::endl );
-#else
-samples.resize(samples_found);
-//        this->SetNumberOfSpatialSamples(sample_found);
-break;
-#endif
-      }
-      count++;
-
-      // Get sampled index
-      FixedImageIndexType index = randIter.GetIndex();
-      // Check if the Index is inside the mask, translate index to point
-      this->m_FixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-      // If not inside the mask, ignore the point
-      if( !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-        ++randIter; // jump to another random position
-        continue;
-      }
-
-      // Get sampled fixed image value
-      (*iter).FixedImageValue = randIter.Get();
-      // Translate index to point
-      (*iter).FixedImagePointValue = inputPoint;
-      samples_found++;
-      // Jump to random position
-      ++randIter;
-      ++iter;
-    }
-  } else {
-    for( iter=samples.begin(); iter != end; ++iter ) {
-      // Get sampled index
-      FixedImageIndexType index = randIter.GetIndex();
-      // Get sampled fixed image value
-      (*iter).FixedImageValue = randIter.Get();
-      // Translate index to point
-      this->m_FixedImage->TransformIndexToPhysicalPoint( index,
-          (*iter).FixedImagePointValue );
-      // Jump to random position
-      ++randIter;
-
-    }
-  }
-}
-
-/**
- * Sample the fixed image domain using all pixels in the Fixed image region
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::SampleFullFixedImageDomain( FixedImageSpatialSampleContainer& samples )
-{
-
-  // Set up a region interator within the user specified fixed image region.
-  typedef ImageRegionConstIteratorWithIndex<FixedImageType> RegionIterator;
-  RegionIterator regionIter( this->m_FixedImage, this->GetFixedImageRegion() );
-
-  regionIter.GoToBegin();
-
-  typename FixedImageSpatialSampleContainer::iterator iter;
-  typename FixedImageSpatialSampleContainer::const_iterator end=samples.end();
-
-  if( this->m_FixedImageMask ) {
-    InputPointType inputPoint;
-
-    iter=samples.begin();
-    unsigned long nSamplesPicked = 0;
-
-    while( iter != end && !regionIter.IsAtEnd() ) {
-      // Get sampled index
-      FixedImageIndexType index = regionIter.GetIndex();
-      // Check if the Index is inside the mask, translate index to point
-      this->m_FixedImage->TransformIndexToPhysicalPoint( index, inputPoint );
-
-      // If not inside the mask, ignore the point
-      if( !this->m_FixedImageMask->IsInside( inputPoint ) ) {
-        ++regionIter; // jump to next pixel
-        continue;
-      }
-
-      // Get sampled fixed image value
-      (*iter).FixedImageValue = regionIter.Get();
-      // Translate index to point
-      (*iter).FixedImagePointValue = inputPoint;
-
-      ++regionIter;
-      ++iter;
-      ++nSamplesPicked;
-    }
-
-    // If we picked fewer samples than the desired number,
-    // resize the container
-    if (nSamplesPicked != this->m_NumberOfSpatialSamples) {
-      this->m_NumberOfSpatialSamples = nSamplesPicked;
-      samples.resize(this->m_NumberOfSpatialSamples);
-    }
-  } else { // not restricting sample throwing to a mask
-
-    // cannot sample more than the number of pixels in the image region
-    if (  this->m_NumberOfSpatialSamples
-          > this->GetFixedImageRegion().GetNumberOfPixels()) {
-      this->m_NumberOfSpatialSamples
-      = this->GetFixedImageRegion().GetNumberOfPixels();
-      samples.resize(this->m_NumberOfSpatialSamples);
-    }
-
-    for( iter=samples.begin(); iter != end; ++iter ) {
-      // Get sampled index
-      FixedImageIndexType index = regionIter.GetIndex();
-      // Get sampled fixed image value
-      (*iter).FixedImageValue = regionIter.Get();
-      // Translate index to point
-      this->m_FixedImage->TransformIndexToPhysicalPoint( index,
-          (*iter).FixedImagePointValue );
-      ++regionIter;
-    }
-  }
-}
-
-/**
- * Uniformly sample the fixed image domain using a random walk
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::ComputeFixedImageParzenWindowIndices(
-  FixedImageSpatialSampleContainer& samples )
-{
-
-  typename FixedImageSpatialSampleContainer::iterator iter;
-  typename FixedImageSpatialSampleContainer::const_iterator end=samples.end();
-
-  for( iter=samples.begin(); iter != end; ++iter ) {
-
-    // Determine parzen window arguments (see eqn 6 of Mattes paper [2]).
-    double windowTerm =
-      static_cast<double>( (*iter).FixedImageValue ) / m_FixedImageBinSize -
-      m_FixedImageNormalizedMin;
-    unsigned int pindex = static_cast<unsigned int>( vcl_floor(windowTerm ) );
-
-    // Make sure the extreme values are in valid bins
-    if ( pindex < 2 ) {
-      pindex = 2;
-    } else if ( pindex > (m_NumberOfHistogramBins - 3) ) {
-      pindex = m_NumberOfHistogramBins - 3;
-    }
-
-    (*iter).FixedImageParzenWindowIndex = pindex;
-
-  }
-
-}
-
-/**
- * Get the match Measure
- */
-template < class TFixedImage, class TMovingImage  >
-typename MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::MeasureType
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::GetValue( const ParametersType& parameters ) const
-{
-
-  // Reset marginal pdf to all zeros.
-  // Assumed the size has already been set to NumberOfHistogramBins
-  // in Initialize().
-  for ( unsigned int j = 0; j < m_NumberOfHistogramBins; j++ ) {
-    m_FixedImageMarginalPDF[j]  = 0.0;
-    m_MovingImageMarginalPDF[j] = 0.0;
-  }
-
-  // Reset the joint pdfs to zero
-  m_JointPDF->FillBuffer( 0.0 );
-
-  // Set up the parameters in the transform
-  this->m_Transform->SetParameters( parameters );
-
-
-  // Declare iterators for iteration over the sample container
-  typename FixedImageSpatialSampleContainer::const_iterator fiter;
-  typename FixedImageSpatialSampleContainer::const_iterator fend =
-    m_FixedImageSamples.end();
-
-  unsigned long nSamples=0;
-  unsigned long nFixedImageSamples=0;
-
-
-  for ( fiter = m_FixedImageSamples.begin(); fiter != fend; ++fiter ) {
-
-    // Get moving image value
-    MovingImagePointType mappedPoint;
-    bool sampleOk;
-    double movingImageValue;
-
-    this->TransformPoint( nFixedImageSamples, parameters, mappedPoint,
-                          sampleOk, movingImageValue );
-
-    ++nFixedImageSamples;
-
-    if( sampleOk ) {
-
-      ++nSamples;
-
-      /**
-       * Compute this sample's contribution to the marginal and
-       * joint distributions.
-       *
-       */
-
-      // Determine parzen window arguments (see eqn 6 of Mattes paper [2])
-      double movingImageParzenWindowTerm =
-        movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin;
-      unsigned int movingImageParzenWindowIndex =
-        static_cast<unsigned int>( vcl_floor(movingImageParzenWindowTerm ) );
-
-      // Make sure the extreme values are in valid bins
-      if ( movingImageParzenWindowIndex < 2 ) {
-        movingImageParzenWindowIndex = 2;
-      } else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) {
-        movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3;
-      }
-
-
-      // Since a zero-order BSpline (box car) kernel is used for
-      // the fixed image marginal pdf, we need only increment the
-      // fixedImageParzenWindowIndex by value of 1.0.
-      m_FixedImageMarginalPDF[(*fiter).FixedImageParzenWindowIndex] +=
-        static_cast<PDFValueType>( 1 );
-
-      /**
-       * The region of support of the parzen window determines which bins
-       * of the joint PDF are effected by the pair of image values.
-       * Since we are using a cubic spline for the moving image parzen
-       * window, four bins are affected.  The fixed image parzen window is
-       * a zero-order spline (box car) and thus effects only one bin.
-       *
-       *  The PDF is arranged so that moving image bins corresponds to the
-       * zero-th (column) dimension and the fixed image bins corresponds
-       * to the first (row) dimension.
-       *
-       */
-
-      // Pointer to affected bin to be updated
-      JointPDFValueType *pdfPtr = m_JointPDF->GetBufferPointer() +
-                                  ( (*fiter).FixedImageParzenWindowIndex
-                                    * m_JointPDF->GetOffsetTable()[1] );
-
-      // Move the pointer to the first affected bin
-      int pdfMovingIndex = static_cast<int>( movingImageParzenWindowIndex ) - 1;
-      pdfPtr += pdfMovingIndex;
-
-      for (; pdfMovingIndex <= static_cast<int>( movingImageParzenWindowIndex )
-           + 2;
-           pdfMovingIndex++, pdfPtr++ ) {
-
-        // Update PDF for the current intensity pair
-        double movingImageParzenWindowArg =
-          static_cast<double>( pdfMovingIndex ) -
-          static_cast<double>( movingImageParzenWindowTerm );
-
-        *(pdfPtr) += static_cast<PDFValueType>(
-                       m_CubicBSplineKernel->Evaluate( movingImageParzenWindowArg ) );
-
-      }  //end parzen windowing for loop
-
-    } //end if-block check sampleOk
-  } // end iterating over fixed image spatial sample container for loop
-
-  itkDebugMacro( "Ratio of voxels mapping into moving image buffer: "
-                 << nSamples << " / " << m_NumberOfSpatialSamples
-                 << std::endl );
-
-  if( nSamples < m_NumberOfSpatialSamples / 16 ) {
-    itkExceptionMacro( "Too many samples map outside moving image buffer: "
-                       << nSamples << " / " << m_NumberOfSpatialSamples
-                       << std::endl );
-  }
-
-  this->m_NumberOfPixelsCounted = nSamples;
-
-
-  /**
-   * Normalize the PDFs, compute moving image marginal PDF
-   *
-   */
-  typedef ImageRegionIterator<JointPDFType> JointPDFIteratorType;
-  JointPDFIteratorType jointPDFIterator ( m_JointPDF,
-                                          m_JointPDF->GetBufferedRegion() );
-
-  jointPDFIterator.GoToBegin();
-
-  // Compute joint PDF normalization factor
-  // (to ensure joint PDF sum adds to 1.0)
-  double jointPDFSum = 0.0;
-
-  while( !jointPDFIterator.IsAtEnd() ) {
-    jointPDFSum += jointPDFIterator.Get();
-    ++jointPDFIterator;
-  }
-
-  if ( jointPDFSum == 0.0 ) {
-    itkExceptionMacro( "Joint PDF summed to zero" );
-  }
-
-
-  // Normalize the PDF bins
-  jointPDFIterator.GoToEnd();
-  while( !jointPDFIterator.IsAtBegin() ) {
-    --jointPDFIterator;
-    jointPDFIterator.Value() /= static_cast<PDFValueType>( jointPDFSum );
-  }
-
-
-  // Normalize the fixed image marginal PDF
-  double fixedPDFSum = 0.0;
-  for( unsigned int bin = 0; bin < m_NumberOfHistogramBins; bin++ ) {
-    fixedPDFSum += m_FixedImageMarginalPDF[bin];
-  }
-
-  if ( fixedPDFSum == 0.0 ) {
-    itkExceptionMacro( "Fixed image marginal PDF summed to zero" );
-  }
-
-  for( unsigned int bin=0; bin < m_NumberOfHistogramBins; bin++ ) {
-    m_FixedImageMarginalPDF[bin] /= static_cast<PDFValueType>( fixedPDFSum );
-  }
-
-
-  // Compute moving image marginal PDF by summing over fixed image bins.
-  typedef ImageLinearIteratorWithIndex<JointPDFType> JointPDFLinearIterator;
-  JointPDFLinearIterator linearIter( m_JointPDF,
-                                     m_JointPDF->GetBufferedRegion() );
-
-  linearIter.SetDirection( 1 );
-  linearIter.GoToBegin();
-  unsigned int movingIndex1 = 0;
-
-  while( !linearIter.IsAtEnd() ) {
-
-    double sum = 0.0;
-
-    while( !linearIter.IsAtEndOfLine() ) {
-      sum += linearIter.Get();
-      ++linearIter;
-    }
-
-    m_MovingImageMarginalPDF[movingIndex1] = static_cast<PDFValueType>(sum);
-
-    linearIter.NextLine();
-    ++movingIndex1;
-
-  }
-
-  /**
-   * Compute the metric by double summation over histogram.
-   */
-
-  // Setup pointer to point to the first bin
-  JointPDFValueType * jointPDFPtr = m_JointPDF->GetBufferPointer();
-
-  // Initialze sum to zero
-  double sum = 0.0;
-
-  for( unsigned int fixedIndex = 0;
-       fixedIndex < m_NumberOfHistogramBins;
-       ++fixedIndex ) {
-
-    double fixedImagePDFValue = m_FixedImageMarginalPDF[fixedIndex];
-
-    for( unsigned int movingIndex = 0;
-         movingIndex < m_NumberOfHistogramBins;
-         ++movingIndex, jointPDFPtr++ ) {
-
-      double movingImagePDFValue = m_MovingImageMarginalPDF[movingIndex];
-      double jointPDFValue = *(jointPDFPtr);
-
-      // check for non-zero bin contribution
-      if( jointPDFValue > 1e-16 &&  movingImagePDFValue > 1e-16 ) {
-
-        double pRatio = vcl_log(jointPDFValue / movingImagePDFValue );
-        if( fixedImagePDFValue > 1e-16) {
-          sum += jointPDFValue * ( pRatio - vcl_log(fixedImagePDFValue ) );
-        }
-
-      }  // end if-block to check non-zero bin contribution
-    }  // end for-loop over moving index
-  }  // end for-loop over fixed index
-
-  return static_cast<MeasureType>( -1.0 * sum );
-
-}
-
-
-/**
- * Get the both Value and Derivative Measure
- */
-template < class TFixedImage, class TMovingImage  >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::GetValueAndDerivative(
-  const ParametersType& parameters,
-  MeasureType& value,
-  DerivativeType& derivative) const
-{
-
-  // Set output values to zero
-  value = NumericTraits< MeasureType >::Zero;
-
-  if( this->m_UseExplicitPDFDerivatives ) {
-    m_JointPDFDerivatives->FillBuffer( 0.0 );
-    derivative = DerivativeType( this->GetNumberOfParameters() );
-    derivative.Fill( NumericTraits< MeasureType >::Zero );
-  } else {
-    this->m_MetricDerivative.Fill( NumericTraits< MeasureType >::Zero );
-    this->m_PRatioArray.Fill( 0.0 );
-  }
-
-  // Reset marginal pdf to all zeros.
-  // Assumed the size has already been set to NumberOfHistogramBins
-  // in Initialize().
-  for ( unsigned int j = 0; j < m_NumberOfHistogramBins; j++ ) {
-    m_FixedImageMarginalPDF[j]  = 0.0;
-    m_MovingImageMarginalPDF[j] = 0.0;
-  }
-
-  // Reset the joint pdfs to zero
-  m_JointPDF->FillBuffer( 0.0 );
-
-
-  // Set up the parameters in the transform
-  this->m_Transform->SetParameters( parameters );
-
-
-  // Declare iterators for iteration over the sample container
-  typename FixedImageSpatialSampleContainer::const_iterator fiter;
-  typename FixedImageSpatialSampleContainer::const_iterator fend =
-    m_FixedImageSamples.end();
-
-  unsigned long nSamples=0;
-  unsigned long nFixedImageSamples=0;
-
-  for ( fiter = m_FixedImageSamples.begin(); fiter != fend; ++fiter ) {
-
-    // Get moving image value
-    MovingImagePointType mappedPoint;
-    bool sampleOk;
-    double movingImageValue;
-
-
-    this->TransformPoint( nFixedImageSamples, parameters, mappedPoint,
-                          sampleOk, movingImageValue );
-
-    if( sampleOk ) {
-      ++nSamples;
-
-      // Get moving image derivative at the mapped position
-      ImageDerivativesType movingImageGradientValue;
-      this->ComputeImageDerivatives( mappedPoint, movingImageGradientValue );
-
-
-      /**
-       * Compute this sample's contribution to the marginal
-       *   and joint distributions.
-       *
-       */
-
-      // Determine parzen window arguments (see eqn 6 of Mattes paper [2])
-      double movingImageParzenWindowTerm =
-        movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin;
-      unsigned int movingImageParzenWindowIndex =
-        static_cast<unsigned int>( vcl_floor(movingImageParzenWindowTerm ) );
-
-      // Make sure the extreme values are in valid bins
-      if ( movingImageParzenWindowIndex < 2 ) {
-        movingImageParzenWindowIndex = 2;
-      } else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) {
-        movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3;
-      }
-
-
-      // Since a zero-order BSpline (box car) kernel is used for
-      // the fixed image marginal pdf, we need only increment the
-      // fixedImageParzenWindowIndex by value of 1.0.
-      m_FixedImageMarginalPDF[(*fiter).FixedImageParzenWindowIndex] +=
-        static_cast<PDFValueType>( 1 );
-
-      /**
-       * The region of support of the parzen window determines which bins
-       * of the joint PDF are effected by the pair of image values.
-       * Since we are using a cubic spline for the moving image parzen
-       * window, four bins are effected.  The fixed image parzen window is
-       * a zero-order spline (box car) and thus effects only one bin.
-       *
-       *  The PDF is arranged so that moving image bins corresponds to the
-       * zero-th (column) dimension and the fixed image bins corresponds
-       * to the first (row) dimension.
-       *
-       */
-
-      // Pointer to affected bin to be updated
-      JointPDFValueType *pdfPtr = m_JointPDF->GetBufferPointer() +
-                                  ( (*fiter).FixedImageParzenWindowIndex * m_NumberOfHistogramBins );
-
-      // Move the pointer to the fist affected bin
-      int pdfMovingIndex = static_cast<int>( movingImageParzenWindowIndex ) - 1;
-      pdfPtr += pdfMovingIndex;
-
-      for (; pdfMovingIndex <= static_cast<int>( movingImageParzenWindowIndex )
-           + 2;
-           pdfMovingIndex++, pdfPtr++ ) {
-        // Update PDF for the current intensity pair
-        double movingImageParzenWindowArg =
-          static_cast<double>( pdfMovingIndex ) -
-          static_cast<double>(movingImageParzenWindowTerm);
-
-        *(pdfPtr) += static_cast<PDFValueType>(
-                       m_CubicBSplineKernel->Evaluate( movingImageParzenWindowArg ) );
-
-        if( this->m_UseExplicitPDFDerivatives ) {
-          // Compute the cubicBSplineDerivative for later repeated use.
-          double cubicBSplineDerivativeValue =
-            m_CubicBSplineDerivativeKernel->Evaluate(
-              movingImageParzenWindowArg );
-
-          // Compute PDF derivative contribution.
-          this->ComputePDFDerivatives( nFixedImageSamples,
-                                       pdfMovingIndex,
-                                       movingImageGradientValue,
-                                       cubicBSplineDerivativeValue );
-        }
-
-      }  //end parzen windowing for loop
-
-    } //end if-block check sampleOk
-
-    ++nFixedImageSamples;
-
-  } // end iterating over fixed image spatial sample container for loop
-
-  itkDebugMacro( "Ratio of voxels mapping into moving image buffer: "
-                 << nSamples << " / " << m_NumberOfSpatialSamples
-                 << std::endl );
-
-  if( nSamples < m_NumberOfSpatialSamples / 16 ) {
-    itkExceptionMacro( "Too many samples map outside moving image buffer: "
-                       << nSamples << " / " << m_NumberOfSpatialSamples
-                       << std::endl );
-  }
-
-  this->m_NumberOfPixelsCounted = nSamples;
-
-  /**
-   * Normalize the PDFs, compute moving image marginal PDF
-   *
-   */
-  typedef ImageRegionIterator<JointPDFType> JointPDFIteratorType;
-  JointPDFIteratorType jointPDFIterator ( m_JointPDF,
-                                          m_JointPDF->GetBufferedRegion() );
-
-  jointPDFIterator.GoToBegin();
-
-
-  // Compute joint PDF normalization factor
-  // (to ensure joint PDF sum adds to 1.0)
-  double jointPDFSum = 0.0;
-
-  while( !jointPDFIterator.IsAtEnd() ) {
-    jointPDFSum += jointPDFIterator.Get();
-    ++jointPDFIterator;
-  }
-
-  if ( jointPDFSum == 0.0 ) {
-    itkExceptionMacro( "Joint PDF summed to zero" );
-  }
-
-
-  // Normalize the PDF bins
-  jointPDFIterator.GoToEnd();
-  while( !jointPDFIterator.IsAtBegin() ) {
-    --jointPDFIterator;
-    jointPDFIterator.Value() /= static_cast<PDFValueType>( jointPDFSum );
-  }
-
-
-  // Normalize the fixed image marginal PDF
-  double fixedPDFSum = 0.0;
-  for( unsigned int bin = 0; bin < m_NumberOfHistogramBins; bin++ ) {
-    fixedPDFSum += m_FixedImageMarginalPDF[bin];
-  }
-
-  if ( fixedPDFSum == 0.0 ) {
-    itkExceptionMacro( "Fixed image marginal PDF summed to zero" );
-  }
-
-  for( unsigned int bin=0; bin < m_NumberOfHistogramBins; bin++ ) {
-    m_FixedImageMarginalPDF[bin] /= static_cast<PDFValueType>( fixedPDFSum );
-  }
-
-
-  // Compute moving image marginal PDF by summing over fixed image bins.
-  typedef ImageLinearIteratorWithIndex<JointPDFType> JointPDFLinearIterator;
-  JointPDFLinearIterator linearIter(
-    m_JointPDF, m_JointPDF->GetBufferedRegion() );
-
-  linearIter.SetDirection( 1 );
-  linearIter.GoToBegin();
-  unsigned int movingIndex1 = 0;
-
-  while( !linearIter.IsAtEnd() ) {
-
-    double sum = 0.0;
-
-    while( !linearIter.IsAtEndOfLine() ) {
-      sum += linearIter.Get();
-      ++linearIter;
-    }
-
-    m_MovingImageMarginalPDF[movingIndex1] = static_cast<PDFValueType>(sum);
-
-    linearIter.NextLine();
-    ++movingIndex1;
-
-  }
-
-  double nFactor = 1.0 / ( m_MovingImageBinSize
-                           * static_cast<double>( nSamples ) );
-
-  if( this->m_UseExplicitPDFDerivatives ) {
-    // Normalize the joint PDF derivatives by the test image binsize and nSamples
-    typedef ImageRegionIterator<JointPDFDerivativesType>
-    JointPDFDerivativesIteratorType;
-    JointPDFDerivativesIteratorType jointPDFDerivativesIterator (
-      m_JointPDFDerivatives,
-      m_JointPDFDerivatives->GetBufferedRegion()
-    );
-
-    jointPDFDerivativesIterator.GoToBegin();
-
-    while( !jointPDFDerivativesIterator.IsAtEnd() ) {
-      jointPDFDerivativesIterator.Value() *= nFactor;
-      ++jointPDFDerivativesIterator;
-    }
-  }
-
-  /**
-   * Compute the metric by double summation over histogram.
-   */
-
-  // Setup pointer to point to the first bin
-  JointPDFValueType * jointPDFPtr = m_JointPDF->GetBufferPointer();
-
-  // Initialize sum to zero
-  double sum = 0.0;
-
-  for( unsigned int fixedIndex = 0;
-       fixedIndex < m_NumberOfHistogramBins;
-       ++fixedIndex ) {
-    double fixedImagePDFValue = m_FixedImageMarginalPDF[fixedIndex];
-
-    for( unsigned int movingIndex = 0; movingIndex < m_NumberOfHistogramBins;
-         ++movingIndex, jointPDFPtr++ ) {
-      double movingImagePDFValue = m_MovingImageMarginalPDF[movingIndex];
-      double jointPDFValue = *(jointPDFPtr);
-
-      // check for non-zero bin contribution
-      if( jointPDFValue > 1e-16 &&  movingImagePDFValue > 1e-16 ) {
-
-        double pRatio = vcl_log(jointPDFValue / movingImagePDFValue );
-
-        if( fixedImagePDFValue > 1e-16) {
-          sum += jointPDFValue * ( pRatio - vcl_log(fixedImagePDFValue ) );
-        }
-
-        if( this->m_UseExplicitPDFDerivatives ) {
-          // move joint pdf derivative pointer to the right position
-          JointPDFValueType * derivPtr = m_JointPDFDerivatives->GetBufferPointer()
-                                         + ( fixedIndex  * m_JointPDFDerivatives->GetOffsetTable()[2] )
-                                         + ( movingIndex * m_JointPDFDerivatives->GetOffsetTable()[1] );
-
-          for( unsigned int parameter=0; parameter < m_NumberOfParameters; ++parameter, derivPtr++ ) {
-            // Ref: eqn 23 of Thevenaz & Unser paper [3]
-            derivative[parameter] -= (*derivPtr) * pRatio;
-          }  // end for-loop over parameters
-        } else {
-          this->m_PRatioArray[fixedIndex][movingIndex] = pRatio * nFactor;
-        }
-      }  // end if-block to check non-zero bin contribution
-    }  // end for-loop over moving index
-  }  // end for-loop over fixed index
-
-  if( !(this->m_UseExplicitPDFDerivatives ) ) {
-    // Second pass: This one is done for accumulating the contributions
-    //              to the derivative array.
-
-    nFixedImageSamples = 0;
-
-    for ( fiter = m_FixedImageSamples.begin(); fiter != fend; ++fiter ) {
-
-      // Get moving image value
-      MovingImagePointType mappedPoint;
-      bool sampleOk;
-      double movingImageValue;
-
-      this->TransformPoint( nFixedImageSamples, parameters, mappedPoint,
-                            sampleOk, movingImageValue );
-
-      if( sampleOk ) {
-        // Get moving image derivative at the mapped position
-        ImageDerivativesType movingImageGradientValue;
-        this->ComputeImageDerivatives( mappedPoint, movingImageGradientValue );
-
-
-        /**
-         * Compute this sample's contribution to the marginal
-         *   and joint distributions.
-         *
-         */
-
-        // Determine parzen window arguments (see eqn 6 of Mattes paper [2]).
-        double movingImageParzenWindowTerm =
-          movingImageValue / m_MovingImageBinSize - m_MovingImageNormalizedMin;
-        unsigned int movingImageParzenWindowIndex =
-          static_cast<unsigned int>( vcl_floor(movingImageParzenWindowTerm ) );
-
-        // Make sure the extreme values are in valid bins
-        if ( movingImageParzenWindowIndex < 2 ) {
-          movingImageParzenWindowIndex = 2;
-        } else if ( movingImageParzenWindowIndex > (m_NumberOfHistogramBins - 3) ) {
-          movingImageParzenWindowIndex = m_NumberOfHistogramBins - 3;
-        }
-
-
-        // Move the pointer to the fist affected bin
-        int pdfMovingIndex = static_cast<int>( movingImageParzenWindowIndex ) - 1;
-
-        for (; pdfMovingIndex <= static_cast<int>( movingImageParzenWindowIndex )
-             + 2;
-             pdfMovingIndex++ ) {
-
-          // Update PDF for the current intensity pair
-          double movingImageParzenWindowArg =
-            static_cast<double>( pdfMovingIndex ) -
-            static_cast<double>(movingImageParzenWindowTerm);
-
-          // Compute the cubicBSplineDerivative for later repeated use.
-          double cubicBSplineDerivativeValue =
-            m_CubicBSplineDerivativeKernel->Evaluate(
-              movingImageParzenWindowArg );
-
-          // Compute PDF derivative contribution.
-          this->ComputePDFDerivatives( nFixedImageSamples,
-                                       pdfMovingIndex,
-                                       movingImageGradientValue,
-                                       cubicBSplineDerivativeValue );
-
-
-        }  //end parzen windowing for loop
-
-      } //end if-block check sampleOk
-
-      ++nFixedImageSamples;
-
-    } // end iterating over fixed image spatial sample container for loop
-
-
-    derivative = this->m_MetricDerivative;
-  }
-
-  value = static_cast<MeasureType>( -1.0 * sum );
-}
-
-
-/**
- * Get the match measure derivative
- */
-template < class TFixedImage, class TMovingImage  >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::GetDerivative( const ParametersType& parameters,
-                 DerivativeType & derivative ) const
-{
-  MeasureType value;
-  // call the combined version
-  this->GetValueAndDerivative( parameters, value, derivative );
-}
-
-
-/**
- * Compute image derivatives using a central difference function
- * if we are not using a BSplineInterpolator, which includes
- * derivatives.
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::ComputeImageDerivatives(
-  const MovingImagePointType& mappedPoint,
-  ImageDerivativesType& gradient ) const
-{
-
-  if( m_InterpolatorIsBSpline ) {
-    // Computed moving image gradient using derivative BSpline kernel.
-    gradient = m_BSplineInterpolator->EvaluateDerivative( mappedPoint );
-  } else {
-    // For all generic interpolator use central differencing.
-    gradient = m_DerivativeCalculator->Evaluate( mappedPoint );
-  }
-
-}
-
-
-/**
- * Transform a point from FixedImage domain to MovingImage domain.
- * This function also checks if mapped point is within support region.
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::TransformPoint(
-  unsigned int sampleNumber,
-  const ParametersType& parameters,
-  MovingImagePointType& mappedPoint,
-  bool& sampleOk,
-  double& movingImageValue ) const
-{
-
-  if ( !m_TransformIsBSpline ) {
-    // Use generic transform to compute mapped position
-    mappedPoint = this->m_Transform->TransformPoint(
-                    m_FixedImageSamples[sampleNumber].FixedImagePointValue );
-
-    // Check if mapped point inside image buffer
-    sampleOk = this->m_Interpolator->IsInsideBuffer( mappedPoint );
-  } else {
-
-    if( this->m_UseCachingOfBSplineWeights ) {
-      // If the transform is BSplineDeformable, we can use the precomputed
-      // weights and indices to obtained the mapped position
-      //
-      const WeightsValueType * weights =
-        m_BSplineTransformWeightsArray[sampleNumber];
-      const IndexValueType   * indices =
-        m_BSplineTransformIndicesArray[sampleNumber];
-      mappedPoint.Fill( 0.0 );
-
-      if ( m_WithinSupportRegionArray[sampleNumber] ) {
-        for ( unsigned int k = 0; k < m_NumBSplineWeights; k++ ) {
-          for ( unsigned int j = 0; j < FixedImageDimension; j++ ) {
-            mappedPoint[j] += weights[k] *
-                              parameters[ indices[k] + m_ParametersOffset[j] ];
-          }
-        }
-      }
-
-      for( unsigned int j = 0; j < FixedImageDimension; j++ ) {
-        mappedPoint[j] += m_PreTransformPointsArray[sampleNumber][j];
-      }
-
-      // Check if mapped point inside image buffer
-      sampleOk = this->m_Interpolator->IsInsideBuffer( mappedPoint );
-
-      // Check if mapped point is within the support region of a grid point.
-      // This is neccessary for computing the metric gradient
-      sampleOk = sampleOk && m_WithinSupportRegionArray[sampleNumber];
-    } else {
-      // If not caching values, we invoke the Transform to recompute the
-      // mapping of the point.
-      this->m_BSplineTransform->TransformPoint(
-        this->m_FixedImageSamples[sampleNumber].FixedImagePointValue,
-        mappedPoint, this->m_Weights, this->m_Indices, sampleOk);
-
-      // Check if mapped point inside image buffer
-      sampleOk = sampleOk && this->m_Interpolator->IsInsideBuffer( mappedPoint );
-    }
-
-  }
-
-  // If user provided a mask over the Moving image
-  if ( this->m_MovingImageMask ) {
-    // Check if mapped point is within the support region of the moving image
-    // mask
-    sampleOk = sampleOk && this->m_MovingImageMask->IsInside( mappedPoint );
-  }
-
-
-  if ( sampleOk ) {
-    movingImageValue = this->m_Interpolator->Evaluate( mappedPoint );
-
-    if ( movingImageValue < m_MovingImageTrueMin ||
-         movingImageValue > m_MovingImageTrueMax ) {
-      // need to throw out this sample as it will not fall into a valid bin
-      sampleOk = false;
-    }
-  }
-}
-
-
-/**
- * Compute PDF derivatives contribution for each parameter
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::ComputePDFDerivatives(
-  unsigned int sampleNumber,
-  int pdfMovingIndex,
-  const ImageDerivativesType& movingImageGradientValue,
-  double cubicBSplineDerivativeValue ) const
-{
-
-  const int pdfFixedIndex =
-    m_FixedImageSamples[sampleNumber].FixedImageParzenWindowIndex;
-
-  JointPDFValueType * derivPtr = NULL;
-  double precomputedWeight = 0.0;
-
-  if( this->m_UseExplicitPDFDerivatives ) {
-    // Update bins in the PDF derivatives for the current intensity pair
-    derivPtr = m_JointPDFDerivatives->GetBufferPointer() +
-               ( pdfFixedIndex  * m_JointPDFDerivatives->GetOffsetTable()[2] ) +
-               ( pdfMovingIndex * m_JointPDFDerivatives->GetOffsetTable()[1] );
-  } else {
-    // Recover the precomputed weight for this specific PDF bin
-    precomputedWeight = this->m_PRatioArray[pdfFixedIndex][pdfMovingIndex];
-  }
-
-  if( !m_TransformIsBSpline ) {
-
-    /**
-     * Generic version which works for all transforms.
-     */
-
-    // Compute the transform Jacobian.
-    typedef typename TransformType::JacobianType JacobianType;
-#if ITK_VERSION_MAJOR >= 4
-      JacobianType jacobian;
-      this->m_Transform->ComputeJacobianWithRespectToParameters( m_FixedImageSamples[sampleNumber].FixedImagePointValue, jacobian );
-#else
-      const JacobianType & jacobian =
-        this->m_Transform->GetJacobian( m_FixedImageSamples[sampleNumber].FixedImagePointValue );
-#endif
-
-    for ( unsigned int mu = 0; mu < m_NumberOfParameters; mu++ ) {
-      double innerProduct = 0.0;
-      for ( unsigned int dim = 0; dim < FixedImageDimension; dim++ ) {
-        innerProduct += jacobian[dim][mu] * movingImageGradientValue[dim];
-      }
-
-      const double derivativeContribution = innerProduct * cubicBSplineDerivativeValue;
-
-      if( this->m_UseExplicitPDFDerivatives ) {
-        *(derivPtr) -= derivativeContribution;
-        ++derivPtr;
-      } else {
-        this->m_MetricDerivative[mu] += precomputedWeight * derivativeContribution;
-      }
-    }
-
-  } else {
-    const WeightsValueType * weights = NULL;
-    const IndexValueType   * indices = NULL;
-
-    if( this->m_UseCachingOfBSplineWeights ) {
-      /**
-       * If the transform is of type BSplineDeformableTransform,
-       * we can obtain a speed up by only processing the affected parameters.
-       * Note that these pointers are just pointing to pre-allocated rows
-       * of the caching arrays. There is therefore, no need to free this
-       * memory.
-       */
-      weights = m_BSplineTransformWeightsArray[sampleNumber];
-      indices = m_BSplineTransformIndicesArray[sampleNumber];
-    } else {
-#if ITK_VERSION_MAJOR >= 4
-      m_BSplineTransform->ComputeJacobianFromBSplineWeightsWithRespectToPosition(
-        m_FixedImageSamples[sampleNumber].FixedImagePointValue, m_Weights, m_Indices );
-#else
-      m_BSplineTransform->GetJacobian(
-        m_FixedImageSamples[sampleNumber].FixedImagePointValue, m_Weights, m_Indices );
-#endif
-    }
-
-    for( unsigned int dim = 0; dim < FixedImageDimension; dim++ ) {
-
-      double innerProduct;
-      int parameterIndex;
-
-      for( unsigned int mu = 0; mu < m_NumBSplineWeights; mu++ ) {
-
-        /* The array weights contains the Jacobian values in a 1-D array
-         * (because for each parameter the Jacobian is non-zero in only 1 of the
-         * possible dimensions) which is multiplied by the moving image
-         * gradient. */
-        if( this->m_UseCachingOfBSplineWeights ) {
-          innerProduct = movingImageGradientValue[dim] * weights[mu];
-          parameterIndex = indices[mu] + m_ParametersOffset[dim];
-        } else {
-          innerProduct = movingImageGradientValue[dim] * this->m_Weights[mu];
-          parameterIndex = this->m_Indices[mu] + this->m_ParametersOffset[dim];
-        }
-
-        const double derivativeContribution = innerProduct * cubicBSplineDerivativeValue;
-
-        if( this->m_UseExplicitPDFDerivatives ) {
-          JointPDFValueType * ptr = derivPtr + parameterIndex;
-          *(ptr) -= derivativeContribution;
-        } else {
-          this->m_MetricDerivative[parameterIndex] += precomputedWeight * derivativeContribution;
-        }
-
-      } //end mu for loop
-    } //end dim for loop
-
-  } // end if-block transform is BSpline
-
-}
-
-
-// Method to reinitialize the seed of the random number generator
-template < class TFixedImage, class TMovingImage  > void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::ReinitializeSeed()
-{
-  Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed();
-}
-
-// Method to reinitialize the seed of the random number generator
-template < class TFixedImage, class TMovingImage  > void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::ReinitializeSeed(int seed)
-{
-  Statistics::MersenneTwisterRandomVariateGenerator::GetInstance()->SetSeed(
-    seed);
-}
-
-
-/**
- * Cache pre-transformed points, weights and indices.
- * This method is only called if the flag UseCachingOfBSplineWeights is ON.
- */
-template < class TFixedImage, class TMovingImage >
-void
-MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
-::PreComputeTransformValues()
-{
-  // Create all zero dummy transform parameters
-  ParametersType dummyParameters( this->m_Transform->GetNumberOfParameters() );
-  dummyParameters.Fill( 0.0 );
-  this->m_Transform->SetParameters( dummyParameters );
-
-  // Cycle through each sampled fixed image point
-  BSplineTransformWeightsType weights( m_NumBSplineWeights );
-  BSplineTransformIndexArrayType indices( m_NumBSplineWeights );
-  bool valid;
-  MovingImagePointType mappedPoint;
-
-  // Declare iterators for iteration over the sample container
-  typename FixedImageSpatialSampleContainer::const_iterator fiter;
-  typename FixedImageSpatialSampleContainer::const_iterator fend =
-    m_FixedImageSamples.end();
-  unsigned long counter = 0;
-
-  for( fiter = m_FixedImageSamples.begin(); fiter != fend; ++fiter, counter++ ) {
-    m_BSplineTransform->TransformPoint(
-      m_FixedImageSamples[counter].FixedImagePointValue,
-      mappedPoint, weights, indices, valid );
-
-    for( unsigned long k = 0; k < m_NumBSplineWeights; k++ ) {
-      m_BSplineTransformWeightsArray[counter][k] = weights[k];
-      m_BSplineTransformIndicesArray[counter][k] = indices[k];
-    }
-
-    m_PreTransformPointsArray[counter]      = mappedPoint;
-    m_WithinSupportRegionArray[counter]     = valid;
-
-  }
-
-}
-
-
-} // end namespace itk
-
-
-#endif
-
 #endif
index f6d745dec64d4cc96ec18440f34d7649026ffc06..c3be983d68cafdb579d9206427295e64609a238f 100644 (file)
 // gets integrated into the main directories.
 #include "itkConfigure.h"
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.h"
-#else
-
-#include "itkImageToImageMetric.h"
-#include "itkCovariantVector.h"
-#include "itkPoint.h"
-
-
-namespace itk
-{
-/** \class MeanSquaresImageToImageMetricFor3DBLUTFFD
- * \brief Computes similarity between two objects to be registered
- *
- * This Class is templated over the type of the fixed and moving
- * images to be compared.
- *
- * This metric computes the sum of squared differences between pixels in
- * the moving image and pixels in the fixed image. The spatial correspondance
- * between both images is established through a Transform. Pixel values are
- * taken from the Moving image. Their positions are mapped to the Fixed image
- * and result in general in non-grid position on it. Values at these non-grid
- * position of the Fixed image are interpolated using a user-selected Interpolator.
- *
- * \ingroup RegistrationMetrics
- */
-template < class TFixedImage, class TMovingImage >
-class ITK_EXPORT MeanSquaresImageToImageMetricFor3DBLUTFFD :
-  public ImageToImageMetric< TFixedImage, TMovingImage>
-{
-public:
-
-  /** Standard class typedefs. */
-  typedef MeanSquaresImageToImageMetricFor3DBLUTFFD                  Self;
-  typedef ImageToImageMetric<TFixedImage, TMovingImage > Superclass;
-  typedef SmartPointer<Self>                             Pointer;
-  typedef SmartPointer<const Self>                       ConstPointer;
-
-  /** Method for creation through the object factory. */
-  itkNewMacro(Self);
-
-  /** Run-time type information (and related methods). */
-  itkTypeMacro(MeanSquaresImageToImageMetricFor3DBLUTFFD, ImageToImageMetric);
-
-
-  /** Types transferred from the base class */
-  typedef typename Superclass::RealType                 RealType;
-  typedef typename Superclass::TransformType            TransformType;
-  typedef typename Superclass::TransformPointer         TransformPointer;
-  typedef typename Superclass::TransformParametersType  TransformParametersType;
-  typedef typename Superclass::TransformJacobianType    TransformJacobianType;
-  typedef typename Superclass::GradientPixelType        GradientPixelType;
-  typedef typename Superclass::GradientImageType        GradientImageType;
-  typedef typename Superclass::InputPointType           InputPointType;
-  typedef typename Superclass::OutputPointType          OutputPointType;
-
-  typedef typename Superclass::MeasureType              MeasureType;
-  typedef typename Superclass::DerivativeType           DerivativeType;
-  typedef typename Superclass::FixedImageType           FixedImageType;
-  typedef typename Superclass::MovingImageType          MovingImageType;
-  typedef typename Superclass::FixedImageConstPointer   FixedImageConstPointer;
-  typedef typename Superclass::MovingImageConstPointer  MovingImageConstPointer;
-
-
-  /** Get the derivatives of the match measure. */
-  void GetDerivative( const TransformParametersType & parameters,
-                      DerivativeType & derivative ) const;
-
-  /**  Get the value for single valued optimizers. */
-  MeasureType GetValue( const TransformParametersType & parameters ) const;
-
-  /**  Get value and derivatives for multiple valued optimizers. */
-  void GetValueAndDerivative( const TransformParametersType & parameters,
-                              MeasureType& Value, DerivativeType& Derivative ) const;
-
-#ifdef ITK_USE_CONCEPT_CHECKING
-  /** Begin concept checking */
-  itkConceptMacro(MovingPixelTypeHasNumericTraitsCheck,
-                  (Concept::HasNumericTraits<typename TMovingImage::PixelType>));
-  itkConceptMacro(MovingRealTypeAdditivieOperatorsCheck,
-                  (Concept::AdditiveOperators<
-                   typename NumericTraits<typename TMovingImage::PixelType>::RealType>));
-  itkConceptMacro(MovingRealTypeMultiplyOperatorCheck,
-                  (Concept::MultiplyOperator<
-                   typename NumericTraits<typename TMovingImage::PixelType>::RealType>));
-
-  /** End concept checking */
-#endif
-
-protected:
-  MeanSquaresImageToImageMetricFor3DBLUTFFD();
-  virtual ~MeanSquaresImageToImageMetricFor3DBLUTFFD() {};
-
-private:
-  MeanSquaresImageToImageMetricFor3DBLUTFFD(const Self&); //purposely not implemented
-  void operator=(const Self&); //purposely not implemented
-
-};
-
-} // end namespace itk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "itkMeanSquaresImageToImageMetricFor3DBLUTFFD.txx"
-#endif
-
-#endif
-
 #endif
 
index d6793e58e18fe1a9106f3ad3b4633058266462f3..67e4ac430e4951b129aa1c97ddddfefaaab55c15 100644 (file)
@@ -40,9 +40,7 @@
 // gets integrated into the main directories.
 #include "itkConfigure.h"
 
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
 #include "itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD.txx"
-#else
 
 #include "itkMeanSquaresImageToImageMetricFor3DBLUTFFD.h"
 #include "itkImageRegionConstIteratorWithIndex.h"
@@ -197,13 +195,8 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
-#if ITK_VERSION_MAJOR >= 4
       TransformJacobianType jacobian;
       this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
 
       const RealType fixedValue     = ti.Value();
       this->m_NumberOfPixelsCounted++;
@@ -315,13 +308,8 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
     if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) ) {
       const RealType movingValue  = this->m_Interpolator->Evaluate( transformedPoint );
 
-#if ITK_VERSION_MAJOR >= 4
       TransformJacobianType jacobian;
       this->m_Transform->ComputeJacobianWithRespectToParameters( inputPoint, jacobian );
-#else
-      const TransformJacobianType & jacobian =
-        this->m_Transform->GetJacobian( inputPoint );
-#endif
 
       const RealType fixedValue     = ti.Value();
       this->m_NumberOfPixelsCounted++;
index 7cfe51e203aa30af2ef6c6c65c8bc2a3e03369e6..1eaa49a2f9ac6096af40dc5dc0ad24f2872b4e7d 100644 (file)
 #ifndef __itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD_h
 #define __itkOptMattesMutualInformationImageToImageMetricFor3DBLUTFFD_h
 
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkImageToImageMetric.h"
-#else
-  #include "itkOptImageToImageMetric.h"
-#endif
+#include "itkImageToImageMetric.h"
 #include "itkCovariantVector.h"
 #include "itkPoint.h"
 #include "itkIndex.h"
index f55b19a5556d1d76c343babb15e80f610b6ec117..dec3acff0b59f079ae9922cd8828cdd057eb0941 100644 (file)
@@ -44,8 +44,8 @@ PURPOSE.  See the above copyright notices for more information.
 #include "vnl/vnl_math.h"
 #include "itkStatisticsImageFilter.h"
 
-#include "vnl/vnl_vector.txx"
-#include "vnl/vnl_c_vector.txx"
+#include "vnl/vnl_vector.h"
+#include "vnl/vnl_c_vector.h"
 
 namespace itk
 {
@@ -630,9 +630,6 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 {
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING
   this->GetValueMultiThreadedInitiate();
@@ -941,9 +938,6 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING ON SAMPLES
   this->GetValueAndDerivativeMultiThreadedInitiate();
@@ -1156,13 +1150,8 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
       transform = this->m_Transform;
     }
 
-#if ITK_VERSION_MAJOR >= 4
     JacobianType jacobian;
     transform->ComputeJacobianWithRespectToParameters(this->m_FixedImageSamples[sampleNumber].point, jacobian);
-#else
-    const JacobianType& jacobian =
-      transform->GetJacobian( this->m_FixedImageSamples[sampleNumber].point );
-#endif
 
     //     for ( unsigned int mu = 0; mu < this->m_NumberOfParameters; mu++ )
     //       {
@@ -1230,15 +1219,9 @@ MattesMutualInformationImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
         indicesHelper = &(this->m_BSplineTransformIndices);
       }
 
-#if ITK_VERSION_MAJOR >= 4
       this->m_BSplineTransform->ComputeJacobianFromBSplineWeightsWithRespectToPosition(
         this->m_FixedImageSamples[sampleNumber].point,
         *weightsHelper, *indicesHelper );
-#else
-      this->m_BSplineTransform->GetJacobian(
-        this->m_FixedImageSamples[sampleNumber].point,
-        *weightsHelper, *indicesHelper );
-#endif
     }
 
     for( unsigned int dim = 0; dim < Superclass::FixedImageDimension; dim++ ) {
index acb0b1b3aa4065be0e402fda51a3ecc0dabea788..949246d4c581b2586eb51ee3862a7b04ec16691f 100644 (file)
 #ifndef __itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD_h
 #define __itkOptMeanSquaresImageToImageMetricFor3DBLUTFFD_h
 
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkImageToImageMetric.h"
-#else
-  #include "itkOptImageToImageMetric.h"
-#endif
+#include "itkImageToImageMetric.h"
 #include "itkCovariantVector.h"
 #include "itkPoint.h"
 #include "itkIndex.h"
index cf173407bf7310fd4e4a921f4b278c2053f5e0a1..dd7000ddec171559063f684d1218d9014cdeddd4 100644 (file)
@@ -153,9 +153,6 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // MUST BE CALLED TO INITIATE PROCESSING
   this->GetValueMultiThreadedInitiate();
@@ -215,12 +212,8 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
   }
 
   // Jacobian should be evaluated at the unmapped (fixed image) point.
-#if ITK_VERSION_MAJOR >= 4
   TransformJacobianType jacobian;
   transform->ComputeJacobianWithRespectToParameters(this->m_FixedImageSamples[fixedImageSample].point, jacobian);
-#else
-  const TransformJacobianType & jacobian = transform ->GetJacobian( this->m_FixedImageSamples[fixedImageSample].point );
-#endif
   //double sum;
   unsigned int par, dim;
   for( par=0; par<this->m_NumberOfParameters; par+=3) {
@@ -257,9 +250,6 @@ MeanSquaresImageToImageMetricFor3DBLUTFFD<TFixedImage,TMovingImage>
 
   // Set up the parameters in the transform
   this->m_Transform->SetParameters( parameters );
-#if ITK_VERSION_MAJOR < 4
-  this->m_Parameters = parameters;
-#endif
 
   // Reset the joint pdfs to zero
   memset( m_ThreaderMSE,
index 5c16569f56b700e7104e1c3cec74786eb73c4d77..ecc136b62f217fae0f4bbf22d3698b65c46ceb66 100644 (file)
@@ -1,11 +1,11 @@
 #=========================================================
 
 # Add Libraries used in vv and clitk to avoid recompilation
-FOREACH(clitkTool clitkExtractLung clitkExtractPatient clitkConnectedComponentLabeling clitkRegionGrowing)
+foreach(clitkTool clitkExtractLung clitkExtractPatient clitkConnectedComponentLabeling clitkRegionGrowing)
     WRAP_GGO(${clitkTool}_GGO_C ${clitkTool}.ggo)
-    SET(GGO_C_FILES ${GGO_C_FILES} ${${clitkTool}_GGO_C})
-ENDFOREACH(clitkTool)
-ADD_LIBRARY(clitkSegmentationGgoLib
+    set(GGO_C_FILES ${GGO_C_FILES} ${${clitkTool}_GGO_C})
+endforeach(clitkTool)
+add_library(clitkSegmentationGgoLib
             clitkFilterWithAnatomicalFeatureDatabaseManagement.cxx
             clitkAnatomicalFeatureDatabase.cxx
             clitkSliceBySliceRelativePositionFilter_uchar.cxx
@@ -13,51 +13,51 @@ ADD_LIBRARY(clitkSegmentationGgoLib
 
 #=========================================================
 
-IF(CLITK_BUILD_SEGMENTATION)
+if(CLITK_BUILD_SEGMENTATION)
     WRAP_GGO(clitkConnectedComponentLabeling_GGO_C clitkConnectedComponentLabeling.ggo)
-    ADD_EXECUTABLE(clitkConnectedComponentLabeling clitkConnectedComponentLabeling.cxx ${clitkConnectedComponentLabeling_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkConnectedComponentLabeling clitkCommon)
-    SET(SEGMENTATION_INSTALL clitkConnectedComponentLabeling)
+    add_executable(clitkConnectedComponentLabeling clitkConnectedComponentLabeling.cxx ${clitkConnectedComponentLabeling_GGO_C})
+    target_link_libraries(clitkConnectedComponentLabeling clitkCommon)
+    set(SEGMENTATION_INSTALL clitkConnectedComponentLabeling)
 
-    ADD_EXECUTABLE(clitkExtractPatient clitkExtractPatient.cxx ${clitkExtractPatient_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkExtractPatient clitkCommon clitkSegmentationGgoLib)
-    SET(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkExtractPatient)
+    add_executable(clitkExtractPatient clitkExtractPatient.cxx ${clitkExtractPatient_GGO_C})
+    target_link_libraries(clitkExtractPatient clitkCommon clitkSegmentationGgoLib)
+    set(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkExtractPatient)
 
-    ADD_EXECUTABLE(clitkExtractLung clitkExtractLung.cxx  ${clitkExtractLung_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkExtractLung clitkSegmentationGgoLib clitkCommon)
-    SET(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkExtractLung)
+    add_executable(clitkExtractLung clitkExtractLung.cxx  ${clitkExtractLung_GGO_C})
+    target_link_libraries(clitkExtractLung clitkSegmentationGgoLib clitkCommon)
+    set(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkExtractLung)
 
     WRAP_GGO(clitkExtractBones_GGO_C clitkExtractBones.ggo)
-    ADD_EXECUTABLE(clitkExtractBones clitkExtractBones.cxx ${clitkExtractBones_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkExtractBones clitkCommon clitkSegmentationGgoLib)
-    SET(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkExtractBones)
+    add_executable(clitkExtractBones clitkExtractBones.cxx ${clitkExtractBones_GGO_C})
+    target_link_libraries(clitkExtractBones clitkCommon clitkSegmentationGgoLib)
+    set(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkExtractBones)
 
     WRAP_GGO(clitkMorphoMath_GGO_C clitkMorphoMath.ggo)
-    ADD_EXECUTABLE(clitkMorphoMath clitkMorphoMath.cxx ${clitkMorphoMath_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMorphoMath clitkCommon)
-    SET(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkMorphoMath)
+    add_executable(clitkMorphoMath clitkMorphoMath.cxx ${clitkMorphoMath_GGO_C})
+    target_link_libraries(clitkMorphoMath clitkCommon)
+    set(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkMorphoMath)
 
     WRAP_GGO(clitkDecomposeAndReconstruct_GGO_C clitkDecomposeAndReconstruct.ggo)
-    ADD_EXECUTABLE(clitkDecomposeAndReconstruct clitkDecomposeAndReconstruct.cxx clitkDecomposeAndReconstructGenericFilter.cxx ${clitkDecomposeAndReconstruct_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkDecomposeAndReconstruct clitkCommon)
-    SET(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkDecomposeAndReconstruct)
+    add_executable(clitkDecomposeAndReconstruct clitkDecomposeAndReconstruct.cxx clitkDecomposeAndReconstructGenericFilter.cxx ${clitkDecomposeAndReconstruct_GGO_C})
+    target_link_libraries(clitkDecomposeAndReconstruct clitkCommon)
+    set(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkDecomposeAndReconstruct)
 
     WRAP_GGO(clitkMotionMask_GGO_C clitkMotionMask.ggo)
-    ADD_EXECUTABLE(clitkMotionMask clitkMotionMask.cxx clitkMotionMaskGenericFilter.cxx ${clitkMotionMask_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMotionMask clitkCommon)
-    SET(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkMotionMask)
-    
+    add_executable(clitkMotionMask clitkMotionMask.cxx clitkMotionMaskGenericFilter.cxx ${clitkMotionMask_GGO_C})
+    target_link_libraries(clitkMotionMask clitkCommon)
+    set(SEGMENTATION_INSTALL ${SEGMENTATION_INSTALL} clitkMotionMask)
+
     WRAP_GGO(clitkRegionGrowing_GGO_C clitkRegionGrowing.ggo)
-    ADD_EXECUTABLE(clitkRegionGrowing clitkRegionGrowing.cxx ${clitkRegionGrowing_GGO_C} ${clitkRelativePosition_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkRegionGrowing clitkCommon)
+    add_executable(clitkRegionGrowing clitkRegionGrowing.cxx ${clitkRegionGrowing_GGO_C} ${clitkRelativePosition_GGO_C})
+    target_link_libraries(clitkRegionGrowing clitkCommon)
 
-    INSTALL (TARGETS ${SEGMENTATION_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
+    install(TARGETS ${SEGMENTATION_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
 
-ENDIF(CLITK_BUILD_SEGMENTATION)
+endif(CLITK_BUILD_SEGMENTATION)
 
-# ADD_EXECUTABLE(ScalarImageMarkovRandomField1 ScalarImageMarkovRandomField1.cxx)
-# TARGET_LINK_LIBRARIES(ScalarImageMarkovRandomField1 clitkCommon ITKStatistics)
-# ADD_EXECUTABLE(ScalarImageKmeansClassifier ScalarImageKmeansClassifier.cxx)
-# TARGET_LINK_LIBRARIES(ScalarImageKmeansClassifier clitkCommon ITKStatistics)
+# add_executable(ScalarImageMarkovRandomField1 ScalarImageMarkovRandomField1.cxx)
+# target_link_libraries(ScalarImageMarkovRandomField1 clitkCommon ITKStatistics)
+# add_executable(ScalarImageKmeansClassifier ScalarImageKmeansClassifier.cxx)
+# target_link_libraries(ScalarImageKmeansClassifier clitkCommon ITKStatistics)
 
 
index 0f5bfdd64a549714aef543b9ddc60801e0cc95bd..13fb26960ad2e29e20dd7c8124806c885609304e 100644 (file)
@@ -106,11 +106,7 @@ void clitk::AnatomicalFeatureDatabase::Load()
 //--------------------------------------------------------------------
 void clitk::AnatomicalFeatureDatabase::SetPoint3D(std::string tag, PointType3D & p)
 {
-#if ITK_VERSION_MAJOR > 3
   std::ostringstream value;
-#else
-  ::itk::OStringStream value;
-#endif
   value << p[0] << " " << p[1] << " " << p[2];
   m_MapOfTag[tag] = value.str();
 }
index b76001f0491397c36648ddb86653c120ddcfb49c..596604b61f44b1f6e1c8c39115f3888a4f069734 100644 (file)
@@ -668,9 +668,7 @@ SearchForTracheaSeed2(int numberOfSlices)
     opening->Update();
     
     typename SlicerFilterType::Pointer slicer = SlicerFilterType::New();
-#if ITK_VERSION_MAJOR >= 4
     slicer->SetDirectionCollapseToIdentity();
-#endif
     slicer->SetInput(opening->GetOutput());
     
     // label result
@@ -752,11 +750,7 @@ SearchForTracheaSeed2(int numberOfSlices)
       for (unsigned int j = 0; j < nlables; j++) {
         shape = label_map->GetNthLabelObject(j);
         if (shape->Size() > 150 && shape->Size() <= max_size) {
-#if ITK_VERSION_MAJOR < 4
-          double e = 1 - 1/shape->GetBinaryElongation();
-#else
           double e = 1 - 1/shape->GetElongation();
-#endif
           //double area = 1 - r->Area() ;
           if (e < max_elongation) {
             nshapes++;
index 7d2369cdf9839eb317ed0ec26b747eca351e3855..cfe366a3bbdaba0d16bdafe1f1db2f9ae5f9fc20 100644 (file)
@@ -141,9 +141,7 @@ GenerateData()
         start2D[m_Directions[i]]=sliceIndex;
         desiredRegion.SetIndex( start2D );
         extractFilter->SetExtractionRegion( desiredRegion );
-#if ITK_VERSION_MAJOR == 4
         extractFilter->SetDirectionCollapseToSubmatrix();
-#endif
         extractFilter->Update( );
         typename ImageSliceType::Pointer slice= extractFilter->GetOutput();
         
index f86c2ba7e082ceb63200a588999a0f43e42fd301..a63400678ac010303277019dcc4e15b9439047b9 100644 (file)
@@ -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
@@ -22,7 +22,6 @@
 // clitk include
 #include "clitkIO.h"
 #include "clitkImageCommon.h"
-#include "clitkMorphoMath_ggo.h"
 #include "clitkConditionalBinaryErodeImageFilter.h"
 #include "clitkConditionalBinaryDilateImageFilter.h"
 
@@ -39,12 +38,12 @@ namespace clitk {
 
   //--------------------------------------------------------------------
   template<class ImageType>
-  class ITK_EXPORT MorphoMathFilter: 
-    public clitk::FilterBase, 
-    public itk::ImageToImageFilter<ImageType, ImageType> 
+  class ITK_EXPORT MorphoMathFilter:
+    public clitk::FilterBase,
+    public itk::ImageToImageFilter<ImageType, ImageType>
   {
-    
-  public: 
+
+  public:
     /** Standard class typedefs. */
     typedef itk::ImageToImageFilter<ImageType, ImageType> Superclass;
     typedef MorphoMathFilter<ImageType>                   Self;
@@ -52,8 +51,8 @@ namespace clitk {
     typedef itk::SmartPointer<const Self>                 ConstPointer;
 
     /** Method for creation through the object factory. */
-    itkNewMacro(Self);  
-    
+    itkNewMacro(Self);
+
     /** Run-time type information (and related methods). */
     itkTypeMacro(AddRelativePositionConstraintToLabelImageFilter, ImageToImageFilter);
     FILTERBASE_INIT;
@@ -61,7 +60,7 @@ namespace clitk {
     /** Some convenient typedefs. */
     typedef typename ImageType::ConstPointer ImageConstPointer;
     typedef typename ImageType::Pointer      ImagePointer;
-    typedef typename ImageType::RegionType   RegionType; 
+    typedef typename ImageType::RegionType   RegionType;
     typedef typename ImageType::PixelType    PixelType;
     typedef typename ImageType::SpacingType  SpacingType;
     typedef typename ImageType::SizeType     SizeType;
@@ -69,17 +68,17 @@ namespace clitk {
     typedef typename ImageType::PointType    PointType;
     typedef float InternalPixelType;
     typedef itk::Image<InternalPixelType, ImageType::ImageDimension> InternalImageType;
-    
+
     /** ImageDimension constants */
     itkStaticConstMacro(ImageDimension, unsigned int, ImageType::ImageDimension);
     typedef itk::Image<float, ImageDimension> FloatImageType;
 
     /** Operation types */
     typedef enum { Erode     = 0, Dilate     = 1,
-                   Close     = 2, Open       = 3, 
+                   Close     = 2, Open       = 3,
                    CondErode = 4, CondDilate = 5
     } OperationTypeEnumeration;
-    
+
     /** Options */
     itkGetConstMacro(VerboseFlag, bool);
     itkSetMacro(VerboseFlag, bool);
@@ -92,7 +91,7 @@ namespace clitk {
     itkSetMacro(ForegroundValue, PixelType);
 
     void SetOperationType(int type);
-    
+
     itkGetConstMacro(RadiusInMM, PointType);
     void SetRadiusInMM(PointType & p);
 
@@ -103,11 +102,11 @@ namespace clitk {
     itkGetConstMacro(BoundaryToForegroundFlag, bool);
     itkSetMacro(BoundaryToForegroundFlag, bool);
     itkBooleanMacro(BoundaryToForegroundFlag);
-    
+
     itkGetConstMacro(ExtendSupportFlag, bool);
     itkSetMacro(ExtendSupportFlag, bool);
     itkBooleanMacro(ExtendSupportFlag);
-    
+
   protected:
     MorphoMathFilter();
     virtual ~MorphoMathFilter();
@@ -132,10 +131,10 @@ namespace clitk {
     MorphoMathFilter(const Self&); //purposely not implemented
     void operator=(const Self&); //purposely not implemented
   };
-  
+
 } // end namespace clitk
 #ifndef ITK_MANUAL_INSTANTIATION
 #include "clitkMorphoMathFilter.txx"
 #endif
-  
+
 #endif //#define CLITKMORPHOMATHFILTER_H
index c6476c2c3d75214c79f5202f9350fd42089fb351..fd21b4629d4da99590b741e4fe7fa9ff634cfb50 100644 (file)
@@ -541,11 +541,8 @@ MotionMaskGenericFilter::InitializeEllips( typename itk::Vector<double,Dimension
 
       // try to guess ideal ellipse axes from the lungs' bounding box and centroid
       // with some hard-coded "magic" constants...
-#if ITK_VERSION_MAJOR >= 4
       typename LabelType::RegionType lung_bbox = label->GetBoundingBox();
-#else
-      typename LabelType::RegionType lung_bbox = label->GetRegion();
-#endif
+
       axes[0] = 0.95*lung_bbox.GetSize()[0]*spacing[0]/2;
       axes[1] = 0.3*lung_bbox.GetSize()[1]*spacing[1]/2;
       axes[2] = 1.25*fabs(lung_centroid[2] - center[2]);
index e8f365317661d7a7e5d83ab28d98440561607ca9..681b98ec57eee4e8e6f12e260d06ecd27e00266a 100644 (file)
@@ -110,24 +110,8 @@ void clitk::RegionGrowingGenericFilter<ArgsInfoType>::UpdateWithInputImageType()
       IteratorType it(ball.GetRadius(),
                       input,
                       input->GetLargestPossibleRegion());
-#if ITK_VERSION_MAJOR < 4
-      typename BallType::ConstIterator nit;
-      unsigned idx = 0;
-      for (nit = ball.Begin(); nit != ball.End(); ++nit, ++idx)
-        {
-          if (*nit)
-            {
-              it.ActivateOffset(it.GetOffset(idx));
-            }
-          else
-            {
-              it.DeactivateOffset(it.GetOffset(idx));
-            }
-        }
-#else
       it.CreateActiveListFromNeighborhood(ball);
       it.NeedToUseBoundaryConditionOff();
-#endif
 
       it.SetLocation(seeds[0]);
       for (typename IteratorType::ConstIterator i = it.Begin(); !i.IsAtEnd(); ++i)
index a3d5dfe7fb0151d82618ea1aa77668244706c9f3..fad0b95d1b075c243877494b30f06455f14f4e49 100644 (file)
@@ -9,9 +9,9 @@ set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Build configuration type"
 set(build_type ${CMAKE_BUILD_TYPE})
 
 #=========================================================
-MACRO (DD in)
-    MESSAGE(${in}=${${in}})
-ENDMACRO(DD)
+macro(DD in)
+    message(${in}=${${in}})
+endmacro(DD)
 #=========================================================
 
 project(SuperBuild_VV)
@@ -38,20 +38,23 @@ set(install_prefix ${base}/Install)
 
 find_package(Git REQUIRED)
 
+if( 1 EQUAL 1)
 #=========================================================
 # QT
-SET(QtWinSpecFiles "${source_prefix}/qt/mkspecs/win32-msvc2003/qmake.conf";
-                   "${source_prefix}/qt/mkspecs/win32-msvc2005/qmake.conf";
-                   "${source_prefix}/qt/mkspecs/win32-msvc2008/qmake.conf";
-                   "${source_prefix}/qt/mkspecs/win32-msvc2010/qmake.conf")
+if(WIN32)
+set(QtWinSpecFiles "${source_prefix}/qt/mkspecs/win32-msvc2003/qmake.conf;${source_prefix}/qt/mkspecs/win32-msvc2005/qmake.conf;${source_prefix}/qt/mkspecs/win32-msvc2008/qmake.conf;${source_prefix}/qt/mkspecs/win32-msvc2010/qmake.conf")
+set(WINPATCH "sed -i \"s/\\-MD/-MT/g\" ${QtWinSpecFiles}")
+else()
+set(WINPATCH "")
+endif()
 ExternalProject_Add(
   QT
   SOURCE_DIR ${source_prefix}/qt
-  GIT_REPOSITORY git://gitorious.org/qt/qt.git
-  GIT_TAG v4.8.3
-  PATCH_COMMAND sed -i "s/\\-MD/-MT/g" ${QtWinSpecFiles}
+  GIT_REPOSITORY git://code.qt.io/qt/qt.git
+  GIT_TAG v4.8.6
+  PATCH_COMMAND ${WINPATCH}
   CONFIGURE_COMMAND ${source_prefix}/qt/configure -confirm-license
-                                                  -static 
+                                                  -static
                                                   -fast
                                                   -opensource
                                                   -release
@@ -65,21 +68,27 @@ ExternalProject_Add(
                                                   -no-glib
   INSTALL_COMMAND ""
 )
-SET(qmake_executable "${build_prefix}/QT/bin/qmake")
+set(qmake_executable "${build_prefix}/QT/bin/qmake")
+set(VTK_DEPEND_QT QT)
+
+else()
+  find_package(qt4 REQUIRED)
+  set(VTK_DEPEND_QT "")
+endif()
 #=========================================================
 
 #=========================================================
 # VTK
-SET(VTK_CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")
-IF(MSVC)
-  SET(VTK_CMAKE_CXX_STANDARD_LIBRARIES "${VTK_CMAKE_CXX_STANDARD_LIBRARIES} Imm32.lib Winmm.lib Ws2_32.lib")
-ENDIF(MSVC)
+set(VTK_CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")
+if(MSVC)
+  set(VTK_CMAKE_CXX_STANDARD_LIBRARIES "${VTK_CMAKE_CXX_STANDARD_LIBRARIES} Imm32.lib Winmm.lib Ws2_32.lib")
+endif(MSVC)
 ExternalProject_Add(
-  VTK 
-  DEPENDS QT
+  VTK
+  DEPENDS ${VTK_DEPEND_QT}
   SOURCE_DIR ${source_prefix}/vtk
   GIT_REPOSITORY git://vtk.org/VTK.git
-  GIT_TAG v5.10.0
+  GIT_TAG release-5.10
   INSTALL_COMMAND ""
   CMAKE_ARGS
     -DQT_QMAKE_EXECUTABLE:FILEPATH=${qmake_executable}
@@ -100,7 +109,7 @@ ExternalProject_Add(
     -DVTK_USE_QVTK_QTOPENGL:BOOL=ON
     -DCMAKE_CXX_STANDARD_LIBRARIES:STRING=${VTK_CMAKE_CXX_STANDARD_LIBRARIES}
 )
-SET(VTK_DIR ${build_prefix}/VTK)
+set(VTK_DIR ${build_prefix}/VTK)
 #=========================================================
 
 #=========================================================
@@ -108,11 +117,10 @@ SET(VTK_DIR ${build_prefix}/VTK)
    ExternalProject_Add(
    GDCM
    SOURCE_DIR ${source_prefix}/gdcm
-   GIT_REPOSITORY git://git.code.sf.net/p/gdcm/gdcm 
-   GIT_TAG v2.2.3
+   GIT_REPOSITORY git://git.code.sf.net/p/gdcm/gdcm
+   GIT_TAG v2.2.4
    INSTALL_COMMAND ""
    CMAKE_ARGS
-   -DQT_QMAKE_EXECUTABLE:FILEPATH=${qmake_executable}
    -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
    -DCMAKE_C_FLAGS_MINSIZEREL:STRING=${CMAKE_C_FLAGS_MINSIZEREL}
    -DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}
@@ -124,7 +132,7 @@ SET(VTK_DIR ${build_prefix}/VTK)
    -DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PREFIX}
    -DCMAKE_BUILD_TYPE:STRING=${build_type}
 )
-SET(GDCM_DIR ${build_prefix}/GDCM)
+set(GDCM_DIR ${build_prefix}/GDCM)
 #=========================================================
 
 #=========================================================
@@ -133,7 +141,7 @@ ExternalProject_Add(
   ITK
   SOURCE_DIR ${source_prefix}/itk
   GIT_REPOSITORY git://itk.org/ITK.git
-  GIT_TAG v4.4.0
+  GIT_TAG v4.5.2
   INSTALL_COMMAND ""
   CMAKE_ARGS
     -DCMAKE_C_FLAGS_DEBUG:STRING=${CMAKE_C_FLAGS_DEBUG}
@@ -150,32 +158,33 @@ ExternalProject_Add(
     -DBUILD_EXAMPLES:BOOL=OFF
     -DBUILD_TESTING:BOOL=OFF
 )
-SET(ITK_DIR ${build_prefix}/ITK)
+set(ITK_DIR ${build_prefix}/ITK)
 #=========================================================
 
 #=========================================================
 # VV
-SET(VV_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+set(VV_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
 if(MSVC)
-  SET(VV_CMAKE_CXX_FLAGS "${VV_CMAKE_CXX_FLAGS} /bigobj")
+  set(VV_CMAKE_CXX_FLAGS "${VV_CMAKE_CXX_FLAGS} /bigobj")
 endif(MSVC)
 
-SET(VV_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
+set(VV_CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS})
 if(CMAKE_COMPILER_IS_GNUCXX)
-  SET(VV_CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
+  set(VV_CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
 endif(CMAKE_COMPILER_IS_GNUCXX)
 
-SET(MAKE_COMMAND "make")
+set(MAKE_COMMAND "make")
 if(MSVC)
-  SET(MAKE_COMMAND "nmake")
+  set(MAKE_COMMAND "nmake")
 endif(MSVC)
 
 ExternalProject_Add(
   VV
-  DEPENDS QT VTK ITK GDCM
+  DEPENDS ${VTK_DEPEND_QT} VTK ITK GDCM
   SOURCE_DIR ${source_prefix}/vv
   GIT_REPOSITORY git://git.creatis.insa-lyon.fr/clitk
-  INSTALL_COMMAND ${MAKE_COMMAND} package
+  INSTALL_DIR ${install_prefix}
+  INSTALL_COMMAND  make install
   CMAKE_ARGS
     -DQT_QMAKE_EXECUTABLE:FILEPATH=${qmake_executable}
     -DGDCM_DIR:PATH=${GDCM_DIR}
@@ -195,10 +204,6 @@ ExternalProject_Add(
     -DCMAKE_BUILD_TYPE:STRING=${build_type}
     -DBUILD_SHARED_LIBS:BOOL=OFF
     -DBUILD_TESTING:BOOL=OFF
-    -DCLITK_BUILD_REGISTRATION:BOOL=ON
-    -DCLITK_BUILD_SEGMENTATION:BOOL=ON
-    -DCLITK_BUILD_TOOLS:BOOL=ON
-    -DCLITK_BUILD_EXPERIMENTAL:BOOL=ON
 )
 #=========================================================
 
index 30beaaaeb2d97781361eae18e0be9181ddfcd7c5..d91dee6a93c88a7222feae05e91795b86abf870f 100644 (file)
@@ -2,31 +2,31 @@ cmake_policy(SET CMP0005 NEW)
 #=========================================================
 #=========================================================
 # Data tests path
-FIND_PATH(CLITK_TEST_DATA_PATH Lung3D.mhd)
-IF(NOT ${CLITK_TEST_DATA_PATH} MATCHES "NOTFOUND$")
SET(CLITK_TEST_DATA_PATH "${CLITK_TEST_DATA_PATH}/")
-ENDIF()
-ADD_DEFINITIONS(-DCLITK_TEST_DATA_PATH="${CLITK_TEST_DATA_PATH}")
+find_path(CLITK_TEST_DATA_PATH Lung3D.mhd)
+if(NOT ${CLITK_TEST_DATA_PATH} MATCHES "NOTFOUND$")
set(CLITK_TEST_DATA_PATH "${CLITK_TEST_DATA_PATH}/")
+endif()
+add_definitions(-DCLITK_TEST_DATA_PATH="${CLITK_TEST_DATA_PATH}")
 #=========================================================
 #=========================================================
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
-SET(BUILDNAME ${CMAKE_SYSTEM_NAME}${CMAKE_OSX_ARCHITECTURES} CACHE INTERNAL DOCSTRING)
+set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests/bin)
+set(BUILDNAME ${CMAKE_SYSTEM_NAME}${CMAKE_OSX_ARCHITECTURES} CACHE INTERNAL DOCSTRING)
 #=========================================================
 #=========================================================
 # Enabled options to test
-IF(CLITK_BUILD_TOOLS)
-  ADD_SUBDIRECTORY(tools)
-ENDIF()
-#IF(CLITK_BUILD_VV)
-#  ADD_SUBDIRECTORY(vv)
-#ENDIF()
-# IF(CLITK_BUILD_SEGMENTATION)
-#   ADD_SUBDIRECTORY(segmentation)
-# ENDIF()
-# 
-# IF(CLITK_BUILD_REGISTATION)
-#   ADD_SUBDIRECTORY(registration)
-# ENDIF()
-#ADD_SUBDIRECTORY(common)
+if(CLITK_BUILD_TOOLS)
+  add_subdirectory(tools)
+endif()
+#if(CLITK_BUILD_VV)
+#  add_subdirectory(vv)
+#endif()
+# if(CLITK_BUILD_SEGMENTATION)
+#   add_subdirectory(segmentation)
+# endif()
+#
+# if(CLITK_BUILD_REGISTATION)
+#   add_subdirectory(registration)
+# endif()
+#add_subdirectory(common)
 #=========================================================
 
index 7282ac49f7b62862434b9f6a310fb57a3ebacf10..c480699cd49f57f71725d96c5201ce1eadf01623 100644 (file)
@@ -3,76 +3,76 @@ include_directories(
   ${PROJECT_SOURCE_DIR}/tools
 )
 
-SET(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING)
-ADD_DEFINITIONS(-DCLITK_TEST_TOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\")
-SET (srcs
+set(BUILDNAME ${BUILDNAME}_tools CACHE INTERNAL DOCSTRING)
+add_definitions(-DCLITK_TEST_TOOLS_PATH=\"${PROJECT_BINARY_DIR}/bin/\")
+set(srcs
   toolTestRunner.cxx
 )
 
-ADD_EXECUTABLE(toolTestRunner ${srcs})
-TARGET_LINK_LIBRARIES(toolTestRunner ${ITK_LIBRARIES})
-SET(exe ${EXECUTABLE_OUTPUT_PATH}/toolTestRunner) 
-SET(p ${CLITK_TEST_DATA_PATH})
+add_executable(toolTestRunner ${srcs})
+target_link_libraries(toolTestRunner ${ITK_LIBRARIES})
+set(exe ${EXECUTABLE_OUTPUT_PATH}/toolTestRunner)
+set(p ${CLITK_TEST_DATA_PATH})
 #=========================================================
 # clitkImageInfo
-ADD_TEST(clitkImageInfo_4d    ${exe} clitkImageInfo ${p}Deformation4D.mhd ${p}Deformation4D_ref.info)
-ADD_TEST(clitkImageInfo_3d    ${exe} clitkImageInfo ${p}Lung3D.mhd      ${p}Lung3D_ref.info)
+add_test(clitkImageInfo_4d    ${exe} clitkImageInfo ${p}Deformation4D.mhd ${p}Deformation4D_ref.info)
+add_test(clitkImageInfo_3d    ${exe} clitkImageInfo ${p}Lung3D.mhd      ${p}Lung3D_ref.info)
 #=========================================================
 # clitkGetSpacing
-ADD_TEST(clitkGetSpacing_4d   ${exe} clitkGetSpacing -i ${p}Deformation4D.mhd ${p}Deformation4D_ref.spacing)
-ADD_TEST(clitkGetSpacing_3d   ${exe} clitkGetSpacing -i ${p}Lung3D.mhd              ${p}Lung3D_ref.spacing)
+add_test(clitkGetSpacing_4d   ${exe} clitkGetSpacing -i ${p}Deformation4D.mhd ${p}Deformation4D_ref.spacing)
+add_test(clitkGetSpacing_3d   ${exe} clitkGetSpacing -i ${p}Lung3D.mhd              ${p}Lung3D_ref.spacing)
 #=========================================================
 # clitkGetOrigin
-ADD_TEST(clitkGetOrigin_4d    ${exe} clitkGetOrigin -i ${p}Deformation4D.mhd ${p}Deformation4D_ref.origin)
-ADD_TEST(clitkGetOrigin_3d    ${exe} clitkGetOrigin -i ${p}Lung3D.mhd      ${p}Lung3D_ref.origin)
+add_test(clitkGetOrigin_4d    ${exe} clitkGetOrigin -i ${p}Deformation4D.mhd ${p}Deformation4D_ref.origin)
+add_test(clitkGetOrigin_3d    ${exe} clitkGetOrigin -i ${p}Lung3D.mhd      ${p}Lung3D_ref.origin)
 #=========================================================
 # clitkGetSize
-ADD_TEST(clitkGetSize_4d      ${exe} clitkGetSize -i ${p}Deformation4D.mhd   ${p}Deformation4D_ref.size)
-ADD_TEST(clitkGetSize_3d     ${exe} clitkGetSize -i ${p}Lung3D.mhd         ${p}Lung3D_ref.size)
+add_test(clitkGetSize_4d      ${exe} clitkGetSize -i ${p}Deformation4D.mhd   ${p}Deformation4D_ref.size)
+add_test(clitkGetSize_3d     ${exe} clitkGetSize -i ${p}Lung3D.mhd         ${p}Lung3D_ref.size)
 #=========================================================
 # clitkGetDirection
-ADD_TEST(clitkGetDirection_4d ${exe} clitkGetDirection -i ${p}Deformation4D.mhd  ${p}Deformation4D_ref.direction)
-ADD_TEST(clitkGetDirection_3d ${exe} clitkGetDirection -i ${p}Lung3D.mhd       ${p}Lung3D_ref.direction)
+add_test(clitkGetDirection_4d ${exe} clitkGetDirection -i ${p}Deformation4D.mhd  ${p}Deformation4D_ref.direction)
+add_test(clitkGetDirection_3d ${exe} clitkGetDirection -i ${p}Lung3D.mhd       ${p}Lung3D_ref.direction)
 #=========================================================
 # clitkBinarize
-ADD_TEST(clitkBinarizeBGl0.1356_4d ${exe} clitkBinarizeImage -i ${p}Deformation4D.mhd --mode BG -l 0.1356 -o Deformation4D_ref.binarizeBGl0.1356.mhd ${p}Deformation4D_ref.binarizeBGl0.1356.mhd)
-ADD_TEST(clitkBinarizeFGl0.1556_3d ${exe} clitkBinarizeImage -i ${p}Lung3D.mhd        --mode FG -l 0.1556 -o Lung3D_ref.binarizeFGl0.1556.mhd ${p}Lung3D_ref.binarizeFGl0.1556.mhd)
+add_test(clitkBinarizeBGl0.1356_4d ${exe} clitkBinarizeImage -i ${p}Deformation4D.mhd --mode BG -l 0.1356 -o Deformation4D_ref.binarizeBGl0.1356.mhd ${p}Deformation4D_ref.binarizeBGl0.1356.mhd)
+add_test(clitkBinarizeFGl0.1556_3d ${exe} clitkBinarizeImage -i ${p}Lung3D.mhd        --mode FG -l 0.1556 -o Lung3D_ref.binarizeFGl0.1556.mhd ${p}Lung3D_ref.binarizeFGl0.1556.mhd)
 #=========================================================
 # clitkImageArithm
-ADD_TEST(clitkImageArithm0_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 0 -o Lung3D_ref.arithm0.mhd ${p}Lung3D_ref.arithm0.mhd)
-ADD_TEST(clitkImageArithm1_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 1 -o Lung3D_ref.arithm1.mhd ${p}Lung3D_ref.arithm1.mhd)
-ADD_TEST(clitkImageArithm2_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 2 -o Lung3D_ref.arithm2.mhd ${p}Lung3D_ref.arithm2.mhd)
-ADD_TEST(clitkImageArithm3_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 3 -o Lung3D_ref.arithm3.mhd ${p}Lung3D_ref.arithm3.mhd)
-ADD_TEST(clitkImageArithm4_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 4 -o Lung3D_ref.arithm4.mhd ${p}Lung3D_ref.arithm4.mhd)
-ADD_TEST(clitkImageArithm5_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 5 -o Lung3D_ref.arithm5.mhd ${p}Lung3D_ref.arithm5.mhd)
-ADD_TEST(clitkImageArithm6_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 6 -o Lung3D_ref.arithm6.mhd ${p}Lung3D_ref.arithm6.mhd)
+add_test(clitkImageArithm0_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 0 -o Lung3D_ref.arithm0.mhd ${p}Lung3D_ref.arithm0.mhd)
+add_test(clitkImageArithm1_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 1 -o Lung3D_ref.arithm1.mhd ${p}Lung3D_ref.arithm1.mhd)
+add_test(clitkImageArithm2_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 2 -o Lung3D_ref.arithm2.mhd ${p}Lung3D_ref.arithm2.mhd)
+add_test(clitkImageArithm3_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 3 -o Lung3D_ref.arithm3.mhd ${p}Lung3D_ref.arithm3.mhd)
+add_test(clitkImageArithm4_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 4 -o Lung3D_ref.arithm4.mhd ${p}Lung3D_ref.arithm4.mhd)
+add_test(clitkImageArithm5_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 5 -o Lung3D_ref.arithm5.mhd ${p}Lung3D_ref.arithm5.mhd)
+add_test(clitkImageArithm6_3d ${exe} clitkImageArithm -i ${p}Lung3D.mhd -j ${p}Lung3D.mhd -t 6 -o Lung3D_ref.arithm6.mhd ${p}Lung3D_ref.arithm6.mhd)
 
-ADD_TEST(clitkImageArithm0_4d ${exe} clitkImageArithm -i ${p}Deformation4D.mhd -j ${p}Deformation4D.mhd -t 0 -o Deformation4D_ref.arithm0.mhd ${p}Deformation4D_ref.arithm0.mhd)
-ADD_TEST(clitkImageArithm2_4d ${exe} clitkImageArithm -i ${p}Deformation4D.mhd -j ${p}Deformation4D.mhd -t 2 -o Deformation4D_ref.arithm2.mhd ${p}Deformation4D_ref.arithm2.mhd)
+add_test(clitkImageArithm0_4d ${exe} clitkImageArithm -i ${p}Deformation4D.mhd -j ${p}Deformation4D.mhd -t 0 -o Deformation4D_ref.arithm0.mhd ${p}Deformation4D_ref.arithm0.mhd)
+add_test(clitkImageArithm2_4d ${exe} clitkImageArithm -i ${p}Deformation4D.mhd -j ${p}Deformation4D.mhd -t 2 -o Deformation4D_ref.arithm2.mhd ${p}Deformation4D_ref.arithm2.mhd)
 #=========================================================
 # clitkCropImage
-ADD_TEST(clitkCropImage_3d ${exe} clitkCropImage -i ${p}Lung3D.mhd -b 1,4,0,2,2,3 -o Lung3D_ref.cropImage.1.4.0.2.2.3.mhd ${p}Lung3D_ref.cropImage.1.4.0.2.2.3.mhd)
+add_test(clitkCropImage_3d ${exe} clitkCropImage -i ${p}Lung3D.mhd -b 1,4,0,2,2,3 -o Lung3D_ref.cropImage.1.4.0.2.2.3.mhd ${p}Lung3D_ref.cropImage.1.4.0.2.2.3.mhd)
 #=========================================================
 #clitkMorphoMath
-ADD_TEST(clitkMorphoMath0_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t0.mhd ${p}Lung3D_ref.morphoMath.t0.mhd)
-ADD_TEST(clitkMorphoMath1_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t1.mhd ${p}Lung3D_ref.morphoMath.t1.mhd)
-ADD_TEST(clitkMorphoMath2_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t2.mhd ${p}Lung3D_ref.morphoMath.t2.mhd)
-ADD_TEST(clitkMorphoMath3_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t3.mhd ${p}Lung3D_ref.morphoMath.t3.mhd)
-ADD_TEST(clitkMorphoMath4_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t4.mhd ${p}Lung3D_ref.morphoMath.t4.mhd)
-ADD_TEST(clitkMorphoMath5_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t5.mhd ${p}Lung3D_ref.morphoMath.t5.mhd)
+add_test(clitkMorphoMath0_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t0.mhd ${p}Lung3D_ref.morphoMath.t0.mhd)
+add_test(clitkMorphoMath1_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t1.mhd ${p}Lung3D_ref.morphoMath.t1.mhd)
+add_test(clitkMorphoMath2_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t2.mhd ${p}Lung3D_ref.morphoMath.t2.mhd)
+add_test(clitkMorphoMath3_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t3.mhd ${p}Lung3D_ref.morphoMath.t3.mhd)
+add_test(clitkMorphoMath4_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t4.mhd ${p}Lung3D_ref.morphoMath.t4.mhd)
+add_test(clitkMorphoMath5_3d ${exe} clitkMorphoMath -i ${p}Lung3D.mhd -o Lung3D_ref.morphoMath.t5.mhd ${p}Lung3D_ref.morphoMath.t5.mhd)
 
-ADD_TEST(clitkMorphoMath0_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t0.mhd ${p}Deformation4D_ref.morphoMath.t0.mhd)
-ADD_TEST(clitkMorphoMath1_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t1.mhd ${p}Deformation4D_ref.morphoMath.t1.mhd)
-ADD_TEST(clitkMorphoMath2_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t2.mhd ${p}Deformation4D_ref.morphoMath.t2.mhd)
-ADD_TEST(clitkMorphoMath3_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t3.mhd ${p}Deformation4D_ref.morphoMath.t3.mhd)
-ADD_TEST(clitkMorphoMath4_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t4.mhd ${p}Deformation4D_ref.morphoMath.t4.mhd)
-ADD_TEST(clitkMorphoMath5_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t5.mhd ${p}Deformation4D_ref.morphoMath.t5.mhd)
+add_test(clitkMorphoMath0_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t0.mhd ${p}Deformation4D_ref.morphoMath.t0.mhd)
+add_test(clitkMorphoMath1_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t1.mhd ${p}Deformation4D_ref.morphoMath.t1.mhd)
+add_test(clitkMorphoMath2_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t2.mhd ${p}Deformation4D_ref.morphoMath.t2.mhd)
+add_test(clitkMorphoMath3_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t3.mhd ${p}Deformation4D_ref.morphoMath.t3.mhd)
+add_test(clitkMorphoMath4_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t4.mhd ${p}Deformation4D_ref.morphoMath.t4.mhd)
+add_test(clitkMorphoMath5_4d ${exe} clitkMorphoMath -i ${p}Deformation4D.mhd -o Deformation4D_ref.morphoMath.t5.mhd ${p}Deformation4D_ref.morphoMath.t5.mhd)
 #=========================================================
 #clitkSetBackground
-ADD_TEST(clitkSetBackground_4d ${exe} clitkSetBackground -i ${p}Deformation4D.mhd -m ${p}Deformation4D.mhd -o Deformation4D_ref.setBackground.mhd ${p}Deformation4D_ref.setBackground.mhd)
-ADD_TEST(clitkSetBackground_3d ${exe} clitkSetBackground -i ${p}Lung3D.mhd -m ${p}Lung3D.mhd -o Lung3D_ref.setBackground.mhd ${p}Lung3D_ref.setBackground.mhd)
+add_test(clitkSetBackground_4d ${exe} clitkSetBackground -i ${p}Deformation4D.mhd -m ${p}Deformation4D.mhd -o Deformation4D_ref.setBackground.mhd ${p}Deformation4D_ref.setBackground.mhd)
+add_test(clitkSetBackground_3d ${exe} clitkSetBackground -i ${p}Lung3D.mhd -m ${p}Lung3D.mhd -o Lung3D_ref.setBackground.mhd ${p}Lung3D_ref.setBackground.mhd)
 #clitkWarpImage
-ADD_TEST(clitkWarpImage_3d ${exe} clitkWarpImage -i ${p}00-P.mhd --vf ${p}vf50-P_1.mhd -o 00-P_ref.warpImage.mhd ${p}00-P_ref.warpImage.mhd)
+add_test(clitkWarpImage_3d ${exe} clitkWarpImage -i ${p}00-P.mhd --vf ${p}vf50-P_1.mhd -o 00-P_ref.warpImage.mhd ${p}00-P_ref.warpImage.mhd)
 
 
 
@@ -82,6 +82,6 @@ ADD_TEST(clitkWarpImage_3d ${exe} clitkWarpImage -i ${p}00-P.mhd --vf ${p}vf50-P
 
 
 
-UNSET(exe)
-UNSET(p)
+unset(exe)
+unset(p)
 
index b67e4ab9eb72379d2704104ed1921e89e7c9c554..e0981f3de7b8c5b47d2e71044f36b999211256f3 100644 (file)
 #=========================================================
 # Add Libraries used in vv and clitk to avoid recompilation
 WRAP_GGO(clitkCropImage_GGO_C clitkCropImage.ggo)
-ADD_LIBRARY(clitkCropImageLib clitkCropImageGenericFilter.cxx ${clitkCropImage_GGO_C})
+add_library(clitkCropImageLib clitkCropImageGenericFilter.cxx ${clitkCropImage_GGO_C})
 
 WRAP_GGO(clitkImageConvert_GGO_C clitkImageConvert.ggo)
-ADD_LIBRARY(clitkImageConvertLib clitkImageConvertGenericFilter.cxx ${clitkImageConvert_GGO_C})
+add_library(clitkImageConvertLib clitkImageConvertGenericFilter.cxx ${clitkImageConvert_GGO_C})
 
 WRAP_GGO(clitkBinarizeImage_GGO_C clitkBinarizeImage.ggo)
-ADD_LIBRARY(clitkBinarizeImageLib clitkBinarizeImageGenericFilter.cxx ${clitkBinarizeImage_GGO_C})
+add_library(clitkBinarizeImageLib clitkBinarizeImageGenericFilter.cxx ${clitkBinarizeImage_GGO_C})
+
+WRAP_GGO(clitkProfileImage_GGO_C clitkProfileImage.ggo)
+add_library(clitkProfileImageLib clitkProfileImageGenericFilter.cxx ${clitkProfileImage_GGO_C})
 
 WRAP_GGO(clitkImageArithm_GGO_C clitkImageArithm.ggo)
-ADD_LIBRARY(clitkImageArithmImageLib clitkImageArithmGenericFilter.cxx ${clitkImageArithm_GGO_C})
+add_library(clitkImageArithmImageLib clitkImageArithmGenericFilter.cxx ${clitkImageArithm_GGO_C})
 
 WRAP_GGO(clitkVectorArithm_GGO_C clitkVectorArithm.ggo)
-ADD_LIBRARY(clitkVectorArithmLib clitkVectorArithmGenericFilter.cxx ${clitkVectorArithm_GGO_C})
+add_library(clitkVectorArithmLib clitkVectorArithmGenericFilter.cxx ${clitkVectorArithm_GGO_C})
 
 WRAP_GGO(clitkResampleImage_GGO_C clitkResampleImage.ggo)
-ADD_LIBRARY(clitkResampleImageLib clitkResampleImageGenericFilter.cxx ${clitkResampleImage_GGO_C})
+add_library(clitkResampleImageLib clitkResampleImageGenericFilter.cxx ${clitkResampleImage_GGO_C})
 
 WRAP_GGO(clitkMIP_GGO_C clitkMIP.ggo)
-ADD_LIBRARY(clitkMIPLib clitkMIPGenericFilter.cxx ${clitkMIP_GGO_C})
+add_library(clitkMIPLib clitkMIPGenericFilter.cxx ${clitkMIP_GGO_C})
 
 WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
-ADD_LIBRARY(clitkMedianImageFilterLib clitkMedianImageGenericFilter.cxx ${clitkMedianImageFilter_GGO_C})
+add_library(clitkMedianImageFilterLib clitkMedianImageGenericFilter.cxx ${clitkMedianImageFilter_GGO_C})
 
 #=========================================================
-IF (CLITK_BUILD_TOOLS)
+if(CLITK_BUILD_TOOLS)
+
   WRAP_GGO(clitkDicomInfo_GGO_C clitkDicomInfo.ggo)
-  ADD_EXECUTABLE(clitkDicomInfo clitkDicomInfo.cxx ${clitkDicomInfo_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkDicomInfo clitkCommon)
+  add_executable(clitkDicomInfo clitkDicomInfo.cxx ${clitkDicomInfo_GGO_C})
+  target_link_libraries(clitkDicomInfo clitkCommon)
   # set_target_properties(clitkDicomInfo
   #   PROPERTIES
   #   LINK_INTERFACE_LIBRARIES ""
   #   )
-  SET(TOOLS_INSTALL clitkDicomInfo)
+  set(TOOLS_INSTALL clitkDicomInfo)
 
   WRAP_GGO(clitkDicom2Image_GGO_C clitkDicom2Image.ggo)
-  ADD_EXECUTABLE(clitkDicom2Image clitkDicom2Image.cxx ${clitkDicom2Image_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkDicom2Image clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicom2Image)
+  add_executable(clitkDicom2Image clitkDicom2Image.cxx ${clitkDicom2Image_GGO_C})
+  target_link_libraries(clitkDicom2Image clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicom2Image)
 
   WRAP_GGO(clitkDicomWave2Text_GGO_C clitkDicomWave2Text.ggo)
-  ADD_EXECUTABLE(clitkDicomWave2Text clitkDicomWave2Text.cxx ${clitkDicomWave2Text_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkDicomWave2Text clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomWave2Text)
+  add_executable(clitkDicomWave2Text clitkDicomWave2Text.cxx ${clitkDicomWave2Text_GGO_C})
+  target_link_libraries(clitkDicomWave2Text clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomWave2Text)
 
   WRAP_GGO(clitkImageInfo_GGO_C clitkImageInfo.ggo)
-  ADD_EXECUTABLE(clitkImageInfo clitkImageInfo.cxx ${clitkImageInfo_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkImageInfo clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageInfo)
-
-  ADD_EXECUTABLE(clitkImageConvert clitkImageConvert.cxx)
-  TARGET_LINK_LIBRARIES(clitkImageConvert clitkImageConvertLib clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageConvert)
-
-  ADD_EXECUTABLE(clitkBinarizeImage clitkBinarizeImage.cxx)
-  TARGET_LINK_LIBRARIES(clitkBinarizeImage clitkBinarizeImageLib clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinarizeImage)
+  add_executable(clitkImageInfo clitkImageInfo.cxx ${clitkImageInfo_GGO_C})
+  target_link_libraries(clitkImageInfo clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageInfo)
+
+  add_executable(clitkImageConvert clitkImageConvert.cxx)
+  target_link_libraries(clitkImageConvert clitkImageConvertLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageConvert)
+
+  add_executable(clitkBinarizeImage clitkBinarizeImage.cxx)
+  target_link_libraries(clitkBinarizeImage clitkBinarizeImageLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinarizeImage)
+  
+  add_executable(clitkProfileImage clitkProfileImage.cxx)
+  target_link_libraries(clitkProfileImage clitkProfileImageLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkProfileImage)
 
   WRAP_GGO(clitkVFResample_GGO_C clitkVFResample.ggo)
-  ADD_EXECUTABLE(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkVFResample clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVFResample)
+  add_executable(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C})
+  target_link_libraries(clitkVFResample clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVFResample)
 
   WRAP_GGO(clitkVFInterpolate_GGO_C clitkVFInterpolate.ggo)
-  ADD_EXECUTABLE(clitkVFInterpolate clitkVFInterpolate.cxx clitkVFInterpolateGenericFilter.cxx ${clitkVFInterpolate_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkVFInterpolate clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVFInterpolate)
+  add_executable(clitkVFInterpolate clitkVFInterpolate.cxx clitkVFInterpolateGenericFilter.cxx ${clitkVFInterpolate_GGO_C})
+  target_link_libraries(clitkVFInterpolate clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVFInterpolate)
 
   WRAP_GGO(clitkImageCreate_GGO_C clitkImageCreate.ggo)
-  ADD_EXECUTABLE(clitkImageCreate clitkImageCreate.cxx ${clitkImageCreate_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkImageCreate clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageCreate)
+  add_executable(clitkImageCreate clitkImageCreate.cxx ${clitkImageCreate_GGO_C})
+  target_link_libraries(clitkImageCreate clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageCreate)
 
   WRAP_GGO(clitkZeroVF_GGO_C clitkZeroVF.ggo)
-  ADD_EXECUTABLE(clitkZeroVF clitkZeroVF.cxx ${clitkZeroVF_GGO_C} clitkZeroVFGenericFilter.cxx)
-  TARGET_LINK_LIBRARIES(clitkZeroVF clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkZeroVF)
+  add_executable(clitkZeroVF clitkZeroVF.cxx ${clitkZeroVF_GGO_C} clitkZeroVFGenericFilter.cxx)
+  target_link_libraries(clitkZeroVF clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkZeroVF)
 
   WRAP_GGO(clitkSplitImage_GGO_C clitkSplitImage.ggo)
-  ADD_EXECUTABLE(clitkSplitImage clitkSplitImage.cxx clitkSplitImageGenericFilter.cxx ${clitkSplitImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkSplitImage clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkSplitImage)
+  add_executable(clitkSplitImage clitkSplitImage.cxx clitkSplitImageGenericFilter.cxx ${clitkSplitImage_GGO_C})
+  target_link_libraries(clitkSplitImage clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkSplitImage)
 
   WRAP_GGO(clitkWriteDicomSeries_GGO_C clitkWriteDicomSeries.ggo)
-  ADD_EXECUTABLE(clitkWriteDicomSeries clitkWriteDicomSeries.cxx ${clitkWriteDicomSeries_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkWriteDicomSeries clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkWriteDicomSeries)
+  add_executable(clitkWriteDicomSeries clitkWriteDicomSeries.cxx ${clitkWriteDicomSeries_GGO_C})
+  target_link_libraries(clitkWriteDicomSeries clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkWriteDicomSeries)
 
   WRAP_GGO(clitkMedianTemporalDimension_GGO_C clitkMedianTemporalDimension.ggo)
-  ADD_EXECUTABLE(clitkMedianTemporalDimension clitkMedianTemporalDimension.cxx
+  add_executable(clitkMedianTemporalDimension clitkMedianTemporalDimension.cxx
     ${clitkMedianTemporalDimension_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMedianTemporalDimension clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMedianTemporalDimension)
+  target_link_libraries(clitkMedianTemporalDimension clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMedianTemporalDimension)
 
   WRAP_GGO(clitkWarpImage_GGO_C clitkWarpImage.ggo)
-  ADD_EXECUTABLE(clitkWarpImage clitkWarpImage.cxx ${clitkWarpImage_GGO_C} clitkWarpImageGenericFilter.cxx)
-  TARGET_LINK_LIBRARIES(clitkWarpImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkWarpImage)
+  add_executable(clitkWarpImage clitkWarpImage.cxx ${clitkWarpImage_GGO_C} clitkWarpImageGenericFilter.cxx)
+  target_link_libraries(clitkWarpImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkWarpImage)
 
   WRAP_GGO(clitkInvertVF_GGO_C clitkInvertVF.ggo)
-  ADD_EXECUTABLE(clitkInvertVF clitkInvertVF.cxx ${clitkInvertVF_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkInvertVF clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkInvertVF)
+  add_executable(clitkInvertVF clitkInvertVF.cxx ${clitkInvertVF_GGO_C})
+  target_link_libraries(clitkInvertVF clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkInvertVF)
 
   WRAP_GGO(clitkAffineTransform_GGO_C clitkAffineTransform.ggo)
-  ADD_EXECUTABLE(clitkAffineTransform clitkAffineTransform.cxx ${clitkAffineTransform_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkAffineTransform clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAffineTransform)
+  add_executable(clitkAffineTransform clitkAffineTransform.cxx ${clitkAffineTransform_GGO_C})
+  target_link_libraries(clitkAffineTransform clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAffineTransform)
 
   WRAP_GGO(clitkElastixTransformToMatrix_GGO_C clitkElastixTransformToMatrix.ggo)
-  ADD_EXECUTABLE(clitkElastixTransformToMatrix clitkElastixTransformToMatrix.cxx ${clitkElastixTransformToMatrix_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkElastixTransformToMatrix clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkElastixTransformToMatrix)
+  add_executable(clitkElastixTransformToMatrix clitkElastixTransformToMatrix.cxx ${clitkElastixTransformToMatrix_GGO_C})
+  target_link_libraries(clitkElastixTransformToMatrix clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkElastixTransformToMatrix)
 
   WRAP_GGO(clitkMatrixToElastixTransform_GGO_C clitkMatrixToElastixTransform.ggo)
-  ADD_EXECUTABLE(clitkMatrixToElastixTransform clitkMatrixToElastixTransform.cxx ${clitkMatrixToElastixTransform_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMatrixToElastixTransform clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixToElastixTransform)
+  add_executable(clitkMatrixToElastixTransform clitkMatrixToElastixTransform.cxx ${clitkMatrixToElastixTransform_GGO_C})
+  target_link_libraries(clitkMatrixToElastixTransform clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixToElastixTransform)
+
+  WRAP_GGO(clitkMatrixMultiply_GGO_C clitkMatrixMultiply.ggo)
+  add_executable(clitkMatrixMultiply clitkMatrixMultiply.cxx ${clitkMatrixMultiply_GGO_C})
+  target_link_libraries(clitkMatrixMultiply clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixMultiply)
 
   WRAP_GGO(clitkMatrixInverse_GGO_C clitkMatrixInverse.ggo)
-  ADD_EXECUTABLE(clitkMatrixInverse clitkMatrixInverse.cxx ${clitkMatrixInverse_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMatrixInverse clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixInverse)
+  add_executable(clitkMatrixInverse clitkMatrixInverse.cxx ${clitkMatrixInverse_GGO_C})
+  target_link_libraries(clitkMatrixInverse clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMatrixInverse)
 
   WRAP_GGO(clitkSetBackground_GGO_C clitkSetBackground.ggo)
-  ADD_EXECUTABLE(clitkSetBackground clitkSetBackground.cxx clitkSetBackgroundGenericFilter.cxx ${clitkSetBackground_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkSetBackground clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkSetBackground)
+  add_executable(clitkSetBackground clitkSetBackground.cxx clitkSetBackgroundGenericFilter.cxx ${clitkSetBackground_GGO_C})
+  target_link_libraries(clitkSetBackground clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkSetBackground)
 
   WRAP_GGO(clitkGammaIndex_GGO_C clitkGammaIndex.ggo)
-  ADD_EXECUTABLE(clitkGammaIndex clitkGammaIndex.cxx ${clitkGammaIndex_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkGammaIndex clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkGammaIndex)
+  add_executable(clitkGammaIndex clitkGammaIndex.cxx ${clitkGammaIndex_GGO_C})
+  target_link_libraries(clitkGammaIndex clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkGammaIndex)
 
-  ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx)
-  TARGET_LINK_LIBRARIES(clitkImageArithm clitkImageArithmImageLib clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageArithm)
+  add_executable(clitkImageArithm clitkImageArithm.cxx)
+  target_link_libraries(clitkImageArithm clitkImageArithmImageLib clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageArithm)
 
-  ADD_EXECUTABLE(clitkVectorArithm clitkVectorArithm.cxx)
-  TARGET_LINK_LIBRARIES(clitkVectorArithm clitkVectorArithmLib clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVectorArithm)
+  add_executable(clitkVectorArithm clitkVectorArithm.cxx)
+  target_link_libraries(clitkVectorArithm clitkVectorArithmLib clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVectorArithm)
 
   WRAP_GGO(clitkUnsharpMask_GGO_C clitkUnsharpMask.ggo)
-  ADD_EXECUTABLE(clitkUnsharpMask clitkUnsharpMask.cxx ${clitkUnsharpMask_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkUnsharpMask clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkUnsharpMask)
-
-  WRAP_GGO(clitkFooImage_GGO_C clitkFooImage.ggo)
-  ADD_EXECUTABLE(clitkFooImage clitkFooImage.cxx ${clitkFooImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkFooImage clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkFooImage)
+  add_executable(clitkUnsharpMask clitkUnsharpMask.cxx ${clitkUnsharpMask_GGO_C})
+  target_link_libraries(clitkUnsharpMask clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkUnsharpMask)
 
-  #WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
-  #ADD_EXECUTABLE(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C})
-  #TARGET_LINK_LIBRARIES(clitkMedianImageFilter clitkMedianImageFilterLib clitkCommon)
-  #SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMedianImageFilter)
+  WRAP_GGO(clitkMedianImageFilter_GGO_C clitkMedianImageFilter.ggo)
+  add_executable(clitkMedianImageFilter clitkMedianImageFilter.cxx ${clitkMedianImageFilter_GGO_C})
+  target_link_libraries(clitkMedianImageFilter clitkMedianImageFilterLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMedianImageFilter)
 
-  ADD_EXECUTABLE(clitkResampleImage clitkResampleImage.cxx)
-  TARGET_LINK_LIBRARIES(clitkResampleImage clitkResampleImageLib clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkResampleImage)
+  add_executable(clitkResampleImage clitkResampleImage.cxx)
+  target_link_libraries(clitkResampleImage clitkResampleImageLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkResampleImage)
 
   WRAP_GGO(clitkMinMaxMask_GGO_C clitkMinMaxMask.ggo)
-  ADD_EXECUTABLE(clitkMinMaxMask clitkMinMaxMask.cxx ${clitkMinMaxMask_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMinMaxMask clitkCommon  )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMinMaxMask)
+  add_executable(clitkMinMaxMask clitkMinMaxMask.cxx ${clitkMinMaxMask_GGO_C})
+  target_link_libraries(clitkMinMaxMask clitkCommon  )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMinMaxMask)
 
   WRAP_GGO(clitkAutoCrop_GGO_C clitkAutoCrop.ggo)
-  ADD_EXECUTABLE(clitkAutoCrop clitkAutoCrop.cxx ${clitkAutoCrop_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkAutoCrop clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAutoCrop)
+  add_executable(clitkAutoCrop clitkAutoCrop.cxx ${clitkAutoCrop_GGO_C})
+  target_link_libraries(clitkAutoCrop clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAutoCrop)
 
   WRAP_GGO(clitkDicomRTStruct2Image_GGO_C clitkDicomRTStruct2Image.ggo)
-  ADD_EXECUTABLE(clitkDicomRTStruct2Image clitkDicomRTStruct2Image.cxx ${clitkDicomRTStruct2Image_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkDicomRTStruct2Image clitkDicomRTStruct)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomRTStruct2Image)
+  add_executable(clitkDicomRTStruct2Image clitkDicomRTStruct2Image.cxx ${clitkDicomRTStruct2Image_GGO_C})
+  target_link_libraries(clitkDicomRTStruct2Image clitkDicomRTStruct)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomRTStruct2Image)
 
-  IF(CLITK_USE_SYSTEM_GDCM)
+  if(CLITK_USE_SYSTEM_GDCM)
     WRAP_GGO(clitkImage2DicomRTStruct_GGO_C clitkImage2DicomRTStruct.ggo)
-    ADD_EXECUTABLE(clitkImage2DicomRTStruct clitkImage2DicomRTStruct.cxx ${clitkImage2DicomRTStruct_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkImage2DicomRTStruct clitkDicomRTStruct)
-  ENDIF()
+    add_executable(clitkImage2DicomRTStruct clitkImage2DicomRTStruct.cxx ${clitkImage2DicomRTStruct_GGO_C})
+    target_link_libraries(clitkImage2DicomRTStruct clitkDicomRTStruct)
+  endif()
 
   WRAP_GGO(clitkComposeVF_GGO_C clitkComposeVF.ggo)
-  ADD_EXECUTABLE(clitkComposeVF clitkComposeVFGenericFilter.cxx clitkComposeVF.cxx ${clitkComposeVF_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkComposeVF clitkCommon  )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkComposeVF)
+  add_executable(clitkComposeVF clitkComposeVFGenericFilter.cxx clitkComposeVF.cxx ${clitkComposeVF_GGO_C})
+  target_link_libraries(clitkComposeVF clitkCommon  )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkComposeVF)
 
   WRAP_GGO(clitkMergeSequence_GGO_C clitkMergeSequence.ggo)
-  ADD_EXECUTABLE(clitkMergeSequence clitkMergeSequence.cxx clitkMergeSequenceGenericFilter.cxx ${clitkMergeSequence_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMergeSequence clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeSequence)
+  add_executable(clitkMergeSequence clitkMergeSequence.cxx clitkMergeSequenceGenericFilter.cxx ${clitkMergeSequence_GGO_C})
+  target_link_libraries(clitkMergeSequence clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeSequence)
 
   WRAP_GGO(clitkBackProjectImage_GGO_C clitkBackProjectImage.ggo)
-  ADD_EXECUTABLE(clitkBackProjectImage clitkBackProjectImage.cxx clitkBackProjectImageGenericFilter.cxx ${clitkBackProjectImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkBackProjectImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBackProjectImage)
+  add_executable(clitkBackProjectImage clitkBackProjectImage.cxx clitkBackProjectImageGenericFilter.cxx ${clitkBackProjectImage_GGO_C})
+  target_link_libraries(clitkBackProjectImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBackProjectImage)
 
-  ADD_EXECUTABLE(clitkCropImage clitkCropImage.cxx ${clitkCropImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkCropImage clitkCropImageLib clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkCropImage)
+  add_executable(clitkCropImage clitkCropImage.cxx ${clitkCropImage_GGO_C})
+  target_link_libraries(clitkCropImage clitkCropImageLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkCropImage)
 
   # WRAP_GGO(clitkExtractSlice_GGO_C clitkExtractSlice.ggo)
-  # ADD_EXECUTABLE(clitkExtractSlice clitkExtractSlice.cxx clitkExtractSliceGenericFilter.cxx ${clitkExtractSlice_GGO_C})
-  # TARGET_LINK_LIBRARIES(clitkExtractSlice clitkCommon)
-  #SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkExtractSlice)
+  # add_executable(clitkExtractSlice clitkExtractSlice.cxx clitkExtractSliceGenericFilter.cxx ${clitkExtractSlice_GGO_C})
+  # target_link_libraries(clitkExtractSlice clitkCommon)
+  #set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkExtractSlice)
 
   WRAP_GGO(clitkFlipImage_GGO_C clitkFlipImage.ggo)
-  ADD_EXECUTABLE(clitkFlipImage clitkFlipImage.cxx clitkFlipImageGenericFilter.cxx ${clitkFlipImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkFlipImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkFlipImage)
+  add_executable(clitkFlipImage clitkFlipImage.cxx clitkFlipImageGenericFilter.cxx ${clitkFlipImage_GGO_C})
+  target_link_libraries(clitkFlipImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkFlipImage)
 
   WRAP_GGO(clitkMirrorPadImage_GGO_C clitkMirrorPadImage.ggo)
-  ADD_EXECUTABLE(clitkMirrorPadImage clitkMirrorPadImage.cxx clitkMirrorPadImageGenericFilter.cxx ${clitkMirrorPadImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMirrorPadImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMirrorPadImage)
+  add_executable(clitkMirrorPadImage clitkMirrorPadImage.cxx clitkMirrorPadImageGenericFilter.cxx ${clitkMirrorPadImage_GGO_C})
+  target_link_libraries(clitkMirrorPadImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMirrorPadImage)
 
   WRAP_GGO(clitkImageMoment_GGO_C clitkImageMoment.ggo)
-  ADD_EXECUTABLE(clitkImageMoment clitkImageMoment.cxx clitkImageMomentGenericFilter.cxx ${clitkImageMoment_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkImageMoment clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageMoment)
+  add_executable(clitkImageMoment clitkImageMoment.cxx clitkImageMomentGenericFilter.cxx ${clitkImageMoment_GGO_C})
+  target_link_libraries(clitkImageMoment clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageMoment)
 
   WRAP_GGO(clitkImageStatistics_GGO_C clitkImageStatistics.ggo)
-  ADD_EXECUTABLE(clitkImageStatistics clitkImageStatistics.cxx clitkImageStatisticsGenericFilter.cxx ${clitkImageStatistics_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkImageStatistics clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageStatistics)
+  add_executable(clitkImageStatistics clitkImageStatistics.cxx clitkImageStatisticsGenericFilter.cxx ${clitkImageStatistics_GGO_C})
+  target_link_libraries(clitkImageStatistics clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageStatistics)
 
   WRAP_GGO(clitkVFConvert_GGO_C clitkVFConvert.ggo)
-  ADD_EXECUTABLE(clitkVFConvert clitkVFConvert.cxx clitkVFConvertGenericFilter.cxx ${clitkVFConvert_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkVFConvert clitkCommon )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVFConvert)
+  add_executable(clitkVFConvert clitkVFConvert.cxx clitkVFConvertGenericFilter.cxx ${clitkVFConvert_GGO_C})
+  target_link_libraries(clitkVFConvert clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVFConvert)
 
   WRAP_GGO(clitkImageToVectorImage_GGO_C clitkImageToVectorImage.ggo)
-  ADD_EXECUTABLE(clitkImageToVectorImage  clitkImageToVectorImage.cxx clitkImageToVectorImageGenericFilter.cxx ${clitkImageToVectorImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkImageToVectorImage  clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageToVectorImage)
+  add_executable(clitkImageToVectorImage  clitkImageToVectorImage.cxx clitkImageToVectorImageGenericFilter.cxx ${clitkImageToVectorImage_GGO_C})
+  target_link_libraries(clitkImageToVectorImage  clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageToVectorImage)
 
   WRAP_GGO(clitkVectorImageToImage_GGO_C clitkVectorImageToImage.ggo)
-  ADD_EXECUTABLE(clitkVectorImageToImage  clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx ${clitkVectorImageToImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkVectorImageToImage  clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVectorImageToImage)
+  add_executable(clitkVectorImageToImage  clitkVectorImageToImage.cxx clitkVectorImageToImageGenericFilter.cxx ${clitkVectorImageToImage_GGO_C})
+  target_link_libraries(clitkVectorImageToImage  clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkVectorImageToImage)
 
-  ADD_EXECUTABLE(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx)
-  TARGET_LINK_LIBRARIES(clitkMIP clitkMIPLib clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMIP)
+  add_executable(clitkMIP clitkMIP.cxx clitkMIPGenericFilter.cxx)
+  target_link_libraries(clitkMIP clitkMIPLib clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMIP)
 
-  WRAP_GGO(clitkTransformLandmarks_GGO_C clitkTransformLandmarks.ggo)
-  ADD_EXECUTABLE(clitkTransformLandmarks clitkTransformLandmarks.cxx ${clitkTransformLandmarks_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkTransformLandmarks clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkTransformLandmarks)
+  WRAP_GGO(clitkSum_GGO_C clitkSum.ggo)
+  add_executable(clitkSum clitkSum.cxx ${clitkSum_GGO_C})
+  target_link_libraries(clitkSum clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkSum)
 
-  WRAP_GGO(clitkDice_GGO_C clitkDice.ggo)
-  ADD_EXECUTABLE(clitkDice clitkDice.cxx ${clitkDice_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkDice clitkSegmentationGgoLib clitkCommon ${ITK_LIBRARIES} )
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDice)
+  WRAP_GGO(clitkTransformLandmarks_GGO_C clitkTransformLandmarks.ggo)
+  add_executable(clitkTransformLandmarks clitkTransformLandmarks.cxx ${clitkTransformLandmarks_GGO_C})
+  target_link_libraries(clitkTransformLandmarks clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkTransformLandmarks)
 
   WRAP_GGO(clitkMaskLandmarks_GGO_C clitkMaskLandmarks.ggo)
-  ADD_EXECUTABLE(clitkMaskLandmarks clitkMaskLandmarks.cxx ${clitkMaskLandmarks_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMaskLandmarks clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMaskLandmarks)
+  add_executable(clitkMaskLandmarks clitkMaskLandmarks.cxx ${clitkMaskLandmarks_GGO_C})
+  target_link_libraries(clitkMaskLandmarks clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMaskLandmarks)
 
   WRAP_GGO(clitkJacobianImage_GGO_C clitkJacobianImage.ggo)
-  ADD_EXECUTABLE(clitkJacobianImage clitkJacobianImage.cxx clitkJacobianImageGenericFilter.cxx ${clitkJacobianImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkJacobianImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkJacobianImage)
+  add_executable(clitkJacobianImage clitkJacobianImage.cxx clitkJacobianImageGenericFilter.cxx ${clitkJacobianImage_GGO_C})
+  target_link_libraries(clitkJacobianImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkJacobianImage)
 
   WRAP_GGO(clitkPadImage_GGO_C clitkPadImage.ggo)
-  ADD_EXECUTABLE(clitkPadImage clitkPadImage.cxx clitkPadImageGenericFilter.cxx ${clitkPadImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkPadImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkPadImage)
+  add_executable(clitkPadImage clitkPadImage.cxx clitkPadImageGenericFilter.cxx ${clitkPadImage_GGO_C})
+  target_link_libraries(clitkPadImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkPadImage)
 
   WRAP_GGO(clitkCatImage_GGO_C clitkCatImage.ggo)
-  ADD_EXECUTABLE(clitkCatImage clitkCatImage.cxx ${clitkCatImage_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkCatImage clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkCatImage)
+  add_executable(clitkCatImage clitkCatImage.cxx ${clitkCatImage_GGO_C})
+  target_link_libraries(clitkCatImage clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkCatImage)
 
   WRAP_GGO(clitkAnisotropicDiffusion_GGO_C clitkAnisotropicDiffusion.ggo)
-  ADD_EXECUTABLE(clitkAnisotropicDiffusion clitkAnisotropicDiffusion.cxx
+  add_executable(clitkAnisotropicDiffusion clitkAnisotropicDiffusion.cxx
     clitkAnisotropicDiffusionGenericFilter.cxx
     ${clitkAnisotropicDiffusion_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkAnisotropicDiffusion clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAnisotropicDiffusion)
+  target_link_libraries(clitkAnisotropicDiffusion clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkAnisotropicDiffusion)
 
   WRAP_GGO(clitkChangeImageInfo_GGO_C clitkChangeImageInfo.ggo)
-  ADD_EXECUTABLE(clitkChangeImageInfo clitkChangeImageInfo.cxx
+  add_executable(clitkChangeImageInfo clitkChangeImageInfo.cxx
     clitkChangeImageInfoGenericFilter.cxx
     ${clitkChangeImageInfo_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkChangeImageInfo clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkChangeImageInfo)
+  target_link_libraries(clitkChangeImageInfo clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkChangeImageInfo)
 
   WRAP_GGO(clitkMergeAsciiDoseActor_GGO_C clitkMergeAsciiDoseActor.ggo)
-  ADD_EXECUTABLE(clitkMergeAsciiDoseActor clitkMergeAsciiDoseActor.cxx ${clitkMergeAsciiDoseActor_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkMergeAsciiDoseActor ITKCommon clitkCommon)
-  SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeAsciiDoseActor)
+  add_executable(clitkMergeAsciiDoseActor clitkMergeAsciiDoseActor.cxx ${clitkMergeAsciiDoseActor_GGO_C})
+  target_link_libraries(clitkMergeAsciiDoseActor ITKCommon clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeAsciiDoseActor)
+
+  WRAP_GGO(clitkImageUncertainty_GGO_C clitkImageUncertainty.ggo)
+  add_executable(clitkImageUncertainty clitkImageUncertainty.cxx clitkImageUncertainty_ggo.c)
+  target_link_libraries(clitkImageUncertainty clitkCommon ${ITK_LIBRARIES})
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageUncertainty)
+
+  WRAP_GGO(clitkNormalizeImageFilter_GGO_C clitkNormalizeImageFilter.ggo)
+  add_executable(clitkNormalizeImageFilter clitkNormalizeImageFilter.cxx ${clitkNormalizeImageFilter_GGO_C})
+  target_link_libraries(clitkNormalizeImageFilter clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkNormalizeImageFilter)
+
+  WRAP_GGO(clitkImageGradientMagnitude_GGO_C clitkImageGradientMagnitude.ggo)
+  add_executable(clitkImageGradientMagnitude clitkImageGradientMagnitude.cxx ${clitkImageGradientMagnitude_GGO_C})
+  target_link_libraries(clitkImageGradientMagnitude clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageGradientMagnitude)
+
+  WRAP_GGO(clitkImageLaplacian_GGO_C clitkImageLaplacian.ggo)
+  add_executable(clitkImageLaplacian clitkImageLaplacian.cxx ${clitkImageLaplacian_GGO_C})
+  target_link_libraries(clitkImageLaplacian clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageLaplacian)
+
+  WRAP_GGO(clitkImageIntensityWindowing_GGO_C clitkImageIntensityWindowing.ggo)
+  add_executable(clitkImageIntensityWindowing clitkImageIntensityWindowing.cxx ${clitkImageIntensityWindowing_GGO_C})
+  target_link_libraries(clitkImageIntensityWindowing clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkImageIntensityWindowing)
+
+  WRAP_GGO(clitkBlurImage_GGO_C clitkBlurImage.ggo)
+  add_executable(clitkBlurImage clitkBlurImage.cxx ${clitkBlurImage_GGO_C})
+  target_link_libraries(clitkBlurImage clitkCommon )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBlurImage)
 
   #=========================================================
   option(CLITK_USE_ROOT "Build experimental tools using root" OFF)
   if (CLITK_USE_ROOT)
-    FIND_PACKAGE(ROOT REQUIRED)
+    find_package(ROOT REQUIRED)
     if(ROOT_FOUND)
-      MESSAGE(STATUS "ROOT found : ${ROOT_LIBRARY_DIR} ${ROOT_INCLUDE_DIR} ${ROOT_LIBRARIES}")
-    ELSE(ROOT_FOUND)
-      MESSAGE(FATAL_ERROR
+      message(STATUS "ROOT found : ${ROOT_LIBRARY_DIR} ${ROOT_INCLUDE_DIR} ${ROOT_LIBRARIES}")
+    else(ROOT_FOUND)
+      message(FATAL_ERROR
         "Cannot build without ROOT.  Please set ROOTSYS environement variable.")
     endif(ROOT_FOUND)
-    INCLUDE_DIRECTORIES(${ROOT_INCLUDE_DIR})
-    LINK_DIRECTORIES(${ROOT_LIBRARY_DIR})
+    include_directories(${ROOT_INCLUDE_DIR})
+    link_directories(${ROOT_LIBRARY_DIR})
     WRAP_GGO(clitkMergeRootFiles_GGO_C clitkMergeRootFiles.ggo)
-    ADD_EXECUTABLE(clitkMergeRootFiles clitkMergeRootFiles.cxx GateMergeManager.cc ${clitkMergeRootFiles_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMergeRootFiles ${ROOT_LIBRARIES})
-    SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeRootFiles)
+    add_executable(clitkMergeRootFiles clitkMergeRootFiles.cxx GateMergeManager.cc ${clitkMergeRootFiles_GGO_C})
+    target_link_libraries(clitkMergeRootFiles ${ROOT_LIBRARIES})
+    set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMergeRootFiles)
   endif()
   #=========================================================
 
 
   #=========================================================
-  IF(CLITK_EXPERIMENTAL)
+  if(CLITK_EXPERIMENTAL)
     WRAP_GGO(clitkBinaryImageToMesh_GGO_C clitkBinaryImageToMesh.ggo)
-    ADD_EXECUTABLE(clitkBinaryImageToMesh clitkBinaryImageToMesh.cxx ${clitkBinaryImageToMesh_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkBinaryImageToMesh clitkCommon)
-    SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinaryImageToMesh)
+    add_executable(clitkBinaryImageToMesh clitkBinaryImageToMesh.cxx ${clitkBinaryImageToMesh_GGO_C})
+    target_link_libraries(clitkBinaryImageToMesh clitkCommon)
+    set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinaryImageToMesh)
 
     WRAP_GGO(clitkMeshToBinaryImage_GGO_C clitkMeshToBinaryImage.ggo)
-    ADD_EXECUTABLE(clitkMeshToBinaryImage clitkMeshToBinaryImage.cxx ${clitkMeshToBinaryImage_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMeshToBinaryImage clitkCommon)
-    SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshToBinaryImage)
+    add_executable(clitkMeshToBinaryImage clitkMeshToBinaryImage.cxx ${clitkMeshToBinaryImage_GGO_C})
+    target_link_libraries(clitkMeshToBinaryImage clitkCommon)
+    set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshToBinaryImage)
 
     WRAP_GGO(clitkMeshViewer_GGO_C clitkMeshViewer.ggo)
-    ADD_EXECUTABLE(clitkMeshViewer clitkMeshViewer.cxx ${clitkMeshViewer_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMeshViewer clitkCommon)
-    SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshViewer)
-  ENDIF(CLITK_EXPERIMENTAL)
+    add_executable(clitkMeshViewer clitkMeshViewer.cxx ${clitkMeshViewer_GGO_C})
+    target_link_libraries(clitkMeshViewer clitkCommon)
+    set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshViewer)
+  endif(CLITK_EXPERIMENTAL)
   #=========================================================
 
 
   #=========================================================
-  IF(ITK_VERSION_MAJOR VERSION_LESS 4)
-    MESSAGE("clitkDicomRTPlan2Gate is not compatible with GDCM<2 (ITK<4). It will not be built.")
-  ELSE(ITK_VERSION_MAJOR VERSION_LESS 4)
-    WRAP_GGO(clitkDicomRTPlan2Gate_GGO_C clitkDicomRTPlan2Gate.ggo)
-    ADD_EXECUTABLE(clitkDicomRTPlan2Gate clitkDicomRTPlan2Gate.cxx clitkDicomRTPlan2Gate_ggo.c)
-    TARGET_LINK_LIBRARIES(clitkDicomRTPlan2Gate clitkCommon)
-    SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomRTPlan2Gate)
-  ENDIF(ITK_VERSION_MAJOR VERSION_LESS 4)
+  WRAP_GGO(clitkDice_GGO_C clitkDice.ggo)
+  add_executable(clitkDice clitkDice.cxx ${clitkDice_GGO_C})
+  target_link_libraries(clitkDice clitkSegmentationGgoLib clitkCommon ${ITK_LIBRARIES} )
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDice)
+
+  WRAP_GGO(clitkDicomRTPlan2Gate_GGO_C clitkDicomRTPlan2Gate.ggo)
+  add_executable(clitkDicomRTPlan2Gate clitkDicomRTPlan2Gate.cxx clitkDicomRTPlan2Gate_ggo.c)
+  target_link_libraries(clitkDicomRTPlan2Gate clitkCommon)
+  set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkDicomRTPlan2Gate)
   #=========================================================
 
 
-  INSTALL (TARGETS ${TOOLS_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+  install(TARGETS ${TOOLS_INSTALL} DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
 
-ENDIF(CLITK_BUILD_TOOLS)
+endif(CLITK_BUILD_TOOLS)
index 3cc4eae503b299a8d23e820340870928159a76c2..bb74448cead8ee4624a9087bd5958ecdaa3e29d5 100644 (file)
@@ -3,33 +3,33 @@ package "clitkAffineTransform"
 version "1.0"
 purpose "Resample with or without affine transform of 2D, 3D, 4D images or vector fields"
 
-option "config"                -       "Config file"                     string        no
-option "verbose"       v       "Verbose"                         flag          off
+option "config"                - "Config file"                   string        no
+option "verbose"       v "Verbose"                       flag          off
 
 section "I/O"
-option "input"         i       "Input image filename"            string        yes
-option "output"        o       "Output image filename"           string        yes
-option "like"          l       "Resample output this image (size, spacing,origin)"     string  no
-option "transform_grid" -       "Apply affine transform to input grid for output's"     flag    off
+option "input"         i "Input image filename"                                          string yes
+option "output"        o "Output image filename"                                         string yes
+option "like"          l "Resample output this image (size, spacing, origin, direction)" string no
+option "transform_grid" - "Apply affine transform to input grid for output's"             flag   off
 
 section "Options"
-option "size"          -       "New output size if different from input"       int     no      multiple
-option "spacing"       -       "New output spacing if different from input"    double  no      multiple
-option "spacinglike"   -       "New output spacing like this image"            string  no
-option "origin"                -       "New output origin if different from input"     double  no      multiple
-option "matrix"                m       "Affine matrix (homogene) filename"             string  no
-option "elastix"       e       "Read EulerTransform from elastix output file (combine if multiple)"    string  no      multiple
-option "rotate"                r       "Rotation to apply (radians)"                   double  no      multiple
-option "translate"     t       "Translation to apply (mm)"                     double  no      multiple
-option "pad"           -       "Edge padding value"                            double  no      default="0.0"
+option "size"          - "New output size if different from input"     int     no      multiple
+option "spacing"       - "New output spacing if different from input"  double  no      multiple
+option "spacinglike"   - "New output spacing like this image"          string  no
+option "origin"                - "New output origin if different from input"   double  no      multiple
+option "matrix"                m "Affine matrix (homogene) filename"           string  no
+option "elastix"       e "Read EulerTransform from elastix output file (combine if multiple)"  string  no
+option "rotate"                r "Rotation to apply (radians)"                 double  no      multiple
+option "translate"     t "Translation to apply (mm)"                   double  no      multiple
+option "pad"           - "Edge padding value"                          double  no      default="0.0"
 
 section "Interpolation"
-option "interp"                -       "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT"      int     no  default="1"
-option "interpOrder"   -       "Order if BLUT or BSpline (0-5)"                        int     no  default="3"
-option "interpSF"      -       "Sampling factor if BLUT"                               int     no  default="20"
-option "interpVF"      -       "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT"      int     no  default="1"
-option "interpVFOrder" -       "Order if BLUT or BSpline (0-5)"                        int     no  default="3"
-option "interpVFSF"    -       "Sampling factor if BLUT"                               int     no  default="20"
+option "interp"                - "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT"    int     no  default="1"
+option "interpOrder"   - "Order if BLUT or BSpline (0-5)"                      int     no  default="3"
+option "interpSF"      - "Sampling factor if BLUT"                             int     no  default="20"
+option "interpVF"      - "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT"    int     no  default="1"
+option "interpVFOrder" - "Order if BLUT or BSpline (0-5)"                      int     no  default="3"
+option "interpVFSF"    - "Sampling factor if BLUT"                             int     no  default="20"
 
 
 
index 150c8c172187c9455af05d8a7861e05d34c46855..65d66dc741c6256637eefbeb5c222a25860caf87 100644 (file)
@@ -182,9 +182,8 @@ namespace clitk
           }
         else {
           if (m_ArgsInfo.elastix_given) {
-            std::vector<std::string> s;
-            for(uint i=0; i<m_ArgsInfo.elastix_given; i++) s.push_back(m_ArgsInfo.elastix_arg[i]);
-            matrix = createMatrixFromElastixFile<Dimension>(s, m_Verbose);
+            std::string filename(m_ArgsInfo.elastix_arg);
+            matrix = createMatrixFromElastixFile<Dimension>(filename, m_Verbose);
           }
           else 
             matrix.SetIdentity();
@@ -213,6 +212,7 @@ namespace clitk
       likeReader->SetFileName(m_ArgsInfo.like_arg);
       likeReader->Update();
       resampler->SetOutputParametersFromImage(likeReader->GetOutput());
+      resampler->SetOutputDirection(likeReader->GetOutput()->GetDirection());
     } else if(m_ArgsInfo.transform_grid_flag) {
       typename itk::Matrix<double, Dimension+1, Dimension+1> invMatrix( matrix.GetInverse() );
       typename itk::Matrix<double, Dimension, Dimension> invRotMatrix( clitk::GetRotationalPartMatrix(invMatrix) );
index e020d543afdacae3bb89b20ebd5c27b110903768..408fe7fc654a58f3a49d56496588c33cd463a959 100644 (file)
@@ -90,6 +90,7 @@ AnisotropicDiffusionGenericFilter::UpdateWithInputImageType()
     gadFilter->SetConductanceParameter(mArgsInfo.conductance_arg);
     gadFilter->Update();
     this->template SetNextOutput<InputImageType>(gadFilter->GetOutput());
+    break;
   case type_arg_Curvature:
     cadFilter->SetInput(input);
     cadFilter->SetNumberOfIterations(mArgsInfo.niterations_arg);
@@ -97,6 +98,10 @@ AnisotropicDiffusionGenericFilter::UpdateWithInputImageType()
     cadFilter->SetConductanceParameter(mArgsInfo.conductance_arg);
     cadFilter->Update();
     this->template SetNextOutput<InputImageType>(cadFilter->GetOutput());
+    break;
+  default:
+    itkGenericExceptionMacro("Unhandled type");
+    break;
   }
 }
 //--------------------------------------------------------------------
diff --git a/tools/clitkBlurImage.cxx b/tools/clitkBlurImage.cxx
new file mode 100644 (file)
index 0000000..2aa80d8
--- /dev/null
@@ -0,0 +1,50 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+/* =================================================
+ * @file   clitkBlurImageGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief BlurImage an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkBlurImage_ggo.h"
+#include "clitkBlurImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkBlurImage, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::BlurImageGenericFilter<args_info_clitkBlurImage> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  filter->Update();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkBlurImage.ggo b/tools/clitkBlurImage.ggo
new file mode 100644 (file)
index 0000000..cbcd40c
--- /dev/null
@@ -0,0 +1,14 @@
+#File clitkBlurImage.ggo
+package "clitkBlurImage"
+version "1.0"
+purpose "Filter the input image with a Gaussian"
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "output"        o       "Output image filename"           string        required
+
+option "variance"       -      "value of the gaussian variance (multiple values=number of image dimension) - default=1.0" double  optional  multiple
diff --git a/tools/clitkBlurImageGenericFilter.h b/tools/clitkBlurImageGenericFilter.h
new file mode 100644 (file)
index 0000000..be79889
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  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 CLITKBlurImageGENERICFILTER_H
+#define CLITKBlurImageGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT BlurImageGenericFilter:
+        public ImageToImageGenericFilter<BlurImageGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    BlurImageGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef BlurImageGenericFilter             Self;
+    typedef itk::SmartPointer<Self>            Pointer;
+    typedef itk::SmartPointer<const Self>      ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(BlurImageGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkBlurImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkBlurImageGenericFilter_h
diff --git a/tools/clitkBlurImageGenericFilter.txx b/tools/clitkBlurImageGenericFilter.txx
new file mode 100644 (file)
index 0000000..307ddb6
--- /dev/null
@@ -0,0 +1,129 @@
+/*=========================================================================
+  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 clitkBlurImageGenericFilter_txx
+#define clitkBlurImageGenericFilter_txx
+
+/* =================================================
+ * @file   clitkBlurImageGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date   29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// itk include
+#include "itkDiscreteGaussianImageFilter.h"
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+BlurImageGenericFilter<args_info_type>::BlurImageGenericFilter():
+  ImageToImageGenericFilter<Self>("BlurImage")
+{
+  InitializeImageType<2>();
+  InitializeImageType<3>();
+  //InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void BlurImageGenericFilter<args_info_type>::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void BlurImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+  mArgsInfo=a;
+  this->SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+  if (mArgsInfo.input_given) {
+    this->SetInputFilename(mArgsInfo.input_arg);
+  }
+  if (mArgsInfo.output_given) {
+    this->SetOutputFilename(mArgsInfo.output_arg);
+  }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+BlurImageGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+  const unsigned int dim = InputImageType::ImageDimension;
+  double varianceArray[dim];
+
+  //std::cout<<"mArgsInfo.variance_given"<<mArgsInfo.variance_given<<std::endl;
+
+
+  //if (mArgsInfo.variance_given != dim) {
+  //  std::cerr << "The number of variance parameters must be equal to the image dimension." << std::endl;
+  //  return;
+  //}
+
+  if (mArgsInfo.variance_given && mArgsInfo.variance_given == dim) {
+  for (unsigned int i = 0; i < dim; i++) {
+    //std::cout<<"mArgsInfo.variance_arg[i]"<<mArgsInfo.variance_arg[i]<<std::endl;
+    varianceArray[i] = mArgsInfo.variance_arg[i];
+  }
+  } else {
+      for (unsigned int i = 0; i < dim; i++) {
+          varianceArray[i] = 1.0;
+      }
+  }
+  // Reading input
+  typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+  // Main filter
+  typedef typename InputImageType::PixelType PixelType;
+  typedef itk::Image<float, InputImageType::ImageDimension> OutputImageType;
+
+  // Filter
+  typedef itk::DiscreteGaussianImageFilter<InputImageType, OutputImageType> DiscreteGaussianImageFilterType;
+  typename DiscreteGaussianImageFilterType::Pointer gaussianFilter=DiscreteGaussianImageFilterType::New();
+  gaussianFilter->SetInput(input);
+  gaussianFilter->SetVariance(varianceArray);
+  gaussianFilter->Update();
+
+  //std::cout<<"variance value="<<gaussianFilter->GetVariance()<<std::endl;
+
+  // Write/Save results
+  this->template SetNextOutput<OutputImageType>(gaussianFilter->GetOutput());
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkBlurImageGenericFilter_txx
index ede400746d028373718d3f3d45444ab6865a3468..0e2818ac67e4d3584e20891545aa37d641ce0fba 100644 (file)
@@ -183,8 +183,7 @@ void clitk::CropImageGenericFilter::UpdateWithInputImageType()
   typename ImageType::PointType origin = output->GetOrigin();
   typename ImageType::SpacingType spacing = output->GetSpacing();
   if (mArgsInfo.verbose_flag) std::cout << "origin before crop " << origin << std::endl;
-  for (unsigned int i = 0; i < output->GetImageDimension(); i++)
-    origin[i] += index[i]*spacing[i];
+  input->TransformIndexToPhysicalPoint(index,origin);
   if (mArgsInfo.verbose_flag) std::cout << "origin after crop " << origin << std::endl;
   output->SetOrigin(origin);
 
index b25b001dea3a19c75edec04b1bcf790891c5cf6a..a6323da9de5ba6ad89c75ab8372049ef569b3200 100644 (file)
@@ -23,6 +23,7 @@
 #include "vvImageReader.h"
 #include "vvImageWriter.h"
 #include <gdcmFile.h>
+#include <vtkVersion.h>
 #include <vtkImageChangeInformation.h>
 #if GDCM_MAJOR_VERSION == 2
   #include <gdcmImageHelper.h>
@@ -191,7 +192,11 @@ int main(int argc, char * argv[])
       std::vector<int> size = image->GetSize();
       origin[0] = -spacing[0]*size[0]/2.0;
       origin[1] = -spacing[1]*size[1]/2.0;
+#if VTK_MAJOR_VERSION <= 5
       modifier->SetInput(vtk_image);
+#else
+      modifier->SetInputData(vtk_image);
+#endif
       modifier->SetOutputOrigin(origin[0], origin[1], locs[sliceIndex[0]]);
       modifier->Update();
       vvImage::Pointer focal_image = vvImage::New();
index b713d9412d20897bea105aa16bcf596c941bfd72..302f65ced9ed72ec44964b0650b4e5b01c480832 100644 (file)
 #include "clitkDicomRTStruct2ImageFilter.h"
 #include "clitkDicomRT_StructureSet.h"
 #include "clitkDicomRTStruct2Image_ggo.h"
+#include "clitkIO.h"
 
 //--------------------------------------------------------------------
 int main(int argc, char * argv[]) {
 
   // Init command line
   GGO(clitkDicomRTStruct2Image, args_info);
+  CLITK_INIT;
 
   // Read and display information
   clitk::DicomRT_StructureSet::Pointer s = clitk::DicomRT_StructureSet::New();
@@ -66,11 +68,21 @@ int main(int argc, char * argv[]) {
         filter.SetCropMaskEnabled(args_info.crop_flag);
         filter.SetImageFilename(args_info.image_arg);  // Used to get spacing + origin
         name.erase(remove_if(name.begin(), name.end(), isspace), name.end());
-        std::string n = std::string(args_info.output_arg).append
-          (clitk::toString(num)).append
-          ("_").append
-          (name).append
-          (".mhd");
+        std::string n;
+        if (args_info.mha_flag) {
+          n = std::string(args_info.output_arg).append
+            (clitk::toString(num)).append
+            ("_").append
+            (name).append
+            (".mha");
+        }
+        else {
+          n = std::string(args_info.output_arg).append
+            (clitk::toString(num)).append
+            ("_").append
+            (name).append
+            (".mhd");
+        }
         if (args_info.verbose_flag) {
           std::cout << num << " " << roi->GetName() << " num=" << num << " : " << n << std::endl;
         }
index 8a09da1c5b4baa33a2e915d3eb303ae5a48c4e3c..980f8a92bcba6322586a158c0f4a8da3d5d695cc 100644 (file)
@@ -16,6 +16,8 @@ groupoption "roiNameSubstr"     s "Substring of ROI name to binarize (reuturns a
 
 option "crop"           c "Crop binary mask"            flag off
 
+option "mha"  - "Write the RTStruct as a mha image to avoid special character problems"                 flag off
+
 #option "roi"           r "ROI to print (ID)"           int            no
 #option "contour"       c "contour to print (ID)"       int            no
 #option "offset"                o "to display points as image offsets" flag    off
index 7efc4e965161c8171f80f1d4157431fcdb02abd2..08113b2441481f38b7b3a3ca04bcab86d1cad160 100644 (file)
@@ -31,9 +31,9 @@ int main(int argc, char * argv[])
   CLITK_INIT;
 
   // Use static fct of AffineTransformGenericFilter
-  std::vector<std::string> l;
-  l.push_back(args_info.input_arg);
-  itk::Matrix<double, 4, 4> m = clitk::createMatrixFromElastixFile<3>(l, args_info.verbose_flag);
+  std::string filename(args_info.input_arg);
+  itk::Matrix<double, 4, 4> m = clitk::createMatrixFromElastixFile<3>(filename,
+                                                                      args_info.verbose_flag);
 
   // Print matrix
   std::ofstream os;
index 51d00ba4814f84d10e4d5dcef4d218db4be12573..046f6aab8b3b1e536f9acb20c46aad6b3b36b9ad 100644 (file)
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
 
-/* =================================================
- * @file   clitkFooImageGenericFilter.txx
- * @author xxx <xxx@creatis.insa-lyon.fr>
- * @date   29 June 2029
- *
- * @brief FooImage an image
- *
- ===================================================*/
-
 // clitk
 #include "clitkFooImage_ggo.h"
 #include "clitkFooImageGenericFilter.h"
index 3d0c8dbf97d92ef173713193fba0761dcbf7a9a5..d85977318e339b55a582840972986bf8c0bda215 100644 (file)
@@ -10,9 +10,4 @@ option "imagetypes"   -       "Display allowed image types"     flag          off
 
 option "input"         i       "Input image filename"            string        required
 option "output"        o       "Output image filename"           string        required
-option "lower"         l       "Lower intensity (default=min), fg is greater than this value"    double        optional
-option "upper"         u       "Upper intensity (default=max), fg is lower than this value"      double        optional
 
-option "fg"                    -       "Foreground (FG) or 'inside' value"               double        optional        default="1"
-option "bg"                    -       "Background (BG) or 'ouside' value"               double        optional        default="0"
-option "mode"          -       "Use FG and/or BG values (if FG, the BG is replaced by the input image values)" values="FG","BG","both"  default="both" optional
index e230f91b47f793e2549b44a7dd3d037fb9529c56..7578411864512546a8d46e2840a377154a037590 100644 (file)
@@ -15,8 +15,8 @@
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
-#ifndef CLITKFooIMAGEGENERICFILTER_H
-#define CLITKFooIMAGEGENERICFILTER_H
+#ifndef clitkFooImageGenericFilter_h
+#define clitkFooImageGenericFilter_h
 #include "clitkIO.h"
 #include "clitkImageToImageGenericFilter.h"
 
index 88473a02a0f65e3b234d0eb24c0384912ad9ff90..1724454b17a10776e711227679ed46c999f17f27 100644 (file)
 #ifndef clitkFooImageGenericFilter_txx
 #define clitkFooImageGenericFilter_txx
 
-/* =================================================
- * @file   clitkFooImageGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date   29 june 2009
- *
- * @brief
- *
- ===================================================*/
-
 // itk include
 #include "itkBinaryThresholdImageFilter.h"
 #include "itkMaskImageFilter.h"
@@ -95,40 +86,11 @@ FooImageGenericFilter<args_info_type>::UpdateWithInputImageType()
   typedef itk::BinaryThresholdImageFilter<InputImageType, OutputImageType> BinaryThresholdImageFilterType;
   typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New();
   thresholdFilter->SetInput(input);
-  thresholdFilter->SetInsideValue(mArgsInfo.fg_arg);
-
-  if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast<PixelType>(mArgsInfo.lower_arg));
-  if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast<PixelType>(mArgsInfo.upper_arg));
-
-  if (mArgsInfo.mode_arg == std::string("both")) {
-    thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg);
-    thresholdFilter->Update();
-
-    typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
-    this->template SetNextOutput<OutputImageType>(outputImage);
-  } else {
-    typename InputImageType::Pointer outputImage;
-    thresholdFilter->SetOutsideValue(0);
-    if (mArgsInfo.mode_arg == std::string("BG")) {
-      typedef itk::MaskImageFilter<InputImageType,OutputImageType> maskFilterType;
-      typename maskFilterType::Pointer maskFilter = maskFilterType::New();
-      maskFilter->SetInput1(input);
-      maskFilter->SetInput2(thresholdFilter->GetOutput());
-      maskFilter->SetOutsideValue(mArgsInfo.bg_arg);
-      maskFilter->Update();
-      outputImage = maskFilter->GetOutput();
-    } else {
-      typedef itk::MaskNegatedImageFilter<InputImageType,OutputImageType> maskFilterType;
-      typename maskFilterType::Pointer maskFilter = maskFilterType::New();
-      maskFilter->SetInput1(input);
-      maskFilter->SetInput2(thresholdFilter->GetOutput());
-      maskFilter->SetOutsideValue(mArgsInfo.fg_arg);
-      maskFilter->Update();
-      outputImage = maskFilter->GetOutput();
-    }
-    // Write/Save results
-    this->template SetNextOutput<InputImageType>(outputImage);
-  }
+  // Set filter members
+
+  // Write/Save results
+  typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
+  this->template SetNextOutput<OutputImageType>(outputImage);
 }
 //--------------------------------------------------------------------
 
index 7e5a92eba7cf32d67775e1910d596290c8f5eee9..1f5fd03f3a78c905ecd666dc2376569b674e9fa3 100644 (file)
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================*/
+
+#include "clitkGammaIndex_ggo.h"
+#include "clitkIO.h"
+#include "clitkDD.h"
+
+#include <iostream>
+#include <cmath>
+#include <cassert>
+
 #include <vtkPoints.h>
 #include <vtkCellArray.h>
 #include <vtkPointData.h>
 #include <vtkPNGReader.h>
 #include <vtkPolyData.h>
 #include <vtkCellLocator.h>
-#include <iostream>
-#include <cmath>
-#include <cassert>
-using std::endl;
-using std::cout;
 
-#include "clitkGammaIndex_ggo.h"
-
-#include <clitkIO.h>
 #include <vvImage.h>
 #include <vvImageReader.h>
 #include <vvImageWriter.h>
@@ -42,6 +43,9 @@ using std::cout;
 typedef itk::Image<double> OutputImageType;
 typedef itk::ImageRegionIterator<OutputImageType> OutputImageIterator;
 
+using std::endl;
+using std::cout;
+
 vtkImageData* loadImage(const std::string& filename)
 {
     vvImageReader::Pointer reader = vvImageReader::New();
@@ -224,7 +228,7 @@ int main(int argc,char * argv[])
     // load reference
     vtkImageData* reference = loadImage(reference_filename);
     assert(reference);
+
     // translate target with arguments values
     // reference is translated instead of target so that the output space stay the same as target
     {
@@ -248,10 +252,13 @@ int main(int argc,char * argv[])
 
     vtkAbstractCellLocator *locator = vtkCellLocator::New();
     locator->SetDataSet(data);
-    data->Delete();
+    DD("here");
+    //    data->Delete();
     locator->CacheCellBoundsOn();
     locator->AutomaticOn();
+    DD("BuildLocator");
     locator->BuildLocator();
+    DD("end BuildLocator");
 
     // load target
     vtkImageData* target = loadImage(target_filename);
@@ -277,6 +284,7 @@ int main(int argc,char * argv[])
     unsigned long over_one = 0;
     OutputImageIterator iter(output,output->GetLargestPossibleRegion());
     iter.GoToBegin();
+    DD("loop");
     while (!iter.IsAtEnd()) {
        double *point = target->GetPoint(kk);
        double value = target->GetPointData()->GetScalars()->GetTuple1(kk);
@@ -315,4 +323,3 @@ int main(int argc,char * argv[])
 
     return 0;
 }
-
index abedc61a800310e4a951ae64fe5bb63ccf46b156..81386821e37e62d4725748729f7f9a5883fcd66b 100644 (file)
@@ -67,6 +67,8 @@ int main(int argc, char * argv[])
   filter->SetInputFilenames(l);
   filter->SetIOVerbose(args_info.verbose_flag);
   filter->SetOutputFilename(output);
+  filter->SetVV(args_info.vv_flag);
+  filter->SetCorrectNegativeSpacingFlag(args_info.correct_flag);
   filter->EnableWriteCompression(args_info.compression_flag);
   if (args_info.type_given) filter->SetOutputPixelType(args_info.type_arg);
 
@@ -79,4 +81,3 @@ int main(int argc, char * argv[])
 //-------------------------------------------------------------------=
 
 #endif /* end #define CLITKIMAGECONVERT_CXX */
-
index 837ee03bb6c75e5ef39e9b489eeb4929bcf95dd2..6d74318e776a08770c2be3ac0ab4bbeba04a40d4 100644 (file)
@@ -3,9 +3,11 @@ 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 "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
index e8d8efb79d9f8c6a54d9cc1b5f37e0401d613c75..a60338513175f4bb526f79b31d784af495a8fc39 100644 (file)
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
   ===========================================================================**/
+
 #ifndef CLITKIMAGECONVERTGENERICFILTER_CXX
 #define CLITKIMAGECONVERTGENERICFILTER_CXX
 
 #include "clitkImageConvertGenericFilter.h"
+#include "vvImageReader.h"
+#include "vvImageWriter.h"
+#include "itkFlipImageFilter.h"
+#include "itkGDCMImageIO.h"
+
+#include "gdcmReader.h"
+#include "gdcmAttribute.h"
+#include "gdcmPrinter.h"
+#include "gdcmDict.h"
+#include "gdcmStringFilter.h"
 
 //--------------------------------------------------------------------
 clitk::ImageConvertGenericFilter::ImageConvertGenericFilter():
@@ -28,7 +39,8 @@ clitk::ImageConvertGenericFilter::ImageConvertGenericFilter():
   mDisplayWarning = true;
   mWarning = "";
   mWarningOccur = false;
-  
+  SetCorrectNegativeSpacingFlag(false);
+
   InitializeImageType<2>();
   InitializeImageType<3>();
   InitializeImageType<4>();
@@ -70,13 +82,103 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType()
     }
   }
 
-  if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) {
+  if(mVV) {
+    if (mOutputPixelTypeName != "NotSpecified" || m_WriteCompression) {
+      std::cerr << "--vv is not compatible with --compression and --type options." << std::endl;
+      exit(-1);
+    }
+
+    vvImageReader::Pointer reader = vvImageReader::New();
+    reader->SetInputFilenames(m_InputFilenames);
+    reader->Update(vvImageReader::IMAGE);
+
+    vvImageWriter::Pointer writer = vvImageWriter::New();
+    writer->SetOutputFileName(m_OutputFilenames.front());
+    writer->SetSaveTransform(true);
+    writer->SetInput(reader->GetOutput());
+    writer->Update();
+    return;
+  }
+  else if ((m_PixelTypeName == mOutputPixelTypeName) || (mOutputPixelTypeName == "NotSpecified")) {
+
+    // Get input image
     typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
-    this->SetNextOutput<InputImageType>(input);
+
+    if (mCorrectNegativeSpacingFlag) {
+      // Read dicom
+      gdcm::Reader reader;
+      reader.SetFileName(m_InputFilenames[0].c_str());
+      // if (!reader.CanReadFile(m_InputFilenames[0])) {
+      //   std::cout << "Error: " << m_InputFilenames[0] << " is not a dicom file. Abort." << std::endl;
+      //   exit(0);
+      // }
+      reader.Read();
+
+      // the dataset is the the set of element we are interested in:
+      gdcm::DataSet & ds = reader.GetFile().GetDataSet();
+
+      // Read the attribute SpacingBetweenSlices, check if negative and replace
+      gdcm::Attribute<0x0018,0x0088> SpacingBetweenSlices;
+      SpacingBetweenSlices.SetFromDataSet(ds);
+      double s = SpacingBetweenSlices.GetValue();
+      if (s >=0) {
+        std::cout << "Error: no negative spacing found SpacingBetweenSlices = " << s << " Abort. " << std::endl;
+        exit(0);
+      }
+      s = -s;
+
+      // Set spacing
+      typename InputImageType::SpacingType spacing = input->GetSpacing();
+      spacing[2] = s;
+      input->SetSpacing(spacing);
+
+      // Flip
+      typedef itk::FlipImageFilter< InputImageType >  FilterType;
+      typename FilterType::Pointer filter = FilterType::New();
+      typedef typename FilterType::FlipAxesArrayType     FlipAxesArrayType;
+      FlipAxesArrayType flipArray;
+      flipArray[0] = false;
+      flipArray[1] = false;
+      flipArray[2] = true;
+      filter->SetFlipAxes(flipArray);
+      filter->SetInput(input);
+      filter->Update();
+
+      // Read the attribute  Image Position (Patient)
+      gdcm::Tag  DetectorInformationSequenceTag(0x0054,0x0022);
+      const gdcm::DataElement & DIS = ds.GetDataElement(DetectorInformationSequenceTag);
+      gdcm::SmartPointer<gdcm::SequenceOfItems> sqf = DIS.GetValueAsSQ();
+      gdcm::Item & item = sqf->GetItem(1);
+      gdcm::DataSet & ds_position = item.GetNestedDataSet();
+      gdcm::Attribute<0x0020,0x0032> ImagePositionPatient;
+      ImagePositionPatient.SetFromDataSet(ds_position);
+      double x = ImagePositionPatient.GetValue(0);
+      double y = ImagePositionPatient.GetValue(1);
+      double z = ImagePositionPatient.GetValue(2);
+
+      // Set offset
+      typename InputImageType::PointType origin = input->GetOrigin();
+      origin[0] = x;
+      origin[1] = y;
+      origin[2] = z;
+      input->SetOrigin(origin);
+
+      // Orientation
+      typename InputImageType::DirectionType direction = input->GetDirection();
+      direction[2][2] = -1;
+      input->SetDirection(direction);
+
+      // Empty meta info
+      itk::MetaDataDictionary dict;// = new itk::MetaDataDictionary;
+      input->SetMetaDataDictionary(dict);
+
+      this->SetNextOutput<InputImageType>(input);
+    }
+
   } else {
-    // "trick" to call independent versions of update according to the 
+    // "trick" to call independent versions of update according to the
     // pixel type (vector or scalar), using partial specializations
-    if (!UpdateWithSelectiveOutputType<InputImageType, ImageConvertTraits<typename InputImageType::PixelType>::IS_VECTOR>::Run(*this, mOutputPixelTypeName))    
+    if (!UpdateWithSelectiveOutputType<InputImageType, ImageConvertTraits<typename InputImageType::PixelType>::IS_VECTOR>::Run(*this, mOutputPixelTypeName))
       exit(-1);
   }
 }
@@ -124,4 +226,3 @@ void clitk::ImageConvertGenericFilter::CheckTypes(
 
 
 #endif /* end #define CLITKIMAGECONVERTGENERICFILTER_CXX */
-
index 20717144431725a5f793d061467e10f170dc61bb..aa8b2ba64b69496ee2580bc77f3ef3383bd5542b 100644 (file)
@@ -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 @@
  * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
  * @date   05 May 2008 10:40:24
 
- * @brief  
+ * @brief
 
  ===================================================================*/
 
@@ -36,7 +36,7 @@
 
 
 namespace clitk {
-  
+
   template <class TPixel>
   class ImageConvertTraits
   {
@@ -47,17 +47,17 @@ namespace clitk {
     }
   };
 
-  template < class TPixel, unsigned int Comp > 
-  class ImageConvertTraits< itk::Vector<TPixel, Comp> > 
-  { 
-  public: 
-    enum { IS_VECTOR = true }; 
+  template < class TPixel, unsigned int Comp >
+  class ImageConvertTraits< itk::Vector<TPixel, Comp> >
+  {
+  public:
+    enum { IS_VECTOR = true };
   };
 
-  class ImageConvertGenericFilter: 
+  class ImageConvertGenericFilter:
     public clitk::ImageToImageGenericFilter<ImageConvertGenericFilter> {
-    
-  public: 
+
+  public:
     // constructor - destructor
     ImageConvertGenericFilter();
 
@@ -68,23 +68,25 @@ namespace clitk {
 
     // New
     itkNewMacro(Self);
-    
+
     // Members functions
     std::string GetInputPixelTypeName() { return m_PixelTypeName; }
     std::string GetOutputPixelTypeName() { return mOutputPixelTypeName; }
     void SetOutputPixelType(std::string p) { mOutputPixelTypeName = p; }
+    void SetVV(bool b) { mVV = b; }
     bool IsWarningOccur() { return mWarningOccur; }
     std::string & GetWarning() { return mWarning; }
     void EnableDisplayWarning(bool b) { mDisplayWarning = b; }
+    void SetCorrectNegativeSpacingFlag(bool b) { mCorrectNegativeSpacingFlag = b; }
 
     //--------------------------------------------------------------------
     // Main function called each time the filter is updated
-    template<class InputImageType>  
+    template<class InputImageType>
     void UpdateWithInputImageType();
 
     template<class PixelType, class OutputPixelType>
     void CheckTypes(std::string inType, std::string outType);
-    
+
   protected:
 
     template<unsigned int Dim> void InitializeImageType();
@@ -92,6 +94,8 @@ namespace clitk {
     std::string mWarning;
     bool mWarningOccur;
     bool mDisplayWarning;
+    bool mVV;
+    bool mCorrectNegativeSpacingFlag;
 
   private:
     template <class InputImageType, bool isVector>
@@ -117,17 +121,17 @@ namespace clitk {
           else
           {
             std::string list = CreateListOfTypes<float, double>();
-            std::cerr << "Error, I don't know the vector output type '" << outputPixelType 
+            std::cerr << "Error, I don't know the vector output type '" << outputPixelType
                       << "'. " << std::endl << "Known types are " << list << "." << std::endl;
             return false;
           }
-          
+
           return true;
       }
 
     private:
-      
-      template <class OutputPixelType> 
+
+      template <class OutputPixelType>
       static void UpdateWithOutputType(ImageConvertGenericFilter& filter)
       {
         // Read
@@ -150,7 +154,7 @@ namespace clitk {
         filter.SetNextOutput<OutputImageType>(cast_filter->GetOutput());
       }
     };
-    
+
     template <class InputImageType>
     class UpdateWithSelectiveOutputType<InputImageType, true>
     {
@@ -158,7 +162,7 @@ namespace clitk {
       static bool Run(ImageConvertGenericFilter& filter, std::string outputPixelType)
       {
         /*
-        // RP: future conversions? 
+        // RP: future conversions?
         if (IsSameType<char>(outputPixelType))
           UpdateWithOutputVectorType<char>();
         else if (IsSameType<uchar>(outputPixelType))
@@ -169,7 +173,7 @@ namespace clitk {
           UpdateWithOutputVectorType<ushort>();
         else if (IsSameType<int>(outputPixelType))
           UpdateWithOutputVectorType<int>();
-        else 
+        else
           */
         if (IsSameType<float>(outputPixelType))
           UpdateWithOutputVectorType<float>(filter);
@@ -178,17 +182,17 @@ namespace clitk {
         else
         {
           std::string list = CreateListOfTypes<float, double>();
-          std::cerr << "Error, I don't know the vector output type '" << outputPixelType  
+          std::cerr << "Error, I don't know the vector output type '" << outputPixelType
                     << "'. " << std::endl << "Known types are " << list << "." << std::endl;
           return false;
         }
-        
+
         return true;
       }
-      
+
     private:
-      
-      template <class OutputPixelType> 
+
+      template <class OutputPixelType>
       static void UpdateWithOutputVectorType(ImageConvertGenericFilter& filter)
       {
         // Read
@@ -199,7 +203,7 @@ namespace clitk {
 
         // Warning
         filter.CheckTypes<PixelType, OutputPixelType>(filter.GetInputPixelTypeName(), filter.GetOutputPixelTypeName());
-        
+
         // Cast
         typedef itk::Image<itk::Vector<OutputPixelType, InputImageType::PixelType::Dimension>, InputImageType::ImageDimension> OutputImageType;
         typedef itk::VectorCastImageFilter<InputImageType, OutputImageType> FilterType;
@@ -218,4 +222,3 @@ namespace clitk {
 } // end namespace
 
 #endif /* end #define CLITKIMAGECONVERTGENERICFILTER_H */
-
diff --git a/tools/clitkImageGradientMagnitude.cxx b/tools/clitkImageGradientMagnitude.cxx
new file mode 100644 (file)
index 0000000..7371bf0
--- /dev/null
@@ -0,0 +1,50 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+/* =================================================
+ * @file   clitkImageGradientMagnitudeGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief ImageGradientMagnitude an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkImageGradientMagnitude_ggo.h"
+#include "clitkImageGradientMagnitudeGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkImageGradientMagnitude, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::ImageGradientMagnitudeGenericFilter<args_info_clitkImageGradientMagnitude> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  filter->Update();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkImageGradientMagnitude.ggo b/tools/clitkImageGradientMagnitude.ggo
new file mode 100644 (file)
index 0000000..90c2073
--- /dev/null
@@ -0,0 +1,15 @@
+#File clitkImageGradientMagnitude.ggo
+package "clitkImageGradientMagnitude"
+version "1.0"
+purpose "Compute the gradient magnitude of the input image"
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "mask"          m       "Mask input image filename"       string        optional
+option "output"        o       "Output image filename"           string        required
+option "normalize"      n       "Normalize the output image between 0 and 1"    flag off
+option "gaussian_filter" g      "Gaussian filtering - default sigma value=1.0"              flag          off
diff --git a/tools/clitkImageGradientMagnitudeGenericFilter.h b/tools/clitkImageGradientMagnitudeGenericFilter.h
new file mode 100644 (file)
index 0000000..660ff89
--- /dev/null
@@ -0,0 +1,72 @@
+/*=========================================================================
+  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 CLITKImageGradientMagnitudeGENERICFILTER_H
+#define CLITKImageGradientMagnitudeGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT ImageGradientMagnitudeGenericFilter:
+        public ImageToImageGenericFilter<ImageGradientMagnitudeGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    ImageGradientMagnitudeGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef ImageGradientMagnitudeGenericFilter         Self;
+    typedef itk::SmartPointer<Self>                     Pointer;
+    typedef itk::SmartPointer<const Self>               ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(ImageGradientMagnitudeGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+private:
+    bool m_NormalizeOutput;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkImageGradientMagnitudeGenericFilter.txx"
+#endif
+
+#endif // #define clitkImageGradientMagnitudeGenericFilter_h
diff --git a/tools/clitkImageGradientMagnitudeGenericFilter.txx b/tools/clitkImageGradientMagnitudeGenericFilter.txx
new file mode 100644 (file)
index 0000000..1df5601
--- /dev/null
@@ -0,0 +1,196 @@
+/*=========================================================================
+  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 clitkImageGradientMagnitudeGenericFilter_txx
+#define clitkImageGradientMagnitudeGenericFilter_txx
+
+/* =================================================
+ * @file   clitkImageGradientMagnitudeGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date   29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// itk include
+#include "itkGradientMagnitudeImageFilter.h"
+#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
+#include "itkLabelStatisticsImageFilter.h"
+#include "itkMaskImageFilter.h"
+#include "itkMaskNegatedImageFilter.h"
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    ImageGradientMagnitudeGenericFilter<args_info_type>::ImageGradientMagnitudeGenericFilter():
+        ImageToImageGenericFilter<Self>("ImageGradientMagnitude")
+    {
+        InitializeImageType<2>();
+        InitializeImageType<3>();
+    }
+    //--------------------------------------------------------------------
+
+
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    template<unsigned int Dim>
+    void ImageGradientMagnitudeGenericFilter<args_info_type>::InitializeImageType()
+    {
+        ADD_DEFAULT_IMAGE_TYPES(Dim);
+    }
+    //--------------------------------------------------------------------
+
+
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    void ImageGradientMagnitudeGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+    {
+        mArgsInfo=a;
+        this->SetIOVerbose(mArgsInfo.verbose_flag);
+        if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+        if (mArgsInfo.input_given) {
+            this->SetInputFilename(mArgsInfo.input_arg);
+        }
+        if (mArgsInfo.output_given) {
+            this->SetOutputFilename(mArgsInfo.output_arg);
+        }
+        //
+        if (mArgsInfo.normalize_flag) {
+            this->m_NormalizeOutput = 1;
+        }
+        else {
+            this->m_NormalizeOutput = 0;
+        }
+        if (mArgsInfo.mask_given) {
+          this->AddInputFilename(mArgsInfo.mask_arg);
+        }
+    }
+    //--------------------------------------------------------------------
+
+    //--------------------------------------------------------------------
+    // Update with the number of dimensions and the pixeltype
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    template<class InputImageType>
+    void
+    ImageGradientMagnitudeGenericFilter<args_info_type>::UpdateWithInputImageType()
+    {
+        // Main filter
+        typedef typename InputImageType::PixelType InputPixelType;
+        typedef itk::Image<float, InputImageType::ImageDimension> OutputImageType;
+        typedef itk::Image<unsigned char, OutputImageType::ImageDimension> MaskImageType;
+
+        // Reading input
+        typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+        typename MaskImageType::Pointer mask = NULL;
+        if(mArgsInfo.mask_given) {
+            mask = this->template GetInput<MaskImageType>(1);
+        }
+        else {
+            mask = MaskImageType::New();
+            mask->SetRegions(input->GetLargestPossibleRegion());
+            mask->SetOrigin(input->GetOrigin());
+            mask->SetSpacing(input->GetSpacing());
+            mask->Allocate();
+            mask->FillBuffer(1);
+        }
+
+
+        // Create output image
+        typename OutputImageType::Pointer outputImage = OutputImageType::New();
+        outputImage->SetRegions(input->GetLargestPossibleRegion());
+        outputImage->SetOrigin(input->GetOrigin());
+        outputImage->SetSpacing(input->GetSpacing());
+        outputImage->Allocate();
+        outputImage->FillBuffer(0.0);
+        // Set output iterator
+        typedef itk::ImageRegionIterator<OutputImageType> IteratorOutputType;
+        IteratorOutputType ito = IteratorOutputType(outputImage, outputImage->GetLargestPossibleRegion());
+
+        // Filter
+        typename OutputImageType::Pointer outputGradientFilter;
+        if (mArgsInfo.gaussian_filter_flag == 0) {
+        typedef itk::GradientMagnitudeImageFilter<InputImageType, OutputImageType> GradientMagnitudeImageFilterType;
+        typename GradientMagnitudeImageFilterType::Pointer gradientFilter=GradientMagnitudeImageFilterType::New();
+        gradientFilter->SetInput(input);
+        gradientFilter->Update();
+        outputGradientFilter = gradientFilter->GetOutput();
+        }
+        else {
+            typedef itk::GradientMagnitudeRecursiveGaussianImageFilter<InputImageType, OutputImageType> GradientMagnitudeImageFilterType;
+            typename GradientMagnitudeImageFilterType::Pointer gradientFilter=GradientMagnitudeImageFilterType::New();
+            gradientFilter->SetInput(input);
+            gradientFilter->Update();
+            //std::cout<<"sigma value="<<gradientFilter->GetSigma()<<std::endl;
+            outputGradientFilter = gradientFilter->GetOutput();
+        }
+        // Set iterator
+        typedef itk::ImageRegionIterator<OutputImageType> IteratorType;
+        IteratorType it(outputGradientFilter, outputGradientFilter->GetLargestPossibleRegion());
+
+        // Set mask iterator
+        typedef itk::ImageRegionIterator<MaskImageType> IteratorMaskType;
+        IteratorMaskType itm(mask, mask->GetLargestPossibleRegion());
+
+        //typedef itk::MinimumMaximumImageCalculator <OutputImageType> ImageCalculatorFilterType;
+        //typename ImageCalculatorFilterType::Pointer imageCalculatorFilter = ImageCalculatorFilterType::New();
+        //imageCalculatorFilter->SetImage(outputGradientFilter);
+        //imageCalculatorFilter->Compute();
+        typedef itk::LabelStatisticsImageFilter< OutputImageType, MaskImageType > LabelStatisticsImageFilterType;
+        typename LabelStatisticsImageFilterType::Pointer labelStatisticsImageFilter = LabelStatisticsImageFilterType::New();
+        labelStatisticsImageFilter->SetLabelInput( mask );
+        labelStatisticsImageFilter->SetInput(outputGradientFilter);
+        labelStatisticsImageFilter->Update();
+
+        //std::cout << "Number of labels: " << labelStatisticsImageFilter->GetNumberOfLabels() << std::endl;
+
+        float minImg = labelStatisticsImageFilter->GetMinimum(1);
+        //std::cout << "minImg: " << minImg << std::endl;
+        float maxImg = labelStatisticsImageFilter->GetMaximum(1);
+        //std::cout << "maxImg: " << maxImg << std::endl;
+
+        it.GoToBegin();
+        ito.GoToBegin();
+        itm.GoToBegin();
+
+        while (!ito.IsAtEnd()) {
+            if(m_NormalizeOutput && itm.Get() == 1) {
+                ito.Set(((float) it.Get() - minImg)/(maxImg-minImg));
+            }
+            if (m_NormalizeOutput == 0 && itm.Get() == 1) {
+                ito.Set((float) it.Get());
+            }
+            ++it;
+            ++ito;
+            ++itm;
+        }
+
+        //typename OutputImageType::Pointer outputImage = outputGradientFilter;
+        this->template SetNextOutput<OutputImageType>(outputImage);
+    }
+    //--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkImageGradientMagnitudeGenericFilter_txx
index a7c70798abc215bf4de9ab9dc357f04ae8939862..33d80cbf3551bdaae3af0b0934411d9df8e06aa6 100644 (file)
@@ -30,6 +30,7 @@
 #include "clitkIO.h"
 #include "clitkImageCommon.h"
 #include "clitkCommon.h"
+#include "vvImageReader.h"
 
 //====================================================================
 int main(int argc, char * argv[])
@@ -61,7 +62,29 @@ int main(int argc, char * argv[])
     else {
       std::cerr << "*** Warning : I could not read '" << args_info.inputs[i] << "' ***" << std::endl;
     }
-  }
+
+    if (args_info.matrix_flag) {
+      vvImageReader::Pointer r = vvImageReader::New();
+      r->SetInputFilename(args_info.inputs[i]);
+      r->Update(vvImageReader::IMAGE);
+      vtkMatrix4x4 * m = r->GetOutput()->GetTransform()[0]->GetMatrix();
+      for(int i=0; i<4; i++) {
+        for(int j=0; j<4; j++)
+          std::cout << m->GetElement(i,j) << " ";
+        std::cout << std::endl;
+      }
+
+      // inverse
+      m->Invert();
+      for(int i=0; i<4; i++) {
+        for(int j=0; j<4; j++)
+          std::cout << m->GetElement(i,j) << " ";
+        std::cout << std::endl;
+      }
+
+    }
+  } // end for
+
 
   // this is the end my friend
   return 0;
index 53bdc05f66518eff9940be1cb1b9701503479853..36283d16a28efc39693c1de6131a18355a54757c 100644 (file)
@@ -7,4 +7,4 @@ option "config"          - "Config file"                 string            no
 option "long"           l "Long line output (1 or 2)"   int default = "1" no
 option "verbose"        v "Same as -l 1"                flag off
 option "name"           n "Display filename"            flag off
-
+option "matrix"                 m "Display matrix"              flag off
diff --git a/tools/clitkImageIntensityWindowing.cxx b/tools/clitkImageIntensityWindowing.cxx
new file mode 100644 (file)
index 0000000..e7e01fa
--- /dev/null
@@ -0,0 +1,50 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+/* =================================================
+ * @file   clitkImageIntensityWindowingGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief ImageIntensityWindowing an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkImageIntensityWindowing_ggo.h"
+#include "clitkImageIntensityWindowingGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkImageIntensityWindowing, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::ImageIntensityWindowingGenericFilter<args_info_clitkImageIntensityWindowing> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  filter->Update();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkImageIntensityWindowing.ggo b/tools/clitkImageIntensityWindowing.ggo
new file mode 100644 (file)
index 0000000..6b7fe46
--- /dev/null
@@ -0,0 +1,13 @@
+#File clitkImageIntensityWindowing.ggo
+package "clitkImageIntensityWindowing"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "output"        o       "Output image filename"           string        required
+option "mask"          m       "Mask input image filename"       string        optional
diff --git a/tools/clitkImageIntensityWindowingGenericFilter.h b/tools/clitkImageIntensityWindowingGenericFilter.h
new file mode 100644 (file)
index 0000000..41f88e1
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  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 CLITKImageIntensityWindowingGENERICFILTER_H
+#define CLITKImageIntensityWindowingGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT ImageIntensityWindowingGenericFilter:
+        public ImageToImageGenericFilter<ImageIntensityWindowingGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    ImageIntensityWindowingGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef ImageIntensityWindowingGenericFilter         Self;
+    typedef itk::SmartPointer<Self>                      Pointer;
+    typedef itk::SmartPointer<const Self>                ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(ImageIntensityWindowingGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkImageIntensityWindowingGenericFilter.txx"
+#endif
+
+#endif // #define clitkImageIntensityWindowingGenericFilter_h
diff --git a/tools/clitkImageIntensityWindowingGenericFilter.txx b/tools/clitkImageIntensityWindowingGenericFilter.txx
new file mode 100644 (file)
index 0000000..02f4acd
--- /dev/null
@@ -0,0 +1,167 @@
+/*=========================================================================
+  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 clitkImageIntensityWindowingGenericFilter_txx
+#define clitkImageIntensityWindowingGenericFilter_txx
+
+/* =================================================
+ * @file   clitkImageIntensityWindowingGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date   29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// itk include
+#include "itkIntensityWindowingImageFilter.h"
+#include "itkLabelStatisticsImageFilter.h"
+#include "itkMaskImageFilter.h"
+#include "itkMaskNegatedImageFilter.h"
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+ImageIntensityWindowingGenericFilter<args_info_type>::ImageIntensityWindowingGenericFilter():
+  ImageToImageGenericFilter<Self>("ImageIntensityWindowing")
+{
+  InitializeImageType<2>();
+  InitializeImageType<3>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void ImageIntensityWindowingGenericFilter<args_info_type>::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void ImageIntensityWindowingGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+  mArgsInfo=a;
+  this->SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+  if (mArgsInfo.input_given) {
+    this->SetInputFilename(mArgsInfo.input_arg);
+  }
+  if (mArgsInfo.output_given) {
+    this->SetOutputFilename(mArgsInfo.output_arg);
+  }
+  if (mArgsInfo.mask_given) {
+    this->AddInputFilename(mArgsInfo.mask_arg);
+  }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+ImageIntensityWindowingGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+
+  // Main filter
+  typedef typename InputImageType::PixelType InputPixelType;
+  typedef itk::Image<float, InputImageType::ImageDimension> OutputImageType;
+  typedef itk::Image<unsigned char, InputImageType::ImageDimension> MaskImageType;
+
+  // Reading input
+  typename OutputImageType::Pointer input = this->template GetInput<OutputImageType>(0);
+
+  typename MaskImageType::Pointer mask = NULL;
+  if(mArgsInfo.mask_given) {
+   mask = this->template GetInput<MaskImageType>(1);
+  }
+  else {
+   mask = MaskImageType::New();
+   mask->SetRegions(input->GetLargestPossibleRegion());
+   mask->SetOrigin(input->GetOrigin());
+   mask->SetSpacing(input->GetSpacing());
+   mask->Allocate();
+   mask->FillBuffer(1);
+  }
+  // Set mask iterator
+  typedef itk::ImageRegionIterator<MaskImageType> IteratorMaskType;
+  IteratorMaskType itm(mask, mask->GetLargestPossibleRegion());
+  //
+  typedef itk::LabelStatisticsImageFilter< OutputImageType, MaskImageType > LabelStatisticsImageFilterType;
+  typename LabelStatisticsImageFilterType::Pointer labelStatisticsImageFilter = LabelStatisticsImageFilterType::New();
+  labelStatisticsImageFilter->SetLabelInput( mask );
+  labelStatisticsImageFilter->SetInput(input);
+  labelStatisticsImageFilter->Update();
+  float maxImg = labelStatisticsImageFilter->GetMaximum(1);
+  //std::cout << "maxImg: " << maxImg << std::endl;
+  // Filter
+  typedef itk::IntensityWindowingImageFilter <OutputImageType, OutputImageType> IntensityWindowingImageFilterType;
+  typename IntensityWindowingImageFilterType::Pointer filter = IntensityWindowingImageFilterType::New();
+  filter->SetInput(input);
+  filter->SetWindowMinimum(0.0);
+  filter->SetWindowMaximum(maxImg);
+  filter->SetOutputMinimum(0.0);
+  filter->SetOutputMaximum(1.0);
+  filter->Update();
+
+  // Set iterator
+  typedef itk::ImageRegionIterator<OutputImageType> IteratorType;
+  IteratorType it(filter->GetOutput(), filter->GetOutput()->GetLargestPossibleRegion());
+  //A little bit strange to do that but I think I need to do it.
+  // Create output image
+  typename OutputImageType::Pointer outputImage = OutputImageType::New();
+  outputImage->SetRegions(filter->GetOutput()->GetLargestPossibleRegion());
+  outputImage->SetOrigin(filter->GetOutput()->GetOrigin());
+  outputImage->SetSpacing(filter->GetOutput()->GetSpacing());
+  outputImage->Allocate();
+  outputImage->FillBuffer(-100.0);
+  // Set output iterator
+  typedef itk::ImageRegionIterator<OutputImageType> IteratorOutputType;
+  IteratorOutputType ito = IteratorOutputType(outputImage, outputImage->GetLargestPossibleRegion());
+
+  it.GoToBegin();
+  ito.GoToBegin();
+  itm.GoToBegin();
+
+  while (!ito.IsAtEnd()) {
+      if(itm.Get() > 0) {
+          ito.Set(it.Get());
+      }
+      ++it;
+      ++ito;
+      ++itm;
+  }
+
+  // Write/Save results
+  this->template SetNextOutput<OutputImageType>(outputImage);
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkImageIntensityWindowingGenericFilter_txx
diff --git a/tools/clitkImageLaplacian.cxx b/tools/clitkImageLaplacian.cxx
new file mode 100644 (file)
index 0000000..9f9901e
--- /dev/null
@@ -0,0 +1,50 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+/* =================================================
+ * @file   clitkImageLaplacianGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief ImageLaplacian an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkImageLaplacian_ggo.h"
+#include "clitkImageLaplacianGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkImageLaplacian, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::ImageLaplacianGenericFilter<args_info_clitkImageLaplacian> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  filter->Update();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkImageLaplacian.ggo b/tools/clitkImageLaplacian.ggo
new file mode 100644 (file)
index 0000000..43b70d1
--- /dev/null
@@ -0,0 +1,15 @@
+#File clitkImageLaplacian.ggo
+package "clitkImageLaplacian"
+version "1.0"
+purpose "Compute the laplacian of the input image"
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "mask"          m       "Mask input image filename"       string        optional
+option "output"        o       "Output image filename"           string        required
+option "normalize"      n       "Normalize the output image between 0 and 1"    flag off
+option "gaussian_filter" g      "Gaussian filtering - default sigma value=1.0"              flag          on
diff --git a/tools/clitkImageLaplacianGenericFilter.h b/tools/clitkImageLaplacianGenericFilter.h
new file mode 100644 (file)
index 0000000..928f3a5
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  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 CLITKImageLaplacianGENERICFILTER_H
+#define CLITKImageLaplacianGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT ImageLaplacianGenericFilter:
+        public ImageToImageGenericFilter<ImageLaplacianGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    ImageLaplacianGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef ImageLaplacianGenericFilter         Self;
+    typedef itk::SmartPointer<Self>            Pointer;
+    typedef itk::SmartPointer<const Self>      ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(ImageLaplacianGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkImageLaplacianGenericFilter.txx"
+#endif
+
+#endif // #define clitkImageLaplacianGenericFilter_h
diff --git a/tools/clitkImageLaplacianGenericFilter.txx b/tools/clitkImageLaplacianGenericFilter.txx
new file mode 100644 (file)
index 0000000..ba36d18
--- /dev/null
@@ -0,0 +1,198 @@
+/*=========================================================================
+  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 clitkImageLaplacianGenericFilter_txx
+#define clitkImageLaplacianGenericFilter_txx
+
+/* =================================================
+ * @file   clitkImageLaplacianGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date   29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// itk include
+#include "itkCastImageFilter.h"
+#include "itkLaplacianImageFilter.h"
+#include "itkLaplacianRecursiveGaussianImageFilter.h"
+#include "itkLabelStatisticsImageFilter.h"
+#include "itkMaskImageFilter.h"
+#include "itkMaskNegatedImageFilter.h"
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+ImageLaplacianGenericFilter<args_info_type>::ImageLaplacianGenericFilter():
+  ImageToImageGenericFilter<Self>("ImageLaplacian")
+{
+  InitializeImageType<2>();
+  InitializeImageType<3>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void ImageLaplacianGenericFilter<args_info_type>::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void ImageLaplacianGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+  mArgsInfo=a;
+  this->SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+  if (mArgsInfo.input_given) {
+    this->SetInputFilename(mArgsInfo.input_arg);
+  }
+  if (mArgsInfo.output_given) {
+    this->SetOutputFilename(mArgsInfo.output_arg);
+  }
+  if (mArgsInfo.mask_given) {
+    this->AddInputFilename(mArgsInfo.mask_arg);
+  }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+ImageLaplacianGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+    // Main filter
+    typedef typename InputImageType::PixelType InputPixelType;
+    typedef itk::Image<float, InputImageType::ImageDimension> FloatImageType;
+    typedef itk::Image<unsigned char, FloatImageType::ImageDimension> MaskImageType;
+
+    // Reading input
+    typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+    //Cast input to float
+    typedef itk::CastImageFilter< InputImageType, FloatImageType > CastFilterType;
+    typename CastFilterType::Pointer castFilter = CastFilterType::New();
+    castFilter->SetInput(input);
+    castFilter->Update();
+
+    typename MaskImageType::Pointer mask = NULL;
+    if(mArgsInfo.mask_given) {
+        mask = this->template GetInput<MaskImageType>(1);
+    }
+    else {
+        mask = MaskImageType::New();
+        mask->SetRegions(input->GetLargestPossibleRegion());
+        mask->SetOrigin(input->GetOrigin());
+        mask->SetSpacing(input->GetSpacing());
+        mask->Allocate();
+        mask->FillBuffer(1);
+    }
+
+
+    // Create output image
+    typename FloatImageType::Pointer outputImage = FloatImageType::New();
+    outputImage->SetRegions(input->GetLargestPossibleRegion());
+    outputImage->SetOrigin(input->GetOrigin());
+    outputImage->SetSpacing(input->GetSpacing());
+    outputImage->Allocate();
+    outputImage->FillBuffer(0.0);
+    // Set output iterator
+    typedef itk::ImageRegionIterator<FloatImageType> IteratorOutputType;
+    IteratorOutputType ito = IteratorOutputType(outputImage, outputImage->GetLargestPossibleRegion());
+
+    // Filter
+    typename FloatImageType::Pointer outputLaplacianFilter;
+    if (mArgsInfo.gaussian_filter_flag == 0) {
+        //std::cout<<"gaussian filter flag == 0"<<std::endl;
+        typedef itk::LaplacianImageFilter<FloatImageType, FloatImageType> LaplacianImageFilterType;
+        typename LaplacianImageFilterType::Pointer laplacianFilter=LaplacianImageFilterType::New();
+        laplacianFilter->SetInput(castFilter->GetOutput());
+        laplacianFilter->Update();
+        outputLaplacianFilter = laplacianFilter->GetOutput();
+    }
+    else {
+        //std::cout<<"gaussian filter flag == 1"<<std::endl;
+        typedef itk::LaplacianRecursiveGaussianImageFilter< FloatImageType, FloatImageType >  LaplacianImageFilterType;
+        typename LaplacianImageFilterType::Pointer laplacianFilter=LaplacianImageFilterType::New();
+        laplacianFilter->SetInput(castFilter->GetOutput());
+        laplacianFilter->Update();
+        //std::cout<<"sigma value="<<laplacianFilter->GetSigma()<<std::endl;
+        outputLaplacianFilter = laplacianFilter->GetOutput();
+    }
+    // Set iterator
+    typedef itk::ImageRegionIterator<FloatImageType> IteratorType;
+    IteratorType it(outputLaplacianFilter, outputLaplacianFilter->GetLargestPossibleRegion());
+
+    // Set mask iterator
+    typedef itk::ImageRegionIterator<MaskImageType> IteratorMaskType;
+    IteratorMaskType itm(mask, mask->GetLargestPossibleRegion());
+
+    //typedef itk::MinimumMaximumImageCalculator <OutputImageType> ImageCalculatorFilterType;
+    //typename ImageCalculatorFilterType::Pointer imageCalculatorFilter = ImageCalculatorFilterType::New();
+    //imageCalculatorFilter->SetImage(gradientFilter->GetOutput());
+    //imageCalculatorFilter->Compute();
+    typedef itk::LabelStatisticsImageFilter< FloatImageType, MaskImageType > LabelStatisticsImageFilterType;
+    typename LabelStatisticsImageFilterType::Pointer labelStatisticsImageFilter = LabelStatisticsImageFilterType::New();
+    labelStatisticsImageFilter->SetLabelInput( mask );
+    labelStatisticsImageFilter->SetInput(outputLaplacianFilter);
+    labelStatisticsImageFilter->Update();
+
+    //std::cout << "Number of labels: " << labelStatisticsImageFilter->GetNumberOfLabels() << std::endl;
+
+    float minImg = labelStatisticsImageFilter->GetMinimum(1);
+    //std::cout << "minImg: " << minImg << std::endl;
+    float maxImg = labelStatisticsImageFilter->GetMaximum(1);
+    //std::cout << "maxImg: " << maxImg << std::endl;
+
+    it.GoToBegin();
+    ito.GoToBegin();
+    itm.GoToBegin();
+
+    while (!ito.IsAtEnd()) {
+        if(mArgsInfo.normalize_flag && itm.Get() == 1) {
+            ito.Set(((float) it.Get() - minImg)/(maxImg-minImg));
+        }
+        if (mArgsInfo.normalize_flag == 0 && itm.Get() == 1) {
+            ito.Set((float) it.Get());
+        }
+        ++it;
+        ++ito;
+        ++itm;
+    }
+
+    //typename OutputImageType::Pointer outputImage = gradientFilter->GetOutput();
+    this->template SetNextOutput<FloatImageType>(outputImage);
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkImageLaplacianGenericFilter_txx
index bc7998bf2be05d2ce65a84d23444f4e9c65e4327..7e28e42c6a0f73c280cafcfc21f9ff9afc449298 100644 (file)
@@ -12,6 +12,7 @@ option "channel"    c "Image channel to be used in statistics (-1 to process all
 option "mask"          m       "Mask image filename (uchar)"             string        no
 option "label"         l       "Label(s) in the mask image to consider"        int     no      multiple        default="1"
 option "histogram"     -       "Compute histogram, allows median calculation"  string  no
+option "dvhistogram" - "Compute dose volume histogram" string  no
 option "bins"          -       "Number of histogram bins"                      int     no      default="100"
 option "lower"         -       "Lower histogram bound" double  no default="-1000"      
 option "upper"         -       "Upper histogram bound" double  no default="1000"               
index 931e1bfe7c12b8002cc2e18eeb5ba5181fb044e8..3d9bea5041106e5d2e6afdd40f5636fcdb29757e 100644 (file)
@@ -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
@@ -33,7 +33,7 @@ namespace clitk
     m_InputFileName="";
   }
   //-----------------------------------------------------------
-  
+
 
   //-----------------------------------------------------------
   // Update
@@ -44,12 +44,12 @@ namespace clitk
     int Dimension, Components;
     std::string PixelType;
     ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-    
+
     if (m_ArgsInfo.channel_arg < -1 || m_ArgsInfo.channel_arg >= Components) {
       std::cout << "Invalid image channel" << std::endl;
       return;
     }
-    
+
     if (m_ArgsInfo.mask_given) {
       int maskDimension, maskComponents;
       std::string maskPixelType;
@@ -60,17 +60,17 @@ namespace clitk
       }
     }
 
-    
+
     // Call UpdateWithDim
     if (Dimension==2) {
       switch (Components) {
-        case 1: 
+        case 1:
           UpdateWithDim<2,1>(PixelType);
           break;
-        case 2: 
+        case 2:
           UpdateWithDim<2,2>(PixelType);
           break;
-        case 3: 
+        case 3:
           UpdateWithDim<2,3>(PixelType);
           break;
         default:
@@ -80,13 +80,13 @@ namespace clitk
     }
     else if (Dimension==3) {
       switch (Components) {
-        case 1: 
+        case 1:
           UpdateWithDim<3,1>(PixelType);
           break;
-        case 2: 
+        case 2:
           UpdateWithDim<3,2>(PixelType);
           break;
-        case 3: 
+        case 3:
           UpdateWithDim<3,3>(PixelType);
           break;
         default:
@@ -96,13 +96,13 @@ namespace clitk
     }
     else if (Dimension==4) {
       switch (Components) {
-        case 1: 
+        case 1:
           UpdateWithDim<4,1>(PixelType);
           break;
-        case 2: 
+        case 2:
           UpdateWithDim<4,2>(PixelType);
           break;
-        case 3: 
+        case 3:
           UpdateWithDim<4,3>(PixelType);
           break;
         default:
index f5c82356dff35c50bd2a3c841d9dc07ae820bdea..b3eff93ce1082304554c03f1a71589a41d2fa059 100644 (file)
@@ -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
@@ -32,28 +32,28 @@ namespace clitk
   // Update with the number of dimensions
   //-------------------------------------------------------------------
   template<unsigned int Dimension, unsigned int Components>
-  void 
+  void
   ImageStatisticsGenericFilter::UpdateWithDim(std::string PixelType)
   {
     if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<" with " << Components << " channel(s)..."<<std::endl;
 
-    if(PixelType == "short"){  
+    if(PixelType == "short"){
       if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
-      UpdateWithDimAndPixelType<Dimension, signed short, Components>(); 
+      UpdateWithDimAndPixelType<Dimension, signed short, Components>();
     }
-    else if(PixelType == "unsigned_short"){  
+    else if(PixelType == "unsigned_short"){
       if (m_Verbose) std::cout  << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
-      UpdateWithDimAndPixelType<Dimension, unsigned short, Components>(); 
+      UpdateWithDimAndPixelType<Dimension, unsigned short, Components>();
     }
-    
-    else if (PixelType == "unsigned_char"){ 
+
+    else if (PixelType == "unsigned_char"){
       if (m_Verbose) std::cout  << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
       UpdateWithDimAndPixelType<Dimension, unsigned char, Components>();
     }
-        
-    else if(PixelType == "double"){  
+
+    else if(PixelType == "double"){
       if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and double..." << std::endl;
-      UpdateWithDimAndPixelType<Dimension, double, Components>(); 
+      UpdateWithDimAndPixelType<Dimension, double, Components>();
     }
     else {
       if (m_Verbose) std::cout  << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
@@ -65,8 +65,8 @@ namespace clitk
   //-------------------------------------------------------------------
   // Update with the number of dimensions and the pixeltype
   //-------------------------------------------------------------------
-  template <unsigned int Dimension, class  PixelType, unsigned int Components> 
-  void 
+  template <unsigned int Dimension, class  PixelType, unsigned int Components>
+  void
   ImageStatisticsGenericFilter::UpdateWithDimAndPixelType()
   {
 
@@ -74,20 +74,20 @@ namespace clitk
     typedef unsigned char LabelPixelType;
     typedef itk::Image<itk::Vector<PixelType, Components>, Dimension> InputImageType;
     typedef itk::Image<LabelPixelType, Dimension> LabelImageType;
-    
+
     // Read the input
     typedef itk::ImageFileReader<InputImageType> InputReaderType;
     typename InputReaderType::Pointer reader = InputReaderType::New();
     reader->SetFileName( m_InputFileName);
     reader->Update();
     typename InputImageType::Pointer input= reader->GetOutput();
-    
+
     typedef itk::NthElementImageAdaptor<InputImageType, PixelType> InputImageAdaptorType;
     typedef itk::Image<PixelType, Dimension> OutputImageType;
 
     typename InputImageAdaptorType::Pointer input_adaptor = InputImageAdaptorType::New();
     input_adaptor->SetImage(input);
-    
+
     // Filter
     typedef itk::LabelStatisticsImageFilter<InputImageAdaptorType, LabelImageType> StatisticsImageFilterType;
     typename StatisticsImageFilterType::Pointer statisticsFilter=StatisticsImageFilterType::New();
@@ -104,13 +104,13 @@ namespace clitk
         // Due to a limitation of filter itk::LabelStatisticsImageFilter, InputImageType and LabelImageType
         // must have the same image dimension. However, we want to support label images with Dl = Di - 1,
         // so we need to replicate the label image as many times as the size along dimension Di.
-        if (m_Verbose) 
+        if (m_Verbose)
           std::cout << "Replicating label image to match input image's dimension... " << std::endl;
-        
+
         typedef itk::Image<LabelPixelType, Dimension - 1> ReducedLabelImageType;
         typedef itk::ImageFileReader<ReducedLabelImageType> LabelImageReaderType;
         typedef itk::JoinSeriesImageFilter<ReducedLabelImageType, LabelImageType> JoinImageFilterType;
-        
+
         typename LabelImageReaderType::Pointer labelImageReader=LabelImageReaderType::New();
         labelImageReader->SetFileName(m_ArgsInfo.mask_arg);
         labelImageReader->Update();
@@ -119,7 +119,7 @@ namespace clitk
         typename InputImageType::SizeType size = input->GetLargestPossibleRegion().GetSize();
         for (unsigned int i = 0; i < size[Dimension - 1]; i++)
           joinFilter->PushBackInput(labelImageReader->GetOutput());
-        
+
         joinFilter->Update();
         labelImage = joinFilter->GetOutput();
       }
@@ -140,22 +140,23 @@ namespace clitk
             typename ResamplerType::Pointer resampler = ResamplerType::New();
             resampler->SetInput(labelImage);
             resampler->SetOutputSpacing(input->GetSpacing());
+            resampler->SetOutputOrigin(labelImage->GetOrigin());
             resampler->SetGaussianFilteringEnabled(false);
             resampler->Update();
             labelImage = resampler->GetOutput();
             //writeImage<LabelImageType>(labelImage, "test1.mha");
-            
+
             typedef clitk::CropLikeImageFilter<LabelImageType> FilterType;
             typename FilterType::Pointer crop = FilterType::New();
             crop->SetInput(labelImage);
             crop->SetCropLikeImage(input);
             crop->Update();
-            labelImage = crop->GetOutput();                        
+            labelImage = crop->GetOutput();
             //writeImage<LabelImageType>(labelImage, "test2.mha");
 
           }
           else {
-            std::cerr << "Mask image has a different size/spacing than input. Abort" << std::endl;
+            std::cerr << "Mask image has a different size/spacing than input. Abort. (Use option to resize)" << std::endl;
             exit(-1);
           }
         }
@@ -163,16 +164,27 @@ namespace clitk
       }
 
     }
-    else { 
+    else {
       labelImage=LabelImageType::New();
+      labelImage->SetDirection(input->GetDirection());
       labelImage->SetRegions(input->GetLargestPossibleRegion());
       labelImage->SetOrigin(input->GetOrigin());
       labelImage->SetSpacing(input->GetSpacing());
+      labelImage->SetDirection(input->GetDirection());
       labelImage->Allocate();
       labelImage->FillBuffer(m_ArgsInfo.label_arg[0]);
     }
     statisticsFilter->SetLabelInput(labelImage);
 
+    // Check/compute spacing
+    const typename LabelImageType::SpacingType& spacing = input->GetSpacing();
+    double spacing_cc = (spacing[0]*spacing[1]*spacing[2])/1000;
+    // std::cout<<"Spacing x : " << spacing[0]<<std::endl;
+    // std::cout<<"Spacing y :  " << spacing[1]<<std::endl;
+    // std::cout<<"Spacing z :  " << spacing[2]<<std::endl;
+    // std::cout <<"spacing_cc : " << spacing_cc << std::endl;
+
+
     // For each Label
     typename LabelImageType::PixelType label;
     unsigned int numberOfLabels;
@@ -183,26 +195,26 @@ namespace clitk
 
     unsigned int firstComponent = 0, lastComponent = 0;
     if (m_ArgsInfo.channel_arg == -1) {
-      firstComponent = 0; 
+      firstComponent = 0;
       lastComponent = Components - 1;
     }
     else {
       firstComponent = m_ArgsInfo.channel_arg;
       lastComponent = m_ArgsInfo.channel_arg;
     }
-    
+
     for (unsigned int c=firstComponent; c<=lastComponent; c++) {
       if (m_Verbose) std::cout << std::endl << "Processing channel " << c << std::endl;
-      
+
       input_adaptor->SelectNthElement(c);
       input_adaptor->Update();
-      
+
       for (unsigned int k=0; k< numberOfLabels; k++) {
         label=m_ArgsInfo.label_arg[k];
 
         std::cout<<std::endl;
         if (m_Verbose) std::cout<<"-------------"<<std::endl;
-        if (m_Verbose) std::cout<<"| Label: "<<label<<"  |"<<std::endl;
+        if (m_Verbose) std::cout<<"| Label: "<< (int) label<<"  |"<<std::endl;
         if (m_Verbose) std::cout<<"-------------"<<std::endl;
 
         // Histograms
@@ -210,34 +222,36 @@ namespace clitk
           statisticsFilter->SetUseHistograms(true);
           statisticsFilter->SetHistogramParameters(m_ArgsInfo.bins_arg, m_ArgsInfo.lower_arg, m_ArgsInfo.upper_arg);
         }
+
+        // DVH
+        if(m_ArgsInfo.dvhistogram_given)
+        {
+          statisticsFilter->SetUseHistograms(true);
+          statisticsFilter->SetHistogramParameters(m_ArgsInfo.bins_arg, m_ArgsInfo.lower_arg, m_ArgsInfo.upper_arg);
+        }
+
         statisticsFilter->Update();
 
         // Output
-        if (m_Verbose) std::cout<<"N° of pixels: ";
-          std::cout<<statisticsFilter->GetCount(label)<<std::endl;
-
+       if (m_Verbose) std::cout<<"N° of pixels: ";
+        std::cout<<statisticsFilter->GetCount(label)<<std::endl;
         if (m_Verbose) std::cout<<"Mean: ";
-          std::cout<<statisticsFilter->GetMean(label)<<std::endl;
-
+        std::cout<<statisticsFilter->GetMean(label)<<std::endl;
         if (m_Verbose) std::cout<<"SD: ";
-          std::cout<<statisticsFilter->GetSigma(label)<<std::endl;
-
+        std::cout<<statisticsFilter->GetSigma(label)<<std::endl;
         if (m_Verbose) std::cout<<"Variance: ";
-          std::cout<<statisticsFilter->GetVariance(label)<<std::endl;
-
+        std::cout<<statisticsFilter->GetVariance(label)<<std::endl;
         if (m_Verbose) std::cout<<"Min: ";
-          std::cout<<statisticsFilter->GetMinimum(label)<<std::endl;
-
+        std::cout<<statisticsFilter->GetMinimum(label)<<std::endl;
         if (m_Verbose) std::cout<<"Max: ";
-          std::cout<<statisticsFilter->GetMaximum(label)<<std::endl;
-
+        std::cout<<statisticsFilter->GetMaximum(label)<<std::endl;
         if (m_Verbose) std::cout<<"Sum: ";
-          std::cout<<statisticsFilter->GetSum(label)<<std::endl;
-
+        std::cout<<statisticsFilter->GetSum(label)<<std::endl;
+        if (m_Verbose) std::cout<<"Volume (cc): ";
+        std::cout<<statisticsFilter->GetCount(label)*spacing_cc<<std::endl;
         if (m_Verbose) std::cout<<"Bounding box: ";
-        
         for(unsigned int i =0; i <statisticsFilter->GetBoundingBox(label).size(); i++)
-          std::cout<<statisticsFilter->GetBoundingBox(label)[i]<<" ";
+            std::cout<<statisticsFilter->GetBoundingBox(label)[i]<<" ";
         std::cout<<std::endl;
 
         // Histogram
@@ -261,14 +275,77 @@ namespace clitk
           for( int i =0; i <m_ArgsInfo.bins_arg; i++)
             histogramFile<<histogram->GetBinMin(0,i)<<"\t"<<histogram->GetMeasurement(i,0)<<"\t"<<histogram->GetBinMax(0,i)<<"\t"<<histogram->GetFrequency(i)<<std::endl;
         }
+
+        // DVH
+        if(m_ArgsInfo.dvhistogram_given)
+        {
+            typename StatisticsImageFilterType::HistogramPointer dvhistogram = statisticsFilter->GetHistogram(label);
+            double totalVolumeCC = ((statisticsFilter->GetCount(label))*spacing_cc);
+            double totalVolume = statisticsFilter->GetCount(label);
+
+            // Screen
+            std::cout<<"# Total volume : ";
+            std::cout<<totalVolume<<" [No. of voxels]"<<std::endl;
+            std::cout<<"# Total volume : ";
+            std::cout<<totalVolumeCC<<" [cc]"<<std::endl;
+            std::cout<<"# Dose mean: ";
+            std::cout<<statisticsFilter->GetMean(label)<<" [Gy]"<<std::endl;
+            std::cout<<"# Dose min: ";
+            std::cout<<statisticsFilter->GetMinimum(label)<<" [Gy]"<<std::endl;
+            std::cout<<"# Dose max: ";
+            std::cout<<statisticsFilter->GetMaximum(label)<<" [Gy]"<<std::endl;
+            std::cout<<" "<<std::endl;
+            std::cout<<"#Dose_diff[Gy] Volume_diff[No. of voxels] Volume_diff[%] Volume_diff[cc] Volume_cumul[No. of voxels] Volume_cumul[%] Volume_cumul[cc]"<<std::endl;
+            for( int i =0; i <m_ArgsInfo.bins_arg; i++)
+            {
+              double popCumulativeVolume = 0;
+              for(int j=0; j<i; j++)
+              {
+                 popCumulativeVolume+=(dvhistogram->GetFrequency(j));
+              }
+              double cumulativeVolume = (totalVolume - (popCumulativeVolume + (dvhistogram->GetFrequency(i))));
+              double percentCumulativeVolume =(cumulativeVolume*100)/(statisticsFilter->GetCount(label)) ;
+              double ccCumulativeVolume = (totalVolumeCC -((popCumulativeVolume + (dvhistogram->GetFrequency(i)))*spacing_cc));
+              double percentDiffVolume = dvhistogram->GetFrequency(i)*100/(statisticsFilter->GetCount(label));
+              std::cout<<dvhistogram->GetBinMax(0,i)<<"\t  "<<dvhistogram->GetFrequency(i)<<"\t  "<<percentDiffVolume<<"\t "<<((dvhistogram->GetFrequency(i))*spacing_cc)<<"\t "<<"\t "<<cumulativeVolume<<"\t  "<<percentCumulativeVolume<<"\t  "<<ccCumulativeVolume<<"\t "<<std::endl;
+            }
+
+            // Add to the file
+            std::ofstream dvhistogramFile(m_ArgsInfo.dvhistogram_arg);
+            dvhistogramFile<<"# Total volume : ";
+            dvhistogramFile<<statisticsFilter->GetCount(label)<<" [No. of voxels]"<<std::endl;
+            dvhistogramFile<<"# Total volume : ";
+            dvhistogramFile<<totalVolumeCC<<" [cc]"<<std::endl;
+            dvhistogramFile<<"# Dose mean: ";
+            dvhistogramFile<<statisticsFilter->GetMean(label)<<" [Gy]"<<std::endl;
+            dvhistogramFile<<"# Dose min: ";
+            dvhistogramFile<<statisticsFilter->GetMinimum(label)<<" [Gy]"<<std::endl;
+            dvhistogramFile<<"# Dose max: ";
+            dvhistogramFile<<statisticsFilter->GetMaximum(label)<<" [Gy]"<<std::endl;
+            dvhistogramFile<<"  "<<std::endl;
+            dvhistogramFile<<"#Dose_diff[Gy] Volume_diff[No. of voxels] Volume_diff[%] Volume_diff[cc] Volume_cumul[No. of voxels] Volume_cumul[%] Volume_cumul[cc]"<<std::endl;
+            for( int i =0; i <m_ArgsInfo.bins_arg; i++)
+            {
+               double popCumulativeVolume = 0;
+               for(int j=0; j<i; j++)
+               {
+                 popCumulativeVolume+=(dvhistogram->GetFrequency(j));
+               }
+               double cumulativeVolume = (totalVolume - (popCumulativeVolume + (dvhistogram->GetFrequency(i))));
+               double percentCumulativeVolume =(cumulativeVolume*100)/(statisticsFilter->GetCount(label));
+               double ccCumulativeVolume = (totalVolumeCC -((popCumulativeVolume + (dvhistogram->GetFrequency(i)))*spacing_cc));
+               double percentDiffVolume = ((dvhistogram->GetFrequency(i))*100)/(statisticsFilter->GetCount(label));
+               dvhistogramFile<<dvhistogram->GetBinMax(0,i)<<"\t  "<<dvhistogram->GetFrequency(i)<<"\t  "<<percentDiffVolume<<"\t "<<((dvhistogram->GetFrequency(i))*spacing_cc)<<"\t "<<cumulativeVolume<<"\t "<<percentCumulativeVolume<<"\t  "<<ccCumulativeVolume<<std::endl;
+           }
+        }
       }
     }
 
     return;
 
   }
-  
-  
+
+
 }//end clitk
 
 #endif //#define clitkImageStatisticsGenericFilter_txx
index 8bbeab86ab3bc53853ce0554dc247edaeb44e3c8..f159dc7bf04091d00785cf3b86678a4398d9603e 100644 (file)
  * @brief 
  * 
  ===================================================*/
-#if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
-# include "itkCompose3DVectorImageFilter.h"
-#else
 # include "itkComposeImageFilter.h"
-#endif
 
 namespace clitk
 {
@@ -82,11 +78,7 @@ namespace clitk
     typedef itk::Image<itk::Vector<PixelType,3>, Dimension> OutputImageType;
     
     // Filter
-#if ITK_VERSION_MAJOR < 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR <= 2)
-    typedef itk::Compose3DVectorImageFilter<InputImageType,OutputImageType> ComposeFilterType;
-#else
     typedef itk::ComposeImageFilter<InputImageType,OutputImageType> ComposeFilterType;
-#endif
     typename ComposeFilterType::Pointer composeFilter=ComposeFilterType::New();
 
     // Read the inputs
diff --git a/tools/clitkImageUncertainty.cxx b/tools/clitkImageUncertainty.cxx
new file mode 100644 (file)
index 0000000..a8e76de
--- /dev/null
@@ -0,0 +1,112 @@
+/*=========================================================================
+
+  Program:   clitk
+  Module:    $RCSfile: clitkImageUncertainty.cxx,v $
+  Language:  C++
+  Date:      $Date: 2011/03/03 15:03:30 $
+  Version:   $Revision: 1.3 $
+
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+
+=========================================================================*/
+
+#ifndef CLITKIMAGEUNCERTAINTY_CXX
+#define CLITKIMAGEUNCERTAINTY_CXX
+
+/**
+ =================================================
+ * @file   clitkImageUncertainty.cxx
+ * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
+ * @date   04 Jul 2006 14:03:57
+ *
+ * @brief
+ *
+ *
+ =================================================*/
+
+// clitk include
+#include "clitkImageUncertainty_ggo.h"
+#include "clitkImageCommon.h"
+#include "clitkCommon.h"
+#include "clitkPortability.h"
+
+// itk include
+#include "itkImageRegionConstIterator.h"
+#include "itkImageRegionIterator.h"
+
+//====================================================================
+int main(int argc, char * argv[]) {
+
+  // init command line
+  GGO(clitkImageUncertainty, args_info);
+
+  // Declare main types
+  typedef float                          PixelType;
+  const unsigned int                              Dimension=3;
+  typedef itk::Image< PixelType, Dimension >      ImageType;
+
+  // Read images
+  ImageType::Pointer input =
+    clitk::readImage<ImageType>(args_info.input_arg, args_info.verbose_flag);
+  ImageType::Pointer inputSquared =
+    clitk::readImage<ImageType>(args_info.inputSquared_arg, args_info.verbose_flag);
+
+  // Create Output
+  ImageType::Pointer output = ImageType::New();
+  output->SetRegions(input->GetLargestPossibleRegion());
+  output->CopyInformation(input);
+  output->Allocate();
+
+  // Loop
+  typedef itk::ImageRegionConstIterator<ImageType> ConstIteratorType;
+  ConstIteratorType pi(input, input->GetLargestPossibleRegion());
+  ConstIteratorType pii(inputSquared, inputSquared->GetLargestPossibleRegion());
+  pi.GoToBegin();
+  pii.GoToBegin();
+  typedef itk::ImageRegionIterator<ImageType> IteratorType;
+  IteratorType po(output, output->GetLargestPossibleRegion());
+  po.GoToBegin();
+
+  int NumberOfEvents = args_info.NumberOfEvents_arg;
+  while ( !pi.IsAtEnd() ) {
+    double squared = pii.Get();
+    double mean = pi.Get();
+    double uncert = sqrt((NumberOfEvents*squared - mean*mean) / (NumberOfEvents-1));
+    if(!args_info.absolute_flag)
+      uncert /= std::abs(mean);
+    if (!IsNormal(uncert)) uncert = args_info.default_arg;
+    po.Set(uncert);
+    ++pi;
+    ++pii;
+    ++po;
+  }
+
+  // Write output image
+  // DD(clitk::GetExtension(args_info.output_arg));
+  if (clitk::GetExtension(args_info.output_arg) != "txt") {
+    clitk::writeImage<ImageType>(output, args_info.output_arg, args_info.verbose_flag);
+  }
+  else {
+    std::ofstream os;
+    clitk::openFileForWriting(os, args_info.output_arg);
+    typedef itk::ImageRegionConstIterator<ImageType> IteratorType;
+    IteratorType pi(output, output->GetLargestPossibleRegion());
+    pi.GoToBegin();
+    os << "# Image size = " << output->GetLargestPossibleRegion().GetSize() << std::endl;
+    os << "# Image spacing = " << output->GetSpacing() << std::endl;
+    os << "# Number of events = " << NumberOfEvents << std::endl;
+    while (!pi.IsAtEnd()) {
+      os << pi.Get() << std::endl;
+      ++pi;
+    }
+  }
+}
+
+
+#endif /* end #define CLITKIMAGEUNCERTAINTY_CXX */
diff --git a/tools/clitkImageUncertainty.ggo b/tools/clitkImageUncertainty.ggo
new file mode 100644 (file)
index 0000000..00b105a
--- /dev/null
@@ -0,0 +1,12 @@
+# file clitkImageRescaleIntensity.ggo
+package "clitk"
+version "Compute the uncertainty of simulation outputs using Chetty's history-by-history's method"
+
+option "config"         - "Config file"                      string  no
+option "input"          i "Input image filename"             string  yes
+option "inputSquared"   s "Input squared image filename"     string  yes
+option "output"         o "Output image filename"            string  yes
+option "NumberOfEvents" n "Number of events"                 int     yes
+option "verbose"        v "Verbose"                          flag    off
+option "absolute"       a "Absolute instead of the relative" flag    off
+option "default"        d "Default when input is 0."         double  no   default="1."
index 012524c8fc266d817b9cda408cde4259def6d5d9..7765e561c1736fcdb4141f7128c17b3f996ac8b1 100644 (file)
 
 //itk include
 #include "itkLightObject.h"
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkInverseDisplacementFieldImageFilter.h"
-#else
-  #include "itkInverseDeformationFieldImageFilter.h"
-#endif
+#include "itkInverseDisplacementFieldImageFilter.h"
 
 namespace clitk 
 {
index 812ed0c69db5737b56b0eccc26e68c48dab90f3b..a18a6417c6b0ad26c3efc14225fba5d1c7444153 100644 (file)
@@ -205,11 +205,7 @@ InvertVFGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
 
   case 2: {
     // Create the InverseDeformationFieldFilter
-#if ITK_VERSION_MAJOR >= 4
     typedef itk::InverseDisplacementFieldImageFilter<InputImageType,OutputImageType> FilterType;
-#else
-    typedef itk::InverseDeformationFieldImageFilter<InputImageType,OutputImageType> FilterType;
-#endif
     typename FilterType::Pointer filter =FilterType::New();
     filter->SetInput(input);
     filter->SetOutputOrigin(input->GetOrigin());
index 73e9b64a289653e1d503706ae7cbfcd6592deb43..1ddc301056d73924d3fc139448c39a1a94e01bed 100644 (file)
 
 //itk include
 #include "itkLightObject.h"
-#if ITK_VERSION_MAJOR >= 4
-  #include "itkInverseDisplacementFieldImageFilter.h"
-#else
-  #include "itkInverseDeformationFieldImageFilter.h"
-#endif
+#include "itkInverseDisplacementFieldImageFilter.h"
 
 namespace clitk 
 {
diff --git a/tools/clitkMatrixMultiply.cxx b/tools/clitkMatrixMultiply.cxx
new file mode 100644 (file)
index 0000000..95e1a40
--- /dev/null
@@ -0,0 +1,59 @@
+/*=========================================================================
+  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 "clitkMatrixMultiply_ggo.h"
+#include "clitkTransformUtilities.h"
+#include "clitkIO.h"
+#include "clitkMatrix.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+  // Init command line
+  GGO(clitkMatrixMultiply, args_info);
+  CLITK_INIT;
+
+  // Read matrix
+  itk::Matrix<double, 4, 4> matrix1, matrix2;
+  try {
+    matrix1 = clitk::ReadMatrix3D(args_info.input1_arg);
+    matrix2 = clitk::ReadMatrix3D(args_info.input2_arg);
+  }
+  catch (itk::ExceptionObject & err) {
+    std::cerr << "Error reading "
+              << args_info.input1_arg
+              << " and "
+              << args_info.input2_arg
+              << std::endl;
+    std::cerr << err.GetDescription() << std::endl;
+    exit(-1);
+  }
+
+  itk::Matrix<double, 4, 4> matrix(matrix2.GetVnlMatrix() * matrix1.GetVnlMatrix());
+
+  // Print matrix
+  std::ofstream os;
+  clitk::openFileForWriting(os, args_info.output_arg);
+  os << clitk::Get4x4MatrixDoubleAsString(matrix, 16);
+  os.close();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkMatrixMultiply.ggo b/tools/clitkMatrixMultiply.ggo
new file mode 100644 (file)
index 0000000..5463bdd
--- /dev/null
@@ -0,0 +1,8 @@
+package "clitkMatrixMultiply"
+version "1.0"
+purpose "Multiply two 4x4 matrices. In matrice notations, does input2*input"
+
+option "config"  - "Config file"            string optional
+option "input1"  i "Input matrix filename"  string required
+option "input2"  j "Input matrix filename"  string required
+option "output"  o "Output matrix filename" string required
index 58fac09b3816d5332601851ed2b981cc59670cbb..f6dc478618331b989ee5919f05cf3c93c9712203 100644 (file)
@@ -61,10 +61,11 @@ namespace clitk
   public:
 
     //--------------------------------------------------------------------
-   MedianImageGenericFilter();
+    MedianImageGenericFilter();
 
     //--------------------------------------------------------------------
-    typedef MedianImageGenericFilter         Self;
+    typedef MedianImageGenericFilter           Self;
+    typedef ImageToImageGenericFilter<MedianImageGenericFilter<args_info_type> > Superclass;
     typedef itk::SmartPointer<Self>            Pointer;
     typedef itk::SmartPointer<const Self>      ConstPointer;
    
@@ -81,15 +82,15 @@ namespace clitk
     // Main function called each time the filter is updated
     template<class InputImageType>  
     void UpdateWithInputImageType();
-    
-
 
   protected:
     template<unsigned int Dim> void InitializeImageType();
-    
     args_info_type mArgsInfo;
-    
+
+  private:
+    MedianImageGenericFilter(const Self&); //purposely not implemented
+    void operator=(const Self&); //purposely not implemented
+
   }; // end class
   //--------------------------------------------------------------------
     
index 7e4a426539e6b0ecc9c64973f118e4da2ee9b94d..75567c496b5cb6856043ea16ccbd060d11dccde9 100644 (file)
@@ -89,28 +89,26 @@ MedianImageGenericFilter<args_info_type>::UpdateWithInputImageType()
 
   // typedef itk::Image<PixelType,InputImageType::ImageDimension> OutputImageType;
 
-  // Main filter
-  typedef itk::Image<PixelType, InputImageType::ImageDimension> OutputImageType;
-  typename InputImageType::SizeType indexRadius;
-
   // Filter
-  typedef itk::MedianImageFilter<InputImageType, OutputImageType> MedianImageFilterType;
-  typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
-  thresholdFilter->SetInput(input);
-
-  for (unsigned i = 0; i < InputImageType::ImageDimension; ++i)
-    indexRadius[i]=mArgsInfo.radius_arg[i];
-
-  // indexRadius[0] = 1;
-  // indexRadius[1] = 1;
-
-  thresholdFilter->SetRadius( indexRadius );
-
-  typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
-  thresholdFilter->Update();
+  typedef itk::MedianImageFilter<InputImageType, InputImageType> MedianImageFilterType;
+  typename MedianImageFilterType::Pointer medianFilter=MedianImageFilterType::New();
+  typename MedianImageFilterType::InputSizeType radius;
+  radius.Fill(1);
+  medianFilter->SetInput(input);
+
+  if(mArgsInfo.radius_given) {
+      for (unsigned i = 0; i < InputImageType::ImageDimension; ++i)
+          radius[i]=mArgsInfo.radius_arg[i];
+  }
+  //
+  std::cout<<"radius median filter= "<<radius<<std::endl;
+  //
+  medianFilter->SetRadius( radius );
 
+  medianFilter->Update();
   // Write/Save results
-  this->template SetNextOutput<OutputImageType>(outputImage);
+  typename InputImageType::Pointer outputImage = medianFilter->GetOutput();
+  this->template SetNextOutput<InputImageType>(outputImage);
 }
 
 //--------------------------------------------------------------------
index 4bd0634a763afd5e84cc234a4b0e5613472d6b9a..022ae0bf070cd74255dcdfe7cb02e2adcb07c2f1 100644 (file)
@@ -2,16 +2,17 @@
    =================================================
    * @file   clitkMergeRootFiles.cxx
    * @author David Sarrut <david.sarrut@creatis.insa-lyon.fr>
-   * @date   01 Apr 2009
-   * 
-   * @brief  
-   * 
+   * @author Brent Huisman <brent.huisman@insa-lyon.fr>
+   * @date   06 May 2014
+   *
+   * @brief
+   *
    =================================================*/
 
 #include "clitkMergeRootFiles_ggo.h"
 #include "clitkCommon.h"
 #include "GateMergeManager.hh"
-#include <string> 
+#include <string>
 #include <TROOT.h>
 #include <TPluginManager.h>
 #include <TFile.h>
 #include <TH1.h>
 #include <TH2.h>
 #include <iostream>
+#include <TApplication.h>
 
 using std::endl;
 using std::cout;
 
-struct PetInputFile
-{
-       string filename;
-       double mean_time;
+struct PetInputFile {
+    string filename;
+    double mean_time;
 };
 
-bool sort_pet_input_file(const PetInputFile& a, const PetInputFile& b)
-{
-       return a.mean_time<b.mean_time;
+bool sort_pet_input_file(const PetInputFile &a, const PetInputFile &b) {
+    return a.mean_time < b.mean_time;
 };
 
 typedef std::vector<PetInputFile> PetInputFiles;
 
 //-----------------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
-  gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*",
-      "TStreamerInfo", "RIO", "TStreamerInfo()");
-
-  // init command line
-  GGO(clitkMergeRootFiles, args_info);
-
-  // Check parameters
-  if (args_info.input_given < 2) {
-    FATAL("Error, please provide at least two inputs files");
-  }
-
-  { // Detect Pet output
-         bool all_pet_output = true;
-         PetInputFiles pet_input_files;
-         for (uint i=0; i<args_info.input_given; i++) 
-         {
-                 const char* filename = args_info.input_arg[i];
-                 PetInputFile input_file;
-                 input_file.filename = filename;
-                 TFile* handle = TFile::Open(filename,"READ");
-                 assert(handle);
-                 TTree* hits = dynamic_cast<TTree*>(handle->Get("Hits"));
-                 TTree* singles = dynamic_cast<TTree*>(handle->Get("Singles"));
-                 const bool is_pet_output = (hits!=NULL) && (singles!=NULL);
-                 cout << "testing " << filename << " is_pet_output " << is_pet_output;
-
-                 if (is_pet_output)
-                 {
-                         double time;
-                         double time_accum = 0;
-                         singles->SetBranchAddress("time",&time);
-                         size_t total = singles->GetEntries();
-                         for (size_t kk=0; kk<total; kk++)
-                         {
-                                 singles->GetEntry(kk);
-                                 time_accum += time;
-                         }
-                                 
-                         input_file.mean_time = time_accum/total;
-                         pet_input_files.push_back(input_file);
-                         cout << " mean_time " << input_file.mean_time;
-                 }
-
-                 cout << endl;
-
-                 handle->Close();
-                 delete handle;
-                 all_pet_output &= is_pet_output;
-         }
-         cout << "all_pet_output " << all_pet_output << endl;
-
-         if (all_pet_output)
-         {
-                 GateMergeManager manager(args_info.fastmerge_given,args_info.verbose_arg,true,0,"");
-
-                 cout << "sorting input file using singles time" << endl;
-                 std::sort(pet_input_files.begin(),pet_input_files.end(),sort_pet_input_file);
-
-                 Strings input_filenames;
-                 for (PetInputFiles::const_iterator iter=pet_input_files.begin(); iter!=pet_input_files.end(); iter++)
-                         input_filenames.push_back(iter->filename);
-
-                 manager.StartMergingFromFilenames(input_filenames,args_info.output_arg);
-                 return 0;
-         }
-  }
-
-
-  // Merge
-  TFileMerger * merger = new TFileMerger;
-  for (uint i=0; i<args_info.input_given; i++) merger->AddFile(args_info.input_arg[i]);
-  merger->OutputFile(args_info.output_arg);
-  merger->Merge();
-
-  // this is the end my friend  
-  return 0;
+int main(int argc, char *argv[]) {
+       //this fixes a bug in TFileMerger. See http://root.cern.ch/phpBB3/viewtopic.php?t=18016.
+    TApplication app("app", 0, 0);
+
+    gROOT->GetPluginManager()->AddHandler("TVirtualStreamerInfo", "*",
+                                          "TStreamerInfo", "RIO", "TStreamerInfo()");
+
+    // init command line
+    GGO(clitkMergeRootFiles, args_info);
+
+    // Check parameters
+    if (args_info.input_given < 2) {
+        FATAL("Error, please provide at least two inputs files");
+    }
+
+    /* The following block does some bookkeeping necesary for files originating from a pet simulation.
+    Seems fixing some timing info, for coincidences between files perhaps.
+    It seems the files are later on reopened and merged, if the conditions were met.
+    It's not required for merging other .root files.
+    GateMergeManager reportedly exists specifically for the purpose of merging pet simulations. */
+    {
+        // Detect Pet output
+        bool all_pet_output = true;
+        PetInputFiles pet_input_files;
+        for (uint i = 0; i < args_info.input_given; i++) {
+            const char *filename = args_info.input_arg[i];
+            PetInputFile input_file;
+            input_file.filename = filename;
+            TFile *handle = TFile::Open(filename, "READ");
+            assert(handle);
+            TTree *hits = dynamic_cast<TTree *>(handle->Get("Hits"));
+            TTree *singles = dynamic_cast<TTree *>(handle->Get("Singles"));
+            const bool is_pet_output = (hits != NULL) && (singles != NULL);
+            cout << "testing " << filename << " is_pet_output " << is_pet_output;
+
+               //TTree *histos = dynamic_cast<TH1F *>(handle->Get("histo;1"));
+               //const bool is_hist_output = (histos != NULL);
+
+
+            if (is_pet_output) {
+                double time;
+                double time_accum = 0;
+                singles->SetBranchAddress("time", &time);
+                size_t total = singles->GetEntries();
+                for (size_t kk = 0; kk < total; kk++) {
+                    singles->GetEntry(kk);
+                    time_accum += time;
+                }
+
+                input_file.mean_time = time_accum / total;
+                pet_input_files.push_back(input_file);
+                cout << " mean_time " << input_file.mean_time;
+            }
+
+            cout << endl;
+
+            handle->Close();
+            delete handle;
+            //bitwise on booleans?
+            all_pet_output &= is_pet_output;
+        }
+        cout << "all_pet_output " << all_pet_output << endl;
+
+        if (all_pet_output) {
+            GateMergeManager manager(args_info.fastmerge_given, args_info.verbose_arg, true, 0, "");
+
+            cout << "sorting input file using singles time" << endl;
+            std::sort(pet_input_files.begin(), pet_input_files.end(), sort_pet_input_file);
+
+            Strings input_filenames;
+            for (PetInputFiles::const_iterator iter = pet_input_files.begin(); iter != pet_input_files.end(); iter++)
+                input_filenames.push_back(iter->filename);
+
+            manager.StartMergingFromFilenames(input_filenames, args_info.output_arg);
+            //if the file was PET, then we're done.
+            return 0;
+        }
+    }
+
+    //if the file was not PET, but a generic Rootfile, use TFileMerger.
+
+    // Merge
+    TFileMerger *merger = new TFileMerger;
+    for (uint i = 0; i < args_info.input_given; i++) merger->AddFile(args_info.input_arg[i]);
+    merger->OutputFile(args_info.output_arg);
+    bool whatbool = merger->Merge();
+
+    cout << "whatbool: " << whatbool << " no more whatbool" << endl;
+    // this is the end my friend
+    return 0;
+    
 }
 //-----------------------------------------------------------------------------
diff --git a/tools/clitkNormalizeImageFilter.cxx b/tools/clitkNormalizeImageFilter.cxx
new file mode 100644 (file)
index 0000000..071aa4d
--- /dev/null
@@ -0,0 +1,50 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+/* =================================================
+ * @file   clitkNormalizeImageFilterGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief NormalizeImageFilter an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkNormalizeImageFilter_ggo.h"
+#include "clitkNormalizeImageFilterGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkNormalizeImageFilter, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::NormalizeImageFilterGenericFilter<args_info_clitkNormalizeImageFilter> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  filter->Update();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkNormalizeImageFilter.ggo b/tools/clitkNormalizeImageFilter.ggo
new file mode 100644 (file)
index 0000000..b67e3b8
--- /dev/null
@@ -0,0 +1,13 @@
+#File clitkNormalizeImageFilter.ggo
+package "clitkNormalizeImageFilter"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "output"        o       "Output image filename"           string        required
+option "mask"          m       "Mask input image filename"       string        optional
diff --git a/tools/clitkNormalizeImageFilterGenericFilter.h b/tools/clitkNormalizeImageFilterGenericFilter.h
new file mode 100644 (file)
index 0000000..85f28e4
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  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 CLITKNormalizeImageFilterGENERICFILTER_H
+#define CLITKNormalizeImageFilterGENERICFILTER_H
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT NormalizeImageFilterGenericFilter:
+        public ImageToImageGenericFilter<NormalizeImageFilterGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    NormalizeImageFilterGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef NormalizeImageFilterGenericFilter         Self;
+    typedef itk::SmartPointer<Self>                   Pointer;
+    typedef itk::SmartPointer<const Self>             ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(NormalizeImageFilterGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkNormalizeImageFilterGenericFilter.txx"
+#endif
+
+#endif // #define clitkNormalizeImageFilterGenericFilter_h
diff --git a/tools/clitkNormalizeImageFilterGenericFilter.txx b/tools/clitkNormalizeImageFilterGenericFilter.txx
new file mode 100644 (file)
index 0000000..99a43a4
--- /dev/null
@@ -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 clitkNormalizeImageFilterGenericFilter_txx
+#define clitkNormalizeImageFilterGenericFilter_txx
+
+/* =================================================
+ * @file   clitkNormalizeImageFilterGenericFilter.txx
+ * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
+ * @date   29 june 2009
+ *
+ * @brief
+ *
+ ===================================================*/
+
+// itk include
+#include "itkLabelStatisticsImageFilter.h"
+#include "itkMaskImageFilter.h"
+#include "itkMaskNegatedImageFilter.h"
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    NormalizeImageFilterGenericFilter<args_info_type>::NormalizeImageFilterGenericFilter():
+        ImageToImageGenericFilter<Self>("NormalizeImageFilter")
+    {
+        InitializeImageType<2>();
+        InitializeImageType<3>();
+    }
+    //--------------------------------------------------------------------
+
+
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    template<unsigned int Dim>
+    void NormalizeImageFilterGenericFilter<args_info_type>::InitializeImageType()
+    {
+        ADD_DEFAULT_IMAGE_TYPES(Dim);
+    }
+    //--------------------------------------------------------------------
+
+
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    void NormalizeImageFilterGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+    {
+        mArgsInfo=a;
+        this->SetIOVerbose(mArgsInfo.verbose_flag);
+        if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+        if (mArgsInfo.input_given) {
+            this->SetInputFilename(mArgsInfo.input_arg);
+        }
+        if (mArgsInfo.output_given) {
+            this->SetOutputFilename(mArgsInfo.output_arg);
+        }
+        if (mArgsInfo.mask_given) {
+            this->AddInputFilename(mArgsInfo.mask_arg);
+        }
+    }
+    //--------------------------------------------------------------------
+
+    //--------------------------------------------------------------------
+    // Update with the number of dimensions and the pixeltype
+    //--------------------------------------------------------------------
+    template<class args_info_type>
+    template<class InputImageType>
+    void
+    NormalizeImageFilterGenericFilter<args_info_type>::UpdateWithInputImageType()
+    {
+
+        // Main filter
+        typedef typename InputImageType::PixelType InputPixelType;
+        typedef itk::Image<float, InputImageType::ImageDimension> OutputImageType;
+        typedef itk::Image<unsigned char, OutputImageType::ImageDimension> MaskImageType;
+
+        // Reading input
+        typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+        typename MaskImageType::Pointer mask = NULL;
+        if(mArgsInfo.mask_given) {
+            mask = this->template GetInput<MaskImageType>(1);
+        }
+        else {
+            mask = MaskImageType::New();
+            mask->SetRegions(input->GetLargestPossibleRegion());
+            mask->SetOrigin(input->GetOrigin());
+            mask->SetSpacing(input->GetSpacing());
+            mask->Allocate();
+            mask->FillBuffer(1);
+        }
+
+        // Create output image
+        typename OutputImageType::Pointer outputImage = OutputImageType::New();
+        outputImage->SetRegions(input->GetLargestPossibleRegion());
+        outputImage->SetOrigin(input->GetOrigin());
+        outputImage->SetSpacing(input->GetSpacing());
+        outputImage->Allocate();
+        outputImage->FillBuffer(0.0);
+        // Set output iterator
+        typedef itk::ImageRegionIterator<OutputImageType> IteratorOutputType;
+        IteratorOutputType ito = IteratorOutputType(outputImage, outputImage->GetLargestPossibleRegion());
+
+        // Filter
+        // Set iterator
+        typedef itk::ImageRegionIterator<InputImageType> IteratorType;
+        IteratorType it(input, input->GetLargestPossibleRegion());
+
+        // Set mask iterator
+        typedef itk::ImageRegionIterator<MaskImageType> IteratorMaskType;
+        IteratorMaskType itm(mask, mask->GetLargestPossibleRegion());
+
+        typedef itk::LabelStatisticsImageFilter< InputImageType, MaskImageType > LabelStatisticsImageFilterType;
+        typename LabelStatisticsImageFilterType::Pointer labelStatisticsImageFilter = LabelStatisticsImageFilterType::New();
+        labelStatisticsImageFilter->SetLabelInput( mask );
+        labelStatisticsImageFilter->SetInput(input);
+        labelStatisticsImageFilter->Update();
+
+        //std::cout << "Number of labels: " << labelStatisticsImageFilter->GetNumberOfLabels() << std::endl;
+
+        float minImg = labelStatisticsImageFilter->GetMinimum(1);
+        //std::cout << "minImg= " << minImg << std::endl;
+        float maxImg = labelStatisticsImageFilter->GetMaximum(1);
+        //std::cout << "maxImg= " << maxImg << std::endl;
+
+        it.GoToBegin();
+        ito.GoToBegin();
+        itm.GoToBegin();
+
+        while (!ito.IsAtEnd()) {
+            if(itm.Get() == 1) {
+                ito.Set(((float) it.Get() - minImg)/(maxImg-minImg));
+            }
+            ++it;
+            ++ito;
+            ++itm;
+        }
+        //
+        //
+        // Write/Save results
+        this->template SetNextOutput<OutputImageType>(outputImage);
+    }
+    //--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkNormalizeImageFilterGenericFilter_txx
index 49d4075997b87e278216d2546a19e2faa393311d..8477a35d8c085574e7829a2b7dd1e2dfc8af2280 100644 (file)
@@ -155,7 +155,7 @@ namespace clitk
     SpacingType spacing = input->GetSpacing(), like_spacing = like_image->GetSpacing(); 
     if (spacing != like_spacing) {
       std::cerr << "Like-image must have same spacing as input: " << spacing << " " << like_spacing << std::endl;
-      return ERR_NOT_SAME_SPACING;
+      return PAD_ERR_NOT_SAME_SPACING;
     }
     
     SizeType size = input->GetLargestPossibleRegion().GetSize(), like_size = like_image->GetLargestPossibleRegion().GetSize();
@@ -175,7 +175,7 @@ namespace clitk
 
       if (auxl < 0 || auxu < 0) {
         std::cerr << "Like-image's bounding box must be larger than input's" << std::endl;
-        return ERR_NOT_LIKE_LARGER;
+        return PAD_ERR_NOT_LIKE_LARGER;
       }
 
       padLower[i] = (PadBoundType)auxl;
@@ -184,7 +184,7 @@ namespace clitk
     
     if (mArgsInfo.verbose_flag)
       std::cout << "PadLike - OUT" << std::endl;
-    return ERR_SUCCESS;
+    return PAD_ERR_SUCCESS;
   }
 } //end clitk
 
index 3aa9318057fa8ca850c2a29169dd058778f9807b..429d203d6588909abc7130d87ebf4e4b609a1679 100644 (file)
@@ -24,7 +24,6 @@
 #include "clitkImageToImageGenericFilter.h"
 #include "clitkPadImage_ggo.h"
 
-
 //--------------------------------------------------------------------
 namespace clitk
 {
@@ -35,9 +34,9 @@ namespace clitk
   public:
     enum
     {
-      ERR_SUCCESS = 0,
-      ERR_NOT_SAME_SPACING = -1,
-      ERR_NOT_LIKE_LARGER = -2
+      PAD_ERR_SUCCESS = 0,
+      PAD_ERR_NOT_SAME_SPACING = -1,
+      PAD_ERR_NOT_LIKE_LARGER = -2
     };
 
     //--------------------------------------------------------------------
diff --git a/tools/clitkPointRigidRegistration.cxx b/tools/clitkPointRigidRegistration.cxx
new file mode 100644 (file)
index 0000000..065b7d9
--- /dev/null
@@ -0,0 +1,503 @@
+/*=========================================================================
+  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
+===========================================================================**/
+
+/* =================================================
+ * @file   clitkPointRigidRegistrationGenericFilter.txx
+ * @author xxx <xxx@creatis.insa-lyon.fr>
+ * @date   29 June 2029
+ *
+ * @brief PointRigidRegistration an image
+ *
+ ===================================================*/
+
+// clitk
+#include "clitkPointRigidRegistration_ggo.h"
+
+
+//paste from RigidRegistration
+#include "itkImageFileReader.h"
+#include "itkImageFileWriter.h"
+#include "itkImage.h"
+#include "itkVector.h"
+#include "itkResampleImageFilter.h"
+#include "itkLandmarkBasedTransformInitializer.h"
+#include "itkRigid2DTransform.h"
+#include "itkVersorRigid3DTransform.h"
+#include <iostream>
+
+
+#include "itkMatrix.h"
+#include "itkArray.h"
+//#include "itkPoint.h"
+#include "clitkImageCommon.h"
+#include "clitkCommon.h"
+//#define VTK_EXCLUDE_STRSTREAM_HEADERS
+#include <vtkMatrix4x4.h>
+#include <vtkSmartPointer.h>
+
+//for open file for reading
+#include "clitkIO.h"
+#include "clitkImageCommon.h"
+#include "clitkCommon.h"
+
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkPointRigidRegistration, args_info);
+  CLITK_INIT;
+
+
+
+
+  // Iinit itk
+  // read input file
+  //open stream to reading
+  std::ifstream is;
+  clitk::openFileForReading(is, args_info.input_arg);
+
+
+
+  //reading first line of input file to chck thw dimension of data
+  double x = 0;
+  //clitk::skipComment(is);
+  is >> x;
+
+    typedef   unsigned char  PixelType;
+
+
+
+
+
+    unsigned int Dimension_temp = (unsigned int)x;
+
+
+
+        if (Dimension_temp==2)
+        {
+            const     unsigned int   Dimension = 2;
+            typedef   itk::Image< PixelType, Dimension > ImageType;
+            typedef   float          VectorComponentType;
+            typedef   itk::Vector< VectorComponentType, Dimension >    VectorType;
+            //Typ LandmarkBasedTransormInitializer
+            typedef itk::Rigid2DTransform< double > Rigid2DTransformType;
+            typedef itk::LandmarkBasedTransformInitializer< Rigid2DTransformType,ImageType, ImageType>
+                LandmarkBasedTransformInitializerType;
+
+            LandmarkBasedTransformInitializerType::Pointer landmarkBasedTransformInitializer = LandmarkBasedTransformInitializerType::New();
+
+            //  Create source and target landmarks.
+            typedef LandmarkBasedTransformInitializerType::LandmarkPointContainer     LandmarkContainerType;
+            typedef LandmarkBasedTransformInitializerType::LandmarkPointType          LandmarkPointType;
+
+            LandmarkContainerType imageLandmarks;
+            LandmarkContainerType trackerLandmarks;
+
+            LandmarkPointType imagePoint;
+            LandmarkPointType trackerPoint;
+
+            is >> x;
+
+
+            while (is && !is.eof()) {
+                imagePoint[0] = x;
+                is >> imagePoint[1];
+
+
+                is >> trackerPoint[0];
+                is >> trackerPoint[1];
+
+                imageLandmarks.push_back(imagePoint );
+                trackerLandmarks.push_back(trackerPoint );
+
+
+              is >> x;
+            }
+
+            is.close();
+
+            landmarkBasedTransformInitializer->SetFixedLandmarks( imageLandmarks);
+            landmarkBasedTransformInitializer->SetMovingLandmarks( trackerLandmarks);
+
+            Rigid2DTransformType::Pointer transform = Rigid2DTransformType::New();
+
+            transform->SetIdentity();
+
+            landmarkBasedTransformInitializer->SetTransform(transform);
+            landmarkBasedTransformInitializer->InitializeTransform();
+
+            Rigid2DTransformType::MatrixType matrix = transform->GetMatrix();
+            Rigid2DTransformType::OffsetType offset = transform->GetOffset();
+
+            // Write result
+              std::ofstream out;
+              clitk::openFileForWriting(out, args_info.output_arg);
+
+              out << matrix[0][0] << ' ' << matrix[0][1] << ' ' << offset[0] << std::endl;
+              out << matrix[1][0] << ' ' << matrix[1][1] << ' ' << offset[1] << std::endl;
+              out << 0.0  << ' ' << 0.0 << ' ' << 1.0;
+              out.close();
+
+
+
+              // Write result
+             if (args_info.error_arg != 0)
+             {
+                std::ofstream error;
+                clitk::openFileForWriting(error, args_info.error_arg);
+
+
+              //imagePoints
+              int nImagePoints = imageLandmarks.size();
+              double  imagePoints[3][nImagePoints];
+              double  trackerPoints[3][nImagePoints];
+              double  imagePointstoTrackerCoordinate[3][nImagePoints];
+              double FRE = 0;
+              double PointEuclideanDistance = 0;
+              double SumofPointsEuclideanDistance = 0;
+
+
+              for(int n= 0; n < imageLandmarks.size(); n++)
+              {
+                  for(int j= 0; j < 2; j++)
+                  {
+                      imagePoints[j][n] = imageLandmarks[n][j];
+                      trackerPoints[j][n] = trackerLandmarks[n][j];
+
+
+
+
+//                      imagePoints[j][n] = trackerLandmarks[n][j];
+//                      trackerPoints[j][n] = imageLandmarks[n][j];
+                      imagePointstoTrackerCoordinate[j][n] = 0;
+
+                  }
+                  imagePoints[2][n] = 1.0;
+                  trackerPoints[2][n] = 1.0;
+                  imagePointstoTrackerCoordinate[2][n] = 0;
+              }
+
+
+              //transformation matrix
+              double RigidTransformationImagetoTracker[4][4];
+
+
+              for(int i = 0; i < 2; i++)
+                for(int j = 0; j < 2; j++)
+                    RigidTransformationImagetoTracker[i][j] = matrix[i][j];
+
+
+              for(int i = 0; i < 2; i++)
+                  RigidTransformationImagetoTracker[i][2] = offset[i];
+
+              RigidTransformationImagetoTracker[2][0] = 0.0;
+              RigidTransformationImagetoTracker[2][1] = 0.0;
+              RigidTransformationImagetoTracker[2][2] = 1.0;
+
+
+              //writing results
+              error << "ImagePoints:    CorrespondingTrackerPoints:     ImagePointstoTrackerCoordinateSystem:  PointsDistanceafterRigidRegistration:" << std::endl;
+
+
+
+
+
+              //Calculate FRE
+
+              for(int n= 0; n < imageLandmarks.size(); n++)
+              {
+
+
+                   //Calculate imagePointstoTrackerCoordinate
+                   for(int i = 0; i < 3; i++)
+                   {
+
+                       for(int k = 0; k < 3; k++)
+                       {
+                            imagePointstoTrackerCoordinate[i][n] = imagePointstoTrackerCoordinate[i][n] + RigidTransformationImagetoTracker[i][k]*imagePoints[k][n];
+
+                       }
+
+                   }
+
+
+                   //writing results
+
+                   for(int i = 0; i < 2; i++)
+                            error << imagePoints[i][n] << ' ';
+
+                   error << "    ";
+
+                   for(int i = 0; i < 2; i++)
+                            error << trackerPoints[i][n] << ' ';
+
+                   error << "   ";
+
+                   for(int i = 0; i < 2; i++)
+                            error << imagePointstoTrackerCoordinate[i][n] << ' ';
+
+
+
+                   //calculate PointEuclideanDistance
+                   PointEuclideanDistance = 0;
+                   for(int i=0; i < 2;i++)
+                   {
+                       PointEuclideanDistance = PointEuclideanDistance + std::pow((trackerPoints[i][n] - imagePointstoTrackerCoordinate[i][n]),2);
+                   }
+                   PointEuclideanDistance = std::sqrt(PointEuclideanDistance);
+                   error << "   " <<   PointEuclideanDistance   << "   ";
+
+                   SumofPointsEuclideanDistance = SumofPointsEuclideanDistance +  std::pow(PointEuclideanDistance,2);
+
+
+
+
+
+
+                   error << std::endl;
+
+
+
+
+
+              } //end loop via points
+
+              error << std::endl;
+              SumofPointsEuclideanDistance = std::sqrt(SumofPointsEuclideanDistance/nImagePoints);
+              error << "Fiducial Registration Error:   " <<  SumofPointsEuclideanDistance;
+              error.close();
+
+            } //end if (args_info.error_arg != null)
+        } //end Dimension == 2 case
+        else if (Dimension_temp==3)
+        {
+
+            const     unsigned int   Dimension = 3;
+            typedef   itk::Image< PixelType, Dimension > ImageType;
+            typedef   float          VectorComponentType;
+            typedef   itk::Vector< VectorComponentType, Dimension >    VectorType;
+            //Typ LandmarkBasedTransormInitializer
+            typedef itk::VersorRigid3DTransform< double > Rigid3DTransformType;
+            typedef itk::LandmarkBasedTransformInitializer< Rigid3DTransformType,ImageType, ImageType>
+                LandmarkBasedTransformInitializerType;
+
+            LandmarkBasedTransformInitializerType::Pointer landmarkBasedTransformInitializer = LandmarkBasedTransformInitializerType::New();
+
+            //  Create source and target landmarks.
+            typedef LandmarkBasedTransformInitializerType::LandmarkPointContainer     LandmarkContainerType;
+            typedef LandmarkBasedTransformInitializerType::LandmarkPointType          LandmarkPointType;
+
+            LandmarkContainerType imageLandmarks;
+            LandmarkContainerType trackerLandmarks;
+            LandmarkContainerType imageLandmarksTotrackerCoordinate;
+
+
+            LandmarkPointType imagePoint;
+            LandmarkPointType trackerPoint;
+
+            is >> x;
+
+            while (is && !is.eof()) {
+                imagePoint[0] = x;
+                is >> imagePoint[1];
+                is >> imagePoint[2];
+
+                is >> trackerPoint[0];
+                is >> trackerPoint[1];
+                is >> trackerPoint[2];
+
+                imageLandmarks.push_back(imagePoint );
+                trackerLandmarks.push_back(trackerPoint );
+
+                is >> x;
+            }
+
+            is.close();
+
+            landmarkBasedTransformInitializer->SetFixedLandmarks( imageLandmarks);
+            landmarkBasedTransformInitializer->SetMovingLandmarks( trackerLandmarks);
+
+            Rigid3DTransformType::Pointer transform = Rigid3DTransformType::New();
+
+            transform->SetIdentity();
+
+            landmarkBasedTransformInitializer->SetTransform(transform);
+            landmarkBasedTransformInitializer->InitializeTransform();
+
+            Rigid3DTransformType::MatrixType matrix = transform->GetMatrix();
+            Rigid3DTransformType::OffsetType offset = transform->GetOffset();
+
+            // Write result
+              std::ofstream out;
+              clitk::openFileForWriting(out, args_info.output_arg);
+
+              out << matrix[0][0] << ' ' << matrix[0][1] << ' ' << matrix[0][2] << ' '<< offset[0] << std::endl;
+              out << matrix[1][0] << ' ' << matrix[1][1] << ' ' << matrix[1][2] << ' '<< offset[1] << std::endl;
+              out << matrix[2][0] << ' ' << matrix[2][1] << ' ' << matrix[2][2] << ' '<< offset[2] << std::endl;
+              out << 0.0  << ' ' << 0.0 << ' ' << 0.0 << ' ' << 1.0;
+              out.close();
+
+
+              if (args_info.error_arg != 0)
+              {
+              // Write result
+                std::ofstream error;
+                clitk::openFileForWriting(error, args_info.error_arg);
+
+
+              //imagePoints
+              int nImagePoints = imageLandmarks.size();
+              double  imagePoints[4][nImagePoints];
+              double  trackerPoints[4][nImagePoints];
+              double  imagePointstoTrackerCoordinate[4][nImagePoints];
+              double FRE = 0;
+              double PointEuclideanDistance = 0;
+              double SumofPointsEuclideanDistance = 0;
+
+
+              for(int n= 0; n < imageLandmarks.size(); n++)
+              {
+                  for(int j= 0; j < 3; j++)
+                  {
+                      imagePoints[j][n] = imageLandmarks[n][j];
+                      trackerPoints[j][n] = trackerLandmarks[n][j];
+
+
+
+
+//                      imagePoints[j][n] = trackerLandmarks[n][j];
+//                      trackerPoints[j][n] = imageLandmarks[n][j];
+                      imagePointstoTrackerCoordinate[j][n] = 0;
+
+                  }
+                  imagePoints[3][n] = 1.0;
+                  trackerPoints[3][n] = 1.0;
+                  imagePointstoTrackerCoordinate[3][n] = 0;
+              }
+
+
+              //transformation matrix
+              double RigidTransformationImagetoTracker[4][4];
+
+
+              for(int i = 0; i < 3; i++)
+                for(int j = 0; j < 3; j++)
+                    RigidTransformationImagetoTracker[i][j] = matrix[i][j];
+
+
+              for(int i = 0; i < 3; i++)
+                  RigidTransformationImagetoTracker[i][3] = offset[i];
+
+              RigidTransformationImagetoTracker[3][0] = 0.0;
+              RigidTransformationImagetoTracker[3][1] = 0.0;
+              RigidTransformationImagetoTracker[3][2] = 0.0;
+              RigidTransformationImagetoTracker[3][3] = 1.0;
+
+              //writing results
+              error << "ImagePoints:    CorrespondingTrackerPoints:     ImagePointstoTrackerCoordinateSystem:  PointsDistanceafterRigidRegistration:" << std::endl;
+
+
+
+
+
+              //Calculate FRE
+
+              for(int n= 0; n < imageLandmarks.size(); n++)
+              {
+
+
+                   //Calculate imagePointstoTrackerCoordinate
+                   for(int i = 0; i < 4; i++)
+                   {
+
+                       for(int k = 0; k < 4; k++)
+                       {
+                            imagePointstoTrackerCoordinate[i][n] = imagePointstoTrackerCoordinate[i][n] + RigidTransformationImagetoTracker[i][k]*imagePoints[k][n];
+
+                       }
+
+                   }
+
+
+                   //writing results
+
+                   for(int i = 0; i < 3; i++)
+                            error << imagePoints[i][n] << ' ';
+
+                   error << "    ";
+
+                   for(int i = 0; i < 3; i++)
+                            error << trackerPoints[i][n] << ' ';
+
+                   error << "   ";
+
+                   for(int i = 0; i < 3; i++)
+                            error << imagePointstoTrackerCoordinate[i][n] << ' ';
+
+
+
+                   //calculate PointEuclideanDistance
+                   PointEuclideanDistance = 0;
+                   for(int i=0; i < 3;i++)
+                   {
+                       PointEuclideanDistance = PointEuclideanDistance + std::pow((trackerPoints[i][n] - imagePointstoTrackerCoordinate[i][n]),2);
+                   }
+                   PointEuclideanDistance = std::sqrt(PointEuclideanDistance);
+                   error << "   " <<   PointEuclideanDistance   << "   ";
+
+                   SumofPointsEuclideanDistance = SumofPointsEuclideanDistance +  std::pow(PointEuclideanDistance,2);
+
+
+
+
+
+
+                   error << std::endl;
+
+
+
+
+
+              } //end loop via points
+
+              error << std::endl;
+              SumofPointsEuclideanDistance = std::sqrt(SumofPointsEuclideanDistance/nImagePoints);
+              error << "Fiducial Registration Error:   " <<  SumofPointsEuclideanDistance;
+              error.close();
+
+
+              } //end if (args_info.error_arg != null)
+          } //end Dimension == 3 case
+        else
+        {
+              is.close();
+              return EXIT_FAILURE;
+
+        }
+
+
+
+
+
+
+
+  return EXIT_SUCCESS;
+}// end main
+//--------------------------------------------------------------------
diff --git a/tools/clitkPointRigidRegistration.ggo b/tools/clitkPointRigidRegistration.ggo
new file mode 100644 (file)
index 0000000..3508459
--- /dev/null
@@ -0,0 +1,14 @@
+#File clitkPointRigidRegistration.ggo
+package "clitkPointRigidRegistration"
+version "1.0"
+purpose "Finding the rigid transformation between two cartesian coordinate systems\n
+based on corresponding points positions"
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+
+
+option "input"         i       "Corresponding points' positions filename"        string        required
+option "output"        o       "Output transformation filename"                  string        required
+option "error"         e       "Output error filename"                           string        optional
diff --git a/tools/clitkProfileImage.cxx b/tools/clitkProfileImage.cxx
new file mode 100644 (file)
index 0000000..c8332c9
--- /dev/null
@@ -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 "clitkProfileImage_ggo.h"
+#include "clitkProfileImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkProfileImage, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::ProfileImageGenericFilter 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/clitkProfileImage.ggo b/tools/clitkProfileImage.ggo
new file mode 100644 (file)
index 0000000..773790d
--- /dev/null
@@ -0,0 +1,16 @@
+#File clitkProfileImage.ggo
+package "clitkProfileImage"
+version "1.0"
+purpose "Save the profile between 2 points 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 "point1"     f   "First point (mm)"              double     yes multiple(-4)
+option "point2"     s   "Second point (mm)"             double     yes multiple(-4)
+
+
+
diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx
new file mode 100644 (file)
index 0000000..02394d3
--- /dev/null
@@ -0,0 +1,189 @@
+/*=========================================================================
+  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 clitkProfileImageGenericFilter_cxx
+#define clitkProfileImageGenericFilter_cxx
+
+/* =================================================
+ * @file   clitkProfileImageGenericFilter.cxx
+ * @author Thomas Baudier <thomas.baudier@creatis.insa-lyon.fr>
+ * @date   22 dec 2015
+ *
+ * @brief
+ *
+ ===================================================*/
+
+#include "clitkProfileImageGenericFilter.h"
+
+// itk include
+#include <itkLineIterator.h>
+#include <itkPoint.h>
+
+#include <clitkCommon.h>
+
+
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+ProfileImageGenericFilter::ProfileImageGenericFilter():
+  ImageToImageGenericFilter<Self>("ProfileImage")
+{
+  InitializeImageType<2>();
+  InitializeImageType<3>();
+  InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<unsigned int Dim>
+void ProfileImageGenericFilter::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetArrayX()
+{
+  return(mArrayX);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetArrayY()
+{
+  return(mArrayY);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+vtkFloatArray* ProfileImageGenericFilter::GetCoord()
+{
+  return(mCoord);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+void ProfileImageGenericFilter::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);
+  }
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class InputImageType>
+void
+ProfileImageGenericFilter::UpdateWithInputImageType()
+{
+
+  // Reading input
+  typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+  typedef typename InputImageType::PixelType PixelType;
+  typedef typename InputImageType::IndexType IndexType;
+
+  mArrayX = vtkSmartPointer<vtkFloatArray>::New();
+  mArrayY = vtkSmartPointer<vtkFloatArray>::New();
+  mCoord = vtkSmartPointer<vtkFloatArray>::New();
+  mCoord->SetNumberOfComponents(InputImageType::ImageDimension);
+  
+  /*typename InputImageType::Pointer outputImage;
+  outputImage = InputImageType::New();
+  outputImage->SetRegions(input->GetLargestPossibleRegion());
+  outputImage->Allocate();
+  outputImage->FillBuffer(0); */
+  
+  //Iterator
+  IndexType pointBegin, pointEnd;
+  
+  for (int i = 0; i < mArgsInfo.point1_given; ++i) {
+    pointBegin[i] = mArgsInfo.point1_arg[i];
+    pointEnd[i] = mArgsInfo.point2_arg[i];
+  }
+  
+  itk::LineConstIterator<InputImageType> itProfile(input, pointBegin, pointEnd);
+  itProfile.GoToBegin();
+  int lineNumber(1);
+  double *tuple;
+  double distance;
+  tuple = new double[InputImageType::ImageDimension];
+  itk::Point<double, InputImageType::ImageDimension> transformedFirstPoint;
+  itk::Point<double, InputImageType::ImageDimension> transformedCurrentPoint;
+  
+  input->TransformIndexToPhysicalPoint(itProfile.GetIndex(), transformedFirstPoint);
+  
+  while (!itProfile.IsAtEnd())
+  {    
+    // Fill in the table the intensity value
+    mArrayY->InsertNextTuple1(itProfile.Get());
+        
+    for (int i=0; i<InputImageType::ImageDimension; ++i) {
+        tuple[i] = itProfile.GetIndex()[i];
+    }
+
+    input->TransformIndexToPhysicalPoint(itProfile.GetIndex(), transformedCurrentPoint);
+    distance = transformedFirstPoint.EuclideanDistanceTo(transformedCurrentPoint);
+
+    // Fill in the table the distance value
+    mArrayX->InsertNextTuple1(distance);
+    
+    // Fille in the table the voxel coordinate value
+    mCoord->InsertNextTuple(tuple);
+    ++lineNumber;
+    ++itProfile;
+  }
+  
+  /*
+  itk::LineIterator<InputImageType> otProfile(outputImage, pointBegin, pointEnd);
+  otProfile.GoToBegin();  
+  while (!otProfile.IsAtEnd())
+  {    
+    otProfile.Set(1.0);
+    ++otProfile;
+  }
+  
+  this->template SetNextOutput<InputImageType>(outputImage): */
+  
+  delete [] tuple;
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif  //#define clitkProfileImageGenericFilter_cxx
diff --git a/tools/clitkProfileImageGenericFilter.h b/tools/clitkProfileImageGenericFilter.h
new file mode 100644 (file)
index 0000000..573a41c
--- /dev/null
@@ -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 clitkProfileImageGenericFilter_h
+#define clitkProfileImageGenericFilter_h
+
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+#include "clitkProfileImage_ggo.h"
+
+#include <vtkIntArray.h>
+#include <vtkFloatArray.h>
+
+//--------------------------------------------------------------------
+namespace clitk 
+{
+  
+  class ITK_EXPORT ProfileImageGenericFilter: 
+    public ImageToImageGenericFilter<ProfileImageGenericFilter>
+  {
+    
+  public:
+    //--------------------------------------------------------------------
+    typedef ProfileImageGenericFilter         Self;
+    typedef itk::SmartPointer<Self>           Pointer;
+    typedef itk::SmartPointer<const Self>     ConstPointer;
+    typedef args_info_clitkProfileImage       args_info_type;
+   
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);  
+    itkTypeMacro(ProfileImageGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>  
+    void UpdateWithInputImageType();
+    
+    vtkFloatArray* GetArrayX();
+    vtkFloatArray* GetArrayY();
+    vtkFloatArray* GetCoord();
+
+  protected:
+    ProfileImageGenericFilter();
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+    
+  
+    vtkSmartPointer<vtkFloatArray> mArrayX;
+    vtkSmartPointer<vtkFloatArray> mArrayY;
+    vtkSmartPointer<vtkFloatArray> mCoord;
+    
+    
+  }; // end class
+  //--------------------------------------------------------------------
+    
+} // end namespace clitk
+//--------------------------------------------------------------------
+
+#endif // #define clitkProfileImageGenericFilter_h
index bd2f3747cc5e5d5c042eb6face19c04e7756b4fe..64be16799a63a5c185e8acf65aa3488435f49dc0 100644 (file)
@@ -27,6 +27,7 @@ int main(int argc, char * argv[])
 
   // Init command line
   GGO(clitkResampleImage, args_info);
+  CLITK_INIT;
 
   // Filter
   typedef clitk::ResampleImageGenericFilter FilterType;
index 3448227a370cd0feb79276624fc40c2f4bea9f09..7ecf84298ba01aad9a1a63b749ed326857681309 100644 (file)
@@ -49,6 +49,8 @@ clitk::ResampleImageGenericFilter::UpdateWithInputImageType()
   static const unsigned int dim = OutputImageType::ImageDimension;
   typename OutputImageType::SpacingType spacing;
   typename OutputImageType::SizeType size;
+  typename OutputImageType::PointType origin;
+  typename OutputImageType::DirectionType direction;
 
   if (mArgsInfo.like_given) {
     itk::ImageIOBase::Pointer header = clitk::readImageHeader(mArgsInfo.like_arg);
@@ -56,9 +58,17 @@ clitk::ResampleImageGenericFilter::UpdateWithInputImageType()
       for(unsigned int i=0; i<dim; i++){
         spacing[i] = header->GetSpacing(i);
         size[i] = header->GetDimensions(i);
+        origin[i] = header->GetOrigin(i);
+      }
+      for(unsigned int i=0; i<dim; i++) {
+        for(unsigned int j=0;j<dim;j++) {
+            direction(i,j) = header->GetDirection(i)[j];
+        }
       }
       filter->SetOutputSpacing(spacing);
       filter->SetOutputSize(size);
+      filter->SetOutputOrigin(origin);
+      filter->SetOutputDirection(direction);
     }
     else {
       std::cerr << "*** Warning : I could not read '" << mArgsInfo.like_arg << "' ***" << std::endl;
@@ -91,6 +101,16 @@ clitk::ResampleImageGenericFilter::UpdateWithInputImageType()
         size[i] = mArgsInfo.size_arg[i];
       filter->SetOutputSize(size);
     }
+    for(unsigned int i=0; i<dim; i++){
+      origin[i] = input->GetOrigin()[i];
+    }
+    for(unsigned int i=0; i<dim; i++) {
+      for(unsigned int j=0;j<dim;j++) {
+          direction(i,j) = input->GetDirection()[i][j];
+      }
+    }
+    filter->SetOutputOrigin(origin);
+    filter->SetOutputDirection(direction);
   }
 
   // Set temporal dimension
index 71d93c5bc4f2245e7dbbcf6dd3d54b48da7f7e59..4eb00b9bac7d4b880e0ac77f7883e3ab6f9a8346 100644 (file)
@@ -105,9 +105,7 @@ void clitk::SplitImageGenericFilter::UpdateWithInputImageType()
   size[mSplitDimension]=0;
   typename ImageType::RegionType extracted_region;
   extracted_region.SetSize(size);
-#if ITK_VERSION_MAJOR >= 4
-  filter->SetDirectionCollapseToSubmatrix();
-#endif
+  filter->SetDirectionCollapseToIdentity();
   filter->SetExtractionRegion(extracted_region);
   filter->Update();
 
diff --git a/tools/clitkSum.cxx b/tools/clitkSum.cxx
new file mode 100644 (file)
index 0000000..6a4e185
--- /dev/null
@@ -0,0 +1,45 @@
+/*=========================================================================
+  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 "clitkSum_ggo.h"
+#include "clitkSumGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[])
+{
+
+  // Init command line
+  GGO(clitkSum, args_info);
+  CLITK_INIT;
+
+  // Filter
+  typedef clitk::SumGenericFilter<args_info_clitkSum> FilterType;
+  FilterType::Pointer filter = FilterType::New();
+
+  filter->SetArgsInfo(args_info);
+  try {
+    filter->Update();
+  } catch(std::runtime_error e) {
+    std::cout << e.what() << std::endl;
+  }
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkSum.ggo b/tools/clitkSum.ggo
new file mode 100644 (file)
index 0000000..e9938f2
--- /dev/null
@@ -0,0 +1,13 @@
+#File clitkSum.ggo
+package "clitkSum"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        optional
+option "verbose"       v       "Verbose"                         flag          off
+
+option "imagetypes"    -       "Display allowed image types"     flag          off
+
+option "input"         i       "Input image filename"            string        required
+option "output"        o       "Output image filename"           string        required
+option "dimension"     d       "Dimension along which to sum"    int           yes
diff --git a/tools/clitkSumGenericFilter.h b/tools/clitkSumGenericFilter.h
new file mode 100644 (file)
index 0000000..acebb90
--- /dev/null
@@ -0,0 +1,69 @@
+/*=========================================================================
+  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 clitkSumGenericFilter_h
+#define clitkSumGenericFilter_h
+#include "clitkIO.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk
+{
+
+template<class args_info_type>
+class ITK_EXPORT SumGenericFilter:
+        public ImageToImageGenericFilter<SumGenericFilter<args_info_type> >
+{
+
+public:
+
+    //--------------------------------------------------------------------
+    SumGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef SumGenericFilter                   Self;
+    typedef itk::SmartPointer<Self>            Pointer;
+    typedef itk::SmartPointer<const Self>      ConstPointer;
+
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);
+    itkTypeMacro(SumGenericFilter, LightObject);
+
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>
+    void UpdateWithInputImageType();
+
+protected:
+    template<unsigned int Dim> void InitializeImageType();
+    args_info_type mArgsInfo;
+
+}; // end class
+//--------------------------------------------------------------------
+
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkSumGenericFilter.txx"
+#endif
+
+#endif // #define clitkSumGenericFilter_h
diff --git a/tools/clitkSumGenericFilter.txx b/tools/clitkSumGenericFilter.txx
new file mode 100644 (file)
index 0000000..f7fb5f0
--- /dev/null
@@ -0,0 +1,97 @@
+/*=========================================================================
+  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 clitkSumGenericFilter_txx
+#define clitkSumGenericFilter_txx
+
+// itk include
+#include <itkSumProjectionImageFilter.h>
+#include <clitkCommon.h>
+
+namespace clitk
+{
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+SumGenericFilter<args_info_type>::SumGenericFilter():
+  ImageToImageGenericFilter<Self>("Sum")
+{
+  InitializeImageType<3>();
+  InitializeImageType<4>();
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<unsigned int Dim>
+void SumGenericFilter<args_info_type>::InitializeImageType()
+{
+  ADD_DEFAULT_IMAGE_TYPES(Dim);
+}
+//--------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------
+template<class args_info_type>
+void SumGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a)
+{
+  mArgsInfo=a;
+  this->SetIOVerbose(mArgsInfo.verbose_flag);
+  if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
+
+  if (mArgsInfo.input_given) {
+    this->SetInputFilename(mArgsInfo.input_arg);
+  }
+  if (mArgsInfo.output_given) {
+    this->SetOutputFilename(mArgsInfo.output_arg);
+  }
+}
+//--------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// Update with the number of dimensions and the pixeltype
+//--------------------------------------------------------------------
+template<class args_info_type>
+template<class InputImageType>
+void
+SumGenericFilter<args_info_type>::UpdateWithInputImageType()
+{
+
+  // Reading input
+  typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+
+  // Main filter
+  typedef typename InputImageType::PixelType PixelType;
+  const int Dim = InputImageType::ImageDimension;
+  typedef itk::Image<PixelType,Dim> ImageType;
+  typedef itk::Image<PixelType,Dim-1> OutputImageType;
+
+  // Filter
+  typedef itk::SumProjectionImageFilter<ImageType,OutputImageType> FilterType;
+  typename FilterType::Pointer filter = FilterType::New();
+  filter->SetProjectionDimension(mArgsInfo.dimension_arg);
+  filter->SetInput(input);
+  filter->Update();
+  this->template SetNextOutput<OutputImageType>(filter->GetOutput());
+}
+//--------------------------------------------------------------------
+
+
+}//end clitk
+
+#endif //#define clitkSumGenericFilter_txx
index e2971f4e1962a34fb6aea5067dcfbb0b7b7e46ba..f2288f0381de2295dc6d4dc6c67fe00afeb010b6 100644 (file)
@@ -86,11 +86,7 @@ namespace clitk
     //----------------------------------------  
     // Update
     //----------------------------------------  
-#if ITK_VERSION_MAJOR >= 4
     void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId );
-#else
-    void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId );
-#endif
    
     //----------------------------------------  
     // Data members
index 539e8dced07cb13b989d63b654b8f7444a8617d5..361f8dd4684a6ba5f8e7af0d796638b49381a37b 100644 (file)
@@ -46,12 +46,7 @@ namespace clitk
   // Generate Data
   //-------------------------------------------------------------------
   template<class InputImageType, class  OutputImageType> 
-  void 
-#if ITK_VERSION_MAJOR >= 4
-  VectorImageToImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId)
-#else
-  VectorImageToImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId)
-#endif
+  void VectorImageToImageFilter<InputImageType, OutputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, itk::ThreadIdType threadId)
   {
     // Iterators
     typename OutputImageType::Pointer output=this->GetOutput();
index cc3b17dd76666fbce0639ff3935ac1ebc58279cc..d1d1f714f3a76b46978fd0e9f3335740c1006a2c 100644 (file)
@@ -205,11 +205,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType()
     //Backward mapping
     typedef itk::WarpImageFilter<InputImageType, InputImageType, DeformationFieldType> BackwardWarpFilterType;
     typename BackwardWarpFilterType::Pointer backwardWarpFilter= BackwardWarpFilterType::New();
-#if ITK_VERSION_MAJOR >= 4
     backwardWarpFilter->SetDisplacementField( deformationField );
-#else
-    backwardWarpFilter->SetDeformationField( deformationField );
-#endif
     backwardWarpFilter->SetEdgePaddingValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
     backwardWarpFilter->SetOutputSpacing( deformationField->GetSpacing() );
     backwardWarpFilter->SetOutputOrigin( input->GetOrigin() );
index faa08cb44492dad8574303acf3f5d89bcc40a08f..d5f1347cc6bb504a55c829ba337da6cc7aa5fff7 100644 (file)
@@ -14,3 +14,4 @@ option "tag"          t       "Tags values"                    string         no multiple default="MIDPOSITION"
 option "newSeriesUID"          e       "Write the series with a new series UID (ignored if given in key/tag option)"   flag    off
 option "newStudyUID"           u       "Write the series with a new study UID (ignored if given in key/tag option; forces newSeriesUID = true)"        flag    off
 option "useSizeAsReference"            s       "Use the size of the dicom image as reference for an occasional resampling"     flag    off
+option "preserve"              p       "Preserve private tags and keep original UID (eg: Xio)" flag    off
index 2477aafcc46d477f80731983949363b0f2f7c66a..a2bccc4aa0daa52fbef3b8a34cb115b3eb9cc20c 100644 (file)
@@ -153,6 +153,12 @@ WriteDicomSeriesGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
 
   // Read the series
   typename ReaderType::Pointer reader = ReaderType::New();
+  if (m_ArgsInfo.preserve_flag) {
+#if GDCM_MAJOR_VERSION >= 2
+    gdcmIO->LoadPrivateTagsOn();
+    gdcmIO->KeepOriginalUIDOn();
+#endif
+  }
   reader->SetImageIO( gdcmIO );
   reader->SetFileNames( filenames_in );
   try {
index fe2c787ab850cbc292af77ef19519014b60c76e8..98f8f8fdcaa905309eb5c46aa30e07daa619a340 100644 (file)
@@ -1,6 +1,6 @@
-INCLUDE(../../cmake/common.cmake)
+include(../../cmake/common.cmake)
 
-ADD_LIBRARY(clitkCxImage STATIC
+add_library(clitkCxImage STATIC
     ximaenc.cpp
     ximatran.cpp
     ximath.cpp
@@ -14,5 +14,5 @@ ADD_LIBRARY(clitkCxImage STATIC
     ximasel.cpp
     xmemfile.cpp
     )
-INCLUDE_DIRECTORIES(.)
+include_directories(.)
 
index 7829924967130d20593c54a1795abdb5f0b068ca..49d15b735959fb874ff5465bb64cb6ff07f6d801 100644 (file)
@@ -1,24 +1,24 @@
 # Gengetopt: http://www.gnu.org/software/gengetopt/
 
-ADD_DEFINITIONS(-DPACKAGE=\"gengetopt\")
-ADD_DEFINITIONS(-DVERSION=\"2.22.4\")
-ADD_DEFINITIONS(-DHAVE_SSTREAM)
-ADD_DEFINITIONS(-DHAVE_NAMESPACES)
+add_definitions(-DPACKAGE=\"gengetopt\")
+add_definitions(-DVERSION=\"2.22.4\")
+add_definitions(-DHAVE_SSTREAM)
+add_definitions(-DHAVE_NAMESPACES)
 
 # Remove compiler warnings
-STRING(REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-STRING(REPLACE "/W3" "/w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
-STRING(REPLACE "-Wall" "-w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-STRING(REPLACE "-Wall" "-w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REPLACE "/W3" "/w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "/W3" "/w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REPLACE "-Wall" "-w" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+string(REPLACE "-Wall" "-w" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 
 # MSVC specific issues
-IF(MSVC)
-  ADD_DEFINITIONS(-DHAVE_STRING_H)
-  ADD_DEFINITIONS(-DYY_NO_UNISTD_H)
-  ADD_DEFINITIONS(-Disatty=!)
-ENDIF(MSVC)
+if(MSVC)
+  add_definitions(-DHAVE_STRING_H)
+  add_definitions(-DYY_NO_UNISTD_H)
+  add_definitions(-Disatty=!)
+endif(MSVC)
 
-ADD_EXECUTABLE(gengetopt 
+add_executable(gengetopt
   ./cmdline.c
   ./ggos.cpp
   ./scanner.cc
@@ -64,6 +64,6 @@ ADD_EXECUTABLE(gengetopt
   ./yyerror.cc
   ./parser.cc)
 
-INCLUDE_DIRECTORIES(.)
-INCLUDE_DIRECTORIES(skels)
-#INCLUDE_DIRECTORIES(includes)
+include_directories(.)
+include_directories(skels)
+#include_directories(includes)
index 998678949445350b4841c8ab7d0d136f2f76b9d8..f43f41a10f2ea0474e7f3651882d3b647b3b2a27 100644 (file)
@@ -4,12 +4,13 @@ cmake_minimum_required(VERSION 2.4)
 # To avoid warning with some version
 if(COMMAND cmake_policy)
   cmake_policy(SET CMP0003 NEW)
+  cmake_policy(SET CMP0007 NEW)
 endif(COMMAND cmake_policy)
 #=========================================================
 OPTION(CLITK_USE_PACS_CONNECTION "USE PACS CONNECTION"       OFF)
 #=========================================================
 #List of vv tools to compile
-SET(vv_TOOLS
+set(vv_TOOLS
   vvToolMedianFilter
   vvToolRigidReg
   vvToolCropImage
@@ -20,11 +21,13 @@ SET(vv_TOOLS
   vvToolConvert ## with dummy vvToolConvert.ui
   vvToolROIManager
   vvToolSegmentation
+  vvToolProfile
   ## these ones are for tests (not working)
+  # vvToolTest
   # vvToolFoo
   # vvToolFooWithWidgetBase
   # vvToolPlastimatch
-  # vvToolConnectedComponentLabeling  
+  # vvToolConnectedComponentLabeling
   ## these ones are old ones
   # vvToolExtractPatient
   # vvToolExtractLung
@@ -33,42 +36,43 @@ SET(vv_TOOLS
 # dependencies of the tools
 # Future issues : when tool depend on other tools ... how to manage that ?
 #  >> add the relevant $_LIBS variable to the tool that has dependencies?
-SET(vvToolBinarize_LIBS clitkBinarizeImageLib)
-SET(vvToolResample_LIBS clitkResampleImageLib)
-SET(vvToolConvert_LIBS clitkImageConvertLib)
-SET(vvToolExtractPatient_LIBS clitkSegmentationGgoLib)
-SET(vvToolExtractLung_LIBS clitkSegmentationGgoLib)
-SET(vvToolCropImage_LIBS clitkCropImageLib)
-SET(vvToolMIP_LIBS clitkMIPLib)
-SET(vvToolMedianFilter_LIBS clitkMedianImageFilterLib)
-SET(vvToolImageArithm_LIBS clitkImageArithmImageLib)
-SET(vvToolROIManager_LIBS clitkDicomRTStruct)
+set(vvToolBinarize_LIBS clitkBinarizeImageLib)
+set(vvToolProfile_LIBS clitkProfileImageLib)
+set(vvToolResample_LIBS clitkResampleImageLib)
+set(vvToolConvert_LIBS clitkImageConvertLib)
+set(vvToolExtractPatient_LIBS clitkSegmentationGgoLib)
+set(vvToolExtractLung_LIBS clitkSegmentationGgoLib)
+set(vvToolCropImage_LIBS clitkCropImageLib)
+set(vvToolMIP_LIBS clitkMIPLib)
+set(vvToolMedianFilter_LIBS clitkMedianImageFilterLib)
+set(vvToolImageArithm_LIBS clitkImageArithmImageLib)
+set(vvToolROIManager_LIBS clitkDicomRTStruct)
 
 #=========================================================
 # List of vv source files
 
 # in COMMON_WITH_UI -> must have .h and .cxx and .ui
-SET(vv_COMMON_WITH_UI
+set(vv_COMMON_WITH_UI
   vvInfoPanel
-  vvMainWindow 
-  vvLinkPanel 
-  vvOverlayPanel 
-  vvLandmarksPanel 
-  vvProgressDialog 
+  vvMainWindow
+  vvLinkPanel
+  vvOverlayPanel
+  vvLandmarksPanel
+  vvProgressDialog
   vvSegmentationDialog
   vvSurfaceViewerDialog
   vvDeformationDialog
   vvStructSelector
   vvIntensityValueSlider
   vvLabelImageLoaderWidget
-  vvToolWidgetBase  
+  vvToolWidgetBase
   vvToolSimpleInputSelectorWidget
   vvToolInputSelectorWidget
   vvRegisterForm
 )
 
 # All others sources
-SET(vv_SRCS
+set(vv_SRCS
   vvQProgressDialogITKCommand.cxx
   vvQDicomSeriesSelector.cxx
   QTreePushButton.cxx
@@ -105,196 +109,303 @@ SET(vv_SRCS
 
 #=========================================================
 # Qt related commands
-FIND_PACKAGE(Qt4 REQUIRED)
+if(vv_QT_VERSION VERSION_GREATER "4")
+  find_package(Qt5Widgets REQUIRED)
+  find_package(Qt5Network REQUIRED)
+  find_package(Qt5Designer REQUIRED)
+else()
+  find_package(Qt4 REQUIRED)
+endif()
 
-QT4_WRAP_CPP(vv_SRCS 
-  vvMainWindowBase.h 
-  QTreePushButton.h 
-  vvDocumentation.h  
-  vvHelpDialog.h  
-  vvQDicomSeriesSelector.h 
-  vvSlicerManager.h
-  vvStructureSetActor.h
-  vvROIActor.h
-  vvToolCreatorBase.h
-  )
+if(vv_QT_VERSION VERSION_GREATER "4")
+  link_directories(${QT5Widgets_LIBRARIES})
+  link_directories(${QT5Network_LIBRARIES})
+  link_directories(${QT5Designer_LIBRARIES})
+else()
+  link_directories(${QT_LIBRARY_DIR})
+endif()
 
-QT4_WRAP_UI(vv_UI_CXX 
-  qt_ui/vvHelpDialog.ui 
-  qt_ui/vvDocumentation.ui 
-  qt_ui/vvDicomSeriesSelector.ui
-qt_ui/vvDummyWindow.ui          #For testing 
-#qt_ui/vvPacsConnection.ui
- #    qt_ui/vvPacsSettingsDialog.ui
-)
+if(vv_QT_VERSION VERSION_GREATER "4")
+  qt5_wrap_cpp(vv_SRCS
+    vvMainWindowBase.h
+    QTreePushButton.h
+    vvDocumentation.h
+    vvHelpDialog.h
+    vvQDicomSeriesSelector.h
+    vvSlicerManager.h
+    vvSlicer.h
+    vvStructureSetActor.h
+    vvROIActor.h
+    vvToolCreatorBase.h
+    )
+else()
+  QT4_WRAP_CPP(vv_SRCS
+    vvMainWindowBase.h
+    QTreePushButton.h
+    vvDocumentation.h
+    vvHelpDialog.h
+    vvQDicomSeriesSelector.h
+    vvSlicerManager.h
+    vvSlicer.h
+    vvStructureSetActor.h
+    vvROIActor.h
+    vvToolCreatorBase.h
+    )
+endif()
 
-QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc)
+if(vv_QT_VERSION VERSION_GREATER "4")
+  qt5_wrap_ui(vv_UI_CXX
+    qt_ui/vvHelpDialog.ui
+    qt_ui/vvDocumentation.ui
+    qt_ui/vvDicomSeriesSelector.ui
+    qt_ui/vvDummyWindow.ui #For testing
+    )
+else()
+  QT4_WRAP_UI(vv_UI_CXX
+    qt_ui/vvHelpDialog.ui
+    qt_ui/vvDocumentation.ui
+    qt_ui/vvDicomSeriesSelector.ui
+    qt_ui/vvDummyWindow.ui #For testing
+    )
+endif()
+
+if(vv_QT_VERSION VERSION_GREATER "4")
+  QT5_add_resources(vv_SRCS vvIcons.qrc)
+else()
+  QT4_ADD_RESOURCES(vv_SRCS vvIcons.qrc)
+endif()
 
 # Add DICOM SERVER gui selector if the adequate GDCM is available
-IF(CLITK_USE_PACS_CONNECTION)
+if(CLITK_USE_PACS_CONNECTION)
   SET(vv_SRCS ${vv_SRCS}
-      vvQPacsConnection.cxx
-         vvPacsSettingsDialog.cxx
-         vvDicomServerQueryFactory.cxx
-         )
-  QT4_WRAP_CPP(vv_SRCS vvQPacsConnection.h
-     vvPacsSettingsDialog.h)
-  QT4_WRAP_UI(vv_UI_CXX 
-       qt_ui/vvPacsConnection.ui
-     qt_ui/vvPacsSettingsDialog.ui)
-ENDIF(CLITK_USE_PACS_CONNECTION)
-
-# Add the autotools in the header vvToolsList.h for initialization of the dummy
-# variables in vv.cxx for the tools contained in vvLib
-if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-  file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-  foreach(tool ${vv_TOOLS})
-    FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
-    FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
-    FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
+    vvQPacsConnection.cxx
+       vvPacsSettingsDialog.cxx
+       vvDicomServerQueryFactory.cxx
+       )
+  if(vv_QT_VERSION VERSION_GREATER "4")
+    qt5_wrap_cpp(vv_SRCS vvQPacsConnection.h
+      vvPacsSettingsDialog.h)
+    qt5_wrap_ui(vv_UI_CXX 
+         qt_ui/vvPacsConnection.ui
+      qt_ui/vvPacsSettingsDialog.ui)
+  else()
+    QT4_WRAP_CPP(vv_SRCS vvQPacsConnection.h
+      vvPacsSettingsDialog.h)
+    QT4_WRAP_UI(vv_UI_CXX 
+         qt_ui/vvPacsConnection.ui
+      qt_ui/vvPacsSettingsDialog.ui)
+  endif()
+endif(CLITK_USE_PACS_CONNECTION)
+  
+  # Add the autotools in the header vvToolsList.h for initialization of the dummy
+  # variables in vv.cxx for the tools contained in vvLib
+  if(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+    file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+    foreach(tool ${vv_TOOLS})
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "#include \"${tool}.h\"\n")
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "extern const vvToolCreator<${tool}> *dummy${tool};\n")
+      file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h "const vvToolCreator<${tool}> *dummy${tool}2 = dummy${tool};\n\n")
+    endforeach(tool)
+  endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
+  
+  # Add the autotools and the common files ui
+  foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
+      set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
+      if(vv_QT_VERSION VERSION_GREATER "4")
+        QT5_WRAP_CPP(vv_SRCS ${tool}.h)
+        QT5_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
+      else()
+        QT4_WRAP_CPP(vv_SRCS ${tool}.h)
+        QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
+      endif()
   endforeach(tool)
-endif(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt IS_NEWER_THAN ${CMAKE_CURRENT_BINARY_DIR}/vvToolsList.h)
-
-# Add the autotools and the common files ui
-foreach(tool ${vv_TOOLS} ${vv_COMMON_WITH_UI})
-  SET(vv_SRCS ${vv_SRCS} ${tool}.cxx)
-  QT4_WRAP_CPP(vv_SRCS ${tool}.h)
-  QT4_WRAP_UI(vv_UI_CXX qt_ui/${tool}.ui)
-endforeach(tool)
-
-# Add the common source files
-foreach(tool ${vv_COMMON})
-  SET(vv_SRCS ${vv_SRCS} ${tool}.cxx)
-  QT4_WRAP_CPP(vv_SRCS ${tool}.h)
-endforeach(tool)
-
-# if Windows and Qt was built as a static lib then don't set QT_DLL flag
-SET(QT_STATIC 0)
-IF (WIN32)
-  IF(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
-    FILE(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL)
-    IF(${QT_CORE_PRL} MATCHES "static")
-      SET(QT_STATIC 1)
-    ENDIF(${QT_CORE_PRL} MATCHES "static")
-  ENDIF(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
-ENDIF(WIN32)
-IF(NOT QT_STATIC)
-  ADD_DEFINITIONS(-DQT_DLL)
-ENDIF(NOT QT_STATIC)
-
-ADD_DEFINITIONS(-DQT_THREAD_SUPPORT)
+  
+  # Add the common source files
+  foreach(tool ${vv_COMMON})
+      set(vv_SRCS ${vv_SRCS} ${tool}.cxx)
+      if(vv_QT_VERSION VERSION_GREATER "4")
+        QT5_WRAP_CPP(vv_SRCS ${tool}.h)
+      else()
+        QT4_WRAP_CPP(vv_SRCS ${tool}.h)
+      endif()
+  endforeach(tool)
+  
+  # if Windows and Qt was built as a static lib then don't set QT_DLL flag
+  set(QT_STATIC 0)
+  if(WIN32)
+    if(vv_QT_VERSION VERSION_GREATER "4")
+      if(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
+        file(READ ${Qt5Widgets_LIBRARIES}/QtCore.prl QT_CORE_PRL)
+        if(${QT_CORE_PRL} MATCHES "static")
+          set(QT_STATIC 1)
+        endif(${QT_CORE_PRL} MATCHES "static")
+      endif(EXISTS ${Qt5Widgets_LIBRARIES}/QtCore.prl)
+    else()
+      if(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
+        file(READ ${QT_LIBRARY_DIR}/QtCore.prl QT_CORE_PRL)
+        if(${QT_CORE_PRL} MATCHES "static")
+          set(QT_STATIC 1)
+        endif(${QT_CORE_PRL} MATCHES "static")
+      endif(EXISTS ${QT_LIBRARY_DIR}/QtCore.prl)
+    endif()
+  endif(WIN32)
+  if(NOT QT_STATIC)
+    add_definitions(-DQT_DLL)
+  endif(NOT QT_STATIC)
 
-INCLUDE_DIRECTORIES(
-  ${QT_INCLUDES}
-  ${QT_INCLUDE_DIR}
-  ${QT_QTGUI_INCLUDE_DIR}
-  ${QT_QTCORE_INCLUDE_DIR}
-  ${CMAKE_CURRENT_BINARY_DIR}
-  ${CMAKE_CURRENT_SOURCE_DIR}
-)
+  add_definitions(-DQT_THREAD_SUPPORT)
+  if(vv_QT_VERSION VERSION_GREATER "4")
+    include_directories(
+      ${Qt5Widgets_INCLUDE_DIRS}
+      ${Qt5Gui_INCLUDE_DIRS}
+      ${Qt5Core_INCLUDE_DIRS}
+      ${Qt5Network_INCLUDE_DIRS}
+      ${Qt5Designer_INCLUDE_DIRS}
+      ${CMAKE_CURRENT_BINARY_DIR}
+      ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+  else()
+    include_directories(
+      ${QT_INCLUDES}
+      ${QT_INCLUDE_DIR}
+      ${QT_QTGUI_INCLUDE_DIR}
+      ${QT_QTCORE_INCLUDE_DIR}
+      ${CMAKE_CURRENT_BINARY_DIR}
+      ${CMAKE_CURRENT_SOURCE_DIR}
+    )
+  endif()
 #=========================================================
 
 #=========================================================
 #support for parallel deformable registration with OpenMP
-IF(NOT APPLE)
-IF(CMAKE_COMPILER_IS_GNUCC)
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
-ENDIF(CMAKE_COMPILER_IS_GNUCC)
-ENDIF(NOT APPLE)
+if(NOT APPLE)
+if(CMAKE_COMPILER_IS_GNUCC)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
+endif(CMAKE_COMPILER_IS_GNUCC)
+endif(NOT APPLE)
 #=========================================================
 
 #=========================================================
-INCLUDE_DIRECTORIES(
+include_directories(
   ../common
   ../tools
   ../segmentation
   )
 
-LINK_DIRECTORIES(${QT_LIBRARY_DIR})
-
 #=========================================================
 #Add each tool's dependencies
 foreach(tool ${vv_TOOLS})
-  SET(toolLibs ${toolLibs} ${${tool}_LIBS})
+  set(toolLibs ${toolLibs} ${${tool}_LIBS})
 endforeach(tool)
 
 #=========================================================
 #Add Foundation Libraries (this should be after our libraries, since we depend
 #on them)
-SET(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
+if(VTK_VERSION VERSION_GREATER "6.2.0")
+set(foundationLibraries clitkCommon ${ITK_LIBRARIES} ${VTK_LIBRARIES})
+else()
+set(foundationLibraries clitkCommon ${ITK_LIBRARIES} QVTK vtkHybrid)
+endif()
 
 #=========================================================
 # Use CxImage to create animated gifs
-IF(CLITK_EXPERIMENTAL)
-  SET(vvCxImage clitkCxImage)
-  SET(vv_SRCS ${vv_SRCS} vvAnimatedGIFWriter.cxx)
-  INCLUDE_DIRECTORIES(${CLITK_SOURCE_DIR}/utilities/CxImage)
-  ADD_SUBDIRECTORY(${CLITK_SOURCE_DIR}/utilities/CxImage ${PROJECT_BINARY_DIR}/utilities/CxImage)
-ENDIF(CLITK_EXPERIMENTAL)
+if(CLITK_EXPERIMENTAL)
+  set(vvCxImage clitkCxImage)
+  set(vv_SRCS ${vv_SRCS} vvAnimatedGIFWriter.cxx)
+  include_directories(${CLITK_SOURCE_DIR}/utilities/CxImage)
+  add_subdirectory(${CLITK_SOURCE_DIR}/utilities/CxImage ${PROJECT_BINARY_DIR}/utilities/CxImage)
+endif(CLITK_EXPERIMENTAL)
 #=========================================================
 
+#-----------------------------------------------------------------------------
+# Avoid linker bug in Mac OS 10.5
+# See http://wiki.finkproject.org/index.php/Fink:Packaging:Preparing_for_10.5#OpenGL_Bug
+#
+if(APPLE)
+  find_library(CoreFoundation_LIBRARY CoreFoundation REQUIRED)
+  find_library(ApplicationServices_LIBRARY ApplicationServices REQUIRED)
+  find_library(SystemConfiguration_LIBRARY SystemConfiguration REQUIRED)
+  find_library(Security_LIBRARY Security REQUIRED)
+  set(APPLE_FRAMEWORKS ${CoreFoundation_LIBRARY}
+    ${ApplicationServices_LIBRARY}
+    ${SystemConfiguration_LIBRARY}
+    ${Security_LIBRARY}
+    )
+  message(STATUS "===== ${APPLE_FRAMEWORKS}")
+endif()
 #=========================================================
 #Create binary and libs for tests
-SET(vvExternalLibs ${QT_QTNETWORK_LIBRARY} clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage})
-# QtNetwork is required by vvRegisterForm
+if(vv_QT_VERSION VERSION_GREATER "4")
+set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} Qt5::Widgets Qt5::Network Qt5::Designer ${APPLE_FRAMEWORKS})
+else()
+set(vvExternalLibs clitkSegmentationGgoLib ${toolLibs} ${foundationLibraries} ${vvCxImage} ${QT_LIBRARIES} ${APPLE_FRAMEWORKS})
+endif()
+# QtNetwork is required by vvRegisterForm ${QT_QTNETWORK_LIBRARY}
+
+#-----------------------------------------------------------------------------
+# For retina displays, see
+# http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
+if(APPLE)
+  set(vv_SRCS ${vv_SRCS} vvOSXHelper.mm)
+endif()
 
-ADD_LIBRARY(vvLib ${vv_SRCS} ${vv_UI_CXX})
-TARGET_LINK_LIBRARIES(vvLib ${vvExternalLibs})
+add_library(vvLib ${vv_SRCS} ${vv_UI_CXX})
+target_link_libraries(vvLib ${vvExternalLibs})
 
-IF(WIN32)
-  ADD_EXECUTABLE(vv WIN32 vv.cxx vvIcon.rc)
-ELSE(WIN32)
-  ADD_EXECUTABLE(vv vv.cxx)
-ENDIF(WIN32)
+if(WIN32)
+  add_executable(vv WIN32 vv.cxx vvIcon.rc)
+else(WIN32)
+  add_executable(vv vv.cxx)
+endif(WIN32)
 
-TARGET_LINK_LIBRARIES(vv vvLib)
+target_link_libraries(vv vvLib)
 
 #=========================================================
 # Install options (also used by CPack)
-INSTALL (TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
+install(TARGETS vv DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE)
 
 #=========================================================
 
 #=========================================================
 # CPack options
-SET(CPACK_PACKAGE_NAME "vv")
-SET(CPACK_SOURCE_PACKAGE_FILE_NAME "vv-src")
-SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "vv, the 4D slicer : let's jump into a new dimension !")
-SET(CPACK_PACKAGE_VENDOR "Creatis-CLB")
-SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
-SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
-SET(CPACK_PACKAGE_VERSION_MAJOR "1")
-SET(CPACK_PACKAGE_VERSION_MINOR "3")
-SET(CPACK_PACKAGE_VERSION_PATCH "0")
-IF(NIGHTLY)
-  SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vv-nightly")
-ELSE(NIGHTLY)
-  SET(CPACK_PACKAGE_INSTALL_DIRECTORY "vv")
-ENDIF(NIGHTLY)
-SET(CPACK_STRIP_FILES TRUE)
+set(CPACK_PACKAGE_NAME "vv")
+set(CPACK_SOURCE_PACKAGE_FILE_NAME "vv-src")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "vv, the 4D slicer : let's jump into a new dimension !")
+set(CPACK_PACKAGE_VENDOR "Creatis-CLB")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/ReadMe.txt")
+set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
+set(CPACK_PACKAGE_VERSION_MAJOR "1")
+set(CPACK_PACKAGE_VERSION_MINOR "3")
+set(CPACK_PACKAGE_VERSION_PATCH "0")
+if(NIGHTLY)
+  set(CPACK_PACKAGE_INSTALL_DIRECTORY "vv-nightly")
+else(NIGHTLY)
+  set(CPACK_PACKAGE_INSTALL_DIRECTORY "vv")
+endif(NIGHTLY)
+set(CPACK_STRIP_FILES TRUE)
 
-IF(WIN32)
+if(WIN32)
   # There is a bug in NSI that does not handle full unix paths properly. Make
   # sure there is at least one set of four (4) backlasshes.
-  SET(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\icons\\\\ducky.ico")
-  SET(CPACK_NSIS_INSTALLED_ICON_NAME "vv.exe")
-IF(NIGHTLY)
-  SET(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer (nightly)")
-ELSE(NIGHTLY)
-  SET(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer")
-ENDIF(NIGHTLY)
-  SET(CPACK_NSIS_HELP_LINK "http://www.creatis.insa-lyon.fr/rio/vv")
-  SET(CPACK_NSIS_URL_INFO_ABOUT "http://www.creatis.insa-lyon.fr/rio")
-  SET(CPACK_NSIS_CONTACT "vv@creatis.insa-lyon.fr")
-  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\vv.lnk\\\" \\\"$INSTDIR\\\\bin\\\\vv.exe\\\" ")
-  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\vv.lnk\\\" ")
-  #SET(CPACK_NSIS_MODIFY_PATH ON) SR: buggy, wait for cmake updates for a fix
-  #SET(CPACK_BINARY_ZIP ON)
-ELSE(WIN32)
-  SET(CPACK_GENERATOR "STGZ")
-  SET(CPACK_SOURCE_GENERATOR "TGZ") 
-ENDIF(WIN32)
-INCLUDE(CPack)
+  set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\icons\\\\ducky.ico")
+  set(CPACK_NSIS_INSTALLED_ICON_NAME "vv.exe")
+if(NIGHTLY)
+  set(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer (nightly)")
+else(NIGHTLY)
+  set(CPACK_NSIS_DISPLAY_NAME "vv - The 4D slicer")
+endif(NIGHTLY)
+  set(CPACK_NSIS_HELP_LINK "http://www.creatis.insa-lyon.fr/rio/vv")
+  set(CPACK_NSIS_URL_INFO_ABOUT "http://www.creatis.insa-lyon.fr/rio")
+  set(CPACK_NSIS_CONTACT "vv@creatis.insa-lyon.fr")
+  set(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\vv.lnk\\\" \\\"$INSTDIR\\\\bin\\\\vv.exe\\\" ")
+  set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\vv.lnk\\\" ")
+  #set(CPACK_NSIS_MODIFY_PATH ON) SR: buggy, wait for cmake updates for a fix
+  #set(CPACK_BINARY_ZIP ON)
+else(WIN32)
+  set(CPACK_GENERATOR "STGZ")
+  set(CPACK_SOURCE_GENERATOR "TGZ")
+endif(WIN32)
+include(CPack)
 #=========================================================
 #=========================================================
 configure_file(vvConfiguration.h.in vvConfiguration.h)
index 290e0a2d230c2930ebe90e98b5caefdf2a5f7461..518d289880758c3077375996e291ae82f812bb1b 100644 (file)
@@ -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
diff --git a/vv/icons/profile.png b/vv/icons/profile.png
new file mode 100644 (file)
index 0000000..656113a
Binary files /dev/null and b/vv/icons/profile.png differ
index 8cbe197d9134697bf47c17da6acb55d0c6ad4fd5..9337b52c96c3c8207add01903bb37cdf393bfb73 100644 (file)
@@ -14,7 +14,7 @@
    <string>Form</string>
   </property>
   <layout class="QGridLayout" name="gridLayout">
-   <item row="0" column="0" colspan="2">
+   <item row="0" column="0" colspan="-1">
     <widget class="QLabel" name="nameLabel">
      <property name="text">
       <string>&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
index 444b00fdbed022ba34e72d48b897900b9d08348d..ec4051a3b58bfc22032c84286e8acacc6de3f2a5 100644 (file)
      <x>0</x>
      <y>0</y>
      <width>1008</width>
-     <height>21</height>
+     <height>27</height>
     </rect>
    </property>
    <property name="defaultUp">
    <property name="text">
     <string>Open image(s)</string>
    </property>
+   <property name="shortcut">
+    <string>Ctrl+O</string>
+   </property>
    <property name="iconVisibleInMenu">
     <bool>true</bool>
    </property>
    <property name="text">
     <string>Navigation Help</string>
    </property>
-   <property name="shortcut">
-    <string>F1</string>
-   </property>
    <property name="iconVisibleInMenu">
     <bool>true</bool>
    </property>
+   <property name="priority">
+    <enum>QAction::NormalPriority</enum>
+   </property>
   </action>
   <action name="actionOpen_Dicom_Struct">
    <property name="icon">
index e6c044ab7a20fbcc9bea507ac5837fae7cdc3c40..3347fec2ad23ce2585a67ad8e1e4f50ae3b3c030 100644 (file)
       <string>Save</string>
      </property>
     </widget>
-    <widget class="QWidget" name="layoutWidget">
+    <widget class="QWidget" name="layoutWidget1">
      <property name="geometry">
       <rect>
        <x>0</x>
diff --git a/vv/qt_ui/vvToolProfile.ui b/vv/qt_ui/vvToolProfile.ui
new file mode 100644 (file)
index 0000000..bc3c9c8
--- /dev/null
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolProfile</class>
+ <widget class="QWidget" name="vvToolProfile">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>505</width>
+    <height>452</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Profile image</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_3">
+     <item>
+      <layout class="QGridLayout" name="gridLayout_2">
+       <property name="horizontalSpacing">
+        <number>6</number>
+       </property>
+       <item row="2" column="1">
+        <layout class="QHBoxLayout" name="horizontalLayout_3">
+         <item>
+          <widget class="QPushButton" name="mSelectPoint2Button">
+           <property name="text">
+            <string>Select point 2</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="Point2">
+           <property name="text">
+            <string>Center of voxel2 (vox):</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="2" column="3">
+        <layout class="QHBoxLayout" name="horizontalLayout_2">
+         <item>
+          <widget class="QLabel" name="mPosPoint2Label">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="minimumSize">
+            <size>
+             <width>200</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="3" column="3">
+        <layout class="QHBoxLayout" name="horizontalLayout_6">
+         <item>
+          <widget class="QToolButton" name="mCancelPointsButton">
+           <property name="text">
+            <string>Cancel</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QPushButton" name="mSaveProfileButton">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text">
+            <string>Save Profile</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="1" column="1">
+        <layout class="QHBoxLayout" name="horizontalLayout_7">
+         <item>
+          <widget class="QPushButton" name="mSelectPoint1Button">
+           <property name="text">
+            <string>Select point 1</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="Point1">
+           <property name="text">
+            <string>Center of voxel1 (vox):</string>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+       <item row="1" column="3">
+        <layout class="QHBoxLayout" name="horizontalLayout">
+         <item>
+          <widget class="QLabel" name="mPosPoint1Label">
+           <property name="sizePolicy">
+            <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="minimumSize">
+            <size>
+             <width>200</width>
+             <height>0</height>
+            </size>
+           </property>
+           <property name="text">
+            <string/>
+           </property>
+          </widget>
+         </item>
+        </layout>
+       </item>
+      </layout>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <layout class="QVBoxLayout" name="verticalLayout_2">
+     <item>
+      <widget class="Line" name="line_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QVTKWidget" name="ProfileWidget" native="true">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>300</height>
+        </size>
+       </property>
+       <property name="mouseTracking">
+        <bool>true</bool>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>QVTKWidget</class>
+   <extends>QWidget</extends>
+   <header>QVTKWidget.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
index f4848dba1b53f0ae5688b3455835f86b2af38c8a..8e0d3c23864336aa29dad45e1faea6145b0861fc 100644 (file)
               </sizepolicy>
              </property>
              <property name="text">
-              <string>        </string>
+              <string/>
              </property>
             </widget>
            </item>
              </property>
             </spacer>
            </item>
+           <item>
+            <widget class="QPushButton" name="mRemoveButton">
+             <property name="text">
+              <string>1</string>
+             </property>
+             <property name="icon">
+              <iconset resource="../vvIcons.qrc">
+               <normaloff>:/common/icons/standardbutton-cancel-16.png</normaloff>:/common/icons/standardbutton-cancel-16.png</iconset>
+             </property>
+            </widget>
+           </item>
            <item>
             <widget class="QLabel" name="mROInameLabel_3">
              <property name="sizePolicy">
           <bool>false</bool>
          </property>
          <property name="text">
-          <string/>
+          <string>All</string>
          </property>
          <property name="icon">
           <iconset resource="../vvIcons.qrc">
-           <normaloff>:/common/icons/exit.png</normaloff>:/common/icons/exit.png</iconset>
+           <normaloff>:/common/icons/standardbutton-cancel-16.png</normaloff>:/common/icons/standardbutton-cancel-16.png</iconset>
          </property>
         </widget>
        </item>
diff --git a/vv/qt_ui/vvToolTest.ui b/vv/qt_ui/vvToolTest.ui
new file mode 100644 (file)
index 0000000..01279b5
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolTest</class>
+ <widget class="QWidget" name="vvToolTest">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>433</width>
+    <height>222</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Test sphere</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="Line" name="line_3">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
index 944fea4a290d3255b532f947624187311cac05f9..69a68967b6209f21416124f0f2b02ba4cd769af0 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>179</width>
+    <width>194</width>
     <height>62</height>
    </rect>
   </property>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true"/>
+     <widget class="vvToolInputSelectorWidget" name="mToolInputSelectionWidget" native="true">
+      <property name="maximumSize">
+       <size>
+        <width>16777215</width>
+        <height>200</height>
+       </size>
+      </property>
+     </widget>
      <widget class="QWidget" name="mToolWidget" native="true">
       <property name="sizePolicy">
        <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
index 4d7c92cc63b1f25fb3b7f4685c1e65dace9ecffb..7ffecb5edbe6e4b3671005864ce82b435c31788d 100644 (file)
 #include "vtkObjectFactory.h"
 #include "vtkStreamingDemandDrivenPipeline.h"
 #include "vtkDataSetAttributes.h"
-
-#include <vtkstd/string>
+#include <vtkVersion.h>
+#include <vtkAlgorithm.h>
 
 #include <sys/stat.h>
 
 //----------------------------------------------------------------------------
-vtkCxxRevisionMacro(vtkVOXImageWriter, "DummyRevision");
 vtkStandardNewMacro(vtkVOXImageWriter);
 
 //----------------------------------------------------------------------------
@@ -55,9 +54,11 @@ vtkVOXImageWriter::~vtkVOXImageWriter()
 void vtkVOXImageWriter::Write( )
 {
   this->SetErrorCode(vtkErrorCode::NoError);
-
+#if VTK_MAJOR_VERSION <= 5
   this->GetInput()->UpdateInformation();
-
+#else
+  this->UpdateInformation();
+#endif
   // Error checking
   if (this->GetInput() == NULL ) {
     vtkErrorMacro(<<"Write:Please specify an input!");
@@ -70,7 +71,11 @@ void vtkVOXImageWriter::Write( )
   }
 
   int nDims = 3;
+#if VTK_MAJOR_VERSION <= 5
   int * ext = this->GetInput()->GetWholeExtent();
+#else
+  int * ext = this->GetInformation()->Get(vtkDataObject::DATA_EXTENT());
+#endif
   if ( ext[4] == ext[5] ) {
     nDims = 2;
     if ( ext[2] == ext[3] ) {
@@ -134,12 +139,15 @@ void vtkVOXImageWriter::Write( )
   origin[1] += ext[2] * spacing[1];
   origin[2] += ext[4] * spacing[2];
 
+#if VTK_MAJOR_VERSION <= 5
   this->GetInput()->SetUpdateExtent(ext[0], ext[1],
                                     ext[2], ext[3],
                                     ext[4], ext[5]);
   this->GetInput()->UpdateData();
-
-
+#else
+  this->SetUpdateExtent(ext);
+  this->Update();
+#endif
   this->SetFileDimensionality(nDims);
 
   this->InvokeEvent(vtkCommand::StartEvent);
index 89b11a8a136c32ec0fd06482918ebb56edb09448..a4ce3e334a0fd601e8bf05d2ad6960ea4d3500ba 100644 (file)
@@ -15,7 +15,7 @@
   - BSD        See included LICENSE.txt file
   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
 ===========================================================================**/
-#ifndef __vtkVoxImageWriter_h
+#ifndef __vtkVOXImageWriter_h
 #define __vtkVOXImageWriter_h
 #include "vtkImageWriter.h"
 #include <string>
@@ -24,7 +24,7 @@
 class vtkVOXImageWriter : public vtkImageWriter
 {
 public:
-    vtkTypeRevisionMacro(vtkVOXImageWriter,vtkImageWriter);
+    vtkTypeMacro(vtkVOXImageWriter,vtkImageWriter);
     void PrintSelf(ostream& os, vtkIndent indent);
 
     // Description:
index 7071a1b8e22a78e23f5cd6271b21df7c191f0418..2502866a80b7ee953d4566c9af076f0028668b2c 100644 (file)
--- a/vv/vv.cxx
+++ b/vv/vv.cxx
 #include <QDesktopWidget>
 #include <QDir>
 
+#if VTK_MAJOR_VERSION > 5
+#include <vtkAutoInit.h>
+ VTK_MODULE_INIT(vtkInteractionStyle);
+ VTK_MODULE_INIT(vtkRenderingOpenGL);
+ VTK_MODULE_INIT(vtkRenderingFreeType);
+#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL)
+#endif
+
+
 #include "clitkIO.h"
 #include "vvMainWindow.h"
 #include "vvReadState.h"
@@ -78,11 +87,11 @@ void open_sequence(vvMainWindow &window,
   const std::string open_mode_names[] = {"base", "overlay", "fusion", "vf", "contour", "fusionSequence"};
   if(open_mode==O_BASE)
     window.LoadImages(sequence_filenames, vvImageReader::MERGEDWITHTIME);
-  else if (open_mode==O_OVERLAY)
+  else if (open_mode==O_OVERLAY && window.CheckAddedImage(n_image_loaded-1, "overlay"))
     window.AddOverlayImage(n_image_loaded-1,sequence_filenames,vvImageReader::MERGEDWITHTIME);
   else if (open_mode==O_LANDMARKS)
     window.AddLandmarks(n_image_loaded-1,sequence_filenames);
-  else if (open_mode==O_FUSION)
+  else if (open_mode==O_FUSION && window.CheckAddedImage(n_image_loaded-1, "fusion") && window.CheckAddedImage(n_image_loaded-1, "fusionSequence"))
     window.AddFusionImage(n_image_loaded-1,sequence_filenames,vvImageReader::MERGEDWITHTIME);
   else {
     std::cerr << "Sequences are not managed for opening " << open_mode_names[open_mode] << std::endl;
@@ -183,8 +192,8 @@ int main( int argc, char** argv )
                     << std::endl
                     << "These last options must follow a file name since they overlay something on an image:" << std::endl
                     << "--vf file      \t Overlay the vector field in file." << std::endl
-                    << "--overlay file \t Overlay the image in file with complementary colors." << std::endl
-                    << "--fusion file  \t Overlay the image in file with alpha blending and colormap." << std::endl
+                    << "--overlay [--sequence] file(s) \t Overlay the image in file with complementary colors." << std::endl
+                    << "--fusion [--sequence] file(s)  \t Overlay the image in file with alpha blending and colormap." << std::endl
                     //<< "--roi file     \t Overlay binary mask images. Option may be repeated on a single base image." << std::endl
                     << "--contour file \t Overlay DICOM RT-STRUCT contours." << std::endl
                     << "--landmarks [--sequence] file(s)  \t Overlay the landmarks in file(s) (.txt or .pts)." << std::endl;
@@ -274,13 +283,13 @@ int main( int argc, char** argv )
             first_of_wl_set = n_image_loaded-1;
           }
         }
-        else if (open_mode==O_VF)
+        else if (open_mode==O_VF && window.CheckAddedImage(n_image_loaded-1, "vector"))
           window.AddField(current.c_str(), n_image_loaded-1);
-        else if (open_mode==O_OVERLAY)
+        else if (open_mode==O_OVERLAY && window.CheckAddedImage(n_image_loaded-1, "overlay"))
           window.AddOverlayImage(n_image_loaded-1,image,vvImageReader::IMAGE);
         else if (open_mode==O_CONTOUR)
           window.AddDCStructContour(n_image_loaded-1,current.c_str());
-        else if (open_mode==O_FUSION)
+        else if (open_mode==O_FUSION && window.CheckAddedImage(n_image_loaded-1, "fusion") && window.CheckAddedImage(n_image_loaded-1, "fusionSequence"))
           window.AddFusionImage(n_image_loaded-1,image,vvImageReader::IMAGE);
         else if (open_mode==O_LANDMARKS)
           window.AddLandmarks(n_image_loaded-1,image);
index 8ba0f69062a3b0b2591c79ce409e3ddbcd1bbcf8..0ab7cb806d5c7aa7100ea1e620b73169f3763c2a 100644 (file)
@@ -1,8 +1,9 @@
 #include "vvAnimatedGIFWriter.h"
 #include "clitkDD.h"
 
-#include "ximagif.h"
-
+#include <vtkVersion.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
 #include <vtkImageData.h>
 #include <vtkImageQuantizeRGBToIndex.h>
 #include <vtkImageAppend.h>
@@ -10,6 +11,8 @@
 #include <vtkObjectFactory.h>
 #include <vtkLookupTable.h>
 
+#include "ximagif.h"
+
 //---------------------------------------------------------------------------
 vtkStandardNewMacro(vvAnimatedGIFWriter);
 
@@ -39,14 +42,25 @@ void vvAnimatedGIFWriter::Start()
 void vvAnimatedGIFWriter::Write()
 {
   // get the data
+#if VTK_MAJOR_VERSION <= 5
   this->GetInput()->UpdateInformation();
   int *wExtent = this->GetInput()->GetWholeExtent();
   this->GetInput()->SetUpdateExtent(wExtent);
   this->GetInput()->Update();
+#else
+  this->UpdateInformation();
+  int *wExtent = this->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT());
+  this->SetUpdateExtent(wExtent);
+  this->Update();
+#endif
 
   RGBslices.push_back( vtkSmartPointer<vtkImageData>::New() );
   RGBslices.back()->ShallowCopy(this->GetInput());
+#if VTK_MAJOR_VERSION <= 5
   RGBvolume->AddInput(RGBslices.back());
+#else
+  RGBvolume->AddInputData(RGBslices.back());
+#endif
 }
 
 //---------------------------------------------------------------------------
@@ -57,12 +71,20 @@ void vvAnimatedGIFWriter::End()
   // Quantize to 8 bit colors
   vtkSmartPointer<vtkImageQuantizeRGBToIndex> quant = vtkSmartPointer<vtkImageQuantizeRGBToIndex>::New();
   quant->SetNumberOfColors(256);
+#if VTK_MAJOR_VERSION <= 5
   quant->SetInput(RGBvolume->GetOutput());
+#else
+  quant->SetInputConnection(RGBvolume->GetOutputPort());
+#endif
   quant->Update();
 
   // Convert to 8 bit image
   vtkSmartPointer<vtkImageCast> cast =  vtkSmartPointer<vtkImageCast>::New();
+#if VTK_MAJOR_VERSION <= 5
   cast->SetInput( quant->GetOutput() );
+#else
+  cast->SetInputConnection( quant->GetOutputPort() );
+#endif
   cast->SetOutputScalarTypeToUnsignedChar();
   cast->Update();
 
index b4a4a3df204dfcd5ce4980939010c8bfd1bd756f..b5935c3692ea3a7c98afe69b14a7c5fba645bea5 100644 (file)
@@ -18,6 +18,9 @@
 
 #include "vvBinaryImageOverlayActor.h"
 #include "vvImage.h"
+#include <vtkVersion.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
 #include <vtkImageActor.h>
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 #include <vtkProperty.h>
 #include <vtkImageMapToRGBA.h>
 #include <vtkLookupTable.h>
+#include <vtkImageMapper3D.h>
 
 //------------------------------------------------------------------------------
 vvBinaryImageOverlayActor::vvBinaryImageOverlayActor()
-{
+{ 
   mTSlice = -1;
   mSlice = 0;
   mColor.resize(3);
@@ -49,7 +53,7 @@ vvBinaryImageOverlayActor::vvBinaryImageOverlayActor()
 
 //------------------------------------------------------------------------------
 vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor()
-{
+{ 
   mImageActorList.clear();
 }
 //------------------------------------------------------------------------------
@@ -57,7 +61,7 @@ vvBinaryImageOverlayActor::~vvBinaryImageOverlayActor()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::RemoveActors()
-{
+{ 
   for (unsigned int i = 0; i < mImageActorList.size(); i++) {
     if (mSlicer != 0) {
       if (mSlicer != NULL) {
@@ -75,7 +79,7 @@ void vvBinaryImageOverlayActor::RemoveActors()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetColor(double r, double g, double b)
-{
+{ 
   mColor[0] = r;
   mColor[1] = g;
   mColor[2] = b;
@@ -85,7 +89,7 @@ void vvBinaryImageOverlayActor::SetColor(double r, double g, double b)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer)
-{
+{ 
   mSlicer = slicer;
 }
 //------------------------------------------------------------------------------
@@ -93,7 +97,7 @@ void vvBinaryImageOverlayActor::SetSlicer(vvSlicer * slicer)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
-{
+{ 
   if (!mSlicer) {
     std::cerr << "ERROR. Please use setSlicer before setSlicer in vvBinaryImageOverlayActor." << std::endl;
     exit(0);
@@ -107,10 +111,30 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
     // how many intensity ?
     vtkSmartPointer<vtkImageMapToRGBA> mOverlayMapper = vtkSmartPointer<vtkImageMapToRGBA>::New();
-    mOverlayMapper->SetInput(mImage->GetVTKImages()[0]); // DS TODO : to change if it is 4D !!!
+    if (mImage->IsTimeSequence())
+    {
+ #if VTK_MAJOR_VERSION <= 5
+        mOverlayMapper->SetInput(mImage->GetVTKImages()[numImage]);
+#else
+        mOverlayMapper->SetInputData(mImage->GetVTKImages()[numImage]);
+#endif
+    }
+    else {
+#if VTK_MAJOR_VERSION <= 5
+        mOverlayMapper->SetInput(mImage->GetVTKImages()[0]);
+#else
+        mOverlayMapper->SetInputData(mImage->GetVTKImages()[0]);
+#endif
+    }
 
     double range[2];
-    mImage->GetVTKImages()[0]->GetScalarRange(range);
+    if (mImage->IsTimeSequence())
+    {
+        mImage->GetVTKImages()[numImage]->GetScalarRange(range);
+    }
+    else {
+        mImage->GetVTKImages()[0]->GetScalarRange(range);
+    }
     int n = range[1]-range[0]+1;
     mColorLUT->SetRange(range[0],range[1]);
     mColorLUT->SetNumberOfTableValues(n);
@@ -133,7 +157,11 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
     mOverlayMapper->SetLookupTable(mColorLUT);
 
     vtkSmartPointer<vtkImageActor> mOverlayActor = vtkSmartPointer<vtkImageActor>::New();
+#if VTK_MAJOR_VERSION <= 5
     mOverlayActor->SetInput(mOverlayMapper->GetOutput());
+#else
+    mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort());
+#endif
     mOverlayActor->SetPickable(0);
     mOverlayActor->SetVisibility(IsVisible);
     //mOverlayActor->SetOpacity(1.0);  
@@ -144,7 +172,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
 
     mMapperList.push_back(mOverlayMapper);
     mImageActorList.push_back(mOverlayActor);
-    mSlicer->GetRenderer()->AddActor(mOverlayActor);
+    mSlicer->GetRenderer()->AddActor(mImageActorList[numImage]);
   }
 }
 //------------------------------------------------------------------------------
@@ -152,7 +180,7 @@ void vvBinaryImageOverlayActor::Initialize(bool IsVisible)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetOpacity(double d)
-{
+{ 
   mAlpha = d;
 }
 //------------------------------------------------------------------------------
@@ -194,7 +222,7 @@ void vvBinaryImageOverlayActor::SetOpacity(double d)
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool modeBG)
-{
+{ 
   mImage = image;
   if (modeBG) {
     mBackgroundValue = bg;
@@ -210,7 +238,7 @@ void vvBinaryImageOverlayActor::SetImage(vvImage::Pointer image, double bg, bool
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::HideActors()
-{
+{ 
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   for(unsigned int i=0; i<mImageActorList.size(); i++) {
@@ -224,14 +252,12 @@ void vvBinaryImageOverlayActor::HideActors()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::ShowActors()
-{
+{ 
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   mTSlice = mSlicer->GetTSlice();
-  //  for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
   mImageActorList[mTSlice]->VisibilityOn();
   UpdateSlice(0, mSlice);
-  //}
   // Caller MUST call Render
   //mSlicer->Render();
 }
@@ -240,7 +266,7 @@ void vvBinaryImageOverlayActor::ShowActors()
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::UpdateColor()
-{
+{ 
   mColorLUT->SetTableValue(1, mColor[0], mColor[1], mColor[2], mAlpha); // FG
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
     // how many intensity ?
@@ -248,14 +274,18 @@ void vvBinaryImageOverlayActor::UpdateColor()
     mOverlayMapper->SetLookupTable(mColorLUT);
 
     vtkImageActor * mOverlayActor = mImageActorList[numImage];
+#if VTK_MAJOR_VERSION <= 5
     mOverlayActor->SetInput(mOverlayMapper->GetOutput());
+#else
+    mOverlayActor->SetInputData(mOverlayMapper->GetOutput());
+#endif
   }
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice, bool force)
-{
+{ 
   if (!mSlicer) return;
 
   if (!force) {
@@ -275,8 +305,14 @@ void vvBinaryImageOverlayActor::UpdateSlice(int slicer, int slice, bool force)
   int orientation = mSlicer->GetOrientation();
   int maskExtent[6];
   ComputeExtent(orientation, mSlice, imageExtent, maskExtent);
-  ComputeExtent(maskExtent, maskExtent, mSlicer->GetImage()->GetFirstVTKImageData(), mImage->GetFirstVTKImageData());
+  ComputeExtent(maskExtent, maskExtent, mSlicer->GetImage()->GetVTKImages()[mTSlice], mImage->GetVTKImages()[mTSlice]);
+#if VTK_MAJOR_VERSION <= 5
   mSlicer->ClipDisplayedExtent(maskExtent, mMapperList[mTSlice]->GetInput()->GetWholeExtent());
+#else
+  mSlicer->ClipDisplayedExtent(maskExtent, mMapperList[mTSlice]->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT()));
+#endif
+  HideActors();
+  mImageActorList[mTSlice]->VisibilityOn();
   SetDisplayExtentAndCameraPosition(orientation, mSlice, maskExtent, mImageActorList[mTSlice], mDepth);
 
   // set previous slice
@@ -291,7 +327,7 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation,
                                              int slice,
                                              int * inExtent,
                                              int * outExtent)
-{
+{ 
   switch (orientation) {
   case vtkImageViewer2::SLICE_ORIENTATION_XY:
     for(int i=0; i<4; i++) outExtent[i] = inExtent[i];
@@ -313,7 +349,7 @@ void vvBinaryImageOverlayActor::ComputeExtent(int orientation,
 
 //----------------------------------------------------------------------------
 void vvBinaryImageOverlayActor::ComputeExtent(int * inExtent, int * outExtent, vtkImageData * image, vtkImageData * overlay)
-{
+{ 
   for(int i=0; i<3; i++) {
     double a = (image->GetOrigin()[i] + inExtent[i*2]*image->GetSpacing()[i] - 
                 overlay->GetOrigin()[i]) / overlay->GetSpacing()[i];
@@ -341,7 +377,7 @@ void vvBinaryImageOverlayActor::SetDisplayExtentAndCameraPosition(int orientatio
                                                                  int * extent,
                                                                  vtkImageActor * actor,
                                                                  double position)
-{
+{ 
   /* FIXME
      Error according to camera orientation
    */
index 5d429a8b71f1c15d9486320f47ba53612be0fdc8..12a2959aa33679b8ab5f6bde9349e0d859eeba5c 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "vtkVOXImageWriter.h"
 #include <vtkImageData.h>
+#include <vtkVersion.h>
 
 #include "clitkCommon.h"
 #include "vvSlicerManager.h"
@@ -133,7 +134,11 @@ void vvDeformableRegistration::run()
   for (unsigned int i=0; i<images.size(); i++) {
     std::stringstream filename;
     filename << temp_dir << "/temp_" << i << ".vox";
+#if VTK_MAJOR_VERSION <= 5
     vox->SetInput(images[i]);
+#else
+    vox->SetInputData(images[i]);
+#endif
     vox->SetFileName(filename.str().c_str());
     if (i==refimage)
       ref_file=filename.str();
index 594996011266e8b19df3f6ddd071611f71727f37..1856dd272602231ebce81c60c099174390e7c24b 100644 (file)
@@ -17,6 +17,7 @@
 ===========================================================================**/
 #include "vvGlyph2D.h"
 
+#include <vtkVersion.h>
 #include "vtkCell.h"
 #include "vtkDataSet.h"
 #include "vtkFloatArray.h"
@@ -32,7 +33,6 @@
 #include "vtkTransform.h"
 #include "vtkUnsignedCharArray.h"
 
-vtkCxxRevisionMacro(vvGlyph2D, "DummyRevision");
 vtkStandardNewMacro(vvGlyph2D);
 
 vvGlyph2D::vvGlyph2D()
@@ -171,9 +171,14 @@ int vvGlyph2D::RequestData(
     defaultPointIds[0] = 0;
     defaultPointIds[1] = 1;
     defaultSource->SetPoints(defaultPoints);
-    defaultSource->InsertNextCell(VTK_LINE, 2, defaultPointIds);
+    defaultSource->InsertNextCell(VTK_LINE, 2, defaultPointIds); 
+#if VTK_MAJOR_VERSION <= 5
     defaultSource->SetUpdateExtent(0, 1, 0);
     this->SetSource(defaultSource);
+#else
+    this->SetUpdateExtent(0, 1, 0);
+    this->SetSourceData(defaultSource);
+#endif
     defaultSource->Delete();
     defaultSource = NULL;
     defaultPoints->Delete();
index 6ffd68deeb7e555fff9380b49cbe9d5960836647..377bf34433e2571c82ef93d5c657fcebaf17b8d2 100644 (file)
@@ -22,7 +22,7 @@
 class vvGlyph2D : public vtkGlyph3D
 {
 public:
-    vtkTypeRevisionMacro(vvGlyph2D,vtkGlyph3D);
+    vtkTypeMacro(vvGlyph2D,vtkGlyph3D);
     void PrintSelf(ostream& os, vtkIndent indent);
 
     // Description
index 949ecf19010f09571ab7d9d8eb3e550953b168df..3a6763b480aab632c7c199a151f8902e6466a4f5 100644 (file)
@@ -26,7 +26,6 @@
 #include "vtkPolyData.h"
 #include "vtkUnsignedCharArray.h"
 
-vtkCxxRevisionMacro(vvGlyphSource, "DummyRevision");
 vtkStandardNewMacro(vvGlyphSource);
 
 
index a9bebf9944d3d2eb58c425c59fd2f84256b40974..c3db9a06c7dc6a0a03f694407cc03ca1afc5d487 100644 (file)
@@ -25,7 +25,7 @@ class vvGlyphSource: public vtkGlyphSource2D
 {
 public:
     static vvGlyphSource *New();
-    vtkTypeRevisionMacro(vvGlyphSource,vtkGlyphSource2D);
+    vtkTypeMacro(vvGlyphSource,vtkGlyphSource2D);
     void PrintSelf(ostream& os, vtkIndent indent);
 
     void SetGlyphTypeToSpecificArrow() {
index 0737e3c3ec80fefd4802b112469c371340bcc233..a5e31ccdfbfc6853ade30da993a50c4498b868ee 100644 (file)
@@ -12,6 +12,7 @@
     <file>icons/8b.png</file>
     <file>icons/1b.png</file>
     <file>icons/binarize.png</file>
+    <file>icons/profile.png</file>
     <file>icons/resample.png</file>
     <file>icons/crop.png</file>
     <file>icons/splashscreen2.png</file>
index 4fecf93e9371f52703dfc9634899547f74965f11..ac43af2cc6a5467be57478aea07c69607f8b5b14 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "vvImageContour.h"
 #include "vvImage.h"
+#include <vtkVersion.h>
 #include <vtkImageActor.h>
 #include <vtkCamera.h>
 #include <vtkRenderer.h>
 #include <vtkImageData.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkProperty.h>
+#include <vtkInformation.h>
 
 //------------------------------------------------------------------------------
 vvImageContour::vvImageContour()
-{
+{ 
   mTSlice = -1;
   mSlice = 0;
   mHiddenImageIsUsed = false;
@@ -44,7 +46,7 @@ vvImageContour::vvImageContour()
 
 //------------------------------------------------------------------------------
 vvImageContour::~vvImageContour()
-{
+{ 
   mSquaresActorList.clear();
 }
 //------------------------------------------------------------------------------
@@ -52,7 +54,7 @@ vvImageContour::~vvImageContour()
 
 //------------------------------------------------------------------------------
 void vvImageContour::RemoveActors()
-{
+{ 
   for (unsigned int i = 0; i < mSquaresActorList.size(); i++) {
     if (mSlicer != 0) {
       if (mSlicer!= NULL) {
@@ -69,7 +71,8 @@ void vvImageContour::RemoveActors()
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::SetSlicer(vvSlicer * slicer) {
+void vvImageContour::SetSlicer(vvSlicer * slicer) 
+{ 
   mSlicer = slicer;  
   // Create an actor for each time slice
   for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) {
@@ -80,9 +83,14 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::SetImage(vvImage::Pointer image) {
+void vvImageContour::SetImage(vvImage::Pointer image) 
+{ 
   for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) {
+#if VTK_MAJOR_VERSION <= 5
     mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]);
+#else
+    mClipperList[numImage]->SetInputData(image->GetVTKImages()[numImage]);
+#endif
   }
   mHiddenImageIsUsed = true;
   mHiddenImage = image;
@@ -91,7 +99,8 @@ void vvImageContour::SetImage(vvImage::Pointer image) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::SetPreserveMemoryModeEnabled(bool b) {
+void vvImageContour::SetPreserveMemoryModeEnabled(bool b) 
+{ 
   // FastCache mode work only if threshold is always the same
   if (mDisplayModeIsPreserveMemory == b) return;
   mDisplayModeIsPreserveMemory = b;
@@ -111,9 +120,11 @@ void vvImageContour::SetPreserveMemoryModeEnabled(bool b) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::SetColor(double r, double g, double b) {
+void vvImageContour::SetColor(double r, double g, double b) 
+{ 
   for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
     mSquaresActorList[i]->GetProperty()->SetColor(r,g,b);
+    mSquaresActorList[i]->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
   }
 }
 //------------------------------------------------------------------------------
@@ -121,7 +132,7 @@ void vvImageContour::SetColor(double r, double g, double b) {
 
 //------------------------------------------------------------------------------
 void vvImageContour::SetLineWidth(double w)
-{
+{ 
   for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
     mSquaresActorList[i]->GetProperty()->SetLineWidth(w);
   }
@@ -130,7 +141,8 @@ void vvImageContour::SetLineWidth(double w)
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::HideActors() {
+void vvImageContour::HideActors() 
+{ 
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
@@ -141,7 +153,8 @@ void vvImageContour::HideActors() {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::ShowActors() {
+void vvImageContour::ShowActors() 
+{ 
   if (!mSlicer) return;
   mSlice = mSlicer->GetSlice();
   mTSlice = mSlicer->GetTSlice();
@@ -166,7 +179,8 @@ void vvImageContour::SetDepth(double d)
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
-void vvImageContour::Update(double value) {
+void vvImageContour::Update(double value) 
+{ 
   if (!mSlicer) return;
   if (mPreviousValue == value) {
     if (mPreviousSlice == mSlicer->GetSlice()) {
@@ -202,7 +216,8 @@ void vvImageContour::Update(double value) {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::UpdateWithPreserveMemoryMode() {
+void vvImageContour::UpdateWithPreserveMemoryMode() 
+{ 
   // Only change actor visibility if tslice change
   mPreviousTslice = mTSlice;
   mTSlice = mSlicer->GetTSlice();
@@ -218,14 +233,15 @@ void vvImageContour::UpdateWithPreserveMemoryMode() {
   if (mPreviousTslice != mTSlice) {
     if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff();
   }
-  
-  mSlicer->Render();
+
+  //mSlicer->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::InitializeCacheMode() {
+void vvImageContour::InitializeCacheMode() 
+{ 
 clitkExceptionMacro("TODO : not implemented yet");
   mPreviousSlice = mPreviousOrientation = 0;
   int dim = mSlicer->GetImage()->GetNumberOfDimensions();
@@ -243,7 +259,8 @@ clitkExceptionMacro("TODO : not implemented yet");
 
 
 //------------------------------------------------------------------------------
-int vvImageContour::ComputeCurrentOrientation() {
+int vvImageContour::ComputeCurrentOrientation() 
+{ 
   // Get extent of image in the slicer
   int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
 
@@ -261,7 +278,8 @@ int vvImageContour::ComputeCurrentOrientation() {
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::UpdateWithFastCacheMode() {
+void vvImageContour::UpdateWithFastCacheMode() 
+{ 
 clitkExceptionMacro("TODO : not implemented yet");
 
   // Compute orientation
@@ -289,22 +307,37 @@ clitkExceptionMacro("TODO : not implemented yet");
 
 
 //------------------------------------------------------------------------------
-void vvImageContour::CreateNewActor(int numImage) {
+void vvImageContour::CreateNewActor(int numImage) 
+{ 
   vtkSmartPointer<vtkActor> squaresActor = vtkSmartPointer<vtkActor>::New();
   vtkSmartPointer<vtkImageClip> clipper = vtkSmartPointer<vtkImageClip>::New();
   vtkSmartPointer<vtkMarchingSquares> squares = vtkSmartPointer<vtkMarchingSquares>::New();
   vtkSmartPointer<vtkPolyDataMapper> squaresMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
 
-  if (mHiddenImageIsUsed)
+  if (mHiddenImageIsUsed) {
+#if VTK_MAJOR_VERSION <= 5
     clipper->SetInput(mHiddenImage->GetVTKImages()[0]);
-  else
+#else
+    clipper->SetInputData(mHiddenImage->GetVTKImages()[0]);
+#endif
+  } else {
+#if VTK_MAJOR_VERSION <= 5
     clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]);
-  
+#else
+    clipper->SetInputData(mSlicer->GetImage()->GetVTKImages()[numImage]);
+#endif
+  }
+#if VTK_MAJOR_VERSION <= 5
   squares->SetInput(clipper->GetOutput());
   squaresMapper->SetInput(squares->GetOutput());
+#else
+  squares->SetInputConnection(clipper->GetOutputPort(0));
+  squaresMapper->SetInputConnection(squares->GetOutputPort(0));
+#endif
   squaresMapper->ScalarVisibilityOff();
   squaresActor->SetMapper(squaresMapper);
   squaresActor->GetProperty()->SetColor(1.0,0,0);
+  squaresActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
   squaresActor->SetPickable(0);
   squaresActor->VisibilityOff();
   mSlicer->GetRenderer()->AddActor(squaresActor);
@@ -322,10 +355,11 @@ void vvImageContour::UpdateActor(vtkActor * actor,
                                  vtkPolyDataMapper * mapper, 
                                  vtkMarchingSquares * squares, 
                                  vtkImageClip * clipper, 
-                                 double threshold, int orientation, int slice) {
+                                 double threshold, int orientation, int slice) 
+{ 
   // Set parameter for the MarchigSquare
   squares->SetValue(0, threshold);
-
+  squares->Update();
   // Get image extent
   int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
 
@@ -362,10 +396,10 @@ void vvImageContour::UpdateActor(vtkActor * actor,
     extent2 = extent;
     actor->VisibilityOn();
   }
+  
   clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2],
                                 extent2[3],extent2[4],extent2[5]);
-
+                                
   if (mHiddenImageIsUsed) delete extent2;
 
   // Move the actor to be visible
@@ -374,7 +408,6 @@ void vvImageContour::UpdateActor(vtkActor * actor,
   // DD(mDepth);
   // position[orientation] = -mDepth;
   // actor->SetPosition(position);
-  
   mapper->Update();
 }
 //------------------------------------------------------------------------------
index ff6580387a3c93aaef6c0af3a17c023f57a413d6..2890ec8188efd8e22a98da6b5e6c0527bcac0272 100644 (file)
@@ -101,11 +101,7 @@ void vvImageWarp::Update_WithDimAndPixelType()
     jacobian_filter->SetUseImageSpacingOn();
     vf_connector->SetInput(mVF->GetVTKImages()[num]);
     warp_filter->SetInput(input[num]);
-#if ITK_VERSION_MAJOR >= 4
     warp_filter->SetDisplacementField(vf_connector->GetOutput());
-#else
-    warp_filter->SetDeformationField(vf_connector->GetOutput());
-#endif
     jacobian_filter->SetInput(vf_connector->GetOutput());
     warp_filter->SetOutputSpacing(input[num]->GetSpacing());
     warp_filter->SetOutputOrigin(input[num]->GetOrigin());
index 41b3ef105f16b21ee80fcf8103dc071736aa82c6..722e5343c91f54803abe4f1ceb874c9a6bfa2133 100644 (file)
@@ -19,6 +19,7 @@
 #define VVINTENSITYVALUESLIDER_H
 
 // qt
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
 
index ac37a8fd22c95442157365a2a03ad3409d662ed1..8ddc4df78c71c06a24a8466ac40664ede6a9ef4a 100644 (file)
@@ -29,8 +29,6 @@
 #include <vtkRendererCollection.h>
 #include "clitkCommon.h"
 
-
-vtkCxxRevisionMacro(vvInteractorStyleNavigator, "DummyRevision");
 vtkStandardNewMacro(vvInteractorStyleNavigator);
 
 //----------------------------------------------------------------------------
index 5b3da5d19be2aaf67fab33d31e1c2fe8aeb307fc..e0de7c0fc0fda275f06fa261b45b17f46747c391 100644 (file)
@@ -29,7 +29,7 @@ class vvInteractorStyleNavigator : public vtkInteractorStyle
 {
 public:
     static vvInteractorStyleNavigator *New();
-    vtkTypeRevisionMacro(vvInteractorStyleNavigator, vtkInteractorStyle);
+    vtkTypeMacro(vvInteractorStyleNavigator, vtkInteractorStyle);
     void PrintSelf(ostream& os, vtkIndent indent);
 
     // Description:
index 62ae8892184e89b381946c040c0cb8ecd4633701..eadf342cb14812b8edb9554e7e360bb06d299918 100644 (file)
@@ -23,6 +23,7 @@
 #include "vvImage.h"
 
 // qt
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
 #include "ui_vvLabelImageLoaderWidget.h"
index fed697ebc2a218943ac125b4676e15ac1f3afd70..dc38cd228f69b27981960e24b220bf3fafa5c4eb 100644 (file)
@@ -23,6 +23,7 @@
 #include <string>
 #include <locale.h>
 
+#include <vtkVersion.h>
 #include "vtkPolyData.h"
 #include "vtkPoints.h"
 #include "vtkFloatArray.h"
@@ -117,6 +118,41 @@ void vvLandmarks::RemoveLastLandmark()
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+void vvLandmarks::RemoveLandmarkWithLabel(vtkStdString label, int time)
+{
+  if (label != "P1" && label != "P2")
+    return;
+  // erase a vtkPoint by shifiting the array .
+  // not a problem here because there are no 
+  // pologyons linking the points
+  int t = time;//mLandmarks[index].coordinates[3];
+  int npoints = mPoints[t]->GetNumberOfPoints();
+  
+  //search of the index corresponding to the label
+  int index(0);
+  while (mLabels[t]->GetValue(index) != label)
+    ++index;
+  
+  for (int i = index; i < npoints - 1; i++) {
+    mPoints[t]->InsertPoint(i, mPoints[t]->GetPoint(i+1));
+       std::string str_i;                   // string which will contain the result
+       std::ostringstream convert;      // stream used for the conversion
+       convert << i;                        // insert the textual representation of 'i' in the characters in the stream
+       str_i = convert.str();           // set 'str_i' to the contents of the stream
+       mLabels[t]->SetValue(i,mLabels[t]->GetValue(i+1));
+    }
+  mPoints[t]->SetNumberOfPoints(npoints-1);
+  mLabels[t]->SetNumberOfValues(npoints-1);
+  mLabels[t]->Modified();
+  mPolyData->Modified();
+
+  mLandmarks[t].erase(mLandmarks[t].begin() + index);
+  mIds[t]->RemoveLastTuple();
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 void vvLandmarks::RemoveLandmark(int index)
 {
@@ -451,7 +487,11 @@ void vvLandmarks::SetTime(int time)
     mPolyData->GetPointData()->SetScalars(mIds[time]);
     mPolyData->GetPointData()->AddArray(mLabels[time]);
     mPolyData->Modified();
+#if VTK_MAJOR_VERSION <= 5
     mPolyData->Update();
+#else
+    //mPolyData->Update();
+#endif
     mTime = time;
   }
 }
index 7920d6f9357787b3ccea6ff27b2e80214a4932d1..6f7e91ff99c6635f83303c0e69c7c924a887c745 100644 (file)
@@ -44,6 +44,7 @@ public :
 
     void AddLandmark(float x,float y,float z,float t,double value);
     void RemoveLastLandmark();
+    void RemoveLandmarkWithLabel(vtkStdString, int);
     void RemoveLandmark(int index);
     void RemoveAll();
     
@@ -51,6 +52,7 @@ public :
     float* GetCoordinates(int index);
     double GetPixelValue(int index);
     std::string GetComments(int index);
+    vtkStringArray* GetLabels() { return mLabels[mTime]; }
     unsigned int GetNumberOfPoints() { return (unsigned int) mLandmarks[mTime].size(); }
     //int GetNumberOfSources(){return mText.size();}
 
index d3d80c288ec0264cb326d81409d6f0d770361637..d25173132f7d7993fe86f6c8745b8f9e5dc3fd65 100644 (file)
@@ -27,7 +27,6 @@
 #include "vtkUnsignedCharArray.h"
 #include <cassert>
 
-vtkCxxRevisionMacro(vvLandmarksGlyph, "DummyRevision");
 vtkStandardNewMacro(vvLandmarksGlyph);
 
 #define vtkfont_width 9
index 8b5020d30ac8776530000dde03e30fa8435f3d29..a8fe029552af7aa1b479a332f742308522a3dca3 100644 (file)
@@ -23,7 +23,7 @@
 class vvLandmarksGlyph : public vtkTextSource
 {
 public:
-    vtkTypeRevisionMacro(vvLandmarksGlyph,vtkTextSource);
+    vtkTypeMacro(vvLandmarksGlyph,vtkTextSource);
     void PrintSelf(ostream& os, vtkIndent indent);
 
     // Description:
index 2d3e1a5503ca4f0702e13947935035afd690d16f..f23631cb1ca734fd41e3e946145c0bb64ceb6563 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <QtGui>
 #include <Qt>
+#include <QFileDialog>
 #include "QTreePushButton.h"
 #include "vvLandmarks.h"
 
@@ -29,7 +30,7 @@
 
 //====================================================================
 vvLandmarksPanel::vvLandmarksPanel(QWidget * parent):QWidget(parent)
-{
+{ 
   setupUi(this);
 
   tableWidget->verticalHeader()->hide();
@@ -47,7 +48,7 @@ vvLandmarksPanel::vvLandmarksPanel(QWidget * parent):QWidget(parent)
 }
 
 void vvLandmarksPanel::Load()
-{
+{ 
   QString file = QFileDialog::getOpenFileName(this,tr("Load Landmarks"),
                  mCurrentPath.c_str(),tr("Landmarks ( *.txt *.pts)"));
   if (!file.isEmpty()) {
@@ -57,17 +58,17 @@ void vvLandmarksPanel::Load()
 }
 
 bool vvLandmarksPanel::LoadFromFile(std::vector<std::string> files)
-{
+{ 
   if (!mCurrentLandmarks->LoadFile(files))
     return false;
   
-  SetCurrentLandmarks(mCurrentLandmarks,2);
+  SetCurrentLandmarks(mCurrentLandmarks,0);
   emit UpdateRenderWindows();
   return true;
 }
 
 void vvLandmarksPanel::Save()
-{
+{ 
   QString file = QFileDialog::getSaveFileName(this,
                  tr("Save Landmarks"),
                  mCurrentPath.c_str(),tr("Landmarks ( *.txt)"));
@@ -80,7 +81,7 @@ void vvLandmarksPanel::Save()
 }
 
 void vvLandmarksPanel::SelectPoint()
-{
+{ 
   if (tableWidget->rowCount() > 0) {
     QList<QTableWidgetItem *> items = tableWidget->selectedItems();
     if (!items.empty()) {
@@ -99,7 +100,7 @@ void vvLandmarksPanel::SelectPoint()
 
 
 void vvLandmarksPanel::RemoveSelectedPoints()
-{
+{ 
   if (tableWidget->rowCount() > 0) {
     QList<QTableWidgetItem *> items = tableWidget->selectedItems();
     if (items.empty()) {
@@ -123,7 +124,7 @@ void vvLandmarksPanel::RemoveSelectedPoints()
 }
 
 void vvLandmarksPanel::RemoveAllPoints()
-{
+{ 
   mCurrentLandmarks->RemoveAll();
   tableWidget->clearContents();
   tableWidget->setRowCount(0);
@@ -131,12 +132,12 @@ void vvLandmarksPanel::RemoveAllPoints()
 }
 
 void vvLandmarksPanel::AddPoint()
-{
+{ 
   AddPoint(mCurrentLandmarks->GetNumberOfPoints()-1);
 }
 
 void vvLandmarksPanel::AddPoint(int landmarksIndex)
-{
+{ 
   int rowIndex = tableWidget->rowCount();
 //   DD(rowIndex);
   tableWidget->setRowCount(rowIndex+1);
@@ -175,10 +176,9 @@ void vvLandmarksPanel::AddPoint(int landmarksIndex)
 }
 
 void vvLandmarksPanel::SetCurrentLandmarks(vvLandmarks* lm,int time)
-{
+{ 
   if (time != lm->GetTime())
     return;
-  
   loadButton->setEnabled(1);
   saveButton->setEnabled(1);
   removeButton->setEnabled(1);
@@ -186,7 +186,8 @@ void vvLandmarksPanel::SetCurrentLandmarks(vvLandmarks* lm,int time)
   tableWidget->clearContents();
   tableWidget->setRowCount(0);
   for (unsigned int i = 0; i < mCurrentLandmarks->GetNumberOfPoints(); i++) {
-      AddPoint(i);
+      if ((mCurrentLandmarks->GetLabels()->GetValue(i) != "P1") && (mCurrentLandmarks->GetLabels()->GetValue(i) != "P2"))
+        AddPoint(i);
   }
   //if (time > 1)
   //tableWidget->setColumnHidden(4,1);
@@ -196,14 +197,14 @@ void vvLandmarksPanel::SetCurrentLandmarks(vvLandmarks* lm,int time)
 }
 
 void vvLandmarksPanel::SetCurrentImage(std::string filename)
-{
+{ 
   QString image = "<b>CurrentImage : </b>";
   image += vtksys::SystemTools::GetFilenameWithoutLastExtension(filename).c_str();
   nameLabel->setText(image);
 }
 
 void vvLandmarksPanel::CommentsChanged(int row, int column)
-{
+{ 
   if (column == 6) {
     mCurrentLandmarks->ChangeComments(row,std::string(tableWidget->item(row,column)->text().toStdString()));
     tableWidget->resizeColumnsToContents();
index a566c3aa96bed30fa99bb5e958efdb71937b1f26..ba3f3136d721d1d5240d498d19fea343d57e13dc 100644 (file)
@@ -23,6 +23,7 @@ It is distributed under dual licence
 #include "QTreePushButton.h"
 #include <QUrl>
 #include <QSettings>
+#include <QShortcut>
 
 // VV include
 #include "vvMainWindow.h"
@@ -52,6 +53,9 @@ It is distributed under dual licence
 #endif
 #include "clitkConfiguration.h"
 #include "clitkMatrix.h"
+#ifdef Q_OS_OSX
+# include "vvOSXHelper.h"
+#endif
 
 // ITK include
 #include <itkImage.h>
@@ -61,6 +65,9 @@ It is distributed under dual licence
 #include <itkNumericSeriesFileNames.h>
 
 // VTK include
+#include <vtkImageMapper3D.h>
+#include <vtkInformation.h>
+#include <vtkVersion.h>
 #include <vtkImageData.h>
 #include <vtkImageActor.h>
 #include <vtkCornerAnnotation.h>
@@ -106,9 +113,9 @@ It is distributed under dual licence
 #define COLUMN_IMAGE_NAME 7
 
 #ifdef CLITK_PRIVATE_FEATURES
-#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf *.svl)"
+#define EXTENSIONS "Images ( *.bmp *.dcm *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz *.usf *.svl)"
 #else
-#define EXTENSIONS "Images ( *.bmp *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)"
+#define EXTENSIONS "Images ( *.bmp *.dcm *.png *.jpeg *.jpg *.tif *.mhd *.mha *.hdr *.vox *.his *.xdr *.SCAN *.nii *.nrrd *.nhdr *.refscan *.nii.gz)"
 #endif
 
 
@@ -124,9 +131,14 @@ It is distributed under dual licence
 
 //------------------------------------------------------------------------------
 vvMainWindow::vvMainWindow():vvMainWindowBase()
-{
+{ 
   setupUi(this); // this sets up the GUI
+
   setDicomClient();
+
+  //Qt::WindowFlags flags = windowFlags();
+  //setWindowFlags(flags | Qt::WindowStaysOnTopHint);
+
   mInputPathName = "";
   mMenuTools = menuTools;
   //  mMenuSegmentation = menuSegmentation;
@@ -143,7 +155,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
   contextActions.resize(0);
   QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/common/icons/fileopen.png")),
     tr("O&pen new Image"));
-  actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O")));
   connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages()));
   contextActions.push_back(actionOpen_new_image);
   contextMenu.addSeparator();
@@ -197,21 +208,6 @@ vvMainWindow::vvMainWindow():vvMainWindowBase()
     tr("Reset transformation to identity"));
   connect(actionResetMatrix, SIGNAL(triggered()), this,SLOT(ResetTransformationToIdentity()));
 
-  // TRIAL DS
-  /*
-  QMenu * m = new QMenu(menubar);
-  m->setTitle("TOTO");
-  //  m->setObjectName(QString::fromUtf8("TOTOTO"));
-  contextMenu.addMenu(m);
-  QAction * a = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
-  tr("BIDON"));
-  QAction * b = m->addAction(QIcon(QString::fromUtf8(":/common/icons/GPSup.png")),
-  tr("BIDON2"));
-  m->addAction(a);
-  m->addAction(b);
-  connect(a,SIGNAL(triggered()),this,SLOT(AddFusionImage()));
-  */
-
   //init the DataTree
   mSlicerManagers.resize(0);
 
@@ -302,6 +298,11 @@ connect(actionConnect_Pacs,SIGNAL(triggered()),this,SLOT(ConnectPacs()));
   connect(actionAdd_overlay_image_to_current_image,SIGNAL(triggered()), this,SLOT(SelectOverlayImage()));
   connect(actionAdd_USSequence_toCT,SIGNAL(triggered()), this,SLOT(SelectFusionSequence()));
   connect(actionNavigation_Help,SIGNAL(triggered()),this,SLOT(ShowHelpDialog()));
+
+  QShortcut *shortcutHelp = new QShortcut(QKeySequence(QKeySequence::HelpContents),this);
+  shortcutHelp->setContext(Qt::ApplicationShortcut);
+  QObject::connect(shortcutHelp, SIGNAL(activated()), this, SLOT(ShowHelpDialog()));
+
   connect(actionDocumentation,SIGNAL(triggered()),this,SLOT(ShowDocumentation()));
   connect(actionRegister_vv,SIGNAL(triggered()),this,SLOT(PopupRegisterForm()));
 
@@ -369,6 +370,13 @@ connect(actionConnect_Pacs,SIGNAL(triggered()),this,SLOT(ConnectPacs()));
   SOViewWidget->hide();
   SEViewWidget->hide();
 
+#ifdef Q_OS_OSX
+  disableGLHiDPI(NOViewWidget->winId());
+  disableGLHiDPI(NEViewWidget->winId());
+  disableGLHiDPI(SOViewWidget->winId());
+  disableGLHiDPI(SEViewWidget->winId());
+#endif
+
   //Recently opened files
   std::list<std::string> recent_files = GetRecentlyOpenedImages();
   recentlyOpenedFilesMenu=NULL;
@@ -381,25 +389,29 @@ connect(actionConnect_Pacs,SIGNAL(triggered()),this,SLOT(ConnectPacs()));
   vvToolManager::GetInstance()->InsertToolsInMenu(this);
   vvToolManager::GetInstance()->EnableToolsInMenu(this, false);
 
+//#ifndef CLITK_EXPERIMENTAL
+//#define CLITK_EXPERIMENTAL 0
+//#endif
+#ifdef CLITK_EXPERIMENTAL
   if (!CLITK_EXPERIMENTAL)
     menuExperimental->menuAction()->setVisible(false);
-
+#endif
 
   QTimer * timerMemory = new QTimer(this);
   //timerMemory->setInterval(5);
   connect(timerMemory, SIGNAL(timeout()), this, SLOT(UpdateMemoryUsage()));
   timerMemory->start(2000);
-
 }
+
 //------------------------------------------------------------------------------
 void vvMainWindow::show()
-{
+{ 
   vvMainWindowBase::show();
   PopupRegisterForm(true);
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateMemoryUsage()
-{
+{ 
   //  clitk::PrintMemory(true);
   if (clitk::GetMemoryUsageInMb() == 0) infoPanel->setMemoryInMb("NA");
   else infoPanel->setMemoryInMb(QString::number(clitk::GetMemoryUsageInMb())+" MiB");
@@ -409,7 +421,7 @@ void vvMainWindow::UpdateMemoryUsage()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::createRecentlyOpenedFilesMenu()
-{
+{ 
   recentlyOpenedFilesMenu = new QMenu("Recently opened files...");
   recentlyOpenedFilesMenu->setIcon(QIcon(QString::fromUtf8(":/common/icons/open.png")));
   menuFile->insertMenu(actionOpen_Image_With_Time,recentlyOpenedFilesMenu);
@@ -421,7 +433,7 @@ void vvMainWindow::createRecentlyOpenedFilesMenu()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list<std::string> &recent_files)
-{
+{ 
   if(recentlyOpenedFilesMenu==NULL) {
     createRecentlyOpenedFilesMenu();
   } else {
@@ -438,11 +450,11 @@ void vvMainWindow::updateRecentlyOpenedFilesMenu(const std::list<std::string> &r
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ComputeMidPosition()
-{
+{ 
   bool ok;
   int index=GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-  int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
-    mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
+  int ref = QInputDialog::getInt(this,"Chose reference phase","Reference phase",0,0,\
+mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
   if (ok) {
     vvMidPosition midp;
     midp.slicer_manager = mSlicerManagers[index];
@@ -463,7 +475,7 @@ void vvMainWindow::ComputeMidPosition()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool propagation)
-{
+{ 
   QTreeWidgetItem *item = new QTreeWidgetItem();
   item->setData(0,Qt::UserRole,"filename.vtk");
   item->setData(1,Qt::UserRole,tr("contour"));
@@ -471,7 +483,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro
   brush.setColor(QColor(contour->r*255,contour->g*255,contour->b*255));
   brush.setStyle(Qt::SolidPattern);
   item->setData(COLUMN_IMAGE_NAME,Qt::BackgroundRole,brush);
-  //  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
+  item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,contour->structure_name.c_str());
 
   for (int j = 1; j <= 4; j++)
     item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(image_index)->data(j,Qt::CheckStateRole));
@@ -510,7 +522,7 @@ void vvMainWindow::AddContour(int image_index, vvMesh::Pointer contour, bool pro
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenVTKContour()
-{
+{ 
   if (mSlicerManagers.size() > 0) {
     QString Extensions = "Images ( *.vtk *.obj)";
     Extensions += ";;All Files (*)";
@@ -533,7 +545,7 @@ void vvMainWindow::OpenVTKContour()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddDCStructContour(int index, QString file)
-{
+{ 
   vvMeshReader reader;
   reader.SetFilename(file.toStdString());
   vvStructSelector selector;
@@ -557,7 +569,7 @@ void vvMainWindow::AddDCStructContour(int index, QString file)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenDCStructContour()
-{
+{ 
   if (mSlicerManagers.size() > 0) {
     QString Extensions = "Dicom Files ( *.dcm RS*)";
     Extensions += ";;All Files (*)";
@@ -573,7 +585,7 @@ void vvMainWindow::OpenDCStructContour()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ComputeDeformableRegistration()
-{
+{ 
   if (mSlicerManagers.size() > 0) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     vvDeformationDialog dialog(index,mSlicerManagers);
@@ -590,11 +602,11 @@ void vvMainWindow::ComputeDeformableRegistration()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WarpImage()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (!mSlicerManagers[index]->GetVF().IsNull()) {
     bool ok;
-    int ref = QInputDialog::getInteger(this,"Chose reference phase","Reference phase",0,0,\
+    int ref = QInputDialog::getInt(this,"Chose reference phase","Reference phase",0,0,\
       mSlicerManagers[index]->GetImage()->GetVTKImages().size()-1,1,&ok);
     if (ok) {
       WarpImage(mSlicerManagers[index],ref);
@@ -607,7 +619,7 @@ void vvMainWindow::WarpImage()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phase)
-{
+{ 
   if (!selected_slicer->GetVF().IsNull()) {
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
     QFileInfo info(selected_slicer->GetFileName().c_str());
@@ -630,17 +642,20 @@ void vvMainWindow::WarpImage(vvSlicerManager* selected_slicer,int reference_phas
 
 //------------------------------------------------------------------------------
 vvMainWindow::~vvMainWindow()
-{
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] != NULL)
       delete mSlicerManagers[i];
   }
+  delete documentation;
+  delete help_dialog;
+  delete dicomSeriesSelector;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 QTabWidget * vvMainWindow::GetTab()
-{
+{ 
   return tabWidget;
 }
 //------------------------------------------------------------------------------
@@ -648,7 +663,7 @@ QTabWidget * vvMainWindow::GetTab()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::MergeImages()
-{
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
   QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images"),mInputPathName,Extensions);
@@ -707,7 +722,7 @@ void vvMainWindow::MergeImages()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SliceImages()
-{
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
 
@@ -724,7 +739,7 @@ void vvMainWindow::SliceImages()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::MergeImagesWithTime()
-{
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
   QStringList files = QFileDialog::getOpenFileNames(this,tr("Merge Images With Time"),mInputPathName,Extensions);
@@ -746,7 +761,7 @@ void vvMainWindow::MergeImagesWithTime()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenDicom()
-{
+{ 
   std::vector<std::string> files;
 
   //std::cout << "dicomSeriesSelector " << std::endl;
@@ -776,7 +791,7 @@ if (PacsConnection->exec() == QDialog::Accepted) {
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenImages()
-{
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
 
@@ -791,7 +806,7 @@ void vvMainWindow::OpenImages()
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenRecentImage()
-{
+{ 
   QAction * caller = qobject_cast<QAction*>(sender());
   std::vector<std::string> images;
   images.push_back(caller->text().toStdString());
@@ -803,7 +818,7 @@ void vvMainWindow::OpenRecentImage()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenImageWithTime()
-{
+{ 
   QString Extensions = EXTENSIONS;
   Extensions += ";;All Files (*)";
 
@@ -822,7 +837,7 @@ void vvMainWindow::OpenImageWithTime()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::LoadedImageType filetype)
-{
+{ 
   //Separate the way to open images and dicoms
   int fileSize;
   if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME)
@@ -885,12 +900,11 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
       // Change filename if an image with the same already exist
       int number = GetImageDuplicateFilenameNumber(files[i] + std::string("_slice"));
 
-      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED)
+      if (filetype == vvImageReader::IMAGE || filetype == vvImageReader::IMAGEWITHTIME || filetype == vvImageReader::SLICED) {
         SetImageSucceed = imageManager->SetImage(files[i],filetype, number, j);
-      else {
+      else {
         SetImageSucceed = imageManager->SetImages(files,filetype, number);
       }
-
       if (!SetImageSucceed) {
         QApplication::restoreOverrideCursor();
         QString error = "Cannot open file \n";
@@ -898,6 +912,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
         QMessageBox::information(this,tr("Reading problem"),error);
         delete imageManager;
       } else {
+
         mSlicerManagers.push_back(imageManager);
 
         //create an item in the tree with good settings
@@ -967,12 +982,12 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
         connect(mSlicerManagers.back(), SIGNAL(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)),
           this,SLOT(ChangeImageWithIndexOffset(vvSlicerManager*,int,int)));
         connect(mSlicerManagers.back(),SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
-
         InitSlicers();
         numberofsuccesulreads++;
       }
     }
   }
+
   if (numberofsuccesulreads) {
     NOViewWidget->show();
     NEViewWidget->show();
@@ -997,7 +1012,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateTree()
-{
+{ 
   DataTree->resizeColumnToContents(COLUMN_TREE);
   DataTree->resizeColumnToContents(COLUMN_UL_VIEW);
   DataTree->resizeColumnToContents(COLUMN_UR_VIEW);
@@ -1011,7 +1026,7 @@ void vvMainWindow::UpdateTree()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CurrentImageChanged(std::string id)
-{
+{ 
   if (id == mCurrentSelectedImageId) return; // Do nothing
   int selected = 0;
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
@@ -1031,14 +1046,14 @@ void vvMainWindow::CurrentImageChanged(std::string id)
                                       mSlicerManagers[selected]->GetTSlice());
   landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
   landmarksPanel->SetCurrentImage(mSlicerManagers[selected]->GetFileName().c_str());
-  
+
   emit SelectedImageHasChanged(mSlicerManagers[selected]);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CurrentPickedImageChanged(std::string id)
-{
+{ 
   if (id == mCurrentPickedImageId) return; // Do nothing
   int selected = 0;
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
@@ -1059,7 +1074,7 @@ void vvMainWindow::CurrentPickedImageChanged(std::string id)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ImageInfoChanged()
-{
+{ 
   contextActions[6]->setEnabled(1);
   contextActions[5]->setEnabled(1);
   actionSave_As->setEnabled(1);
@@ -1194,12 +1209,12 @@ void vvMainWindow::ImageInfoChanged()
 //     infoPanel->setOrigin(GetVectorDoubleAsString(origin));
 //     infoPanel->setSpacing(GetVectorDoubleAsString(inputSpacing));
 //     infoPanel->setNPixel(QString::number(NPixel)+" ("+inputSizeInBytes+")");
-// 
+//
 //     landmarksPanel->SetCurrentLandmarks(mSlicerManagers[index]->GetLandmarks(),
 //                                         mSlicerManagers[index]->GetTSlice());
 //     landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
 //     landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
-// 
+//
 //     overlayPanel->getCurrentImageName(mSlicerManagers[index]->GetFileName().c_str());
 //     for (int i = 0; i < 4; i++) {
 //       if (DataTree->selectedItems()[0]->data(i+1,Qt::CheckStateRole).toInt() > 0 || i == 3) {
@@ -1237,14 +1252,14 @@ void vvMainWindow::ImageInfoChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowDocumentation()
-{
+{ 
   documentation->show();
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::PopupRegisterForm(bool checkCanPush)
-{
+{ 
   vvRegisterForm* registerForm = new vvRegisterForm(QUrl("http://www.creatis.insa-lyon.fr/~dsarrut/vvregister/write.php"), getVVSettingsPath(), getSettingsOptionFormat());
   if(!checkCanPush) {
     registerForm->show();
@@ -1259,14 +1274,14 @@ void vvMainWindow::PopupRegisterForm(bool checkCanPush)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowHelpDialog()
-{
+{ 
   help_dialog->show();
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ChangeViewMode()
-{
+{ 
   typedef struct _SIZE{
     QSplitter* splitter;
     QList<int> size1, size2;
@@ -1350,7 +1365,7 @@ void vvMainWindow::ChangeViewMode()
 
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetSizeInBytes(unsigned long size)
-{
+{ 
   QString result = "";// QString::number(size);
   //result += " bytes (";
   if (size > 1000000000) {
@@ -1372,7 +1387,7 @@ QString vvMainWindow::GetSizeInBytes(unsigned long size)
 
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
-{
+{ 
   QString result;
   for (unsigned int i= 0; i < vectorDouble.size(); i++) {
     if (i != 0)
@@ -1385,7 +1400,7 @@ QString vvMainWindow::GetVectorDoubleAsString(std::vector<double> vectorDouble)
 
 //------------------------------------------------------------------------------
 QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt)
-{
+{ 
   QString result;
   for (unsigned int i= 0; i < vectorInt.size(); i++) {
     if (i != 0)
@@ -1399,7 +1414,7 @@ QString vvMainWindow::GetVectorIntAsString(std::vector<int> vectorInt)
 //------------------------------------------------------------------------------
 //this actually returns the SlicerManager index!
 int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item)
-{
+{ 
   QString id = item->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString();
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
     if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
@@ -1411,7 +1426,7 @@ int vvMainWindow::GetSlicerIndexFromItem(QTreeWidgetItem* item)
 
 //------------------------------------------------------------------------------
 QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm)
-{
+{ 
   QString id = sm->GetId().c_str();
   for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
     if (DataTree->topLevelItem(i)->data(COLUMN_IMAGE_NAME,Qt::UserRole).toString() == id)
@@ -1423,7 +1438,7 @@ QTreeWidgetItem* vvMainWindow::GetItemFromSlicerManager(vvSlicerManager* sm)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
-{
+{ 
   if ( column >= COLUMN_CLOSE_IMAGE || column <= 0)
     return;
 
@@ -1470,7 +1485,7 @@ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
       clickedParentItem->setData(column, Qt::CheckStateRole, vis?2:0);
 
       // Children
-      std::map<std::string, int> actorTypeCounts;      
+      std::map<std::string, int> actorTypeCounts;
       for (int iChild = 0; iChild < clickedParentItem->childCount(); iChild++) {
         QTreeWidgetItem* currentChildItem = clickedParentItem->child(iChild);
         std::string actorType = currentChildItem->data(1,Qt::UserRole).toString().toStdString();
@@ -1491,20 +1506,22 @@ void vvMainWindow::DisplayChanged(QTreeWidgetItem *clickedItem, int column)
 //------------------------------------------------------------------------------
 
 void vvMainWindow::InitSlicers()
-{
+{ 
   if (mSlicerManagers.size()) {
     mSlicerManagers.back()->GenerateDefaultLookupTable();
-
     mSlicerManagers.back()->SetSlicerWindow(0,NOViewWidget->GetRenderWindow());
     mSlicerManagers.back()->SetSlicerWindow(1,NEViewWidget->GetRenderWindow());
     mSlicerManagers.back()->SetSlicerWindow(2,SOViewWidget->GetRenderWindow());
     mSlicerManagers.back()->SetSlicerWindow(3,SEViewWidget->GetRenderWindow());
+#if VTK_MAJOR_VERSION <= 5
+    mSlicerManagers.back()->Render(); // SR: displayed #slice is wrong without this / TB: With VTK6 and multiple images, all slicers are updated, not only the first
+#endif
   }
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::InitDisplay()
-{
+{ 
   if (mSlicerManagers.size()) {
     //BE CAREFUL : this is absolutely necessary to set the interactor style
     //in order to have the same style instanciation for all SlicerManagers in
@@ -1515,14 +1532,14 @@ void vvMainWindow::InitDisplay()
       bool AlreadySelected = false;
       for (int i = 0; i < DataTree->topLevelItemCount(); i++) {
         mSlicerManagers[i]->SetInteractorStyleNavigator(j,style);
-
         //select the image only if previous are not selected
         if (DataTree->topLevelItem(i)->data(j+1,Qt::CheckStateRole).toInt() > 1) {
           mSlicerManagers[i]->UpdateSlicer(j,1);
           AlreadySelected = true;
         } else if (i == DataTree->topLevelItemCount()-1 && !AlreadySelected) {
-          if (DataTree->selectedItems().size() == 0)
+          if (DataTree->selectedItems().size() == 0) {
             DataTree->topLevelItem(i)->setSelected(1);
+          }
           DataTree->topLevelItem(i)->setData(j+1,Qt::CheckStateRole,2);
           mSlicerManagers[i]->UpdateSlicer(j,1);
           DisplaySliders(i,j);
@@ -1539,7 +1556,7 @@ void vvMainWindow::InitDisplay()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::DisplaySliders(int slicer, int window)
-{
+{ 
   if(!mSlicerManagers[slicer]->GetSlicer(window)->GetRenderer()->GetDraw())
     return;
 
@@ -1568,7 +1585,7 @@ void vvMainWindow::DisplaySliders(int slicer, int window)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
-{
+{ 
   int index = GetSlicerIndexFromItem(item);
 
   if (DataTree->topLevelItem(index) != item) {
@@ -1588,7 +1605,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
         if (DataTree->topLevelItem(index)->child(child) == item) break;
       }
       if (overlay_type=="fusionSequence") {
-        //removing the overlay sequence in a fusion sequence visualization mode 
+        //removing the overlay sequence in a fusion sequence visualization mode
         //reset the transforms
         overlayPanel->getFusionSequenceProperty(-1, false, 0, false);
 
@@ -1686,7 +1703,7 @@ void vvMainWindow::CloseImage(QTreeWidgetItem* item, int column)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
-{
+{ 
   // int index = GetSlicerIndexFromItem(item);
   //   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
   //   if (item->data(1,Qt::UserRole).toString() == "vector")
@@ -1710,12 +1727,12 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
   else if (role == "fusionSequence") {
     //both versions of the secondary sequence must be updated.
     mSlicerManagers[index]->ReloadFusionSequence();
-    mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->Reload(); 
+    mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->Reload();
   }
   else {
     mSlicerManagers[index]->Reload();
     //if we update the secondary sequence, then the overlay of the main sequence should also be updated
-    if (mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence()) mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->ReloadFusionSequence(); 
+    if (mSlicerManagers[index]->IsSecondarySequenceOfFusionSequence()) mSlicerManagers[mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager()]->ReloadFusionSequence();
   }
   // Update view and info
   ImageInfoChanged();
@@ -1726,28 +1743,28 @@ void vvMainWindow::ReloadImage(QTreeWidgetItem* item, int column)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::MousePositionChanged(int visibility,double x, double y, double z, double X, double Y, double Z , double value)
-{
+{ 
   infoPanel->setCurrentInfo(visibility,x,y,z,X,Y,Z,value);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::VectorChanged(int visibility,double x, double y, double z, double value)
-{
+{ 
   overlayPanel->getCurrentVectorInfo(visibility,x,y,z,value);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OverlayChanged(int visibility, double valueOver, double valueRef)
-{
+{ 
   overlayPanel->getCurrentOverlayInfo(visibility,valueOver, valueRef);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::FusionChanged(int visibility, double value)
-{
+{ 
   overlayPanel->getCurrentFusionInfo(visibility,value);
 }
 //------------------------------------------------------------------------------
@@ -1757,7 +1774,7 @@ void vvMainWindow::FusionChanged(int visibility, double value)
 //or when UpdateWindowLevel() is called ; when slicerManager emits WindowLevelChanged
 //when ImageInfoChanged() is called
 void vvMainWindow::WindowLevelChanged()
-{
+{ 
   // Base image
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if(index==-1) return;
@@ -1784,7 +1801,7 @@ void vvMainWindow::WindowLevelChanged()
       mSlicerManagers[index]->GetFusionLevel());
     if (mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) {
       overlayPanel->getFusionSequenceProperty(mSlicerManagers[index]->GetFusionSequenceFrameIndex(),
-        mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(), 
+        mSlicerManagers[index]->GetFusionSequenceSpatialSyncFlag(),
         mSlicerManagers[index]->GetFusionSequenceNbFrames(),
         mSlicerManagers[index]->GetFusionSequenceTemporalSyncFlag());
     }
@@ -1798,7 +1815,7 @@ void vvMainWindow::WindowLevelChanged()
       mSlicerManagers[ind]->GetFusionWindow(),
       mSlicerManagers[ind]->GetFusionLevel());
     overlayPanel->getFusionSequenceProperty(mSlicerManagers[ind]->GetFusionSequenceFrameIndex(),
-      mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(), 
+      mSlicerManagers[ind]->GetFusionSequenceSpatialSyncFlag(),
       mSlicerManagers[ind]->GetFusionSequenceNbFrames(),
       mSlicerManagers[ind]->GetFusionSequenceTemporalSyncFlag());
   }
@@ -1812,7 +1829,7 @@ void vvMainWindow::WindowLevelChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::WindowLevelEdited()
-{
+{ 
   presetComboBox->setCurrentIndex(WL_USER);
   UpdateWindowLevel();
 }
@@ -1820,7 +1837,7 @@ void vvMainWindow::WindowLevelEdited()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetWindowLevel(double w, double l)
-{
+{ 
   windowSpinBox->setValue(w);
   levelSpinBox->setValue(l);
   presetComboBox->setCurrentIndex(WL_USER);
@@ -1831,7 +1848,7 @@ void vvMainWindow::SetWindowLevel(double w, double l)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateWindowLevel()
-{
+{ 
   if (DataTree->selectedItems().size()) {
     if (presetComboBox->currentIndex() == WL_VENTILATION) //For ventilation
       colorMapComboBox->setCurrentIndex(5);
@@ -1847,7 +1864,7 @@ void vvMainWindow::UpdateWindowLevel()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSlicingPreset()
-{
+{ 
   if (DataTree->selectedItems().size()) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     mSlicerManagers[index]->SetSlicingPreset(vvSlicerManager::SlicingPresetType(slicingPresetComboBox->currentIndex()));
@@ -1857,7 +1874,7 @@ void vvMainWindow::UpdateSlicingPreset()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateColorMap()
-{
+{ 
   if (DataTree->selectedItems().size()) {
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     mSlicerManagers[index]->SetColorMap(colorMapComboBox->currentIndex());
@@ -1866,7 +1883,7 @@ void vvMainWindow::UpdateColorMap()
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::SwitchWindowLevel()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   int window = mSlicerManagers[index]->GetColorWindow();
   presetComboBox->setCurrentIndex(WL_USER);
@@ -1877,18 +1894,28 @@ void vvMainWindow::SwitchWindowLevel()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ApplyWindowLevelToAllImages()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if(index==-1) return;
   double window = mSlicerManagers[index]->GetColorWindow();
   double level = mSlicerManagers[index]->GetColorLevel();
 
+  double fusWindow = mSlicerManagers[index]->GetFusionWindow();
+  double fusLevel = mSlicerManagers[index]->GetFusionLevel();
+
+  double overWindow = mSlicerManagers[index]->GetOverlayColorWindow();
+  double overLevel = mSlicerManagers[index]->GetOverlayColorLevel();
+
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] == NULL)
       continue;
     mSlicerManagers[i]->SetColorWindow(window);
     mSlicerManagers[i]->SetColorLevel(level);
     mSlicerManagers[i]->SetPreset(WL_USER);
+    mSlicerManagers[i]->SetFusionWindow(fusWindow);
+    mSlicerManagers[i]->SetFusionLevel(fusLevel);
+    mSlicerManagers[i]->SetOverlayColorWindow(overWindow);
+    mSlicerManagers[i]->SetOverlayColorLevel(overLevel);
     mSlicerManagers[i]->Render();
   }
 }
@@ -1896,10 +1923,11 @@ void vvMainWindow::ApplyWindowLevelToAllImages()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ApplyWindowToSetOfImages(double window, unsigned int indexMin, unsigned int indexMax)
-{
+{ 
   for (unsigned int i = indexMin; i <= indexMax && i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] == NULL)
       continue;
+    SetWindowLevel(window, mSlicerManagers[i]->GetColorLevel());
     mSlicerManagers[i]->SetColorWindow(window);
     mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
@@ -1909,10 +1937,11 @@ void vvMainWindow::ApplyWindowToSetOfImages(double window, unsigned int indexMin
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin, unsigned int indexMax)
-{
+{ 
   for (unsigned int i = indexMin; i <= indexMax && i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i] == NULL)
       continue;
+    SetWindowLevel(mSlicerManagers[i]->GetColorWindow(), level);
     mSlicerManagers[i]->SetColorLevel(level);
     mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
@@ -1922,7 +1951,7 @@ void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin,
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, double y, double z, int temps)
-{
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (mSlicerManagers[i]->GetId() == id) {
       mSlicerManagers[i]->GetSlicer(slicer)->SetCurrentPosition(x,y,z,temps);
@@ -1935,7 +1964,7 @@ void vvMainWindow::UpdateLinkManager(std::string id, int slicer, double x, doubl
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm, vvSlicer* refSlicer)
-{
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (id == mSlicerManagers[i]->GetId()) {
       mSlicerManagers[i]->UpdateLinkedNavigation(refSlicer);
@@ -1946,7 +1975,7 @@ void vvMainWindow::UpdateLinkedNavigation(std::string id, vvSlicerManager * sm,
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ShowContextMenu(QPoint point)
-{
+{ 
   if (!DataTree->selectedItems().size()) {
     contextActions[1]->setEnabled(0);
     contextActions[2]->setEnabled(0);
@@ -1975,50 +2004,60 @@ void vvMainWindow::ShowContextMenu(QPoint point)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::CloseImage()
-{
+{ 
   CloseImage(DataTree->selectedItems()[0],0);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReloadImage()
-{
+{ 
   ReloadImage(DataTree->selectedItems()[0],0);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectOverlayImage()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
+  if (!(CheckAddedImage(index, "overlay")))
+    return;
+
+  QString Extensions = EXTENSIONS;
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
+
+  std::vector<std::string> vecFileNames;
+  for (int i = 0; i < files.size(); i++) {
+    vecFileNames.push_back(files[i].toStdString());
+  }
+
+  AddOverlayImage(index,vecFileNames,vvImageReader::IMAGE);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+bool vvMainWindow::CheckAddedImage(int index, QString imageType)
+{ 
   //check if one overlay image is added
   for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "overlay") {
+    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString().compare(imageType) == 0) {
       QString error = "Cannot add more than one compared image\n";
       error += "Please remove first ";
       error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
       QMessageBox::information(this,tr("Problem adding compared image !"),error);
-      return;
-    }
-
-    QString Extensions = EXTENSIONS;
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image"),mInputPathName,Extensions);
-    if (files.isEmpty())
-      return;
-
-    std::vector<std::string> vecFileNames;
-    for (int i = 0; i < files.size(); i++) {
-      vecFileNames.push_back(files[i].toStdString());
+      return false;
     }
-    AddOverlayImage(index,vecFileNames,vvImageReader::IMAGE);
+    return true;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{
+{ 
   QString file(fileNames[0].c_str());
   if (QFile::exists(file))
   {
@@ -2043,6 +2082,10 @@ void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames
       item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
       item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("overlay").c_str());
       qApp->processEvents();
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
 
       for (int j = 1; j <= 4; j++) {
         item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
@@ -2098,7 +2141,7 @@ void vvMainWindow::AddOverlayImage(int index, std::vector<std::string> fileNames
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddROI(int index, QString file)
-{
+{ 
   /*
   // Get slice manager
 
@@ -2125,37 +2168,29 @@ void vvMainWindow::AddROI(int index, QString file)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectFusionImage()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
-  //check if one fusion image is added
-  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
-      (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
-        QString error = "Cannot add more than one fusion image\n";
-        error += "Please remove first ";
-        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        QMessageBox::information(this,tr("Problem adding fusion image !"),error);
-        return;
-    }
+  if (!(CheckAddedImage(index, "fusion")) || !(CheckAddedImage(index, "fusionSequence")))
+    return;
 
-    QString Extensions = EXTENSIONS;
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Fusion image"),mInputPathName,Extensions);
-    if (files.isEmpty())
-      return;
+  QString Extensions = EXTENSIONS;
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Fusion image"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
 
-    std::vector<std::string> vecFileNames;
-    for (int i = 0; i < files.size(); i++) {
-      vecFileNames.push_back(files[i].toStdString());
-    }
-    AddFusionImage(index,vecFileNames,vvImageReader::IMAGE);
+  std::vector<std::string> vecFileNames;
+  for (int i = 0; i < files.size(); i++) {
+    vecFileNames.push_back(files[i].toStdString());
+  }
+  AddFusionImage(index,vecFileNames,vvImageReader::IMAGE);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ResetTransformationToIdentity()
-{
+{ 
   std::string actorType = DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString().toStdString();
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   mSlicerManagers[index]->ResetTransformationToIdentity(actorType);
@@ -2165,7 +2200,7 @@ void vvMainWindow::ResetTransformationToIdentity()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{
+{ 
   QString file(fileNames[0].c_str());
   if (QFile::exists(file))
   {
@@ -2190,7 +2225,10 @@ void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames,
           item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
           item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusion").c_str());
           qApp->processEvents();
-
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
       for (int j = 1; j <= 4; j++) {
         item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
       }
@@ -2243,45 +2281,39 @@ void vvMainWindow::AddFusionImage(int index, std::vector<std::string> fileNames,
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 void vvMainWindow::AddLandmarks(int index, std::vector<std::string> files)
-{
+{ 
     if (!landmarksPanel->LoadFromFile(files))
       QMessageBox::information(this,tr("Problem reading Landmarks !"),"File doesn't exist!");
-    
+
     landmarksPanel->SetCurrentPath(mInputPathName.toStdString());
     landmarksPanel->SetCurrentImage(mSlicerManagers[index]->GetFileName().c_str());
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::OpenField()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-  //check if a vector field has already been added
-  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "vector") {
-      QString error = "Cannot add more than one vector field\n";
-      error += "Please remove first ";
-      error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-      QMessageBox::information(this,tr("Problem adding vector field!"),error);
-      return;
-    }
+  
+  if (!(CheckAddedImage(index, "vector")))
+    return;
 
-    QString Extensions = "Images ( *.mhd)";
-    Extensions += ";;Images ( *.mha)";
-    Extensions += ";;VF Images ( *.vf)";
-    Extensions += ";;nii Images ( *.nii)";
-    Extensions += ";;nrrd Images ( *.nrrd)";
-    Extensions += ";;nhdr Images ( *.nhdr)";
-    Extensions += ";;All Files (*)";
-    QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
-    if (!file.isEmpty())
-      AddField(file,index);
+  QString Extensions = "Images ( *.mhd *.mha *.vf *.nii *.nrrd *.nhdr)";
+  // Extensions += ";;Images ( *.mha)";
+  // Extensions += ";;VF Images ( *.vf)";
+  // Extensions += ";;nii Images ( *.nii)";
+  // Extensions += ";;nrrd Images ( *.nrrd)";
+  // Extensions += ";;nhdr Images ( *.nhdr)";
+  Extensions += ";;All Files (*)";
+  QString file = QFileDialog::getOpenFileName(this,tr("Load deformation field"),mInputPathName,Extensions);
+  if (!file.isEmpty())
+    AddField(file,index);
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
-{
+{ 
   //create an item in the tree with good settings
   QTreeWidgetItem *item = new QTreeWidgetItem();
   item->setData(0,Qt::UserRole,filename.toStdString().c_str());
@@ -2332,11 +2364,15 @@ void vvMainWindow::AddFieldEntry(QString filename,int index,bool from_disk)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
-{
+{ 
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
   vvSlicerManager* imageManager = mSlicerManagers[index];
   if (imageManager->SetVF(vf,file.toStdString())) {
     AddFieldEntry(file,index,false);
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
   } else {
     QString error = "Cannot import the vector field for this image.\n";
     error += imageManager->GetLastError().c_str();
@@ -2349,7 +2385,7 @@ void vvMainWindow::AddField(vvImage::Pointer vf,QString file,int index)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddField(QString file,int index)
-{
+{ 
   if (QFile::exists(file)) {
     mInputPathName = itksys::SystemTools::GetFilenamePath(file.toStdString()).c_str();
 
@@ -2381,7 +2417,7 @@ void vvMainWindow::AddField(QString file,int index)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width, double r, double g, double b)
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetVF()) {
     for (int i = 0; i < 4; i++) {
@@ -2401,7 +2437,7 @@ void vvMainWindow::SetVFProperty(int subsampling, int scale, int log, int width,
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetOverlayProperty(int color, int linked, double window, double level)
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetOverlay()) {
     mSlicerManagers[index]->SetOverlayColor(color);
@@ -2416,7 +2452,7 @@ void vvMainWindow::SetOverlayProperty(int color, int linked, double window, doub
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap,double window, double level, bool showLegend)
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
     mSlicerManagers[index]->SetFusionColorMap(colormap);
@@ -2434,40 +2470,33 @@ void vvMainWindow::SetFusionProperty(int opacity, int thresOpacity, int colormap
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SelectFusionSequence()
-{
+{ 
   //get the index of the slicer manager of the main sequence (CT)
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
-  //check if one overlay image is already associated
-  for (int child = 0; child < DataTree->topLevelItem(index)->childCount(); child++)
-    if ( (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusion") ||
-      (DataTree->topLevelItem(index)->child(child)->data(1,Qt::UserRole).toString() == "fusionSequence") ) {
-        QString error = "Cannot add more than one compared image\n";
-        error += "Please remove first ";
-        error += DataTree->topLevelItem(index)->child(child)->data(COLUMN_IMAGE_NAME,Qt::DisplayRole).toString();
-        QMessageBox::information(this,tr("Problem adding compared image !"),error);
-        return;
-    }
 
-    QString Extensions = EXTENSIONS;
-    Extensions += ";;All Files (*)";
-    QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions);
-    if (files.isEmpty())
-      return;
+  if (!(CheckAddedImage(index, "fusion")) || !(CheckAddedImage(index, "fusionSequence")))
+    return;
 
-    std::vector<std::string> vecFileNames;
-    for (int i = 0; i < files.size(); i++) {
-      vecFileNames.push_back(files[i].toStdString());
-    }
+  QString Extensions = EXTENSIONS;
+  Extensions += ";;All Files (*)";
+  QStringList files = QFileDialog::getOpenFileNames(this,tr("Load Overlay image sequence"),mInputPathName,Extensions);
+  if (files.isEmpty())
+    return;
 
-    //associate the secondary sequence (US) to the main one
-    AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
+  std::vector<std::string> vecFileNames;
+  for (int i = 0; i < files.size(); i++) {
+    vecFileNames.push_back(files[i].toStdString());
+  }
+
+  //associate the secondary sequence (US) to the main one
+  AddFusionSequence(index,vecFileNames,vvImageReader::MERGEDWITHTIME);
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvMainWindow::SelectFusionSequenceCorrespondances() {
-
+void vvMainWindow::SelectFusionSequenceCorrespondances() 
+{ 
   //make sure the index is right?
   //in the end, I should attach the temporal data to the right sequence!
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
@@ -2495,7 +2524,7 @@ void vvMainWindow::SelectFusionSequenceCorrespondances() {
   bool signalOK = true;
   unsigned nbFrameMain = mSlicerManagers[index]->GetImage()->GetTransform().size();
   unsigned nbFrameSecondary = mSlicerManagers[index]->GetFusionSequenceNbFrames();
-std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSecondary<<", signal size: "<<tmpVect.size()<<std::endl;
+  std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSecondary<<", signal size: "<<tmpVect.size()<<std::endl;
   std::vector<unsigned> temporalCorrespondances;
   if ( tmpVect.size() == nbFrameMain + nbFrameSecondary ) {
     for (unsigned i=0 ; i<tmpVect.size() ; i++) {
@@ -2505,8 +2534,8 @@ std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSeconda
       }
       else { //first part of the file -> index in secondary seq.
         if ( tmpVect(i)<nbFrameMain ) temporalCorrespondances.push_back(tmpVect(i));
-        else { signalOK=false; break; } //pointing outside the secondary sequence...      
-      }      
+        else { signalOK=false; break; } //pointing outside the secondary sequence...
+      }
     }
   }
   else {signalOK=false;}
@@ -2531,7 +2560,7 @@ std::cout<<"nbFrameMain = "<<nbFrameMain<<", nbFrameSecondary= "<<nbFrameSeconda
 //when this function is called index is the slicer manager index corresponding to the main sequence (CT)
 //the files behind fileNames points to the data for the secondary sequence
 void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type)
-{
+{ 
   QString file(fileNames[0].c_str());
   if (QFile::exists(file))
   {
@@ -2559,6 +2588,10 @@ void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNam
       item->setData(COLUMN_IMAGE_NAME,Qt::DisplayRole,fileinfo.fileName());
       item->setToolTip(COLUMN_IMAGE_NAME, mSlicerManagers[index]->GetListOfAbsoluteFilePathInOneString("fusionSequence").c_str());
       qApp->processEvents();
+#if VTK_MAJOR_VERSION > 5
+      for ( unsigned int i = 0; i < mSlicerManagers[index]->GetNumberOfSlicers(); i++)
+        mSlicerManagers[index]->GetSlicer(i)->ForceUpdateDisplayExtent();
+#endif
       for (int j = 1; j <= 4; j++) {
         item->setData(j,Qt::CheckStateRole,DataTree->topLevelItem(index)->data(j,Qt::CheckStateRole));
       }
@@ -2652,10 +2685,10 @@ void vvMainWindow::AddFusionSequence(int index, std::vector<std::string> fileNam
 //------------------------------------------------------------------------------
 //fusionSequenceFrameIndex and fusionSequenceNbFrames are relative to the secondary sequence (US)
 void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool spatialSyncFlag, unsigned int fusionSequenceNbFrames, bool temporalSyncFlag)
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
-  if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return; 
+  if (!mSlicerManagers[index]->IsInvolvedInFusionSequence()) return;
 
   //check if the focus moved to the linked sequence, and in this case, select the master sequence instead
   if (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) {
@@ -2663,8 +2696,8 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
   }
   int secondaryIndex = mSlicerManagers[index]->GetFusionSequenceIndexOfLinkedManager();
   if (secondaryIndex==-1) return; //this should never happen
-  if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) || 
-    (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) ) 
+  if ( (!mSlicerManagers[index]->IsMainSequenceOfFusionSequence()) ||
+    (!mSlicerManagers[secondaryIndex]->IsSecondarySequenceOfFusionSequence()) )
   {return;} //this should never happen, raise an exception?
 
   if (mSlicerManagers[index]->GetSlicer(0)->GetFusion()) {
@@ -2704,7 +2737,7 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
         mainSequenceFrameIndex = mSlicerManagers[index]->GetFusionSequenceCorrespondances()[ nbFramesMain + fusionSequenceFrameIndex];
         //and set it!
         mSlicerManagers[index]->SetTSlice(mainSequenceFrameIndex, false);
-        //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc... 
+        //warning, there is a loopback, and modification of the TSlice in main sequence forces an update of the TSlice in secondary, etc...
       }
 
 
@@ -2732,7 +2765,7 @@ void vvMainWindow::SetFusionSequenceProperty(int fusionSequenceFrameIndex, bool
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveAs()
-{
+{ 
   if (DataTree->selectedItems()[0]->data(1,Qt::UserRole).toString() == "vector") {
     QMessageBox::warning(this,tr("Unsupported type"),tr("Sorry, saving a vector field is unsupported for the moment"));
     return;
@@ -2836,7 +2869,7 @@ void vvMainWindow::SaveAs()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveCurrentState()
-{
+{ 
   QString Extensions = "XML Files(*.xml)";
   QString fileName = QFileDialog::getSaveFileName(this,
     tr("Save Current Window State"),
@@ -2849,14 +2882,14 @@ void vvMainWindow::SaveCurrentState()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveCurrentStateAs(const std::string& stateFile)
-{
+{ 
   vvSaveState save_state;
   save_state.Run(this, stateFile);
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReadSavedState()
-{
+{ 
   QString Extensions = "XML Files(*.xml)";
   QString fileName = QFileDialog::getOpenFileName(this,
     tr("Load Window State"),
@@ -2869,7 +2902,7 @@ void vvMainWindow::ReadSavedState()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ReadSavedStateFile(const std::string& stateFile)
-{
+{ 
   vvReadState read_state;
   read_state.Run(this, stateFile);
 }
@@ -2877,13 +2910,13 @@ void vvMainWindow::ReadSavedStateFile(const std::string& stateFile)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::LinkAllImages()
-{
+{ 
   linkPanel->linkAll();
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel)
-{
+{ 
   if (!fromPanel) {
     // delegate to linkPanel if call came from elsewhere...
     linkPanel->addLinkFromIds(image1, image2);
@@ -2917,7 +2950,7 @@ void vvMainWindow::AddLink(QString image1,QString image2,bool fromPanel)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::RemoveLink(QString image1,QString image2)
-{
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (image1.toStdString() == mSlicerManagers[i]->GetId()) {
       mSlicerManagers[i]->RemoveLink(image2.toStdString());
@@ -2931,7 +2964,7 @@ void vvMainWindow::RemoveLink(QString image1,QString image2)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, int offset)
-{
+{ 
   if(mSlicerManagers.size()==1)
     return;
 
@@ -2947,22 +2980,22 @@ void vvMainWindow::ChangeImageWithIndexOffset(vvSlicerManager *sm, int slicer, i
 }
 //------------------------------------------------------------------------------
 void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
-{
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
     if (DataTree->topLevelItem(i)->data(column,Qt::CheckStateRole).toInt() > 1) {
       //i is the SlicerManager that is in charge of this slicer.
       if (mSlicerManagers[i]->IsInvolvedInFusionSequence()) {
         //if the slicerManager is involved in a fusionSequence as the secondary sequence, then update the slider position in the overlay panel and everything accordingly
-        if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) { 
-          overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true); 
+        if (mSlicerManagers[i]->IsSecondarySequenceOfFusionSequence()) {
+          overlayPanel->updateFusionSequenceSliderValueFromWindow(value, true);
         }
         else { //if this is the primary sequence that has been modified
-          if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {            
+          if (mSlicerManagers[i]->GetFusionSequenceTemporalSyncFlag()) {
             //WARNING: for some obscure reason, there are problems when accessing mSlicerManagers[mSlicerManagers[i]->GetFusionSequenceIndexOfLinkedManager()]->GetFusionSequenceFrameIndex();
 
             int estimatedValue=0;
             //estimate a corresponding time index for the secondary (US) sequence, and update it accordingly.
-            estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ];       
+            estimatedValue = mSlicerManagers[i]->GetFusionSequenceCorrespondances()[ value ];
             //TODO: at the moment, there is a loop in TSlice modifications
             //modifying sequence 1 causes seq 2 to update, which in turns update seq1...
             //I disable control on seq1 at the moment.
@@ -2984,7 +3017,7 @@ void vvMainWindow::HorizontalSliderMoved(int value,int column, int slicer_index)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NOHorizontalSliderMoved()
-{
+{ 
   // if (mCurrentTime == NOHorizontalSlider->value()) return;
   HorizontalSliderMoved(NOHorizontalSlider->value(),COLUMN_UL_VIEW,0);
   //  mCurrentTime = NOHorizontalSlider->value();
@@ -2994,7 +3027,7 @@ void vvMainWindow::NOHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NEHorizontalSliderMoved()
-{
+{ 
   // if (mCurrentTime == NEHorizontalSlider->value()) return;
   HorizontalSliderMoved(NEHorizontalSlider->value(),COLUMN_UR_VIEW,1);
   //  mCurrentTime = NEHorizontalSlider->value();
@@ -3004,7 +3037,7 @@ void vvMainWindow::NEHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SOHorizontalSliderMoved()
-{
+{ 
   // if (mCurrentTime == SOHorizontalSlider->value()) return;
   HorizontalSliderMoved(SOHorizontalSlider->value(),COLUMN_DL_VIEW,2);
   // mCurrentTime = SOHorizontalSlider->value();
@@ -3014,7 +3047,7 @@ void vvMainWindow::SOHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SEHorizontalSliderMoved()
-{
+{ 
   // if (mCurrentTime == SEHorizontalSlider->value()) return;
   HorizontalSliderMoved(SEHorizontalSlider->value(),COLUMN_DR_VIEW,3);
   // mCurrentTime = SEHorizontalSlider->value();
@@ -3023,7 +3056,7 @@ void vvMainWindow::SEHorizontalSliderMoved()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NOVerticalSliderChanged()
-{
+{ 
   static int value=-1;
   if (value == NOVerticalSlider->value()) return;
   else value = NOVerticalSlider->value();
@@ -3049,7 +3082,7 @@ void vvMainWindow::NOVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::NEVerticalSliderChanged()
-{
+{ 
   static int value=-1;
   if (value == NEVerticalSlider->value()) return;
   else value = NEVerticalSlider->value();
@@ -3071,7 +3104,7 @@ void vvMainWindow::NEVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SOVerticalSliderChanged()
-{
+{ 
   static int value=-1;
   if (value == SOVerticalSlider->value()) return;
   else value = SOVerticalSlider->value();
@@ -3094,7 +3127,7 @@ void vvMainWindow::SOVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SEVerticalSliderChanged()
-{
+{ 
   static int value=-1;
   if (value == SEVerticalSlider->value()) return;
   else value = SEVerticalSlider->value();
@@ -3116,7 +3149,7 @@ void vvMainWindow::SEVerticalSliderChanged()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSlice(int slicer, int slice)
-{
+{ 
   // DD("vvMainWindow::UpdateSlice");
   //   DD(slicer);
   //   DD(slice);
@@ -3142,7 +3175,7 @@ void vvMainWindow::UpdateSlice(int slicer, int slice)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateTSlice(int slicer, int slice, int code)
-{
+{ 
   //FusionSequence: the slider value should be updated for slicers which show the same sequence as requested
   bool doUpdate=false;
   if (code==-1) doUpdate=true;
@@ -3181,7 +3214,7 @@ void vvMainWindow::UpdateTSlice(int slicer, int slice, int code)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int tmax)
-{
+{ 
   //int position = int((min+max)/2);
   int position = mSlicerManagers[mCurrentPickedImageIndex]->GetSlicer(slicer)->GetSlice();
   if (slicer == 0) {
@@ -3207,7 +3240,7 @@ void vvMainWindow::UpdateSliceRange(int slicer, int min, int max, int tmin, int
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveNOScreenshot()
-{
+{ 
   SaveScreenshot(NOViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3215,7 +3248,7 @@ void vvMainWindow::SaveNOScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveNEScreenshot()
-{
+{ 
   SaveScreenshot(NEViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3223,7 +3256,7 @@ void vvMainWindow::SaveNEScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveSOScreenshot()
-{
+{ 
   SaveScreenshot(SOViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3231,7 +3264,7 @@ void vvMainWindow::SaveSOScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveSEScreenshot()
-{
+{ 
   SaveScreenshot(SEViewWidget);
 }
 //------------------------------------------------------------------------------
@@ -3239,7 +3272,7 @@ void vvMainWindow::SaveSEScreenshot()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveScreenshotAllSlices()
-{
+{ 
   QVTKWidget *widget = NOViewWidget;
 
   int index = 0;// GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
@@ -3261,9 +3294,9 @@ void vvMainWindow::SaveScreenshotAllSlices()
     // Change the slice
     slicer->SetSlice(i); // -> change the slice of the current slicer
     SM->UpdateSlice(0); // --> this one emit UpdateSlice
-    QCoreApplication::flush(); // -> needed to force display of contours 
+    QCoreApplication::flush(); // -> needed to force display of contours
 
-    // Screenshot  
+    // Screenshot
     vtkSmartPointer<vtkWindowToImageFilter> windowToImageFilter = vtkSmartPointer<vtkWindowToImageFilter>::New();
     windowToImageFilter->SetInput(renderWindow);
     windowToImageFilter->SetMagnification(1);
@@ -3277,10 +3310,14 @@ void vvMainWindow::SaveScreenshotAllSlices()
     if (i<100) num = "0"+num;
     if (i<1000) num = "0"+num;
 
-    fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn 
+    fn = itksys::SystemTools::GetFilenamePath(filename.toStdString()) + "/"+ fn
       + "_" + num + itksys::SystemTools::GetFilenameLastExtension(filename.toStdString());
     writer->SetFileName(fn.c_str());
+#if VTK_MAJOR_VERSION <= 5
     writer->SetInput(windowToImageFilter->GetOutput());
+#else
+    writer->SetInputConnection(windowToImageFilter->GetOutputPort());
+#endif
     writer->Write();
   }
 }
@@ -3289,7 +3326,7 @@ void vvMainWindow::SaveScreenshotAllSlices()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
-{
+{ 
   QString Extensions = "Images( *.png);;";
   Extensions += "Images( *.jpg);;";
   Extensions += "Images( *.bmp);;";
@@ -3334,7 +3371,11 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
 
     // Snapshot image if not null
     if(imgwriter!=NULL) {
+#if VTK_MAJOR_VERSION <= 5
       imgwriter->SetInput(image);
+#else
+      imgwriter->SetInputConnection(w2i->GetOutputPort());
+#endif
       imgwriter->SetFileName(fileName.toStdString().c_str());
       imgwriter->Write();
       return;
@@ -3349,13 +3390,13 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
 
       // FPS
       bool ok;
-      int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+      int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
         tr("FPS:"), 5, 0, 1000, 1, &ok);
       if(ok)
         gif->SetRate(fps);
 
       // Loops
-      int loops = QInputDialog::getInteger(this, tr("Loops"),
+      int loops = QInputDialog::getInt(this, tr("Loops"),
         tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok);
       if(ok)
         gif->SetLoops(loops);
@@ -3374,7 +3415,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
       vidwriter = mpg;
       mpg->SetQuality(2);
       bool ok;
-      int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+      int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
         tr("FPS:"), 5, 0, 1024, 1, &ok);
       if(!ok)
         fps = 5;
@@ -3387,7 +3428,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
       vidwriter = mpg;
       mpg->SetQuality(2);
       bool ok;
-      int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+      int fps = QInputDialog::getInt(this, tr("Number of frames per second"),
         tr("FPS:"), 5, 0, 1024, 1, &ok);
       if(!ok)
         fps = 5;
@@ -3404,7 +3445,11 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
 
     // Take video if not null
     if(vidwriter!=NULL){
+#if VTK_MAJOR_VERSION <= 5
       vidwriter->SetInput(image);
+#else
+      vidwriter->SetInputConnection(w2i->GetOutputPort());
+#endif
       vidwriter->SetFileName(fileName.toStdString().c_str());
       vidwriter->Start();
       int nSlice = mSlicerManagers[smIndex]->GetSlicer(0)->GetTMax();
@@ -3413,7 +3458,11 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
         vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
         w2i->SetInput(widget->GetRenderWindow());
         w2i->Update();
+#if VTK_MAJOR_VERSION <= 5
         vidwriter->SetInput(w2i->GetOutput());
+#else
+        vidwriter->SetInputConnection(w2i->GetOutputPort());
+#endif
         vidwriter->Write();
       }
       vidwriter->End();
@@ -3429,7 +3478,7 @@ void vvMainWindow::SaveScreenshot(QVTKWidget *widget)
 
 //------------------------------------------------------------------------------
 void vvMainWindow::GoToCursor()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   for (int column = 1; column < 5; column++) {
     if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
@@ -3446,7 +3495,7 @@ void vvMainWindow::GoToCursor()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::GoToLandmark()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   for (int column = 1; column < 5; column++) {
     if (DataTree->selectedItems()[0]->data(column,Qt::CheckStateRole).toInt() > 1) {
@@ -3463,7 +3512,7 @@ void vvMainWindow::GoToLandmark()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::PlayPause()
-{
+{ 
   if (playMode) {
     playMode = 0;
     playButton->setIcon(QIcon(QString::fromUtf8(":/common/icons/player_play.png")));
@@ -3488,7 +3537,7 @@ void vvMainWindow::PlayPause()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::PlayNext()
-{
+{ 
   if (playMode && !this->isHidden()) {
     int image_number=DataTree->topLevelItemCount();
     ///Only play one slicer per SM, and only if the SM is being displayed
@@ -3505,23 +3554,24 @@ void vvMainWindow::PlayNext()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::ShowLastImage()
-{
+{ 
   if (mSlicerManagers.size() > 1) {
     QTreeWidgetItem * item=DataTree->topLevelItem(DataTree->topLevelItemCount()-1);
     CurrentImageChanged(mSlicerManagers.back()->GetId()); //select new image
     item->setData(1,Qt::CheckStateRole,2); //show the new image in the first panel
+    //mSlicerManagers[GetSlicerIndexFromItem(item)]->GetSlicer(0)->SetActorVisibility("image", 0, 1); //Set the Last Image visibles
     DisplayChanged(item,1);
   }
 }
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateRenderWindows()
-{
+{ 
   for (unsigned int i = 0; i < mSlicerManagers.size(); i++) {
-    mSlicerManagers[i]->GetSlicer(0)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(1)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(2)->UpdateLandmarks();
-    mSlicerManagers[i]->GetSlicer(3)->UpdateLandmarks();
+      for (unsigned int j = 0; j < 4; ++j) {
+        mSlicerManagers[i]->GetSlicer(j)->RemoveLandmarks();
+        mSlicerManagers[i]->GetSlicer(j)->DisplayLandmarks();
+      }
   }
   if (NOViewWidget->GetRenderWindow()) NOViewWidget->GetRenderWindow()->Render();
   if (NEViewWidget->GetRenderWindow()) NEViewWidget->GetRenderWindow()->Render();
@@ -3532,7 +3582,7 @@ void vvMainWindow::UpdateRenderWindows()
 
 //------------------------------------------------------------------------------
 void vvMainWindow::SegmentationOnCurrentImage()
-{
+{ 
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
 
   vvSegmentationDialog segmentation;
@@ -3542,7 +3592,7 @@ void vvMainWindow::SegmentationOnCurrentImage()
 //------------------------------------------------------------------------------
 
 void vvMainWindow::SurfaceViewerLaunch()
-{
+{ 
   vvSurfaceViewerDialog surfaceViewer;
   surfaceViewer.exec();
 }
@@ -3551,7 +3601,7 @@ void vvMainWindow::SurfaceViewerLaunch()
 
 //------------------------------------------------------------------------------
 int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename)
-{
+{ 
   int number=0;
   for(unsigned int l=0; l<mSlicerManagers.size(); l++) {
     vvSlicerManager * v = mSlicerManagers[l];
@@ -3567,7 +3617,7 @@ int vvMainWindow::GetImageDuplicateFilenameNumber(std::string filename)
 
 //------------------------------------------------------------------------------
 vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filename)
-{
+{ 
   // Change filename if another image exist with the same name
   int number = GetImageDuplicateFilenameNumber(filename);
 
@@ -3649,13 +3699,13 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
   connect(mSlicerManagers.back(), SIGNAL(LandmarkAdded()),landmarksPanel,SLOT(AddPoint()));
 
 
+
+  InitSlicers();
   UpdateTree();
   qApp->processEvents();
-  InitSlicers();
-  ShowLastImage();
   InitDisplay();
+  ShowLastImage();
   qApp->processEvents();
-
   // End
   ImageInfoChanged();
   return slicer_manager;
@@ -3665,7 +3715,7 @@ vvSlicerManager* vvMainWindow::AddImage(vvImage::Pointer image,std::string filen
 
 //------------------------------------------------------------------------------
 void vvMainWindow::UpdateCurrentSlicer()
-{
+{ 
   int index = -1;
   if (DataTree->selectedItems().size() > 0) {
     index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
@@ -3673,4 +3723,3 @@ void vvMainWindow::UpdateCurrentSlicer()
   mSlicerManagerCurrentIndex = index;
 }
 //------------------------------------------------------------------------------
-
index d7bf2ed2bbf09e367804201b041a2a437be28b3a..8f5b41c8c1924676ffa951c7301a3a2092fae96a 100644 (file)
@@ -57,6 +57,7 @@ class vvMainWindow: public vvMainWindowBase,
   void LoadImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type);
   vvSlicerManager * AddImage(vvImage::Pointer image,std::string filename);
   void AddField(QString file,int index);
+  bool CheckAddedImage(int index, QString imageType);
   void AddOverlayImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
   void AddFusionImage(int index, std::vector<std::string> fileNames, vvImageReader::LoadedImageType type);
   void AddROI(int index, QString filename);
index 5b11d48e2d65e1a0bc8a9edb52384127a7e4c55d..15be4a4bedc7e0696bd13ac0aa4441f66989eef7 100644 (file)
@@ -31,6 +31,7 @@
 #include <itksys/SystemTools.hxx>
 
 // vtk
+#include <vtkVersion.h>
 #include <vtkSmartPointer.h>
 #include <vtkFloatArray.h>
 #include <vtkPointData.h>
@@ -135,7 +136,9 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude)
     double *bounds=mesh->GetBounds();
 
     vtkSmartPointer<vtkImageData> binary_image=vtkSmartPointer<vtkImageData>::New();
+#if VTK_MAJOR_VERSION <= 5
     binary_image->SetScalarTypeToUnsignedChar();
+#endif
     ///Use the smallest mask in which the mesh fits
     // Add two voxels on each side to make sure the mesh fits
     double * samp_origin=sample->GetOrigin();
@@ -150,7 +153,11 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude)
     binary_image->SetExtent(0,ceil((bounds[1]-origin[0])/spacing[0]+4),
                             0,ceil((bounds[3]-origin[1])/spacing[1]+4),
                             0,ceil((bounds[5]-origin[2])/spacing[2])+4);
+#if VTK_MAJOR_VERSION <= 5
     binary_image->AllocateScalars();
+#else
+    binary_image->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
+#endif
     memset(binary_image->GetScalarPointer(),0,binary_image->GetDimensions()[0]*binary_image->GetDimensions()[1]*binary_image->GetDimensions()[2]*sizeof(unsigned char));
 
 
@@ -162,16 +169,34 @@ void vvMesh::ComputeMasks(vtkImageData* sample,bool extrude)
 
     if (extrude) {
       vtkSmartPointer<vtkLinearExtrusionFilter> extrude=vtkSmartPointer<vtkLinearExtrusionFilter>::New();
+#if VTK_MAJOR_VERSION <= 5
       extrude->SetInput(mesh);
+#else
+      extrude->SetInputData(mesh);
+#endif
       ///We extrude in the -slice_spacing direction to respect the FOCAL convention
       extrude->SetVector(0, 0, -slice_spacing);
+#if VTK_MAJOR_VERSION <= 5
       sts->SetInput(extrude->GetOutput());
-    } else
+#else
+      sts->SetInputConnection(extrude->GetOutputPort());
+#endif
+    } else {
+#if VTK_MAJOR_VERSION <= 5
       sts->SetInput(mesh);
+#else
+      sts->SetInputData(mesh);
+#endif
+   }
 
     vtkSmartPointer<vtkImageStencil> stencil=vtkSmartPointer<vtkImageStencil>::New();
+#if VTK_MAJOR_VERSION <= 5
     stencil->SetStencil(sts->GetOutput());
     stencil->SetInput(binary_image);
+#else
+    stencil->SetStencilConnection(sts->GetOutputPort());
+    stencil->SetInputData(binary_image);
+#endif
     stencil->Update();
     this->AddMask(stencil->GetOutput());
 
@@ -189,7 +214,11 @@ void vvMesh::ComputeMeshes()
   this->RemoveMeshes();
   for (std::vector<vtkImageData*>::iterator i=masks.begin(); i!=masks.end(); i++) {
     vtkSmartPointer<vtkMarchingCubes> marching = vtkSmartPointer<vtkMarchingCubes>::New();
+#if VTK_MAJOR_VERSION <= 5
     marching->SetInput(*i);
+#else
+    marching->SetInputData(*i);
+#endif
     marching->SetValue(0,0.5);
     marching->Update();
     this->AddMesh(marching->GetOutput());
index 4ace9bb389239a1956477d035e51a8b7e8b48c95..1d6f19b2465cf680439c19a440b890c4cd96f4b2 100644 (file)
@@ -17,6 +17,7 @@
 ===========================================================================**/
 #include "vvMeshActor.h"
 #include "clitkCommon.h"
+#include <vtkVersion.h>
 #include <vtkPolyDataMapper.h>
 #include <vtkMarchingSquares.h>
 #include <vtkImageData.h>
@@ -45,15 +46,28 @@ void vvMeshActor::Init(vvMesh::Pointer mesh,int time_slice,vvImage::Pointer vf)
 
   mMarching=vtkMarchingSquares::New();
   mTimeSlice=time_slice;
-  if (static_cast<unsigned int>(time_slice)<mMesh->GetNumberOfMeshes())
+  if (static_cast<unsigned int>(time_slice)<mMesh->GetNumberOfMeshes()) {
+#if VTK_MAJOR_VERSION <= 5
     mMarching->SetInput(mMesh->GetMask(time_slice));
-  else
+#else
+    mMarching->SetInputData(mMesh->GetMask(time_slice));
+#endif
+  } else {
+#if VTK_MAJOR_VERSION <= 5
     mMarching->SetInput(mMesh->GetMask(0));
+#else
+    mMarching->SetInputData(mMesh->GetMask(0));
+#endif
+  }
   mMarching->SetValue(0,0.5);
   //mMarching->Update();
 
   mMapper=vtkPolyDataMapper::New();
+#if VTK_MAJOR_VERSION <= 5
   mMapper->SetInput(mMarching->GetOutput());
+#else
+  mMapper->SetInputConnection(mMarching->GetOutputPort());
+#endif
   //The following line allows to display the contour over the image
   //(http://www.nabble.com/What-happens-when-two-actors-are-at-the-same-depth--td23175458.html)
   vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
@@ -63,6 +77,7 @@ void vvMeshActor::Init(vvMesh::Pointer mesh,int time_slice,vvImage::Pointer vf)
   mActor->GetProperty()->EdgeVisibilityOn();
   mActor->GetProperty()->SetEdgeColor(mMesh->r,mMesh->g,mMesh->b);
   mActor->GetProperty()->SetLineWidth(2.);
+  mActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
 }
 
 void vvMeshActor::SetCutSlice(double slice)
@@ -96,10 +111,19 @@ void vvMeshActor::SetCutSlice(double slice)
 void vvMeshActor::SetTimeSlice(int time)
 {
   mTimeSlice=time;
-  if (static_cast<unsigned int>(time)<mMesh->GetNumberOfMasks())
+  if (static_cast<unsigned int>(time)<mMesh->GetNumberOfMasks()) {
+#if VTK_MAJOR_VERSION <= 5
     mMarching->SetInput(mMesh->GetMask(time));
-  else
+#else
+    mMarching->SetInputData(mMesh->GetMask(time));
+#endif
+  } else {
+#if VTK_MAJOR_VERSION <= 5
     mMarching->SetInput(mMesh->GetMask(0));
+#else
+    mMarching->SetInputData(mMesh->GetMask(0));
+#endif
+ }
   SetCutSlice(mCutSlice); //We need to find the new mask cut slice,
   //since masks do not all have the same origin
 }
index d03b0ac29c69013051926ae048ddebaa51deb1ca..0feabf3fac5dc8123b5c12b4f468ebf2c97432bd 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 
 // vtk
+#include <vtkVersion.h>
 #include <vtkSmartPointer.h>
 #include <vtkAppendPolyData.h>
 #include <vtkCellArray.h>
@@ -223,13 +224,6 @@ std::vector<vvMesh::Pointer> vvMeshReader::readSelectedContours()
 {
   std::vector<vvMesh::Pointer> result;
 #if GDCM_MAJOR_VERSION == 2
-
-#if CLITK_USE_SYSTEM_GDCM == 0
-  
-  clitkExceptionMacro("ERROR ! You need to compile vv with itk4 + system_gdcm to use this function");
-
-#endif
-
   gdcm::Reader reader;
   reader.SetFileName(filename.c_str());
   reader.Read();
@@ -297,7 +291,11 @@ std::vector<vvMesh::Pointer> vvMeshReader::readSelectedContours()
                       ids[1] = (ids[0] + 1) % tpoint_number.GetValue(); //0-1,1-2,...,n-1-0
                       contour->GetLines()->InsertNextCell(2, ids);
                     }
+#if VTK_MAJOR_VERSION <= 5
                   append->AddInput(contour);
+#else
+                  append->AddInputData(contour);
+#endif
                 }
               else
                 if (contour_type == "POINT ")
index b4582e2275cb52ae8a59375329b537eda3fcfb11..d4192d601ed5877478671d0669e2607c2ca63cc0 100644 (file)
@@ -108,11 +108,7 @@ vvImage::Pointer WarpRefImage(OutputVFType::Pointer vf,vvImage::Pointer image,in
 
   typename FilterType::Pointer warp_filter = FilterType::New();
   warp_filter->SetInput(input);
-#if ITK_VERSION_MAJOR >= 4
   warp_filter->SetDisplacementField(resampler->GetOutput());
-#else
-  warp_filter->SetDeformationField(resampler->GetOutput());
-#endif
   warp_filter->SetOutputSpacing(input->GetSpacing());
   warp_filter->SetOutputOrigin(input->GetOrigin());
   warp_filter->SetOutputSize(input->GetLargestPossibleRegion().GetSize());
@@ -172,7 +168,8 @@ itk::Image<itk::Vector<float,3>,3>::Pointer AverageField(itk::Image<itk::Vector<
 
   // Average
   VFPixelType vector;
-  VFPixelType zeroVector=itk::NumericTraits<VFPixelType>::Zero;
+  VFPixelType zeroVector;//=itk::NumericTraits<VFPixelType>::Zero;
+  for(unsigned int i=0;i <VFPixelType::Dimension; i++) zeroVector[i] = 0.0;
 
   while (!(iterators[0]).IsAtEnd()) {
     vector=zeroVector;
@@ -194,4 +191,3 @@ void vvMidPosition::update_progress()
   p_bar.setValue(progress);
   p_bar.show();
 }
-
diff --git a/vv/vvOSXHelper.h b/vv/vvOSXHelper.h
new file mode 100644 (file)
index 0000000..2d9f296
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _OSX_HELPER_
+#define _OSX_HELPER_
+
+// For retina displays, see
+// http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
+void disableGLHiDPI( long a_id );
+
+#endif
+
diff --git a/vv/vvOSXHelper.mm b/vv/vvOSXHelper.mm
new file mode 100644 (file)
index 0000000..20898a2
--- /dev/null
@@ -0,0 +1,10 @@
+#include <Cocoa/Cocoa.h>
+#include "vvOSXHelper.h"
+
+// For retina displays, see
+// http://public.kitware.com/pipermail/vtkusers/2015-February/090117.html
+void disableGLHiDPI( long a_id ){
+ NSView *view = reinterpret_cast<NSView*>( a_id );
+ [view setWantsBestResolutionOpenGLSurface:NO];
+}
+
index 3490933fb89b3ce180af5d8bdf1bc598d4167c77..2a77e8dcaff5a5a335c23f4366571dfb238691e2 100644 (file)
@@ -233,7 +233,7 @@ void vvOverlayPanel::setFusionProperty()
   if (disableFusionSignals)
     return;
 
-  fusionOpacitySpin->setValue(opacityHorizontalSlider->value()); 
+  fusionOpacitySpin->setValue(opacityHorizontalSlider->value());
   fusionThresSpin->setValue(thresOpacityHorizontalSlider->value());
 
   emit FusionPropertyUpdated(opacityHorizontalSlider->value(), thresOpacityHorizontalSlider->value(), fusionColorMapComboBox->currentIndex(),
index c1f821516be03f05f697cf00925bbf5040f5d5aa..44850bb158aadbd504b4d2edd3c033023e1d2ec5 100644 (file)
@@ -94,8 +94,12 @@ void vvDicomSeriesSelector::close()
 void vvDicomSeriesSelector::BrowseButtonRelease()
 {
   QFileDialog dialog(this);
+  QStringList filters;
+  filters << "DICOM files (*.dcm)"
+          << "All files (*)";
   dialog.setFileMode(QFileDialog::AnyFile);
-  dialog.setFilter("DICOM files (*.dcm); All files (*)");
+  dialog.setNameFilters(filters);
+  //dialog.setFilter(tr("DICOM files (*.dcm); All files (*)"));
   mFoldername = dialog.getExistingDirectory(this,
                 "Select a folder to find DICOM image",
                 mPreviousPath);
index 8f40ae6405b839e39cf5ea5d8c26a99cae94e35f..89ac8412bc37a8a160c788473f2e9af3760b38dd 100644 (file)
@@ -306,7 +306,7 @@ std::vector< std::pair<gdcm::Tag, std::string> > vvQPacsConnection::getKeys()
        //gdcm::Tag tagsdc(8,1030);
        //keys.push_back(std::make_pair(tagsdc, ""));
 
-       //// Accession n°
+       //// Accession
        //gdcm::Tag tagacc(8,50);
        //keys.push_back(std::make_pair(tagacc, ""));
 
@@ -383,7 +383,7 @@ void vvQPacsConnection::on_importButton_clicked()
                        dirpath.mkdir(path);
                }
                bool didItWork =  gdcm::CompositeNetworkFunctions::CMove(m_adress.c_str(),atoi(m_port.c_str()),
-                       gdcm::CompositeNetworkFunctions::ConstructQuery(mQFactory.getMoveQuery().theRoot, mQFactory.getMoveQuery().theLevel ,mQFactory.getMoveQuery().keys,true),
+                       gdcm::CompositeNetworkFunctions::ConstructQuery(mQFactory.getMoveQuery().theRoot, mQFactory.getMoveQuery().theLevel ,mQFactory.getMoveQuery().keys, gdcm::eMove),
                        getDicomClientPort(),  getDicomClientAETitle().c_str(), m_aetitle.c_str(), path.toStdString().c_str() );
                gdcm::Directory theDir;
                theDir.Load(path.toStdString().c_str());
@@ -393,7 +393,7 @@ void vvQPacsConnection::on_importButton_clicked()
      NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
      nameGenerator->SetUseSeriesDetails(true);
 
-     //ds gérer recursive moi-meme pour progress ...
+     //ds gerer recursive moi-meme pour progress ...
      nameGenerator->SetInputDirectory(path.toStdString());
 
      // insert in table
index 74d588328865cdfa27ca192a0d44daf5cdcb7a3d..4e1a9dc880b487c8b38969c67f567e1fb44cd5a4 100644 (file)
@@ -32,7 +32,7 @@
 
 //------------------------------------------------------------------------------
 vvROIActor::vvROIActor()
-{
+{ 
   mIsVisible = true;
   mIsContourVisible = false;
   mOpacity = 0.5;
@@ -52,14 +52,14 @@ vvROIActor::vvROIActor()
 
 //------------------------------------------------------------------------------
 vvROIActor::~vvROIActor()
-{
+{ 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvROIActor::RemoveActors()
-{
+{ 
   for(unsigned int i= 0; i<mOverlayActors.size(); i++) {
     mOverlayActors[i]->RemoveActors();
   }
@@ -69,29 +69,31 @@ void vvROIActor::RemoveActors()
   }  
   
   Update(true);
-  mImageContour.clear();
-  mOverlayActors.clear();
+  //mImageContour.clear();
+  //mOverlayActors.clear();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvROIActor::SetROI(clitk::DicomRT_ROI * s)
-{
+{ 
   mROI = s;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::SetContourWidth(int n) {
+void vvROIActor::SetContourWidth(int n) 
+{ 
   mContourWidth = n;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::SetSlicerManager(vvSlicerManager * s) {
+void vvROIActor::SetSlicerManager(vvSlicerManager * s) 
+{ 
   mSlicerManager = s;
 }
 //------------------------------------------------------------------------------
@@ -99,7 +101,7 @@ void vvROIActor::SetSlicerManager(vvSlicerManager * s) {
 
 //------------------------------------------------------------------------------
 void vvROIActor::UpdateImage()
-{
+{ 
   mOverlayActors.clear();
   mImageContour.clear();
   Initialize(mDepth, mIsVisible);
@@ -110,7 +112,7 @@ void vvROIActor::UpdateImage()
 
 //------------------------------------------------------------------------------
 void vvROIActor::SetVisible(bool b)
-{
+{ 
   mIsVisible = b;
   if (!b) { // remove actor
     for(unsigned int i= 0; i<mOverlayActors.size(); i++)
@@ -119,13 +121,14 @@ void vvROIActor::SetVisible(bool b)
     for(unsigned int i= 0; i<mOverlayActors.size(); i++)
       mOverlayActors[i]->ShowActors();
   }
-  Update(); // No Render
+  //Update(); // No Render
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::SetContourVisible(bool b) {
+void vvROIActor::SetContourVisible(bool b) 
+{ 
   mIsContourVisible = b;
   if (!b) { // remove actor
     for(unsigned int i= 0; i<mImageContour.size(); i++) {
@@ -137,27 +140,30 @@ void vvROIActor::SetContourVisible(bool b) {
       mImageContour[i]->ShowActors();
     }
   }
-  Update(); // No Render
+  //Update(); // No Render
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-bool vvROIActor::IsVisible() {
+bool vvROIActor::IsVisible() 
+{ 
   return mIsVisible;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-bool vvROIActor::IsContourVisible() {
+bool vvROIActor::IsContourVisible() 
+{ 
   return mIsContourVisible;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::Initialize(double depth, bool IsVisible) {
+void vvROIActor::Initialize(double depth, bool IsVisible) 
+{ 
   if (mROI->GetImage()) {
     mImageContour.clear();
     mOverlayActors.clear();
@@ -174,7 +180,7 @@ void vvROIActor::Initialize(double depth, bool IsVisible) {
       mImageContour[i]->SetLineWidth(mContourWidth);
       mImageContour[i]->SetPreserveMemoryModeEnabled(true);
       mImageContour[i]->SetDepth(mDepth+0.5);
-      mImageContour[i]->HideActors();
+      mImageContour[i]->ShowActors();
       
       mOverlayActors.push_back(vvBinaryImageOverlayActor::New());
 
@@ -195,9 +201,8 @@ void vvROIActor::Initialize(double depth, bool IsVisible) {
       mOverlayActors[i]->Initialize(IsVisible);      
       mOverlayActors[i]->SetDepth(mDepth);
     }
-
     connect(mSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
-    //connect(mSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+    connect(mSlicerManager,SIGNAL(UpdateTSlice(int,int,int)),this,SLOT(UpdateSlice(int, int, int)));
     connect(mSlicerManager, SIGNAL(AVerticalSliderHasChanged(int, int)), SLOT(UpdateSlice(int, int)));
   }
 }
@@ -206,7 +211,7 @@ void vvROIActor::Initialize(double depth, bool IsVisible) {
 
 //------------------------------------------------------------------------------
 void vvROIActor::SetDepth(double d)
-{
+{ 
   mDepth = d;
   if (!mSlicerManager) return;
   for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {  
@@ -220,7 +225,7 @@ void vvROIActor::SetDepth(double d)
 
 //------------------------------------------------------------------------------
 void vvROIActor::Update(bool force)
-{
+{ 
   if (!mSlicerManager) return;
   for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
     UpdateSlice(i, mSlicerManager->GetSlicer(i)->GetSlice(), force);
@@ -230,8 +235,8 @@ void vvROIActor::Update(bool force)
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::UpdateSlice(int slicer, int slices, bool force)
-{
+void vvROIActor::UpdateSlice(int slicer, int slices, int force)
+{ 
   if (!mROI->GetImage())  return;
   if ((!mIsVisible) && (!mIsContourVisible)) return; 
   if (!mSlicerManager) {
@@ -244,21 +249,25 @@ void vvROIActor::UpdateSlice(int slicer, int slices, bool force)
   }
 
   // Refresh overlays
-  mOverlayActors[slicer]->UpdateSlice(slicer, slices, force);
+  if (mIsVisible) {
+    mOverlayActors[slicer]->UpdateSlice(slicer, slices, force);
+  }
+  //mSlicerManager->GetSlicer(slicer)->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvROIActor::SetOpacity(double d)
-{
+{ 
   mOpacity = d;
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::SetContourColor(double r, double v, double b) {
+void vvROIActor::SetContourColor(double r, double v, double b) 
+{ 
   mContourColor[0] = r;
   mContourColor[1] = v;
   mContourColor[2] = b;  
@@ -267,7 +276,8 @@ void vvROIActor::SetContourColor(double r, double v, double b) {
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::SetOverlayColor(double r, double v, double b) {
+void vvROIActor::SetOverlayColor(double r, double v, double b) 
+{ 
   if (mROI)
     mROI->SetDisplayColor(r,v,b);
 }
@@ -275,21 +285,24 @@ void vvROIActor::SetOverlayColor(double r, double v, double b) {
 
 
 //------------------------------------------------------------------------------
-std::vector<double> & vvROIActor::GetContourColor() { 
+std::vector<double> & vvROIActor::GetContourColor() 
+{ 
   return mContourColor; 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-std::vector<double> & vvROIActor::GetOverlayColor() { 
+std::vector<double> & vvROIActor::GetOverlayColor() 
+{ 
   return mROI->GetDisplayColor();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvROIActor::UpdateColor() {
+void vvROIActor::UpdateColor() 
+{ 
   for(unsigned int i=0; i<mOverlayActors.size(); i++) {
     mOverlayActors[i]->SetOpacity(mOpacity);
     mOverlayActors[i]->SetColor(mROI->GetDisplayColor()[0],
@@ -309,7 +322,7 @@ void vvROIActor::UpdateColor() {
 
 //------------------------------------------------------------------------------
 double vvROIActor::GetOpacity()
-{
+{ 
   return mOpacity;
 }
 //------------------------------------------------------------------------------
@@ -317,7 +330,7 @@ double vvROIActor::GetOpacity()
 
 //------------------------------------------------------------------------------
 void vvROIActor::SetSelected(bool b)
-{
+{ 
   mIsSelected = b;
   if (b) {
     for(int i=0; i<mSlicerManager->GetNumberOfSlicers(); i++) {
@@ -335,7 +348,7 @@ void vvROIActor::SetSelected(bool b)
 
 //------------------------------------------------------------------------------
 void vvROIActor::CopyParameters(QSharedPointer<vvROIActor> roi)
-{
+{ 
   // Overlay
   SetVisible(roi->IsVisible());
   SetOpacity(roi->GetOpacity());
index 5a54adeeaa653edbc3efb5914f9a0d29f8636f13..04c90290f9fc16c9465ee6d4a332cf51ea682244 100644 (file)
@@ -61,7 +61,7 @@ class vvROIActor: public QObject {
   void RemoveActors();
 
 public slots:
-  void UpdateSlice(int slicer, int slices, bool force=false);
+  void UpdateSlice(int slicer, int slices, int force=0);
   void UpdateColor();
   void UpdateImage();
 
index 112330aca32513e1d9e373f397f4d85738c665ac..2d6057e9e9bed82217ec327ad3a70607589234c0 100644 (file)
@@ -20,6 +20,9 @@
 #include "vvRegisterForm.h"
 #include <QNetworkRequest>
 #include <QDir>
+#if QT_VERSION >= 0x050000
+#include <QUrlQuery>
+#endif
 #include <QPalette>
 #include "clitkConfiguration.h"
 #include "vvConfiguration.h"
@@ -33,6 +36,8 @@ vvRegisterForm::vvRegisterForm(QUrl url, QString path, QSettings::Format format)
 
 void vvRegisterForm::sendData(){
   QUrl url2(url);
+  
+#if QT_VERSION < 0x050000
   url2.addQueryItem("name", firstName->text().toUtf8());
   url2.addQueryItem("lastName", lastName->text().toUtf8());
   url2.addQueryItem("email", email->text().toUtf8());
@@ -42,7 +47,21 @@ void vvRegisterForm::sendData(){
   url2.addQueryItem("architecture", ARCHITECTURE);
   url2.addQueryItem("adressing", QString::number(sizeof(char*)*8)+"-bit");
   url2.addQueryItem("compilationDate", QString(__DATE__) + ", " + QString(__TIME__) );
-
+#else
+  QUrlQuery url2Query;
+    
+  url2Query.addQueryItem("name", firstName->text().toUtf8());
+  url2Query.addQueryItem("lastName", lastName->text().toUtf8());
+  url2Query.addQueryItem("email", email->text().toUtf8());
+  url2Query.addQueryItem("group", group->text().toUtf8());
+  url2Query.addQueryItem("os", OS_NAME);
+  url2Query.addQueryItem("vvVersion", VV_VERSION);
+  url2Query.addQueryItem("architecture", ARCHITECTURE);
+  url2Query.addQueryItem("adressing", QString::number(sizeof(char*)*8)+"-bit");
+  url2Query.addQueryItem("compilationDate", QString(__DATE__) + ", " + QString(__TIME__) );
+  url2.setQuery(url2Query);
+#endif
+  
   manager->get(QNetworkRequest(url2));
 }
 void vvRegisterForm::accept(){
index 888375eefbb2449001e80dd5300998298e421894..b538b9d6919e7bbaa57bbfd6549ddd5bfb48b3b0 100644 (file)
@@ -27,6 +27,9 @@
 #include "vvInteractorStyleNavigator.h"
 #include "vvSlicer.h"
 
+#include <vtkVersion.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
 #include "vtkMarchingCubes.h"
 #include "vtkMarchingSquares.h"
 #include "vtkImageClip.h"
 #include <vtkPolyDataWriter.h>
 
 #include <QMessageBox>
+#include <QFileDialog>
+
+#ifdef Q_OS_OSX
+# include "vvOSXHelper.h"
+#endif
 
 //====================================================================
 vvSegmentationDialog::vvSegmentationDialog(QWidget * parent, Qt::WindowFlags f)
@@ -98,6 +106,10 @@ vvSegmentationDialog::vvSegmentationDialog(QWidget * parent, Qt::WindowFlags f)
   erodeButton->setEnabled(0);
   dilateButton->setEnabled(0);
   infoLabel->setText("Select Up and Down threshold before clicking binarise !");
+
+#ifdef Q_OS_OSX
+  disableGLHiDPI(viewWidget->winId());
+#endif
 }
 
 vvSegmentationDialog::~vvSegmentationDialog()
@@ -188,14 +200,27 @@ void vvSegmentationDialog::SetImage(vvImage::Pointer image)
   clipping1Slider->setValue(range[0]);
   clipping2Slider->setValue(range[1]);
 
+#if VTK_MAJOR_VERSION <= 5
   mClipper->SetInput(mManager->GetSlicer(0)->GetInput());
+#else
+  mClipper->SetInputData(mManager->GetSlicer(0)->GetInput());
+#endif
   mSquares1->SetValue(0,clipping1Slider->value());
   mSquares2->SetValue(0,clipping2Slider->value());
+
+#if VTK_MAJOR_VERSION <= 5
   mSquares1->SetInput(mClipper->GetOutput());
   mSquares2->SetInput(mClipper->GetOutput());
 
   mSquaresMapper1->SetInput(mSquares1->GetOutput());
   mSquaresMapper2->SetInput(mSquares2->GetOutput());
+#else
+  mSquares1->SetInputData(mClipper->GetOutput());
+  mSquares2->SetInputData(mClipper->GetOutput());
+
+  mSquaresMapper1->SetInputData(mSquares1->GetOutput());
+  mSquaresMapper2->SetInputData(mSquares2->GetOutput());
+#endif
   mSquaresMapper1->ScalarVisibilityOff();
   mSquaresMapper2->ScalarVisibilityOff();
 
@@ -225,7 +250,11 @@ void vvSegmentationDialog::UpdateSlice(int slicer,int slices)
 {
   int slice = mManager->GetSlicer(0)->GetSlice();
   int tslice = mManager->GetSlicer(0)->GetTSlice();
+#if VTK_MAJOR_VERSION <= 5
   mClipper->SetInput(mManager->GetSlicer(0)->GetInput());
+#else
+  mClipper->SetInputData(mManager->GetSlicer(0)->GetInput());
+#endif
   int* extent = mManager->GetSlicer(0)->GetImageActor()->GetDisplayExtent();
   mClipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]);
   int i;
@@ -320,7 +349,11 @@ void vvSegmentationDialog::BinariseSurface()
   for (unsigned int numImage = 0; numImage < mManager->GetSlicer(0)->GetImage()->GetVTKImages().size(); numImage++) {
     vtkImageData* image = mManager->GetSlicer(0)->GetImage()->GetVTKImages()[numImage];
     int ext[6];
+#if VTK_MAJOR_VERSION <= 5
     image->GetWholeExtent(ext);
+#else
+    image->GetExtent(ext);
+#endif
     void *in1Ptr;
     in1Ptr = image->GetScalarPointerForExtent(ext);
 
@@ -337,17 +370,34 @@ void vvSegmentationDialog::BinariseSurface()
     outputImage->SetExtent(ext);
     outputImage->SetOrigin(image->GetOrigin());
     outputImage->SetSpacing(image->GetSpacing());
+#if VTK_MAJOR_VERSION <= 5
     outputImage->SetScalarTypeToUnsignedChar();
+#else
+    outputImage->AllocateScalars(VTK_UNSIGNED_CHAR, 1);
+#endif
     outputImage->CopyAndCastFrom(image,ext);
+#if VTK_MAJOR_VERSION <= 5
     outputImage->Update();
+#else
+    //outputImage->Update();
+#endif
 
     image->DeepCopy(outputImage);
+#if VTK_MAJOR_VERSION <= 5
     image->UpdateInformation();
     image->PropagateUpdateExtent();
+#else
+    //image->UpdateInformation();
+    //image->PropagateUpdateExtent();
+#endif
 
     vtkImageData* imageBin = vtkImageData::New();
     imageBin->DeepCopy(image);
+#if VTK_MAJOR_VERSION <= 5
     imageBin->Update();
+#else
+    //imageBin->Update();
+#endif
     mBinaireImages.push_back(imageBin);
   }
 
@@ -366,10 +416,19 @@ void vvSegmentationDialog::Erode()
   erode->SetKernelSize(mKernelValue,mKernelValue,mKernelValue);
   for (unsigned int numImage = 0; numImage < mManager->GetSlicer(0)->GetImage()->GetVTKImages().size(); numImage++) {
     vtkImageData* image = mManager->GetSlicer(0)->GetImage()->GetVTKImages()[numImage];
+#if VTK_MAJOR_VERSION <= 5
     erode->SetInput(image);
     erode->Update();
+#else
+    erode->SetInputData(image);
+    //erode->Update();
+#endif
     image->DeepCopy(erode->GetOutput());
+#if VTK_MAJOR_VERSION <= 5
     image->Update();
+#else
+    //image->Update();
+#endif
   }
   erode->Delete();
   dilateButton->setEnabled(1);
@@ -386,13 +445,26 @@ void vvSegmentationDialog::Dilate()
   dilate->SetKernelSize(mKernelValue,mKernelValue,mKernelValue);
   for (unsigned int numImage = 0; numImage < mManager->GetSlicer(0)->GetImage()->GetVTKImages().size(); numImage++) {
     vtkImageData* image = mManager->GetSlicer(0)->GetImage()->GetVTKImages()[numImage];
+#if VTK_MAJOR_VERSION <= 5
     dilate->SetInput(image);
+#else
+    dilate->SetInputData(image);
+#endif
     vtkImageData* mask = mBinaireImages[numImage];
+#if VTK_MAJOR_VERSION <= 5
     And->SetInput1(dilate->GetOutput());
     And->SetInput2(mask);
+#else
+    And->SetInput1Data(dilate->GetOutput());
+    And->SetInput2Data(mask);
+#endif
     And->Update();
     image->DeepCopy(And->GetOutput());
+#if VTK_MAJOR_VERSION <= 5
     image->Update();
+#else
+    //image->Update();
+#endif
   }
   And->Delete();
   dilate->Delete();
@@ -425,10 +497,18 @@ void vvSegmentationDialog::InsertSeed()
 
   for (unsigned int numImage = 0; numImage < mManager->GetSlicer(0)->GetImage()->GetVTKImages().size(); numImage++) {
     vtkImageData* image = mManager->GetSlicer(0)->GetImage()->GetVTKImages()[numImage];
+#if VTK_MAJOR_VERSION <= 5
     seed->SetInput(image);
+#else
+    seed->SetInputData(image);
+#endif
     seed->Update();
     image->DeepCopy(seed->GetOutput());
+#if VTK_MAJOR_VERSION <= 5
     image->Update();
+#else
+    //image->Update();
+#endif
   }
 
   seed->Delete();
@@ -444,11 +524,19 @@ void vvSegmentationDialog::ChangeDimRendering()
       m3DExtractor->SetValue(0,0.5);
       for (unsigned int numImage = 0; numImage < mManager->GetSlicer(0)->GetImage()->GetVTKImages().size(); numImage++) {
         vtkActor* actor = vtkActor::New();
+#if VTK_MAJOR_VERSION <= 5
         m3DExtractor->SetInput(mManager->GetSlicer(0)->GetImage()->GetVTKImages()[numImage]);
+#else
+        m3DExtractor->SetInputData(mManager->GetSlicer(0)->GetImage()->GetVTKImages()[numImage]);
+#endif
         m3DExtractor->Update();
 
         vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
+#if VTK_MAJOR_VERSION <= 5
         mapper->SetInput(m3DExtractor->GetOutput());
+#else
+        mapper->SetInputData(m3DExtractor->GetOutput());
+#endif
         m3DMappers.push_back(mapper);
 
         actor->SetMapper(mapper);
@@ -503,7 +591,11 @@ void vvSegmentationDialog::Save()
                        "Mesh Files (*.vtk *.vtp)");
     if (!fileName.isEmpty()) {
       vtkSmartPointer<vtkPolyDataWriter> w = vtkSmartPointer<vtkPolyDataWriter>::New();
+#if VTK_MAJOR_VERSION <= 5
       w->SetInput(m3DExtractor->GetOutput());
+#else
+      w->SetInputData(m3DExtractor->GetOutput());
+#endif
       w->SetFileName(fileName.toStdString().c_str());
       w->Write();
     }
index ed53d2c83b138c600eeabf680da7edd775854cbc..db4b0cf525811c16c20b2742fc081d3c06be4336 100644 (file)
 #include "vvGlyphSource.h"
 #include "vvGlyph2D.h"
 
+#include <vtkVersion.h>
+#include <vtkExtentTranslator.h>
+#include <vtkAlgorithm.h>
+#include <vtkExecutive.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
 #include <vtkTextProperty.h>
 #include <vtkTextActor.h>
 #include <vtkTextSource.h>
 #include <vtkImageAccumulate.h>
 #include <vtkImageReslice.h>
 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
+#  include <vtkOpenGLImageSliceMapper.h>
 #  include <vtkImageMapper3D.h>
 #  include <vtkImageSliceMapper.h>
 #endif
 
-vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
 vtkStandardNewMacro(vvSlicer);
 static void copyExtent(int* in, int* to){
- for(int i=0; i<6; ++i) to[i]=in[i]; 
+ for(int i=0; i<6; ++i) 
+ {
+       to[i]=in[i];
+ } 
 }
 //------------------------------------------------------------------------------
 vvSlicer::vvSlicer()
-{
+{ 
        mFusionSequenceCode = -1;
   this->UnInstallPipeline();
   mImage = NULL;
   mReducedExtent = new int[6];
+  mRegisterExtent = NULL;
   mCurrentTSlice = 0;
   mCurrentFusionTSlice = 0;
   mCurrentOverlayTSlice = 0;
@@ -115,7 +125,11 @@ vvSlicer::vvSlicer()
   crossCursor->SetRadius(2);
 
   pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
+#if VTK_MAJOR_VERSION <= 5
   pdm->SetInput(crossCursor->GetOutput());
+#else
+  pdm->SetInputConnection(crossCursor->GetOutputPort(0));
+#endif
 
   pdmA = vtkSmartPointer<vtkActor2D>::New();
   pdmA->SetMapper(pdm);
@@ -162,7 +176,7 @@ vvSlicer::vvSlicer()
 
 //------------------------------------------------------------------------------
 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
-{
+{ 
   return mOverlayMapper.GetPointer();
 }
 //------------------------------------------------------------------------------
@@ -170,7 +184,7 @@ vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
 
 //------------------------------------------------------------------------------
 vvBlendImageActor* vvSlicer::GetOverlayActor()
-{
+{ 
   return mOverlayActor.GetPointer();
 }
 //------------------------------------------------------------------------------
@@ -178,7 +192,7 @@ vvBlendImageActor* vvSlicer::GetOverlayActor()
 
 //------------------------------------------------------------------------------
 vtkImageMapToColors* vvSlicer::GetFusionMapper()
-{
+{ 
   return mFusionMapper.GetPointer();
 }
 //------------------------------------------------------------------------------
@@ -186,7 +200,7 @@ vtkImageMapToColors* vvSlicer::GetFusionMapper()
 
 //------------------------------------------------------------------------------
 vtkImageActor* vvSlicer::GetFusionActor()
-{
+{ 
   return mFusionActor.GetPointer();
 }
 //------------------------------------------------------------------------------
@@ -194,7 +208,7 @@ vtkImageActor* vvSlicer::GetFusionActor()
 
 //------------------------------------------------------------------------------
 vtkActor* vvSlicer::GetVFActor()
-{
+{ 
   return mVFActor.GetPointer();
 }
 //------------------------------------------------------------------------------
@@ -202,7 +216,7 @@ vtkActor* vvSlicer::GetVFActor()
 
 //------------------------------------------------------------------------------
 vtkCornerAnnotation* vvSlicer::GetAnnotation()
-{
+{ 
   return ca.GetPointer();
 }
 //------------------------------------------------------------------------------
@@ -210,7 +224,7 @@ vtkCornerAnnotation* vvSlicer::GetAnnotation()
 
 //------------------------------------------------------------------------------
 void vvSlicer::EnableReducedExtent(bool b)
-{
+{ 
   mUseReducedExtent = b;
 }
 //------------------------------------------------------------------------------
@@ -218,7 +232,7 @@ void vvSlicer::EnableReducedExtent(bool b)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetReducedExtent(int * ext)
-{
+{ 
   copyExtent(ext, mReducedExtent);
 }
 //------------------------------------------------------------------------------
@@ -226,7 +240,7 @@ void vvSlicer::SetReducedExtent(int * ext)
 
 //------------------------------------------------------------------------------
 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
-{
+{ 
 
   mSurfaceCutActors.push_back(new vvMeshActor());
   if (propagate)
@@ -243,7 +257,7 @@ void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
 
 //------------------------------------------------------------------------------
 void vvSlicer::ToggleContourSuperposition()
-{
+{ 
   for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
        i!=mSurfaceCutActors.end(); i++)
     (*i)->ToggleSuperposition();
@@ -253,7 +267,7 @@ void vvSlicer::ToggleContourSuperposition()
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetCursorColor(int r,int g, int b)
-{
+{ 
   pdmA->GetProperty()->SetColor(r,g,b);
 }
 //------------------------------------------------------------------------------
@@ -261,7 +275,7 @@ void vvSlicer::SetCursorColor(int r,int g, int b)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetCursorVisibility(bool s)
-{
+{ 
   pdmA->SetVisibility(s);
 }
 //------------------------------------------------------------------------------
@@ -269,7 +283,7 @@ void vvSlicer::SetCursorVisibility(bool s)
 
 //------------------------------------------------------------------------------
 bool vvSlicer::GetCursorVisibility()
-{
+{ 
   return pdmA->GetVisibility();
 }
 //------------------------------------------------------------------------------
@@ -277,7 +291,7 @@ bool vvSlicer::GetCursorVisibility()
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetCornerAnnotationVisibility(bool s)
-{
+{ 
   ca->SetVisibility(s);
 }
 //------------------------------------------------------------------------------
@@ -285,7 +299,7 @@ void vvSlicer::SetCornerAnnotationVisibility(bool s)
 
 //------------------------------------------------------------------------------
 bool vvSlicer::GetCornerAnnotationVisibility()
-{
+{ 
   return ca->GetVisibility();
 }
 //------------------------------------------------------------------------------
@@ -293,7 +307,7 @@ bool vvSlicer::GetCornerAnnotationVisibility()
 
 //------------------------------------------------------------------------------
 vvSlicer::~vvSlicer()
-{
+{ 
   for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
        i!=mSurfaceCutActors.end(); i++)
     delete (*i);
@@ -303,14 +317,14 @@ vvSlicer::~vvSlicer()
 
 //------------------------------------------------------------------------------
 double* vvSlicer::GetCurrentPosition()
-{
+{ 
   return mCurrentBeforeSlicingTransform;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
-{
+{ 
   mCurrentBeforeSlicingTransform[0]=x;
   mCurrentBeforeSlicingTransform[1]=y;
   mCurrentBeforeSlicingTransform[2]=z;
@@ -322,7 +336,7 @@ void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetImage(vvImage::Pointer image)
-{
+{ 
   if (image->GetVTKImages().size()) {
     mImage = image;
 
@@ -337,13 +351,26 @@ void vvSlicer::SetImage(vvImage::Pointer image)
     mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
     mConcatenatedTransform->Concatenate(mSlicingTransform);
     mImageReslice->SetResliceTransform(mConcatenatedTransform);
+#if VTK_MAJOR_VERSION <= 5
     mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
+#else
+    mImageReslice->SetInputData(0, mImage->GetFirstVTKImageData());
+#endif
     mImageReslice->UpdateInformation();
 
+#if VTK_MAJOR_VERSION <= 5
     this->Superclass::SetInput(mImageReslice->GetOutput());
+#else
+    this->Superclass::SetInputConnection(mImageReslice->GetOutputPort());
+#endif
 
     int extent[6];
+#if VTK_MAJOR_VERSION <= 5
     this->GetInput()->GetWholeExtent(extent);
+#else
+    int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
+    copyExtent(ext, extent);
+#endif
 
     // Prevent crash when reload -> change slice if outside extent
     if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
@@ -352,9 +379,14 @@ void vvSlicer::SetImage(vvImage::Pointer image)
 
     // Make sure that the required part image has been computed
     extent[SliceOrientation*2] = Slice;
-    extent[SliceOrientation*2+1] = Slice;
+    extent[SliceOrientation*2+1] = Slice;    
+#if VTK_MAJOR_VERSION <= 5
     mImageReslice->GetOutput()->SetUpdateExtent(extent);
     mImageReslice->GetOutput()->Update();
+#else
+    //mImageReslice->SetUpdateExtent(extent);
+    mImageReslice->Update();
+#endif
 
     this->UpdateDisplayExtent();
 
@@ -367,7 +399,7 @@ void vvSlicer::SetImage(vvImage::Pointer image)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
-{
+{ 
   if (overlay->GetVTKImages().size()) {
     mOverlay = overlay;
     mOverlayVisibility = true;
@@ -383,16 +415,29 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay)
     mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]);
     mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
     mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform);
+#if VTK_MAJOR_VERSION <= 5
     mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
     mImageReslice->UpdateInformation();
+#else
+    mOverlayReslice->SetInputData(0, mOverlay->GetFirstVTKImageData());
+#endif
+    mOverlayReslice->Update();
 
     if (!mOverlayMapper)
       mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
+#if VTK_MAJOR_VERSION <= 5
     mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
+#else
+    mOverlayMapper->SetInputConnection(mOverlayReslice->GetOutputPort(0));
+#endif
 
     if (!mOverlayActor) {
       mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
+#if VTK_MAJOR_VERSION <= 5
       mOverlayActor->SetInput(mOverlayMapper->GetOutput());
+#else
+      mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort());
+#endif
       mOverlayActor->SetPickable(0);
       mOverlayActor->SetVisibility(true);
       mOverlayActor->SetOpacity(0.5);
@@ -420,7 +465,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
-{
+{ 
        mFusionSequenceCode = fusionSequenceCode;
   if (fusion->GetVTKImages().size()) {
     mFusion = fusion;
@@ -437,8 +482,13 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
     mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]);
     mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
     mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform);
+#if VTK_MAJOR_VERSION <= 5
     mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
     mFusionReslice->UpdateInformation();
+#else
+    mFusionReslice->SetInputData(0, mFusion->GetFirstVTKImageData());
+#endif
+    mFusionReslice->Update();
 
     if (!mFusionMapper)
       mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
@@ -449,17 +499,26 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
     lut->SetSaturationRange(0, 0);
     lut->Build();
     mFusionMapper->SetLookupTable(lut);
+#if VTK_MAJOR_VERSION <= 5
     mFusionMapper->SetInput(mFusionReslice->GetOutput());
-
+#else
+    mFusionMapper->SetInputConnection(mFusionReslice->GetOutputPort(0));
+#endif
+    
     if (!mFusionActor) {
       mFusionActor = vtkSmartPointer<vtkImageActor>::New();
+#if VTK_MAJOR_VERSION <= 5
       mFusionActor->SetInput(mFusionMapper->GetOutput());
+#else
+      mFusionActor->GetMapper()->SetInputConnection(mFusionMapper->GetOutputPort());
+#endif
       mFusionActor->SetPickable(0);
       mFusionActor->SetVisibility(true);
       mFusionActor->SetOpacity(0.7);
 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
       mFusionActor->GetMapper()->BorderOn();
 #endif
+
       this->GetRenderer()->AddActor(mFusionActor);
     }
 
@@ -474,7 +533,7 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
 
 //------------------------------------------------------------------------------
 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
-{
+{ 
   bool vis = false;
   if (actor_type == "image")
     vis = mImageVisibility;
@@ -492,7 +551,7 @@ bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_ind
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
-{
+{ 
   if (actor_type == "image")
     mImageVisibility = vis;
   else if (actor_type == "vector")
@@ -509,7 +568,7 @@ void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_ind
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetVF(vvImage::Pointer vf)
-{
+{ 
   if (vf->GetVTKImages().size()) {
     mVF = vf;
     mVFVisibility = true;
@@ -519,8 +578,13 @@ void vvSlicer::SetVF(vvImage::Pointer vf)
       mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
       mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
     }
+#if VTK_MAJOR_VERSION <= 5
     mVOIFilter->SetInput(vf->GetFirstVTKImageData());
     mAAFilter->SetInput(mVOIFilter->GetOutput());
+#else
+    mVOIFilter->SetInputData(vf->GetFirstVTKImageData());
+    mAAFilter->SetInputConnection(mVOIFilter->GetOutputPort());
+#endif
     ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
     mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
 
@@ -533,8 +597,13 @@ void vvSlicer::SetVF(vvImage::Pointer vf)
     // Glyph the gradient vector (with arrows)
     if (!mGlyphFilter)
       mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
+#if VTK_MAJOR_VERSION <= 5
     mGlyphFilter->SetInput(mAAFilter->GetOutput());
     mGlyphFilter->SetSource(mArrow->GetOutput());
+#else
+    mGlyphFilter->SetInputConnection(mAAFilter->GetOutputPort());
+    mGlyphFilter->SetSourceConnection(mArrow->GetOutputPort());
+#endif
     mGlyphFilter->ScalingOn();
     mGlyphFilter->SetScaleModeToScaleByVector();
     mGlyphFilter->OrientOn();
@@ -552,7 +621,11 @@ void vvSlicer::SetVF(vvImage::Pointer vf)
 
     if (!mVFMapper)
       mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+#if VTK_MAJOR_VERSION <= 5
     mVFMapper->SetInput(mGlyphFilter->GetOutput());
+#else
+    mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
+#endif
     mVFMapper->ImmediateModeRenderingOn();
     mVFMapper->SetLookupTable(mVFColorLUT);
 
@@ -573,7 +646,7 @@ void vvSlicer::SetVF(vvImage::Pointer vf)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
-{
+{ 
   mLandmarks = landmarks;
   if (landmarks) {
 
@@ -597,10 +670,29 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
 
     mLandClipper->SetClipFunction(mClipBox);
     mLandClipper->InsideOutOn();
-    mLandClipper->SetInput(mLandmarks->GetOutput());
+#if VTK_MAJOR_VERSION <= 5
+    mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
+    mLandmarkTransform->SetInput(mLandmarks->GetOutput());
+    mConcatenatedTransform->Identity();
+    mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
+    mConcatenatedTransform->Concatenate(mSlicingTransform);
+    mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
+    mLandClipper->SetInput(mLandmarkTransform->GetOutput());
 
     mLandGlyph->SetSource(mCross->GetOutput());
     mLandGlyph->SetInput(mLandClipper->GetOutput());
+#else
+    mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
+    mLandmarkTransform->SetInputData(mLandmarks->GetOutput());
+    mConcatenatedTransform->Identity();
+    mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
+    mConcatenatedTransform->Concatenate(mSlicingTransform);
+    mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
+    mLandClipper->SetInputConnection(mLandmarkTransform->GetOutputPort());
+
+    mLandGlyph->SetSourceConnection(mCross->GetOutputPort());
+    mLandGlyph->SetInputConnection(mLandClipper->GetOutputPort());
+#endif
     //mLandGlyph->SetIndexModeToScalar();
     //mLandGlyph->SetRange(0,1);
     //mLandGlyph->ScalingOff();
@@ -614,11 +706,11 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
     //mLandMapper->ScalarVisibilityOff();
 
     mLandActor->SetMapper(mLandMapper);
+    mLandActor->GetProperty()->SetOpacity(0.995);  //in order to get VTK to turn on the alpha-blending in OpenGL
     mLandActor->GetProperty()->SetColor(255,10,212);
     mLandActor->SetPickable(0);
     mLandActor->SetVisibility(true);
     this->UpdateDisplayExtent();
-    this->GetRenderer()->AddActor(mLandActor);
   }
 }
 //------------------------------------------------------------------------------
@@ -626,7 +718,7 @@ void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
 //------------------------------------------------------------------------------
 //FIXME: this function leaks memory, we should fix it someday :)
 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
-{
+{ 
   if (actor_type == "vector") {
     Renderer->RemoveActor(mVFActor);
     mGlyphFilter=NULL;
@@ -659,7 +751,7 @@ void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetVFSubSampling(int sub)
-{
+{ 
   if (mVOIFilter) {
     mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
     mSubSampling = sub;
@@ -672,7 +764,7 @@ void vvSlicer::SetVFSubSampling(int sub)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetVFScale(int scale)
-{
+{ 
   mScale = scale;
   if (mArrow)
     mArrow->SetScale(mScale);
@@ -683,7 +775,7 @@ void vvSlicer::SetVFScale(int scale)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetVFWidth(int width)
-{
+{ 
   mVFWidth = width;
   if (mVFActor)
     mVFActor->GetProperty()->SetLineWidth(mVFWidth);
@@ -695,7 +787,7 @@ void vvSlicer::SetVFWidth(int width)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetVFLog(int log)
-{
+{ 
   mVFLog = log;
   if (mGlyphFilter) {
     mGlyphFilter->SetUseLog(mVFLog);
@@ -709,10 +801,14 @@ void vvSlicer::SetVFLog(int log)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
-{
+{ 
        if (!updateLinkedImages) {
                mCurrentTSlice = t;
-               mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
+#if VTK_MAJOR_VERSION <= 5
+                mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
+#else
+                mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
+#endif
                // Update transform
                mConcatenatedTransform->Identity();
                mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
@@ -720,7 +816,6 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
                UpdateDisplayExtent();
                return;
        }
-
   if (t < 0)
     mCurrentTSlice = 0;
   else if ((unsigned int)t >= mImage->GetVTKImages().size())
@@ -734,17 +829,28 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
   mConcatenatedTransform->Concatenate(mSlicingTransform);
 
   // Update image data
-  mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
+#if VTK_MAJOR_VERSION <= 5
+   mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
+#else
+  mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
+#endif
   if (mVF && mVFActor->GetVisibility()) {
     if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
+#if VTK_MAJOR_VERSION <= 5
       mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
+#else
+      mVOIFilter->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]);
+#endif
   }
   //update the overlay
   if (mOverlay && mOverlayActor->GetVisibility()) {
     if (mOverlay->GetVTKImages().size() > (unsigned int)t) {
       mCurrentOverlayTSlice = t;
+#if VTK_MAJOR_VERSION <= 5
       mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
-
+#else
+      mOverlayReslice->SetInputData( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
+#endif
       // Update overlay transform
       mConcatenatedOverlayTransform->Identity();
       mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[mCurrentOverlayTSlice]);
@@ -755,7 +861,11 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
   if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode<0)) {
     if (mFusion->GetVTKImages().size() > (unsigned int)t) {
       mCurrentFusionTSlice = t;
+#if VTK_MAJOR_VERSION <= 5
       mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
+#else
+      mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
+#endif
 
       // Update fusion transform
       mConcatenatedFusionTransform->Identity();
@@ -774,11 +884,15 @@ void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetFusionSequenceTSlice(int t)
-{
+{ 
   if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode>=0)) {
     if (mFusion->GetVTKImages().size() > (unsigned int)t) {
       mCurrentFusionTSlice = t;
+#if VTK_MAJOR_VERSION <= 5
       mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
+#else
+      mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
+#endif
       // Update fusion transform
       mConcatenatedFusionTransform->Identity();
       mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]); //not really useful...
@@ -793,14 +907,14 @@ void vvSlicer::SetFusionSequenceTSlice(int t)
 
 //------------------------------------------------------------------------------
 int vvSlicer::GetTSlice()
-{
+{ 
   return mCurrentTSlice;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 int vvSlicer::GetMaxCurrentTSlice()
-{
+{ 
   int t = mCurrentTSlice;
   if(mOverlay)
     t = std::max(t, mCurrentOverlayTSlice);
@@ -812,24 +926,30 @@ int vvSlicer::GetMaxCurrentTSlice()
 
 //------------------------------------------------------------------------------
 int vvSlicer::GetFusionTSlice()
-{
+{ 
   return mCurrentFusionTSlice;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 int vvSlicer::GetOverlayTSlice()
-{
+{ 
   return mCurrentOverlayTSlice;
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvSlicer::SetSliceOrientation(int orientation)
-{
+{ 
   //if 2D image, force to watch in Axial View
   int extent[6];
-  this->GetInput()->GetWholeExtent(extent);
+#if VTK_MAJOR_VERSION <= 5
+    this->GetInput()->GetWholeExtent(extent);
+#else
+    int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
+    copyExtent(ext, extent);
+#endif
+
   if (extent[5]-extent[4] <= 2)
     orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
 
@@ -858,7 +978,9 @@ void vvSlicer::SetSliceOrientation(int orientation)
     int *range = this->GetSliceRange();
     if (range)
       this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
-    mFirstSetSliceOrientation = false;
+#if VTK_MAJOR_VERSION <= 5
+      mFirstSetSliceOrientation = false;
+#endif
   }
   else if (this->Renderer && this->GetInput()) {
     double s = mCursor[orientation];
@@ -867,8 +989,13 @@ void vvSlicer::SetSliceOrientation(int orientation)
   }
 
   this->UpdateOrientation();
+  
   this->UpdateDisplayExtent();
-
+  
+  if (mFirstSetSliceOrientation) {
+    mFirstSetSliceOrientation = false;
+  }
+  
   if (this->Renderer && this->GetInput()) {
     double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
     this->Renderer->ResetCamera();
@@ -885,11 +1012,15 @@ void vvSlicer::SetSliceOrientation(int orientation)
 // In other words, we change the grid of the reslice in the same way as the grid
 // of the displayed image in the slicing direction.
 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
-{
+{ 
   // Reset autocrop and update output information
   reslice->SetOutputOriginToDefault();
   reslice->SetOutputSpacingToDefault();
+#if VTK_MAJOR_VERSION <= 5
   reslice->GetOutput()->UpdateInformation();
+#else
+  reslice->UpdateInformation();
+#endif
 
   // Ge new origin / spacing
   double origin[3];
@@ -919,16 +1050,26 @@ void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
   reslice->SetOutputOrigin(origin);
   reslice->SetOutputSpacing(spacing);
   reslice->UpdateInformation();
+#if VTK_MAJOR_VERSION <= 5
   reslice->GetOutput()->UpdateInformation();
+#endif
 }
 //------------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
-int * vvSlicer::GetExtent(){
+int * vvSlicer::GetExtent()
+{ 
   int *w_ext;
   if (mUseReducedExtent) {
     w_ext = mReducedExtent;
-  } else w_ext = GetInput()->GetWholeExtent();
+  }
+  else {
+#if VTK_MAJOR_VERSION <= 5
+    w_ext = GetInput()->GetWholeExtent();
+#else
+    w_ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
+#endif
+  }
   return w_ext;
 }
 //----------------------------------------------------------------------------
@@ -936,7 +1077,7 @@ int * vvSlicer::GetExtent(){
 
 //----------------------------------------------------------------------------
 int vvSlicer::GetOrientation()
-{
+{ 
   return this->SliceOrientation;
 }
 //----------------------------------------------------------------------------
@@ -944,25 +1085,40 @@ int vvSlicer::GetOrientation()
 
 //----------------------------------------------------------------------------
 void vvSlicer::UpdateDisplayExtent()
-{
+{ 
+  emit UpdateDisplayExtentBegin(mSlicerNumber);
   vtkImageData *input = this->GetInput();
   if (!input || !this->ImageActor) {
     return;
   }
+
+#if VTK_MAJOR_VERSION <= 5
   input->UpdateInformation();
+#else
+  mRegisterExtent = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
+#endif
   this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents
 
   // Local copy of extent
   int w_ext[6];
+#if VTK_MAJOR_VERSION <= 5
   int* ext = GetExtent();
+#else
+  int* ext = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
+#endif
   copyExtent(ext, w_ext);
+  if (mUseReducedExtent) {
+        copyExtent(mReducedExtent, w_ext);
+    }
   // Set slice value
+
   w_ext[ this->SliceOrientation*2   ] = this->Slice;
   w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
   
   // Image actor
   this->ImageActor->SetVisibility(mImageVisibility);
   this->ImageActor->SetDisplayExtent(w_ext);
+  
 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
   // Fix for bug #1882
   dynamic_cast<vtkImageSliceMapper *>(this->ImageActor->GetMapper())->SetOrientation(this->GetOrientation());
@@ -972,8 +1128,13 @@ void vvSlicer::UpdateDisplayExtent()
   if (mOverlay && mOverlayVisibility) {
     AdjustResliceToSliceOrientation(mOverlayReslice);
     int overExtent[6];
+#if VTK_MAJOR_VERSION <= 5
     this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
     bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
+#else
+    this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mOverlayReslice->GetOutput(), overExtent);
+    bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
+#endif
     mOverlayActor->SetVisibility(!out);
     mOverlayActor->SetDisplayExtent( overExtent );
 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
@@ -988,8 +1149,13 @@ void vvSlicer::UpdateDisplayExtent()
   if (mFusion && mFusionVisibility) {
     AdjustResliceToSliceOrientation(mFusionReslice);
     int fusExtent[6];
+#if VTK_MAJOR_VERSION <= 5
     this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
     bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
+#else
+    this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mFusionReslice->GetOutput(), fusExtent);
+    bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
+#endif
     mFusionActor->SetVisibility(!out);
     mFusionActor->SetDisplayExtent( fusExtent );
 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
@@ -999,7 +1165,6 @@ void vvSlicer::UpdateDisplayExtent()
   }
   else if(mFusion)
     mFusionActor->SetVisibility(false);
-
   // Vector field actor
   double* camera = Renderer->GetActiveCamera()->GetPosition();
   double* image_bounds = ImageActor->GetBounds();
@@ -1020,32 +1185,41 @@ void vvSlicer::UpdateDisplayExtent()
   
   if (mVF && mVFVisibility) {
     int vfExtent[6];
+#if VTK_MAJOR_VERSION <= 5
     mVF->GetVTKImages()[0]->UpdateInformation();
     this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
     bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
+#else
+    mVOIFilter->Update();
+    this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVF->GetVTKImages()[0], vfExtent);
+    bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
+#endif
     mVFActor->SetVisibility(!out);
     mVOIFilter->SetVOI(vfExtent);
     int orientation[3] = {1,1,1};
     orientation[this->SliceOrientation] = 0;
     mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
-    mVFMapper->Update();
-
     position[this->SliceOrientation] += offset;
     mVFActor->SetPosition(position);
+    mVFActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
+    mVFMapper->Update();
+
   }
   else if(mVF)
     mVFActor->SetVisibility(false);
+    
+    
+    double boundsT [6];
+      for(unsigned int i=0; i<6; i++)
+        boundsT[i] = ImageActor->GetBounds()[i];
+      boundsT[ this->SliceOrientation*2   ] = ImageActor->GetBounds()[ this->SliceOrientation*2  ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+      boundsT[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+
 
   // Landmarks actor
   if (mLandActor) {
     if (mClipBox) {
-      double bounds [6];
-      for(unsigned int i=0; i<6; i++)
-        bounds[i] = ImageActor->GetBounds()[i];
-      bounds[ this->SliceOrientation*2   ] = ImageActor->GetBounds()[ this->SliceOrientation*2  ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
-      bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
-      mClipBox->SetBounds(bounds);
-      UpdateLandmarks();
+      RemoveLandmarks();
     }
     
     position[this->SliceOrientation] = offset;
@@ -1070,6 +1244,39 @@ void vvSlicer::UpdateDisplayExtent()
         cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
       }
     }
+    
+    if (mLandActor) {
+        if (mClipBox) {
+            DisplayLandmarks();
+        }
+    }
+  }
+  emit UpdateDisplayExtentEnd(mSlicerNumber);
+}
+//----------------------------------------------------------------------------
+
+//----------------------------------------------------------------------------
+void vvSlicer::ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, const int sourceExtent[6],
+                                                vtkImageData *targetImage, int targetExtent[6])
+{ 
+  double dExtents[6];
+  double *origin, *spacing;
+  origin = sourceImage->Get(vtkDataObject::ORIGIN());
+  spacing = sourceImage->Get(vtkDataObject::SPACING());
+  for(unsigned int i=0; i<6; i++) {
+    // From source voxel coordinates to world coordinates
+    dExtents[i] = origin[i/2] + spacing[i/2] * sourceExtent[i];
+
+    // From world coordinates to floating point target voxel coordinates
+    dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
+    
+    // Round to current slice or larger extent
+    if(i/2==this->GetOrientation())
+      targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
+    else if(i%2==1)
+      targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
+    else
+      targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
   }
 }
 //----------------------------------------------------------------------------
@@ -1099,7 +1306,7 @@ void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const
 
 //----------------------------------------------------------------------------
 bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
-{
+{ 
   bool out = false;
   int maxBound = 6;
 
@@ -1127,7 +1334,7 @@ bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
 
 //----------------------------------------------------------------------------
 void vvSlicer::UpdateOrientation()
-{
+{ 
   // Set the camera position
   vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
   if (cam) {
@@ -1157,7 +1364,7 @@ void vvSlicer::UpdateOrientation()
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetOpacity(double s)
-{
+{ 
   this->GetImageActor()->SetOpacity(s);
 }
 //----------------------------------------------------------------------------
@@ -1165,12 +1372,11 @@ void vvSlicer::SetOpacity(double s)
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
-{
+{ 
   this->Superclass::SetRenderWindow(rw);
   this->SetupInteractor(rw->GetInteractor());
   ca->SetImageActor(this->GetImageActor());
   ca->SetWindowLevel(this->GetWindowLevel());
-  ca->SetText(2, "<slice>");
   ca->SetText(3, "<window>\n<level>");
 
   double bounds[6];
@@ -1182,8 +1388,8 @@ void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
   bounds[3] = max;
   bounds[4] = -max;
   bounds[5] = max;
-
   crossCursor->SetModelBounds(bounds);
+
   this->GetRenderer()->AddActor(pdmA);
   this->GetRenderer()->AddActor(ca);
   this->GetRenderer()->ResetCamera();
@@ -1198,7 +1404,7 @@ void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
 
 //----------------------------------------------------------------------------
 void vvSlicer::ResetCamera()
-{
+{ 
   this->GetRenderer()->ResetCamera();
 }
 //----------------------------------------------------------------------------
@@ -1206,7 +1412,7 @@ void vvSlicer::ResetCamera()
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetDisplayMode(bool i)
-{
+{ 
        this->GetRenderer()->SetDraw(i);
        if (i) UpdateDisplayExtent();
 }
@@ -1215,7 +1421,7 @@ void vvSlicer::SetDisplayMode(bool i)
 
 //----------------------------------------------------------------------------
 void vvSlicer::FlipHorizontalView()
-{
+{ 
   vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
   if (cam) {
     double *position = cam->GetPosition();
@@ -1246,7 +1452,7 @@ void vvSlicer::FlipHorizontalView()
 
 //----------------------------------------------------------------------------
 void vvSlicer::FlipVerticalView()
-{
+{ 
   vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
   if (cam) {
     FlipHorizontalView();
@@ -1260,7 +1466,7 @@ void vvSlicer::FlipVerticalView()
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetColorWindow(double window)
-{
+{ 
   vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
   if ( LUT ) {
     double level = this->GetWindowLevel()->GetLevel();
@@ -1273,7 +1479,7 @@ void vvSlicer::SetColorWindow(double window)
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetColorLevel(double level)
-{
+{ 
   vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
   if ( LUT ) {
     double window = this->GetWindowLevel()->GetWindow();
@@ -1286,7 +1492,7 @@ void vvSlicer::SetColorLevel(double level)
 
 //----------------------------------------------------------------------------
 double vvSlicer::GetOverlayColorWindow()
-{
+{ 
   if(mOverlayMapper)
     return mOverlayMapper->GetWindow();
   else
@@ -1296,7 +1502,7 @@ double vvSlicer::GetOverlayColorWindow()
 
 //----------------------------------------------------------------------------
 double vvSlicer::GetOverlayColorLevel()
-{
+{ 
   if(mOverlayMapper)
     return mOverlayMapper->GetLevel();
   else
@@ -1306,22 +1512,24 @@ double vvSlicer::GetOverlayColorLevel()
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetOverlayColorWindow(double window)
-{
-  mOverlayMapper->SetWindow(window);
+{ 
+  if(mOverlayMapper)
+    mOverlayMapper->SetWindow(window);
 }
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetOverlayColorLevel(double level)
-{
-  mOverlayMapper->SetLevel(level);
+{ 
+  if(mOverlayMapper)
+    mOverlayMapper->SetLevel(level);
 }
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
 // Returns the min an the max value in a 20%x20% region around the mouse pointer
 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
-{
+{ 
   //Get mouse pointer position in view coordinates
   double corner1[3];
   double corner2[3];
@@ -1356,10 +1564,24 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImag
 
     if(iLocalExtents[i*2  ]>iLocalExtents[i*2+1])
       std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
+
+#if VTK_MAJOR_VERSION > 5
+    for(int j=0;j<2; j++) {
+      if(iLocalExtents[i*2+j]< mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i])
+        iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i];
+
+      if(iLocalExtents[i*2+j]> mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1])
+        iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1];
+    }
+#endif
   }
 
   vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
+#if VTK_MAJOR_VERSION <= 5
   voiFilter->SetInput(image);
+#else
+  voiFilter->SetInputData(image);
+#endif
   voiFilter->SetVOI(iLocalExtents);
   voiFilter->Update();
   if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
@@ -1369,7 +1591,11 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImag
   }
 
   vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
+#if VTK_MAJOR_VERSION <= 5
   accFilter->SetInput(voiFilter->GetOutput());
+#else
+  accFilter->SetInputConnection(voiFilter->GetOutputPort(0));
+#endif
   accFilter->Update();
 
   min = *(accFilter->GetMin());
@@ -1379,11 +1605,11 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImag
 
 //----------------------------------------------------------------------------
 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
-{
+{ 
   ix = lrint(X);
   iy = lrint(Y);
   iz = lrint(Z);
-
+#if VTK_MAJOR_VERSION <= 5
   if (ix < image->GetWholeExtent()[0] ||
       ix > image->GetWholeExtent()[1] ||
       iy < image->GetWholeExtent()[2] ||
@@ -1391,16 +1617,27 @@ double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, doubl
       iz < image->GetWholeExtent()[4] ||
       iz > image->GetWholeExtent()[5] )
     return std::numeric_limits<double>::quiet_NaN();
-
   image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
   image->Update();
+#else
+  if (ix < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] ||
+      ix > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] ||
+      iy < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] ||
+      iy > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] ||
+      iz < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] ||
+      iz > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5] )
+    return std::numeric_limits<double>::quiet_NaN();
+  //image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
+  //image->Update();
+#endif
+
   return image->GetScalarComponentAsDouble(ix, iy, iz, component);
 }
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
 void vvSlicer::Render()
-{
+{ 
   if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
     legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
     legend->UseOpacityOn();
@@ -1413,13 +1650,14 @@ void vvSlicer::Render()
   } else legend->SetVisibility(0);
 
   if (ca->GetVisibility()) {
-    std::stringstream worldPos;
+
+    std::stringstream worldPos(" ");
     double pt[3];
     mConcatenatedTransform->TransformPoint(mCurrent, pt);
     double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
     double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
     double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
-
+#if VTK_MAJOR_VERSION <= 5
     if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
         X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
         Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
@@ -1445,7 +1683,38 @@ void vvSlicer::Render()
                              << mCurrentTSlice
                              << std::endl;
     }
+#else
+    if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 &&
+        X <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 &&
+        Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 &&
+        Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 &&
+        Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 &&
+        Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) {
+
+      int ix, iy, iz;
+      double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
+
+      if(ImageActor->GetVisibility())
+        worldPos << "data value : " << value << std::endl;
+
+      worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
+                          << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
+                          << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
+                          << mCurrentTSlice
+                          << std::endl;
+      worldPos << "pixel : " << ix << ' '
+                             << iy << ' '
+                             << iz << ' '
+                             << mCurrentTSlice
+                             << std::endl;
+    
+    }
+#endif
     ca->SetText(1,worldPos.str().c_str());
+
+    std::stringstream slicePos;
+    slicePos << "Slice: " << this->GetSlice();
+    ca->SetText(2, slicePos.str().c_str());
   }
 
   if (pdmA->GetVisibility()) {
@@ -1455,7 +1724,7 @@ void vvSlicer::Render()
     double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
     double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
     double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
-
+#if VTK_MAJOR_VERSION <= 5    
     if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
         xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
         yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
@@ -1472,29 +1741,71 @@ void vvSlicer::Render()
       crossCursor->SetFocalPoint(x,y,z);
     } else
       crossCursor->SetFocalPoint(-1,-1,z);
+    crossCursor->Update();
   }
+#else
+    vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
+    try {
+        mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
+    } catch (const std::bad_cast& e) {
+               std::cerr << e.what() << std::endl;
+               std::cerr << "Conversion error" << std::endl;
+               return;
+       }
 
+    if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 &&
+        xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 &&
+        yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 &&
+        yCursor < mapperOpenGL->GetCroppingRegion()[3]+0.5 &&
+        zCursor >= mapperOpenGL->GetCroppingRegion()[4]-0.5 &&
+        zCursor < mapperOpenGL->GetCroppingRegion()[5]+0.5 ) {
+      vtkRenderer * renderer = this->Renderer;
+
+      renderer->WorldToView(x,y,z);
+      renderer->ViewToNormalizedViewport(x,y,z);
+      renderer->NormalizedViewportToViewport(x,y);
+      renderer->ViewportToNormalizedDisplay(x,y);
+      renderer->NormalizedDisplayToDisplay(x,y);
+      crossCursor->SetFocalPoint(x,y,z);
+    } else
+      crossCursor->SetFocalPoint(-1,-1,z);
+    crossCursor->Update();
+  }
+#endif
 
   if (mOverlay && mOverlayActor->GetVisibility()) {
     if(mLinkOverlayWindowLevel) {
       mOverlayMapper->SetWindow(this->GetColorWindow());
       mOverlayMapper->SetLevel(this->GetColorLevel());
     }
+#if VTK_MAJOR_VERSION <= 5
     mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
-    mOverlayMapper->GetOutput()->Update();
+#else
+    mOverlayMapper->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
+#endif
     mOverlayMapper->Update();
   }
-  if (mLandMapper)
-    UpdateLandmarks();
+  if (mFusion && mFusionActor->GetVisibility()) {
+#if VTK_MAJOR_VERSION <= 5
+    mFusionMapper->GetOutput()->SetUpdateExtent(mFusionActor->GetDisplayExtent());
+#else
+    mFusionMapper->SetUpdateExtent(mFusionActor->GetDisplayExtent());
+#endif
+    mFusionMapper->Update();
+  }
+  if (mLandMapper) {
+    RemoveLandmarks();
+    DisplayLandmarks();
+  }
 
-  this->GetRenderWindow()->Render();
+    this->GetRenderWindow()->Render();
 }
 //----------------------------------------------------------------------------
 
 
 //----------------------------------------------------------------------------
 void vvSlicer::UpdateCursorPosition()
-{
+{ 
   pdmA->SetVisibility(true);
   mCursor[0] = mCurrent[0];
   mCursor[1] = mCurrent[1];
@@ -1505,24 +1816,43 @@ void vvSlicer::UpdateCursorPosition()
 
 
 //----------------------------------------------------------------------------
-void vvSlicer::UpdateLandmarks()
-{
-  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
+void vvSlicer::RemoveLandmarks()
+{ 
+  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
   if (pd->GetPoints()) {
-    //mLandGlyph->SetRange(0,1);
-    //mLandGlyph->Modified();
-    //mLandGlyph->Update();
 
-    mClipBox->Modified();
-    mLandClipper->Update();
-    mLandMapper->Update();
-    //Let's add the captions
     //First remove all captions:
     for(unsigned int i=0;i<mLandLabelActors.size();i++) {
        this->Renderer->RemoveActor2D(mLandLabelActors[i]);
        //allActors2D->Remove (mLandLabelActors[i]);
     }
     mLandLabelActors.clear();
+  }
+}
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+void vvSlicer::DisplayLandmarks()
+{ 
+
+  double bounds [6];
+  for(unsigned int i=0; i<6; i++)
+    bounds[i] = ImageActor->GetBounds()[i];
+  bounds[ this->SliceOrientation*2   ] = ImageActor->GetBounds()[ this->SliceOrientation*2  ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+  bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
+  mClipBox->SetBounds(bounds);
+
+
+  vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
+  if (pd->GetPoints()) {
+    this->GetRenderer()->AddActor(mLandActor);
+    //mLandGlyph->SetRange(0,1);
+    //mLandGlyph->Modified();
+    //mLandGlyph->Update();
+    mClipBox->Modified();
+    mLandClipper->Update();
+    mLandMapper->Update();
     //Next add the captions to the displayed points
     for (vtkIdType id=0; id<mLandClipper->GetOutput()->GetNumberOfPoints(); id++) {
          double *position = mLandClipper->GetOutput()->GetPoint(id);
@@ -1549,7 +1879,7 @@ void vvSlicer::UpdateLandmarks()
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetSlice(int slice)
-{
+{ 
   int *range = this->GetSliceRange();
   if (range) {
     if (slice < range[0]) {
@@ -1574,7 +1904,8 @@ void vvSlicer::SetSlice(int slice)
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
-int vvSlicer::GetTMax() {
+int vvSlicer::GetTMax() 
+{ 
   int tmax = (int)mImage->GetVTKImages().size() - 1;
   if(mOverlay)
     tmax = std::max(tmax, (int)mOverlay->GetVTKImages().size()-1);
@@ -1584,7 +1915,7 @@ int vvSlicer::GetTMax() {
 
 //----------------------------------------------------------------------------
 void vvSlicer::SetContourSlice()
-{
+{ 
   if (mSurfaceCutActors.size() > 0)
     for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
          i!=mSurfaceCutActors.end(); i++) {
@@ -1599,7 +1930,7 @@ void vvSlicer::SetContourSlice()
 
 //----------------------------------------------------------------------------
 void vvSlicer::ForceUpdateDisplayExtent()
-{
+{ 
   this->UpdateDisplayExtent();
 }
 //----------------------------------------------------------------------------
@@ -1607,7 +1938,7 @@ void vvSlicer::ForceUpdateDisplayExtent()
 
 //----------------------------------------------------------------------------
 int* vvSlicer::GetDisplayExtent()
-{
+{ 
   return this->GetImageActor()->GetDisplayExtent();
 }
 //----------------------------------------------------------------------------
@@ -1615,14 +1946,15 @@ int* vvSlicer::GetDisplayExtent()
 
 //----------------------------------------------------------------------------
 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
-{
+{ 
   this->Superclass::PrintSelf(os, indent);
 }
 //----------------------------------------------------------------------------
 
+
 //----------------------------------------------------------------------------
 void vvSlicer::SetVFColor(double r, double g, double b)
-{
+{ 
   double mVFColorHSV[3];
   mVFColor[0] = r;
   mVFColor[1] = g;
@@ -1635,4 +1967,21 @@ void vvSlicer::SetVFColor(double r, double g, double b)
 
   this->Render();
 }  
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+void vvSlicer::SetRegisterExtent(int ext[6])
+{ 
+    copyExtent(ext, mRegisterExtent);
+}
+//----------------------------------------------------------------------------
+
+
+//----------------------------------------------------------------------------
+void vvSlicer::GetRegisterExtent(int ext[6])
+{ 
+    copyExtent(mRegisterExtent, ext);
+}
+//----------------------------------------------------------------------------
 
index 0bffd1f36abcc46f92d5b43a3c51aab519685e59..5027d16e6fd0256b3bc3f32b75c8a307c9cfc511 100644 (file)
@@ -20,6 +20,7 @@
 #include <iostream>
 #include <vector>
 
+#include <QObject>
 #include <QString> //TODO delete
 #include <QMessageBox>
 
@@ -34,6 +35,7 @@
 #include <vtkImageReslice.h>
 #include <vtkImageMapToColors.h>
 #include <vtkCaptionActor2D.h>
+#include <vtkTransformPolyDataFilter.h>
 
 class vtkActor;
 class vtkActor2D;
@@ -58,11 +60,13 @@ class vtkScalarBarActor;
 class vtkTransform;
 class vtkImageReslice;
 
-class vvSlicer: public vtkImageViewer2
-{
+class vvSlicer: public QObject, public vtkImageViewer2 {
+  
+Q_OBJECT
+
 public:
   static vvSlicer *New();
-  vtkTypeRevisionMacro(vvSlicer,vtkImageViewer2);
+  vtkTypeMacro(vvSlicer,vtkImageViewer2);
   void PrintSelf(ostream& os, vtkIndent indent);
 
   void SetImage(vvImage::Pointer inputImages);
@@ -148,7 +152,6 @@ public:
   double* GetCursorPosition() {
     return mCursor;
   }
-
   vtkTransform * GetSlicingTransform() { return mSlicingTransform; }
   vtkTransform * GetConcatenatedTransform() { return mConcatenatedTransform; }
   vtkTransform * GetConcatenatedFusionTransform() { return mConcatenatedFusionTransform; }
@@ -168,7 +171,8 @@ public:
 
   void GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform);
 
-  void UpdateLandmarks();
+  void RemoveLandmarks();
+  void DisplayLandmarks();
   void ForceUpdateDisplayExtent();
 
   int* GetDisplayExtent();
@@ -205,9 +209,19 @@ public:
     return mVFColor;
   }
   void SetVFColor(double r, double g, double b);
-
+  
   //necessary to flag the secondary sequence
   void SetFusionSequenceCode(int code) {mFusionSequenceCode=code;}
+  void SetRegisterExtent(int [6]);
+  void GetRegisterExtent(int [6]);
+  
+  void SetSlicerNumber(const int nbSlicer) {mSlicerNumber = nbSlicer;}
+  int GetSlicerNumber() const {return mSlicerNumber;}
+  
+signals:
+  void UpdateDisplayExtentBegin(int);
+  void UpdateDisplayExtentEnd(int);
+  
 protected:
   vvSlicer();
   ~vvSlicer();
@@ -233,6 +247,7 @@ protected:
   //                         ___|__|___ VTK world coordinates (mm) (never displayed)            mCurrent
 
   vtkSmartPointer<vtkTransform> mSlicingTransform;
+  vtkSmartPointer<vtkTransformPolyDataFilter> mLandmarkTransform;
   vtkSmartPointer<vtkImageReslice> mImageReslice;
   vtkSmartPointer<vtkTransform> mConcatenatedTransform;
   vtkSmartPointer<vtkImageReslice> mOverlayReslice;
@@ -264,6 +279,7 @@ protected:
   vtkSmartPointer<vtkScalarBarActor> legend;
   std::vector<vvMeshActor*> mSurfaceCutActors;
 
+  int mSlicerNumber;
   int mCurrentTSlice;
   int mCurrentFusionTSlice;
   int mCurrentOverlayTSlice;
@@ -277,13 +293,15 @@ protected:
   double mVFColor[3];
   bool mUseReducedExtent;
   int * mReducedExtent;
-  int * mInitialExtent;
+  int * mRegisterExtent;
   bool mLinkOverlayWindowLevel;
   bool showFusionLegend;
 
 private:
   void UpdateOrientation();
   void UpdateDisplayExtent();
+  void ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, const int sourceExtent[6],
+                                        vtkImageData *targetImage, int targetExtent[6]);
   void ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
                                         vtkImageData *targetImage, int targetExtent[6]);
   ///Sets the surfaces to be cut on the image slice: update the vtkCutter
index 89fd42b49fae4177e89ec0c2ee4590e38c9a6f54..1a9ad685f80e355b1fc105083e882b05156ad049 100644 (file)
@@ -25,6 +25,9 @@
 #include "vvMesh.h"\r
 #include "vvBlendImageActor.h"\r
 \r
+#include <vtkVersion.h>\r
+#include <vtkStreamingDemandDrivenPipeline.h>\r
+#include <vtkInformation.h>\r
 #include <vtkImageActor.h>\r
 #include <vtkImageData.h>\r
 #include <vtkRenderWindow.h>\r
 #include <QMessageBox>\r
 //----------------------------------------------------------------------------\r
 vvSlicerManager::vvSlicerManager(int numberOfSlicers)\r
-{\r
+{ \r
+\r
+  connect(this, SIGNAL(callAddLandmark(float,float,float,float)), this, SLOT(AddLandmark(float,float,float,float)));\r
+\r
   mFileName = "";\r
   mId = "";\r
   mVFName = "";\r
@@ -73,8 +79,10 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
   mLandmarks = NULL;\r
   mLinkedId.resize(0);\r
 \r
-  for ( int i = 0; i < numberOfSlicers; i++)\r
+  for ( int i = 0; i < numberOfSlicers; i++) {\r
     mSlicers.push_back(vtkSmartPointer<vvSlicer>::New());\r
+    mSlicers[i]->SetSlicerNumber(i);\r
+  }\r
   mSelectedSlicer = -1;\r
   \r
   mPreviousSlice.resize(numberOfSlicers, 0);\r
@@ -88,7 +96,7 @@ vvSlicerManager::vvSlicerManager(int numberOfSlicers)
 \r
 //----------------------------------------------------------------------------\r
 vvSlicerManager::~vvSlicerManager()\r
-{\r
+{ \r
   if (mLandmarks)\r
     delete mLandmarks;\r
 }\r
@@ -97,7 +105,7 @@ vvSlicerManager::~vvSlicerManager()
 \r
 //------------------------------------------------------------------------------\r
 void vvSlicerManager::SetFilename(std::string filename, int number)\r
-{\r
+{ \r
   mFileName = filename;\r
   mFileName = vtksys::SystemTools::GetFilenameName(mFileName);\r
   mBaseFileName = vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(mFileName));\r
@@ -119,7 +127,7 @@ void vvSlicerManager::SetFilename(std::string filename, int number)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::AddContour(vvMesh::Pointer contour,bool propagate)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->AddContour(contour,propagate);\r
   }\r
@@ -129,7 +137,7 @@ void vvSlicerManager::AddContour(vvMesh::Pointer contour,bool propagate)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::ToggleContourSuperposition()\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++)\r
     mSlicers[i]->ToggleContourSuperposition();\r
 }\r
@@ -137,7 +145,7 @@ void vvSlicerManager::ToggleContourSuperposition()
 \r
 //----------------------------------------------------------------------------\r
 std::string vvSlicerManager::GetListOfAbsoluteFilePathInOneString(const std::string &actorType)\r
-{\r
+{ \r
   vvImageReader *reader = NULL;\r
 \r
   if(actorType=="image")\r
@@ -168,7 +176,7 @@ std::string vvSlicerManager::GetListOfAbsoluteFilePathInOneString(const std::str
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::SetImage(std::string filename, vvImageReader::LoadedImageType type, int n, unsigned int slice)\r
-{\r
+{ \r
   mType = type;\r
   if (mReader.IsNull())\r
     mReader = vvImageReader::New();\r
@@ -203,7 +211,7 @@ bool vvSlicerManager::SetImage(std::string filename, vvImageReader::LoadedImageT
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetImage(vvImage::Pointer image)\r
-{\r
+{ \r
   mImage=image;\r
   for (unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetImage(image);\r
@@ -214,7 +222,7 @@ void vvSlicerManager::SetImage(vvImage::Pointer image)
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReader::LoadedImageType type, int n)\r
-{\r
+{ \r
   mType = type;\r
   std::string fileWithoutExtension = vtksys::SystemTools::GetFilenameWithoutExtension(filenames[0]);\r
   if (type == vvImageReader::DICOM)\r
@@ -254,7 +262,7 @@ bool vvSlicerManager::SetImages(std::vector<std::string> filenames, vvImageReade
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::SetOverlay(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type)\r
-{\r
+{ \r
   mOverlayName = filenames[0];\r
   mOverlayComponent = component;\r
   if (dim > mImage->GetNumberOfDimensions()) {\r
@@ -280,7 +288,7 @@ bool vvSlicerManager::SetOverlay(std::vector<std::string> filenames,int dim, std
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::SetFusion(std::vector<std::string> filenames,int dim, std::string component, vvImageReader::LoadedImageType type)\r
-{\r
+{ \r
   mFusionName = filenames[0];\r
   mFusionComponent = component;\r
   if (dim > mImage->GetNumberOfDimensions()) {\r
@@ -310,7 +318,7 @@ bool vvSlicerManager::SetFusion(std::vector<std::string> filenames,int dim, std:
 //----------------------------------------------------------------------------\r
 //this function is called by vvMainWindow::AddFusionSequence for the primary sequence (CT), while the given files constitute the secondary sequence.\r
 bool vvSlicerManager::SetFusionSequence(std::vector<std::string> filenames, int dim, std::string component, vvImageReader::LoadedImageType type)\r
-{\r
+{ \r
        mFusionSequenceInvolvementCode = 0;\r
 \r
        mFusionName = filenames[0];\r
@@ -359,7 +367,7 @@ bool vvSlicerManager::SetFusionSequence(std::vector<std::string> filenames, int
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::SetVF(std::string filename)\r
-{\r
+{ \r
   if (mVectorReader.IsNull())\r
     mVectorReader = vvImageReader::New();\r
   mVectorReader->SetInputFilename(filename);\r
@@ -379,7 +387,7 @@ bool vvSlicerManager::SetVF(std::string filename)
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename)\r
-{\r
+{ \r
   if (vf->GetNumberOfDimensions() > mImage->GetNumberOfDimensions()) {\r
     mLastError = "Sorry, vector field dimension cannot be greater then reference image.";\r
     return false;\r
@@ -406,7 +414,7 @@ bool vvSlicerManager::SetVF(vvImage::Pointer vf,std::string filename)
 \r
 //----------------------------------------------------------------------------\r
 vvSlicer* vvSlicerManager::GetSlicer(int i)\r
-{\r
+{ \r
   return mSlicers[i];\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -414,7 +422,7 @@ vvSlicer* vvSlicerManager::GetSlicer(int i)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateSlicer(int num, bool state)\r
-{\r
+{ \r
   if (mSlicers[num]->GetImage()) {\r
     mSlicers[num]->SetDisplayMode(state);\r
   }\r
@@ -424,7 +432,7 @@ void vvSlicerManager::UpdateSlicer(int num, bool state)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetSlicerWindow(int i, vtkRenderWindow* RW)\r
-{\r
+{ \r
   mSlicers[i]->SetRenderWindow(i,RW);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -432,7 +440,7 @@ void vvSlicerManager::SetSlicerWindow(int i, vtkRenderWindow* RW)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* style)\r
-{\r
+{ \r
   vvSlicerManagerCommand *smc = vvSlicerManagerCommand::New();\r
   smc->SM = this;\r
   smc->SetSlicerNumber(i);\r
@@ -471,7 +479,7 @@ void vvSlicerManager::SetInteractorStyleNavigator(int i, vtkInteractorStyle* sty
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::LeftButtonReleaseEvent(int slicer)\r
-{\r
+{ \r
   emit LeftButtonReleaseSignal(slicer);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -479,7 +487,7 @@ void vvSlicerManager::LeftButtonReleaseEvent(int slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::EmitMousePositionUpdated(int slicer)\r
-{\r
+{ \r
   emit MousePositionUpdatedSignal(slicer);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -487,7 +495,7 @@ void vvSlicerManager::EmitMousePositionUpdated(int slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::EmitKeyPressed(std::string KeyPress)\r
-{\r
+{ \r
   emit KeyPressedSignal(KeyPress);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -495,7 +503,7 @@ void vvSlicerManager::EmitKeyPressed(std::string KeyPress)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetSliceOrientation(int slicer, int orientation)\r
-{\r
+{ \r
   mSlicers[slicer]->SetSliceOrientation(orientation);\r
   emit UpdateOrientation(slicer, orientation);\r
 }\r
@@ -503,14 +511,14 @@ void vvSlicerManager::SetSliceOrientation(int slicer, int orientation)
 \r
 //----------------------------------------------------------------------------\r
 int vvSlicerManager::GetTSlice()\r
-{\r
+{ \r
   return mSlicers[0]->GetTSlice();\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages)\r
-{\r
+{ \r
        if (!updateLinkedImages) { //for fusionSequence, TMax / MaxCurrentTSlice are irrelevant.\r
                for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
                        mSlicers[i]->SetTSlice(slice, updateLinkedImages);\r
@@ -537,7 +545,7 @@ void vvSlicerManager::SetTSlice(int slice, bool updateLinkedImages)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetFusionSequenceTSlice(int slice)\r
-{\r
+{ \r
        for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
                mSlicers[i]->SetFusionSequenceTSlice(slice);\r
                UpdateTSlice(i);\r
@@ -548,12 +556,11 @@ void vvSlicerManager::SetFusionSequenceTSlice(int slice)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetNextTSlice(int originating_slicer)\r
-{\r
+{ \r
   int t = mSlicers[0]->GetMaxCurrentTSlice();\r
   t++;\r
   if (t > mSlicers[0]->GetTMax())\r
     t = 0;\r
-  //std::cout << "vvSlicerManager::SetNextTSlice" << std::endl;\r
   emit UpdateTSlice(originating_slicer,t, mFusionSequenceInvolvementCode);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -561,12 +568,11 @@ void vvSlicerManager::SetNextTSlice(int originating_slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetPreviousTSlice(int originating_slicer)\r
-{\r
+{ \r
   int t = mSlicers[0]->GetMaxCurrentTSlice();\r
   t--;\r
   if (t < 0)\r
     t = mSlicers[0]->GetTMax();\r
-  //std::cout << "vvSlicerManager::SetPreviousTSlice" << std::endl;\r
   emit UpdateTSlice(originating_slicer,t, mFusionSequenceInvolvementCode);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -574,7 +580,7 @@ void vvSlicerManager::SetPreviousTSlice(int originating_slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::ToggleInterpolation()\r
-{\r
+{ \r
   bool interpolate=!(mSlicers[0]->GetImageActor()->GetInterpolate());\r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->GetImageActor()->SetInterpolate(interpolate);\r
@@ -589,7 +595,7 @@ void vvSlicerManager::ToggleInterpolation()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer)\r
-{\r
+{ \r
   if (tslice < 0)\r
     tslice = 0;\r
   else if (tslice > mSlicers[slicer]->GetTMax())\r
@@ -615,7 +621,7 @@ void vvSlicerManager::SetTSliceInSlicer(int tslice, int slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetColorWindow(double s)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetColorWindow(s);\r
   }\r
@@ -624,7 +630,7 @@ void vvSlicerManager::SetColorWindow(double s)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetColorLevel(double s)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetColorLevel(s);\r
   }\r
@@ -633,7 +639,7 @@ void vvSlicerManager::SetColorLevel(double s)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetOverlayColorWindow(double s)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetOverlayColorWindow(s);\r
   }\r
@@ -642,7 +648,7 @@ void vvSlicerManager::SetOverlayColorWindow(double s)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetOverlayColorLevel(double s)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetOverlayColorLevel(s);\r
   }\r
@@ -651,7 +657,7 @@ void vvSlicerManager::SetOverlayColorLevel(double s)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetLinkOverlayWindowLevel(bool b)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetLinkOverlayWindowLevel(b);\r
   }\r
@@ -660,7 +666,7 @@ void vvSlicerManager::SetLinkOverlayWindowLevel(bool b)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s)\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetCursorVisibility(s);\r
     mSlicers[i]->SetCornerAnnotationVisibility(s);\r
@@ -670,7 +676,7 @@ void vvSlicerManager::SetCursorAndCornerAnnotationVisibility(int s)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetOpacity(int i, double factor)\r
-{\r
+{ \r
   mSlicers[i]->SetOpacity(1/factor);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -678,7 +684,7 @@ void vvSlicerManager::SetOpacity(int i, double factor)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateViews(int current,int slicer)\r
-{\r
+{ \r
   double p[3], pt[3];\r
   p[0] = mSlicers[slicer]->GetCurrentPosition()[0];\r
   p[1] = mSlicers[slicer]->GetCurrentPosition()[1];\r
@@ -691,7 +697,7 @@ void vvSlicerManager::UpdateViews(int current,int slicer)
     /mSlicers[slicer]->GetInput()->GetSpacing()[1];\r
   double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2])\r
     /mSlicers[slicer]->GetInput()->GetSpacing()[2];\r
-\r
+#if VTK_MAJOR_VERSION <= 5\r
   if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&\r
       x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&\r
       y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&\r
@@ -758,13 +764,83 @@ void vvSlicerManager::UpdateViews(int current,int slicer)
       }\r
     }\r
   }\r
+#else\r
+int extentImageReslice[6];\r
+mSlicers[slicer]->GetRegisterExtent(extentImageReslice);\r
+  if (x >= extentImageReslice[0]-0.5 &&\r
+      x <= extentImageReslice[1]+0.5 &&\r
+      y >= extentImageReslice[2]-0.5 &&\r
+      y <= extentImageReslice[3]+0.5 &&\r
+      z >= extentImageReslice[4]-0.5 &&\r
+      z <= extentImageReslice[5]+0.5) {\r
+    mSlicers[slicer]->UpdateCursorPosition();\r
+    mSlicers[slicer]->SetCursorColor(10,212,255);\r
+    mSelectedSlicer = slicer;\r
+\r
+    switch (mSlicers[slicer]->GetSliceOrientation()) {\r
+    case vtkImageViewer2::SLICE_ORIENTATION_XY:\r
+      if (mSlicers[slicer]->GetSlice() != (int)lrint(z))\r
+        mSlicers[slicer]->SetSlice((int)lrint(z));\r
+      break;\r
+\r
+    case vtkImageViewer2::SLICE_ORIENTATION_XZ:\r
+      if (mSlicers[slicer]->GetSlice() != (int)lrint(y))\r
+        mSlicers[slicer]->SetSlice((int)lrint(y));\r
+      break;\r
+\r
+    case vtkImageViewer2::SLICE_ORIENTATION_YZ:\r
+      if (mSlicers[slicer]->GetSlice() != (int)lrint(x))\r
+        mSlicers[slicer]->SetSlice((int)lrint(x));\r
+      break;\r
+    }\r
+    mSlicers[slicer]->Render();\r
+\r
+    for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
+      if (i != (unsigned int)slicer\r
+          && mSlicers[i]->GetRenderer()->GetDraw()\r
+          && mSlicers[i]->GetRenderWindow()->GetSize()[0] > 2\r
+          && mSlicers[i]->GetRenderWindow()->GetSize()[1] > 2) {\r
+        mSlicers[i]->SetCurrentPosition(p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice());\r
+        mSlicers[i]->UpdateCursorPosition();\r
+        if (current) { //do not display corner annotation if image is the one picked\r
+          mSlicers[i]->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,\r
+                                          -VTK_DOUBLE_MAX, mSlicers[slicer]->GetMaxCurrentTSlice());\r
+          mSlicers[i]->SetCursorColor(255,10,212);\r
+        } else {\r
+          mSlicers[i]->SetCursorColor(150,10,282);\r
+        }\r
+        switch (mSlicers[i]->GetSliceOrientation()) {\r
+        case vtkImageViewer2::SLICE_ORIENTATION_XY:\r
+          if (mSlicers[i]->GetSlice() != (int)lrint(z))\r
+            mSlicers[i]->SetSlice((int)lrint(z));\r
+          break;\r
+\r
+        case vtkImageViewer2::SLICE_ORIENTATION_XZ:\r
+          if (mSlicers[i]->GetSlice() != (int)lrint(y))\r
+            mSlicers[i]->SetSlice((int)lrint(y));\r
+          break;\r
+\r
+        case vtkImageViewer2::SLICE_ORIENTATION_YZ:\r
+          if (mSlicers[i]->GetSlice() != (int)lrint(x))\r
+            mSlicers[i]->SetSlice((int)lrint(x));\r
+          break;\r
+        }\r
+        \r
+        mSlicers[i]->Render();\r
+        \r
+        UpdateSlice(i);\r
+        UpdateTSlice(i);\r
+      }\r
+    }\r
+  }\r
+#endif\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateLinked(int slicer)\r
-{\r
+{ \r
   double p[3], pt[3];\r
   p[0] = mSlicers[slicer]->GetCurrentPosition()[0];\r
   p[1] = mSlicers[slicer]->GetCurrentPosition()[1];\r
@@ -773,7 +849,7 @@ void vvSlicerManager::UpdateLinked(int slicer)
   double x = (pt[0] - mSlicers[slicer]->GetInput()->GetOrigin()[0]) / mSlicers[slicer]->GetInput()->GetSpacing()[0];\r
   double y = (pt[1] - mSlicers[slicer]->GetInput()->GetOrigin()[1]) / mSlicers[slicer]->GetInput()->GetSpacing()[1];\r
   double z = (pt[2] - mSlicers[slicer]->GetInput()->GetOrigin()[2]) / mSlicers[slicer]->GetInput()->GetSpacing()[2];\r
-\r
+#if VTK_MAJOR_VERSION <= 5\r
   if (x >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0]-0.5 &&\r
       x <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1]+0.5 &&\r
       y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2]-0.5 &&\r
@@ -790,12 +866,32 @@ void vvSlicerManager::UpdateLinked(int slicer)
                }\r
     }\r
   }\r
+#else\r
+int extentImageReslice[6];\r
+mSlicers[slicer]->GetRegisterExtent(extentImageReslice);\r
+  if (x >= extentImageReslice[0]-0.5 &&\r
+      x <= extentImageReslice[1]+0.5 &&\r
+      y >= extentImageReslice[2]-0.5 &&\r
+      y <= extentImageReslice[3]+0.5 &&\r
+      z >= extentImageReslice[4]-0.5 &&\r
+      z <= extentImageReslice[5]+0.5) {\r
+    for (std::list<std::string>::const_iterator i = mLinkedId.begin(); i != mLinkedId.end(); i++) {\r
+               if (this->IsInvolvedInFusionSequence()) {\r
+                       //this SlicerManager is involved in fusionSequence => do not synchronize the times\r
+                       emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], -1);\r
+               }\r
+               else {\r
+                       emit UpdateLinkManager(*i, slicer, p[0], p[1], p[2], mSlicers[slicer]->GetMaxCurrentTSlice());\r
+               }\r
+    }\r
+  }\r
+#endif\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagate)\r
-{\r
+{ \r
   vtkCamera *refCam = refSlicer->GetRenderer()->GetActiveCamera();\r
 \r
   double refPosition[3];\r
@@ -838,7 +934,7 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat
 \r
 //----------------------------------------------------------------------------\r
 double vvSlicerManager::GetColorWindow() const\r
-{\r
+{ \r
   if (mSlicers.size())\r
     return mSlicers[0]->GetColorWindow();\r
   return -1;\r
@@ -848,7 +944,7 @@ double vvSlicerManager::GetColorWindow() const
 \r
 //----------------------------------------------------------------------------\r
 double vvSlicerManager::GetColorLevel() const\r
-{\r
+{ \r
   if (mSlicers.size())\r
     return mSlicers[0]->GetColorLevel();\r
   return -1;\r
@@ -857,7 +953,7 @@ double vvSlicerManager::GetColorLevel() const
 \r
 //----------------------------------------------------------------------------\r
 double vvSlicerManager::GetOverlayColorWindow() const\r
-{\r
+{ \r
   if (mSlicers.size())\r
     return mSlicers[0]->GetOverlayColorWindow();\r
   return -1;\r
@@ -866,7 +962,7 @@ double vvSlicerManager::GetOverlayColorWindow() const
 \r
 //----------------------------------------------------------------------------\r
 double vvSlicerManager::GetOverlayColorLevel() const\r
-{\r
+{ \r
   if (mSlicers.size())\r
     return mSlicers[0]->GetOverlayColorLevel();\r
   return -1;\r
@@ -875,7 +971,7 @@ double vvSlicerManager::GetOverlayColorLevel() const
 \r
 //----------------------------------------------------------------------------\r
 bool vvSlicerManager::GetLinkOverlayWindowLevel() const\r
-{\r
+{ \r
   if (mSlicers.size())\r
     return mSlicers[0]->GetLinkOverlayWindowLevel();\r
   return -1;\r
@@ -884,7 +980,7 @@ bool vvSlicerManager::GetLinkOverlayWindowLevel() const
 \r
 //------------------------------------------------------------------------------\r
 void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType)\r
-{\r
+{ \r
   if(actorType == "image")\r
     for(unsigned int i=0; i<this->GetImage()->GetTransform().size(); i++)\r
       this->GetImage()->GetTransform()[i]->Identity();\r
@@ -913,7 +1009,7 @@ void vvSlicerManager::ResetTransformationToIdentity(const std::string actorType)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::Render()\r
-{\r
+{ \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->Render();\r
   }\r
@@ -923,7 +1019,7 @@ void vvSlicerManager::Render()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::GenerateDefaultLookupTable()\r
-{\r
+{ \r
   SetPreset(mPreset);\r
   SetColorMap(mColorMap);\r
 }\r
@@ -932,7 +1028,7 @@ void vvSlicerManager::GenerateDefaultLookupTable()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::Reload()\r
-{\r
+{ \r
   mReader->Update(mType);\r
   mImage=mReader->GetOutput();\r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
@@ -949,7 +1045,7 @@ void vvSlicerManager::Reload()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::ReloadFusion()\r
-{\r
+{ \r
   mFusionReader->Update(mImage->GetNumberOfDimensions(),mFusionComponent.c_str(),mType);\r
 \r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
@@ -962,7 +1058,7 @@ void vvSlicerManager::ReloadFusion()
 //----------------------------------------------------------------------------\r
 //the secondary sequence is being reloaded.\r
 void vvSlicerManager::ReloadFusionSequence()\r
-{\r
+{ \r
   //  this is to keep the slice thickness, which needs to be artificially increased for visualization\r
   double sp_x, sp_y, sp_z;\r
   this->GetImage()->GetVTKImages()[0]->GetSpacing(sp_x, sp_y, sp_z);\r
@@ -999,7 +1095,7 @@ void vvSlicerManager::ReloadFusionSequence()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::ReloadOverlay()\r
-{\r
+{ \r
   mOverlayReader->Update(mImage->GetNumberOfDimensions(),mOverlayComponent.c_str(),mType);\r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
     mSlicers[i]->SetOverlay(mOverlayReader->GetOutput());\r
@@ -1011,7 +1107,7 @@ void vvSlicerManager::ReloadOverlay()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::ReloadVF()\r
-{\r
+{ \r
   mVectorReader->Update(vvImageReader::VECTORFIELD); //deletes the old images through the VF::Init() function\r
   mVF=mVectorReader->GetOutput();\r
   for ( unsigned int i = 0; i < mSlicers.size(); i++) {\r
@@ -1024,7 +1120,7 @@ void vvSlicerManager::ReloadVF()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_index)\r
-{\r
+{ \r
   if (actor_type =="overlay")\r
     mOverlayReader = NULL;\r
 \r
@@ -1048,7 +1144,7 @@ void vvSlicerManager::RemoveActor(const std::string& actor_type, int overlay_ind
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::RemoveActors()\r
-{\r
+{ \r
   ///This method leaks a few objects. See RemoveActor for what a\r
   ///correct implementation would look like\r
   //DS -> probably due to the reader (now released in the\r
@@ -1063,7 +1159,7 @@ void vvSlicerManager::RemoveActors()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer)\r
-{\r
+{ \r
   //  int view = mSlicers[slicer]->GetSliceOrientation();\r
   //  int slice = mSlicers[slicer]->GetSlice();\r
   double x = mSlicers[slicer]->GetCursorPosition()[0];\r
@@ -1075,18 +1171,30 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer)
     mSlicers[slicer]->GetInput()->GetSpacing()[1];\r
   double Z = (z - mSlicers[slicer]->GetInput()->GetOrigin()[2])/\r
     mSlicers[slicer]->GetInput()->GetSpacing()[2];\r
+  double xyz[3], xyzTransform[3];\r
+  xyz[0] = x;\r
+  xyz[1] = y;\r
+  xyz[2] = z;\r
+  mSlicers[slicer]->GetConcatenatedTransform()->TransformPoint(xyz, xyzTransform);\r
+  double XTransform = (xyzTransform[0] - mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetOrigin()[0])/\r
+    mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetSpacing()[0];\r
+  double YTransform = (xyzTransform[1] - mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetOrigin()[1])/\r
+    mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetSpacing()[1];\r
+  double ZTransform = (xyzTransform[2] - mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetOrigin()[2])/\r
+    mSlicers[slicer]->GetImage()->GetVTKImages()[GetTSlice()]->GetSpacing()[2];\r
   double value = -VTK_DOUBLE_MAX;\r
   int displayVec = 0;\r
   double xVec=0, yVec=0, zVec=0, valueVec=0;\r
   int displayOver = 0;\r
   int displayFus = 0;\r
   double valueOver=0, valueFus=0;\r
-  if (X >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&\r
-      X <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&\r
-      Y >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&\r
-      Y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&\r
-      Z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&\r
-      Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {\r
+#if VTK_MAJOR_VERSION <= 5\r
+    if (XTransform >= mSlicers[slicer]->GetInput()->GetWholeExtent()[0] &&\r
+      XTransform <= mSlicers[slicer]->GetInput()->GetWholeExtent()[1] &&\r
+      YTransform >= mSlicers[slicer]->GetInput()->GetWholeExtent()[2] &&\r
+      YTransform <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] &&\r
+      ZTransform >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] &&\r
+      ZTransform <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) {\r
 \r
     value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);\r
 \r
@@ -1135,18 +1243,81 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer)
        }\r
 \r
     emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(),\r
-                        x,y,z,X,Y,Z,value);\r
+                        x,y,z,XTransform,YTransform,ZTransform,value);\r
     emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);\r
     emit UpdateOverlay(displayOver,valueOver,value);\r
     emit UpdateFusion(displayFus,valueFus);\r
   }\r
+#else\r
+int extentImageReslice[6];\r
+mSlicers[slicer]->GetRegisterExtent(extentImageReslice);\r
+    if (XTransform >= extentImageReslice[0] &&\r
+      XTransform <= extentImageReslice[1] &&\r
+      YTransform >= extentImageReslice[2] &&\r
+      YTransform <= extentImageReslice[3] &&\r
+      ZTransform >= extentImageReslice[4] &&\r
+      ZTransform <= extentImageReslice[5]) {\r
+\r
+    value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z);\r
+\r
+    if (mSlicers[slicer]->GetVFActor() ) {\r
+      displayVec = 1;\r
+      unsigned int currentTime = mSlicers[slicer]->GetMaxCurrentTSlice();\r
+      vtkImageData *vf = NULL;\r
+\r
+      if (mSlicers[slicer]->GetVF()->GetVTKImages().size() > currentTime)\r
+        vf = mSlicers[slicer]->GetVF()->GetVTKImages()[currentTime];\r
+      else\r
+        vf = mSlicers[slicer]->GetVF()->GetVTKImages()[0];\r
+\r
+      if (vf) {\r
+        double Xvf = (x - vf->GetOrigin()[0])/ vf->GetSpacing()[0];\r
+        double Yvf = (y - vf->GetOrigin()[1])/ vf->GetSpacing()[1];\r
+        double Zvf = (z - vf->GetOrigin()[2])/ vf->GetSpacing()[2];\r
+        xVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 0);\r
+        yVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 1);\r
+        zVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 2);\r
+        valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec);\r
+      }\r
+    }\r
+    if (mSlicers[slicer]->GetOverlayActor() ) {\r
+      displayOver = 1;\r
+      vtkImageData *overlay = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetOverlayMapper()->GetInput());\r
+      double Xover = (x - overlay->GetOrigin()[0]) / overlay->GetSpacing()[0];\r
+      double Yover = (y - overlay->GetOrigin()[1]) / overlay->GetSpacing()[1];\r
+      double Zover = (z - overlay->GetOrigin()[2]) / overlay->GetSpacing()[2];\r
+      valueOver = this->GetScalarComponentAsDouble(overlay, Xover, Yover, Zover);\r
+    }\r
+\r
+       if ( mSlicers[slicer]->GetFusionActor() ) {\r
+               displayFus = 1;\r
+               vtkImageData *fusion = dynamic_cast<vtkImageData*>(mSlicers[slicer]->GetFusionMapper()->GetInput());\r
+               double Xover = (x - fusion->GetOrigin()[0]) / fusion->GetSpacing()[0];\r
+               double Yover = (y - fusion->GetOrigin()[1]) / fusion->GetSpacing()[1];\r
+               double Zover = (z - fusion->GetOrigin()[2]) / fusion->GetSpacing()[2];\r
+               valueFus = this->GetScalarComponentAsDouble(fusion, Xover, Yover, Zover);\r
+       }\r
+       else if (this->IsInvolvedInFusionSequence()) { \r
+    //if the cursor moves over the 'independent' version of the secondary sequence\r
+    //do not update the panel, just keep it as it is.\r
+               displayFus = 1;\r
+               valueFus = std::numeric_limits<double>::quiet_NaN();\r
+       }\r
+\r
+    emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(),\r
+                        x,y,z,XTransform,YTransform,ZTransform,value);\r
+    emit UpdateVector(displayVec,xVec, yVec, zVec, valueVec);\r
+    emit UpdateOverlay(displayOver,valueOver,value);\r
+    emit UpdateFusion(displayFus,valueFus);\r
+  }\r
+#endif\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::Activated()\r
-{\r
+{ \r
   emit currentImageChanged(mId);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -1154,7 +1325,7 @@ void vvSlicerManager::Activated()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::Picked()\r
-{\r
+{ \r
   emit currentPickedImageChanged(mId);\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -1162,7 +1333,7 @@ void vvSlicerManager::Picked()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateWindowLevel()\r
-{\r
+{ \r
   emit WindowLevelChanged();\r
 }\r
 //----------------------------------------------------------------------------\r
@@ -1170,12 +1341,11 @@ void vvSlicerManager::UpdateWindowLevel()
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateSlice(int slicer)\r
-{\r
+{ \r
   if (mPreviousSlice[slicer] == mSlicers[slicer]->GetSlice()) {\r
     //DD("============= NOTHING");\r
     return;\r
   }\r
-  //std::cout << "vvSlicerManager::UpdateSlice " << slicer << " " << mSlicers[slicer]->GetSlice() << std::endl;\r
   emit UpdateSlice(slicer, mSlicers[slicer]->GetSlice());\r
   mSlicers[slicer]->Render(); // DS <-- I add this, this could/must be the only Render ...\r
   mPreviousSlice[slicer] = mSlicers[slicer]->GetSlice();\r
@@ -1185,7 +1355,7 @@ void vvSlicerManager::UpdateSlice(int slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateTSlice(int slicer)\r
-{\r
+{ \r
   int slice = mSlicers[slicer]->GetSlice();\r
 \r
   int tslice = mSlicers[slicer]->GetMaxCurrentTSlice();\r
@@ -1207,7 +1377,7 @@ void vvSlicerManager::UpdateTSlice(int slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::UpdateSliceRange(int slicer)\r
-{\r
+{ \r
   emit UpdateSliceRange(slicer,\r
                         mSlicers[slicer]->GetSliceRange()[0], mSlicers[slicer]->GetSliceRange()[1],\r
                         0,mSlicers[slicer]->GetTMax());\r
@@ -1216,7 +1386,7 @@ void vvSlicerManager::UpdateSliceRange(int slicer)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset)\r
-{\r
+{ \r
   if(mSlicingPreset==preset)\r
     return;\r
 \r
@@ -1238,8 +1408,15 @@ void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset)
       return;\r
     }\r
     s->ForceUpdateDisplayExtent();\r
+#if VTK_MAJOR_VERSION <= 5\r
     s->SetSlice((s->GetInput()->GetWholeExtent()[s->GetSliceOrientation()*2+1]\r
                 +s->GetInput()->GetWholeExtent()[s->GetSliceOrientation()*2])/2.0);\r
+#else\r
+    int extentImageReslice[6];\r
+    s->GetRegisterExtent(extentImageReslice);\r
+    s->SetSlice((extentImageReslice[s->GetSliceOrientation()*2+1]\r
+                +extentImageReslice[s->GetSliceOrientation()*2])/2.0);\r
+#endif\r
     s->ResetCamera();\r
     s->Render();\r
   }\r
@@ -1252,7 +1429,7 @@ void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetPreset(int preset)\r
-{\r
+{ \r
 \r
   //vtkLookupTable* LUT = static_cast<vtkLookupTable*>(mSlicers[0]->GetWindowLevel()->GetLookupTable());\r
   double window = mSlicers[0]->GetColorWindow();\r
@@ -1311,7 +1488,7 @@ void vvSlicerManager::SetPreset(int preset)
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey)\r
-{\r
+{ \r
   double min, max;\r
   if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) {\r
     int t = mSlicers[slicer]->GetFusionTSlice();\r
@@ -1352,7 +1529,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetColorMap(int colormap)\r
-{\r
+{ \r
   double range[2];\r
 \r
   range[0] = mSlicers[0]->GetInput()->GetScalarRange()[0];\r
@@ -1451,7 +1628,6 @@ void vvSlicerManager::SetColorMap(int colormap)
 \r
     fusLUT->ForceBuild();\r
     double v[4];\r
-\r
     // set color table transparency\r
     //double alpha_range=(double)mFusionThresOpacity/10;\r
     double range_end = fusRange[0] + (double)mFusionThresOpacity*(fusRange[1] - fusRange[0])/100;\r
@@ -1507,7 +1683,7 @@ void vvSlicerManager::SetColorMap(int colormap)
 \r
 //----------------------------------------------------------------------------\r
 vvLandmarks* vvSlicerManager::GetLandmarks()\r
-{\r
+{ \r
   if (mLandmarks == NULL) {\r
     mLandmarks = new vvLandmarks(mSlicers[0]->GetTMax()+1);\r
     for (unsigned int i = 0; i < mSlicers.size(); i++)\r
@@ -1516,44 +1692,94 @@ vvLandmarks* vvSlicerManager::GetLandmarks()
   return mLandmarks;\r
 }\r
 //----------------------------------------------------------------------------\r
-\r
+void vvSlicerManager::AddNewLandmark(float x,float y,float z,float t)\r
+{ \r
+    emit callAddLandmark(x,y,z,t);\r
+}\r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::AddLandmark(float x,float y,float z,float t)\r
-{\r
+{ \r
   double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0];\r
   double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1];\r
   double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2];\r
+#if VTK_MAJOR_VERSION <= 5\r
   if (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0]-0.5 &&\r
       x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1]+0.5 &&\r
       y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2]-0.5 &&\r
       y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3]+0.5 &&\r
       z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4]-0.5 &&\r
       z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) {\r
-    double value = this->GetScalarComponentAsDouble(mSlicers[0]->GetInput(), x_index, y_index, z_index);\r
+    double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848\r
     this->GetLandmarks()->AddLandmark(x,y,z,t,value);\r
     emit LandmarkAdded();\r
   }\r
+#else\r
+  int extentImageReslice[6];\r
+  mSlicers[0]->GetRegisterExtent(extentImageReslice);\r
+  if (x_index >= extentImageReslice[0]-0.5 &&\r
+      x_index <= extentImageReslice[1]+0.5 &&\r
+      y_index >= extentImageReslice[2]-0.5 &&\r
+      y_index <= extentImageReslice[3]+0.5 &&\r
+      z_index >= extentImageReslice[4]-0.5 &&\r
+      z_index <= extentImageReslice[5]+0.5) {\r
+    double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848\r
+    this->GetLandmarks()->AddLandmark(x,y,z,t,value);\r
+    emit LandmarkAdded();\r
+  }\r
+#endif\r
+}\r
+//----------------------------------------------------------------------------\r
+\r
+//----------------------------------------------------------------------------\r
+void vvSlicerManager::AddLandmarkProfile(float x,float y,float z,float t)\r
+{ \r
+  double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0];\r
+  double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1];\r
+  double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2];\r
+#if VTK_MAJOR_VERSION <= 5\r
+  if (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0]-0.5 &&\r
+      x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1]+0.5 &&\r
+      y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2]-0.5 &&\r
+      y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3]+0.5 &&\r
+      z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4]-0.5 &&\r
+      z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]+0.5) {\r
+    double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848\r
+    this->GetLandmarks()->AddLandmark(x,y,z,t,value);\r
+  }\r
+#else\r
+  int extentImageReslice[6];\r
+  mSlicers[0]->GetRegisterExtent(extentImageReslice);\r
+  if (x_index >= extentImageReslice[0]-0.5 &&\r
+      x_index <= extentImageReslice[1]+0.5 &&\r
+      y_index >= extentImageReslice[2]-0.5 &&\r
+      y_index <= extentImageReslice[3]+0.5 &&\r
+      z_index >= extentImageReslice[4]-0.5 &&\r
+      z_index <= extentImageReslice[5]+0.5) {\r
+    double value = this->GetScalarComponentAsDouble(mSlicers[mSelectedSlicer]->GetInput(), x_index, y_index, z_index); //Value in selected Slicer (not 0): bug #2848\r
+    this->GetLandmarks()->AddLandmark(x,y,z,t,value);\r
+  }\r
+#endif\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::PrevImage(int slicer)\r
-{\r
+{ \r
   emit ChangeImageWithIndexOffset(this, slicer, -1);\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::NextImage(int slicer)\r
-{\r
+{ \r
   emit ChangeImageWithIndexOffset(this, slicer,  1);\r
 }\r
 //----------------------------------------------------------------------------\r
 \r
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice)\r
-{\r
+{ \r
   emit AVerticalSliderHasChanged(slicer, slice);\r
 }\r
 \r
@@ -1561,7 +1787,7 @@ void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice)
 \r
 //----------------------------------------------------------------------------\r
 double vvSlicerManager::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component)\r
-{\r
+{ \r
   int ix, iy, iz;\r
   return mSlicers[0]->GetScalarComponentAsDouble(image, X, Y, Z, ix, iy, iz, component);\r
 }\r
index bbdd2a41dad6cfb36c24f8c5d8a143f69dd9e7f6..e80ef485f8e54ea9de07b18957b04db35531b039 100644 (file)
@@ -274,7 +274,8 @@ class vvSlicerManager : public QObject {
   void SetSlicingPreset(SlicingPresetType preset);
 
   vvLandmarks *GetLandmarks();
-  void AddLandmark(float x,float y,float z,float t);
+  void AddNewLandmark(float x,float y,float z,float t);
+  void AddLandmarkProfile(float x,float y,float z,float t);
   
   void NextImage(int slicer);
   void PrevImage(int slicer);
@@ -282,7 +283,11 @@ class vvSlicerManager : public QObject {
   void VerticalSliderHasChanged(int slicer, int slice);
   double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0);
 
+public slots:
+  void AddLandmark(float x,float y,float z,float t);
+
 signals :
+  void callAddLandmark(float x,float y,float z,float t);
   void currentImageChanged(std::string id);
   void currentPickedImageChanged(std::string id);
   void UpdatePosition(int visibility,double x, double y, double z, double X, double Y, double Z, double value);
index f5d2b699bd495e881d533abaad7c20a43d511c83..c645a27cc88992345b9e479d4b1409688a7a933c 100644 (file)
@@ -38,7 +38,6 @@
 #include "vtkTransform.h"
 
 #include <cmath>
-
 //------------------------------------------------------------------------------
 vvSlicerManagerCommand::vvSlicerManagerCommand()
 {
@@ -112,53 +111,53 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
           this->SM->SetLocalColorWindowing(VisibleInWindow, bCtrlKey);
           return;
         }
-        if (KeyPress == "0") {
+        if (KeyPress == "0" || KeyPress == "KP_0") {
           this->SM->SetPreset(WL_AUTO);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "1") {
+        if (KeyPress == "1" || KeyPress == "KP_1") {
           this->SM->SetPreset(WL_HOUNSFIELD);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "2") {
+        if (KeyPress == "2" || KeyPress == "KP_2") {
           this->SM->SetPreset(WL_SOFTTISSUE);
           this->SM->UpdateWindowLevel();
 
           return;
         }
-        if (KeyPress == "3") {
+        if (KeyPress == "3" || KeyPress == "KP_3") {
           this->SM->SetPreset(WL_LUNGS);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "4") {
+        if (KeyPress == "4" || KeyPress == "KP_4") {
           this->SM->SetPreset(WL_BONES);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "5") {
+        if (KeyPress == "5" || KeyPress == "KP_5") {
           this->SM->SetPreset(WL_HEAD);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "6") {
+        if (KeyPress == "6" || KeyPress == "KP_6") {
           this->SM->SetColorMap(0);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "7") {
+        if (KeyPress == "7" || KeyPress == "KP_7") {
           this->SM->SetColorMap(1);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "8") {
+        if (KeyPress == "8" || KeyPress == "KP_8") {
           this->SM->SetColorMap(2);
           this->SM->UpdateWindowLevel();
           return;
         }
-        if (KeyPress == "9") {
+        if (KeyPress == "9" || KeyPress == "KP_9") {
           this->SM->SetColorMap(3);
           this->SM->UpdateWindowLevel();
           return;
@@ -382,9 +381,13 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
       //>>>>>>> 921642d767beba2442dacc8fdb40dc36396e1b7d
 
       if (newLandmark) {
-        this->SM->AddLandmark(xWorld,yWorld,zWorld,
+        double pLand[3]; pLand[0] = xWorld; pLand[1] = yWorld; pLand[2] = zWorld;
+        double ptLand[3];
+        this->SM->GetSlicer(VisibleInWindow)->GetConcatenatedTransform()->TransformPoint(pLand, ptLand);
+        this->SM->AddNewLandmark(ptLand[0],ptLand[1],ptLand[2],
                               this->SM->GetSlicer(VisibleInWindow)->GetTSlice());
-        this->SM->GetSlicer(VisibleInWindow)->UpdateLandmarks();
+        this->SM->GetSlicer(VisibleInWindow)->RemoveLandmarks();
+        //this->SM->GetSlicer(VisibleInWindow)->DisplayLandmarks();
         this->SM->Render();
       }
       if (event == vtkCommand::PickEvent || event == vtkCommand::StartPickEvent) {
index 0645ccfa95e8ea3c16d5c959a2cb35d6f7afd5e5..da0381a4521c918c375c9fd027b74c1026d12c67 100644 (file)
@@ -24,7 +24,7 @@
 #include "vtkOBJReader.h"
 #include "vtkInteractorStyle.h"
 
-
+#include <vtkVersion.h>
 #include "vtkPolyDataMapper.h"
 #include "vtkActor.h"
 #include "vtkPolyData.h"
 #include "vtkRenderer.h"
 
 #include <QMessageBox>
+#include <QFileDialog>
+
+#ifdef Q_OS_OSX
+# include "vvOSXHelper.h"
+#endif
 
 //----------------------------------------------------------------------------
 class vvManagerCallback : public vtkCommand
@@ -75,6 +80,10 @@ vvSurfaceViewerDialog::vvSurfaceViewerDialog(QWidget * parent, Qt::WindowFlags f
   mCurrentTime = 0;
 
   connect(loadButton,SIGNAL(clicked()),this,SLOT(LoadSurface()));
+
+#ifdef Q_OS_OSX
+  disableGLHiDPI(renderWidget->winId());
+#endif
 }
 
 vvSurfaceViewerDialog::~vvSurfaceViewerDialog()
@@ -110,8 +119,11 @@ void vvSurfaceViewerDialog::LoadSurface()
     reader->Update();
     mReaders.push_back(reader);
   }
-
+#if VTK_MAJOR_VERSION <= 5
   mMapper->SetInput(mReaders[mCurrentTime]->GetOutput());
+#else
+  mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort());
+#endif
 
   if (!mActor) {
     mActor = vtkActor::New();
@@ -140,7 +152,11 @@ void vvSurfaceViewerDialog::NextTime()
   mCurrentTime++;
   if (mCurrentTime >= mReaders.size())
     mCurrentTime = 0;
+#if VTK_MAJOR_VERSION <= 5
   mMapper->SetInput(mReaders[mCurrentTime]->GetOutput());
+#else
+  mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort());
+#endif
   mMapper->Modified();
   renderWidget->GetRenderWindow()->Render();
 }
@@ -150,7 +166,11 @@ void vvSurfaceViewerDialog::PreviousTime()
   mCurrentTime--;
   if (mCurrentTime < 0)
     mCurrentTime = (unsigned int) mReaders.size() - 1;
+#if VTK_MAJOR_VERSION <= 5
   mMapper->SetInput(mReaders[mCurrentTime]->GetOutput());
+#else
+  mMapper->SetInputConnection(mReaders[mCurrentTime]->GetOutputPort());
+#endif
   mMapper->Modified();
   renderWidget->GetRenderWindow()->Render();
 }
index 90e8b98c54849f0479af286879d28bf520d09534..88a75a6924081fd4eca777d21dbed1c311dffac6 100644 (file)
@@ -46,7 +46,7 @@ private :
     vtkPolyDataMapper* mMapper;
     vtkActor* mActor;
     vtkRenderer * mRenderer;
-    unsigned int mCurrentTime;
+    int mCurrentTime;
 
 }; // end class vvSurfaceViewerDialog
 //====================================================================
index 9859d01adcc101812cd644e4e15b966fbc657f9c..113cee85d6d1262410d54e0530edfb572129c9e8 100644 (file)
@@ -31,6 +31,7 @@
 #include <vtkImageClip.h>
 #include <vtkRenderWindow.h>
 
+
 //------------------------------------------------------------------------------
 // Create the tool and automagically (I like this word) insert it in
 // the main window menu.
@@ -40,7 +41,7 @@ ADD_TOOL(vvToolBinarize);
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::Initialize()
-{
+{ 
   SetToolName("Binarize");
   SetToolMenuName("Binarize");
   SetToolIconFilename(":/common/icons/binarize.png");
@@ -54,7 +55,7 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
   :vvToolWidgetBase(parent,f),
    vvToolBase<vvToolBinarize>(parent),
    Ui::vvToolBinarize()
-{
+{ 
   // GUI Initialization
   Ui_vvToolBinarize::setupUi(mToolWidget);
   mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked();
@@ -82,14 +83,14 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
 
 //------------------------------------------------------------------------------
 vvToolBinarize::~vvToolBinarize()
-{
+{ 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::InteractiveDisplayToggled(bool b)
-{
+{ 
   mInteractiveDisplayIsEnabled = b;
   if (!mInteractiveDisplayIsEnabled) {
     RemoveVTKObjects();
@@ -108,7 +109,7 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b)
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::RemoveVTKObjects()
-{
+{ 
   for(unsigned int i=0; i<mImageContour.size(); i++) {
     mImageContour[i]->HideActors();
     mImageContourLower[i]->HideActors();    
@@ -121,7 +122,7 @@ void vvToolBinarize::RemoveVTKObjects()
 
 //------------------------------------------------------------------------------
 bool vvToolBinarize::close()
-{
+{ 
   // RemoveVTKObjects();
   return vvToolWidgetBase::close();
 }
@@ -129,7 +130,8 @@ bool vvToolBinarize::close()
 
 
 //------------------------------------------------------------------------------
-void vvToolBinarize::closeEvent(QCloseEvent *event) {
+void vvToolBinarize::closeEvent(QCloseEvent *event)
+{ 
   RemoveVTKObjects();
   event->accept();
 }
@@ -138,7 +140,7 @@ void vvToolBinarize::closeEvent(QCloseEvent *event) {
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::reject()
-{
+{ 
   // DD("vvToolBinarize::reject");
   RemoveVTKObjects();
   return vvToolWidgetBase::reject();
@@ -148,7 +150,7 @@ void vvToolBinarize::reject()
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::enableLowerThan(bool b)
-{
+{ 
   if (!b) {
     mThresholdSlider1->resetMaximum();
     for(unsigned int i=0; i<mImageContour.size(); i++) {
@@ -169,7 +171,7 @@ void vvToolBinarize::enableLowerThan(bool b)
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::useFGBGtoggled(bool)
-{
+{ 
   if (!mCheckBoxUseBG->isChecked() && !mCheckBoxUseFG->isChecked())
     mCheckBoxUseBG->toggle();
 }
@@ -182,7 +184,7 @@ void vvToolBinarize::useFGBGtoggled(bool)
 //   DD(m.size());
 // }
 void vvToolBinarize::InputIsSelected(vvSlicerManager * m)
-{
+{ 
   mCurrentSlicerManager = m;
 
   // Specific for this gui
@@ -214,7 +216,7 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m)
     mImageContour.push_back(vvImageContour::New());
     mImageContour[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i));
     mImageContour[i]->SetColor(1.0, 0.0, 0.0);
-    mImageContour[i]->SetDepth(100); // to be in front of (whe used with ROI tool)
+    mImageContour[i]->SetDepth(0); // to be in front of (whe used with ROI tool)
     mImageContourLower.push_back(vvImageContour::New());
     mImageContourLower[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i));
     mImageContourLower[i]->SetColor(0.0, 0.0, 1.0);
@@ -226,12 +228,11 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m)
   connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double)));
 
   connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
-  connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int, int)),this,SLOT(UpdateSlice(int, int, int)));
   
   connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int)));
 
   //  connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
-  
   InteractiveDisplayToggled(mInteractiveDisplayIsEnabled);
 }
 //------------------------------------------------------------------------------
@@ -250,21 +251,22 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m)
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::UpdateOrientation(int slicer,int orientation)
-{
+{ 
   Update(slicer);
 }
 //------------------------------------------------------------------------------
 
+
 //------------------------------------------------------------------------------
-void vvToolBinarize::UpdateSlice(int slicer,int slices)
-{
+void vvToolBinarize::UpdateSlice(int slicer,int slices, int code)
+{ 
   Update(slicer);
 }
 //------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::Update(int slicer)
-{
+{ 
   if (!mInteractiveDisplayIsEnabled) return;
   if (!mCurrentSlicerManager) close();
   mImageContour[slicer]->Update(mThresholdSlider1->GetValue());
@@ -275,7 +277,7 @@ void vvToolBinarize::Update(int slicer)
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::GetArgsInfoFromGUI()
-{
+{ 
 
   /* //KEEP THIS FOR READING GGO FROM FILE
      int argc=1;
@@ -330,11 +332,11 @@ void vvToolBinarize::GetArgsInfoFromGUI()
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::apply()
-{
+{ 
   if (!mCurrentSlicerManager) close();
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-  GetArgsInfoFromGUI();
-
+  GetArgsInfoFromGUI();  
+  
   // Main filter
   clitk::BinarizeImageGenericFilter::Pointer filter =
     clitk::BinarizeImageGenericFilter::New();
@@ -342,8 +344,9 @@ void vvToolBinarize::apply()
   filter->SetArgsInfo(mArgsInfo);
   filter->Update();
 
+
   // Output
-  vvImage::Pointer output = filter->GetOutputVVImage();
+  vvImage::Pointer output = filter->GetOutputVVImage();  
   std::ostringstream osstream;
   osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
   AddImage(output,osstream.str());
@@ -355,7 +358,7 @@ void vvToolBinarize::apply()
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::valueChangedT2(double v)
-{
+{ 
   //  DD("valueChangedT2");
   if (mRadioButtonLowerThan->isChecked()) {
     mThresholdSlider1->SetMaximum(v);
@@ -371,7 +374,7 @@ void vvToolBinarize::valueChangedT2(double v)
 
 //------------------------------------------------------------------------------
 void vvToolBinarize::valueChangedT1(double v)
-{
+{ 
   //  DD("valueChangedT1");
   if (!mCurrentSlicerManager) close();
   mThresholdSlider2->SetMinimum(v);
index 9e61e683cd284872456b3d5030fbdbef1987af90..89e001e5469f3cd0da592ebdcec598ad9910018b 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef VVTOOLBINARIZE_H
 #define VVTOOLBINARIZE_H
 
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 
 #include "vvToolBase.h"
@@ -51,7 +52,7 @@ class vvToolBinarize:
   void valueChangedT1(double v);
   void valueChangedT2(double v);
   void UpdateOrientation(int slicer, int orientation);
-  void UpdateSlice(int slicer,int slices);
+  void UpdateSlice(int slicer,int slices, int code=0);
   void enableLowerThan(bool b);
   void useFGBGtoggled(bool);
   void InteractiveDisplayToggled(bool b);
index c3b55709722033a6445b9b3d0fb0c239ec1d5628..1530341ce83456fa770bebe4e3b595cb9ed72927 100644 (file)
@@ -33,6 +33,9 @@
 #include <QSignalMapper>
 
 // vtk
+#include <vtkVersion.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
 #include <vtkImageClip.h>
 #include <vtkImageTranslateExtent.h>
 #include <vtkImageData.h>
@@ -96,11 +99,19 @@ void vvToolCropImage::closeEvent(QCloseEvent *event)
 {
   if(mCurrentSlicerManager){
 //     Reset extends
-    for(int i=0; i<mExtentSize; i++){
+    for(int i=0; i<6; i++){
       mReducedExtent[i] = mInitialExtent[i];
     }
+    for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++)
+      mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(false);
     UpdateExtent();
   }
+  mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(mConcatenedTransform);
+  for (int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->ResetCamera();
+    mCurrentSlicerManager->GetSlicer(i)->Render();
+    mCurrentSlicerManager->UpdateLinkedNavigation( mCurrentSlicerManager->GetSlicer(i) );
+  }
   vvToolWidgetBase::closeEvent(event);
 }
 //------------------------------------------------------------------------------
@@ -117,7 +128,10 @@ bool vvToolCropImage::close()
 //------------------------------------------------------------------------------
 void vvToolCropImage::reject()
 {
-  for(int i=0; i<mExtentSize; i++) mReducedExtent[i] = mInitialExtent[i];
+  for(int i=0; i<mExtentSize; i++)
+    mReducedExtent[i] = mInitialExtent[i];
+  for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++)
+    mCurrentSlicerManager->GetSlicer(i)->EnableReducedExtent(false);
   UpdateExtent();
   return vvToolWidgetBase::reject();
 }
@@ -154,6 +168,18 @@ void vvToolCropImage::UpdateExtent()
 //------------------------------------------------------------------------------
 void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer)
 {
+  //Save the current transformation
+  mConcatenedTransform = vtkSmartPointer<vtkMatrix4x4>::New();
+  mConcatenedTransform->DeepCopy(slicer->GetSlicer(0)->GetConcatenatedTransform()->GetMatrix());
+  vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
+  matrix->Identity();
+  mCurrentSlicerManager->GetImage()->GetTransform()[0]->SetMatrix(matrix);
+  for (int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->ResetCamera();
+    mCurrentSlicerManager->GetSlicer(i)->Render();
+    mCurrentSlicerManager->UpdateLinkedNavigation( mCurrentSlicerManager->GetSlicer(i) );
+  }
+
   // Change interface according to number of dimension
   mExtentSize = 2*slicer->GetDimension();
    if (slicer->GetDimension()<4) {
@@ -173,8 +199,11 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer)
     spin_zmin->setHidden(true);
     spin_zmax->setHidden(true);
   }
-
+#if VTK_MAJOR_VERSION <= 5
   int *a = mCurrentImage->GetFirstVTKImageData()->GetWholeExtent();
+#else
+  int *a = mCurrentImage->GetFirstVTKImageData()->GetInformation()->Get(vtkDataObject::DATA_EXTENT());
+#endif
   for(int i=0; i<6; i++){
     mInitialExtent[i] = a[i];
     mReducedExtent[i] = a[i];
@@ -185,8 +214,10 @@ void vvToolCropImage::InputIsSelected(vvSlicerManager * slicer)
   }
 
 //   Set initial sliders values
-  std::vector<int> imsize = mCurrentSlicerManager->GetImage()->GetSize();
+  int w_ext[6], imsize[3];
+  mCurrentSlicerManager->GetSlicer(0)->GetRegisterExtent(w_ext);
   for(int dim=0; dim<slicer->GetDimension() && dim<3; ++dim){
+    imsize[dim] = w_ext[2*dim+1] - w_ext[2*dim] +1;
     mSliders[dim*2]->setMaximum(imsize[dim]-1);
     mSliders[dim*2+1]->setMaximum(imsize[dim]-1);
     mSliders[dim*2+1]->setValue(imsize[dim]-1);
@@ -257,7 +288,7 @@ void vvToolCropImage::apply()
   }
   // We MUST reset initial extend to input image before using the
   // filter to retrieve the correct image size
-  for(int i=0; i<mExtentSize; i++) {
+  for(int i=0; i<6; i++) {
     mReducedExtent[i] = mInitialExtent[i];
   }
   
@@ -282,6 +313,8 @@ void vvToolCropImage::apply()
   // Retrieve result and display it
   vvImage::Pointer output = filter->GetOutputVVImage();
   
+  output->GetTransform()[0]->SetMatrix(mConcatenedTransform);
+
   AddImage(output,croppedImageName.str());
   
   // End
index 27a334c3de83c5b7d4e3db96bc0abeda7261b182..014fe3d03789e21a027c240b189a4b764a918c96 100644 (file)
@@ -19,6 +19,7 @@
 #define VVTOOLCROPIMAGE_H
 
 //qt
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
 #include <QSlider>
@@ -27,6 +28,8 @@
 #include "vvToolWidgetBase.h"
 #include "vvMainWindowBase.h"
 #include "ui_vvToolCropImage.h"
+//vtk
+#include <vtkTransform.h>
 
 //------------------------------------------------------------------------------
 class vvToolCropImage:
@@ -66,6 +69,7 @@ public slots:
   virtual void closeEvent(QCloseEvent *event);
 
   std::vector<QSlider*> mSliders;
+  vtkSmartPointer<vtkMatrix4x4> mConcatenedTransform;
 }; // end class vvToolCropImage
 //------------------------------------------------------------------------------
 
index 81919ceb0dbf8f5b013e19ae141d9c93165bef33..9fe70ce15b2062791ee1f001a8301b375ad2afd9 100644 (file)
@@ -17,6 +17,8 @@
 ===========================================================================**/
 #ifndef VVTOOLImageArithm_H
 #define VVTOOLImageArithm_H
+
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 
 #include "vvToolBase.h"
index b33ca5c2c1775f0478bab421cfe551e2c91f54ee..07dbd483735d503f19565be897b260357574375c 100644 (file)
@@ -19,6 +19,7 @@
 #define VVTOOLINPUTSELECTORWIDGET_H
 
 // qt
+#include <QObject>
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
 
index 6975c0e3042e947f7ad44591a11e71efdbda8c6b..e3904a68702f1b7011475fc26531c26b01231703 100644 (file)
@@ -47,6 +47,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <vvImage.h>
 
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include "vvToolBase.h"
 #include "QWidget"
index 5f66395dff4dd13ea1f72416656fed2c749061fd..915271275f706279a0f2348d200096fd1abe164e 100644 (file)
   #ifndef VVTOOLMedianFilter_H
   #define VVTOOLMedianFilter_H
 
+  #include <QtGlobal>
   #include <QtDesigner/QDesignerExportWidget>
   #include "vvToolBase.h"
   #include "QWidget"
   #include "vvToolWidgetBase.h"
   #include "ui_vvToolMedianFilter.h"
   #include "clitkMedianImageFilter_ggo.h"
-   #include <clitkMedianImageGenericFilter.h>
+  #include <clitkMedianImageGenericFilter.h>
 
 
   //------------------------------------------------------------------------------
diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx
new file mode 100644 (file)
index 0000000..4360fee
--- /dev/null
@@ -0,0 +1,709 @@
+/*=========================================================================
+  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 <QFileDialog>
+#include <QShortcut>
+
+#include <algorithm>
+
+// vv
+#include "vvToolProfile.h"
+#include "vvProgressDialog.h"
+#include "vvSlicerManager.h"
+#include "vvSlicer.h"
+#include "vvToolInputSelectorWidget.h"
+
+// vtk
+#include <vtkAxis.h>
+#include <vtkImageActor.h>
+#include <vtkCamera.h>
+#include <vtkImageClip.h>
+#include <vtkRenderWindow.h>
+#include <vtkChartXY.h>
+#include <vtkPlot.h>
+#include <vtkRendererCollection.h>
+#include <vtkRenderer.h>
+
+#include <vtkLine.h>
+#include <vtkCellArray.h>
+#include <vtkCellData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkProperty.h>
+#include <vtkBox.h>
+#include <vtkInformation.h>
+
+#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(vvToolProfile);
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::Initialize()
+{ 
+  SetToolName("Profile");
+  SetToolMenuName("Intensity Profile");
+  SetToolIconFilename(":/common/icons/profile.png");
+  SetToolTip("Display the intensity profile between 2 points of the image.");
+  SetToolExperimental(false);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f)
+  :vvToolWidgetBase(parent,f),
+   vvToolBase<vvToolProfile>(parent),
+   Ui::vvToolProfile()
+{ 
+  // GUI Initialization
+  Ui_vvToolProfile::setupUi(mToolWidget);
+  
+  QShortcut *shortcutPoint1 = new QShortcut(QKeySequence("Ctrl+1"), parent);
+  shortcutPoint1->setContext(Qt::ApplicationShortcut);
+  QObject::connect(shortcutPoint1, SIGNAL(activated()), this, SLOT(selectPoint1()));
+  QShortcut *shortcutPoint2 = new QShortcut(QKeySequence("Ctrl+2"), parent);
+  shortcutPoint2->setContext(Qt::ApplicationShortcut);
+  QObject::connect(shortcutPoint2, SIGNAL(activated()), this, SLOT(selectPoint2()));
+
+  // Connect signals & slots
+  connect(mSelectPoint1Button, SIGNAL(clicked()), this, SLOT(selectPoint1()));
+  connect(mSelectPoint2Button, SIGNAL(clicked()), this, SLOT(selectPoint2()));
+  connect(mCancelPointsButton, SIGNAL(clicked()), this, SLOT(cancelPoints()));
+  connect(mSaveProfileButton, SIGNAL(clicked()), this, SLOT(SaveAs()));
+
+  // Initialize some widget
+  ProfileWidget->hide();
+  mPoint1 = NULL;
+  mPoint2 = NULL;
+  
+  mPoint1Selected = false;
+  mPoint2Selected = false;
+    
+  mView = vtkSmartPointer<vtkContextView>::New();
+  vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
+  chart->SetAutoSize(false);
+  chart->SetRenderEmpty(true);
+  mView->GetScene()->AddItem(chart);
+  this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems();
+  this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer());
+  ProfileWidget->show();
+
+#ifdef Q_OS_OSX
+  disableGLHiDPI(ProfileWidget->winId());
+#endif
+
+  // Main filter
+  mFilter = clitk::ProfileImageGenericFilter::New();
+
+  // Set how many inputs are needed for this tool
+  AddInputSelector("Select one image", mFilter);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolProfile::~vvToolProfile()
+{ 
+  delete [] mPoint1;
+  delete [] mPoint2;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::selectPoint1()
+{
+  QString position = "";
+  
+  if(mCurrentSlicerManager) {
+    if (mPoint1Selected) {
+      ProfileWidget->hide();
+      vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
+      chart->SetAutoSize(false);
+      chart->SetRenderEmpty(true);
+      mView->GetScene()->ClearItems();
+      mView->GetScene()->AddItem(chart);
+      this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems();
+      this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer());
+      ProfileWidget->show();
+      mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P1", mPoint1[3]);
+    }
+  
+    mPoint1Selected = false;
+
+    if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
+      double *pos;
+      pos = new double [4];
+      pos[0] = pos[1] = pos[2] = pos[3] = 0;
+          
+      int i(0);
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
+        pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+        ++i;
+      }
+      double posTransformed[3];
+      mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetConcatenatedTransform()->TransformPoint(pos, posTransformed);
+      i = 0;
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
+        pos[i] = posTransformed[i];
+        mPoint1[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[i]);
+        pos[i] = mPoint1[i]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[i] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[i]; //Ensure to be at the center of the voxel
+        position += QString::number(mPoint1[i],'f',0) + " ";
+        ++i;
+      }
+      if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) {
+        pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice();
+        mPoint1[3] = pos[3];
+        position += QString::number(mPoint1[3],'f',0) + " ";
+      }
+      mPoint1Selected = true;
+      mCurrentSlicerManager->AddLandmarkProfile(pos[0], pos[1], pos[2], pos[3]);
+      mCurrentSlicerManager->GetLandmarks()->GetLabels()->SetNumberOfValues(mCurrentSlicerManager->GetLandmarks()->GetLabels()->GetNumberOfValues()-1);
+      mCurrentSlicerManager->GetLandmarks()->GetLabels()->Modified();
+      mCurrentSlicerManager->GetLandmarks()->GetLabels()->InsertNextValue("P1");
+    }
+  }
+  mPosPoint1Label->setText(position);
+  isPointsSelected();
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::selectPoint2()
+{
+  QString position = "";
+  
+  if(mCurrentSlicerManager) {
+    if (mPoint2Selected) {
+      ProfileWidget->hide();
+      vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
+      chart->SetAutoSize(false);
+      chart->SetRenderEmpty(true);
+      mView->GetScene()->ClearItems();
+      mView->GetScene()->AddItem(chart);
+      this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems();
+      this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer());
+      ProfileWidget->show();
+      mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P2", mPoint2[3]);
+    }
+  
+    mPoint2Selected = false;
+    
+    if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
+      double *pos;
+      pos = new double [4];
+      pos[0] = pos[1] = pos[2] = pos[3] = 0;;
+          
+      int i(0);
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
+        pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+        ++i;
+      }
+      double posTransformed[3];
+      mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetConcatenatedTransform()->TransformPoint(pos, posTransformed);
+      i = 0;
+      while (i<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() && i<3) {
+        pos[i] = posTransformed[i];
+        mPoint2[i] = round((pos[i] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[i])/mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[i]);
+        pos[i] = mPoint2[i]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[i] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[i]; //Ensure to be at the center of the voxel
+        position += QString::number(mPoint2[i],'f',0) + " ";
+        ++i;
+      }
+      if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) {
+        pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice();
+        mPoint2[3] = pos[3];
+        position += QString::number(mPoint2[3],'f',0) + " ";
+      }
+      mPoint2Selected = true;
+      mCurrentSlicerManager->AddLandmarkProfile(pos[0], pos[1], pos[2], pos[3]);
+      mCurrentSlicerManager->GetLandmarks()->GetLabels()->SetNumberOfValues(mCurrentSlicerManager->GetLandmarks()->GetLabels()->GetNumberOfValues()-1);
+      mCurrentSlicerManager->GetLandmarks()->GetLabels()->Modified();
+      mCurrentSlicerManager->GetLandmarks()->GetLabels()->InsertNextValue("P2");
+    }
+  }
+  mPosPoint2Label->setText(position);
+  isPointsSelected();
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+bool vvToolProfile::isPointsSelected()
+{
+  if (mPoint1Selected && mPoint2Selected) {
+      mSaveProfileButton->setEnabled(true);
+      computeProfile();
+      SetPoints();
+      for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+        DisplayLine(i);
+        connect(mCurrentSlicerManager->GetSlicer(i), SIGNAL(UpdateDisplayExtentBegin(int)), this, SLOT(DeleteLine(int)));
+        connect(mCurrentSlicerManager->GetSlicer(i), SIGNAL(UpdateDisplayExtentEnd(int)), this, SLOT(DisplayLine(int)));
+      }
+      mCurrentSlicerManager->Render();
+  }
+  else {
+      mSaveProfileButton->setEnabled(false);
+      for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+        disconnect(mCurrentSlicerManager->GetSlicer(i), SIGNAL(UpdateDisplayExtentBegin(int)), this, SLOT(DeleteLine(int)));
+        disconnect(mCurrentSlicerManager->GetSlicer(i), SIGNAL(UpdateDisplayExtentEnd(int)), this, SLOT(DisplayLine(int)));
+        mCurrentSlicerManager->GetSlicer(i)->GetRenderer()->RemoveActor(mLineActors[i]);
+      }
+
+  }
+  return (mPoint1Selected && mPoint2Selected);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::computeProfile()
+{
+    if (!mCurrentSlicerManager) close();
+    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+    GetArgsInfoFromGUI();
+    ProfileWidget->hide();
+   
+    // Main filter
+    mFilter->SetInputVVImage(mCurrentImage);
+    mFilter->SetArgsInfo(mArgsInfo);
+    mFilter->Update();
+    
+    //Creation of the XY chart
+    vtkSmartPointer<vtkTable> table = vtkSmartPointer<vtkTable>::New();
+    vtkSmartPointer<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
+    vtkSmartPointer<vtkFloatArray> arrY = vtkSmartPointer<vtkFloatArray>::New();
+    arrX = mFilter->GetArrayX();
+    arrY = mFilter->GetArrayY();
+    arrX->SetName("Distance (mm)");
+    arrY->SetName("Intensity");
+    
+    table->AddColumn(arrX);
+    table->AddColumn(arrY);
+    
+    mView->GetRenderer()->SetBackground(1.0, 1.0, 1.0);
+    vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
+    chart->SetAutoSize(true);
+    mView->GetScene()->ClearItems();
+    mView->GetScene()->AddItem(chart);
+    vtkPlot *line = chart->AddPlot(vtkChart::LINE);
+#if VTK_MAJOR_VERSION <= 5
+    line->SetInput(table, 0, 1);
+#else
+    line->SetInputData(table, 0, 1);
+#endif
+    line->SetColor(0, 255, 0, 255);
+    line->SetWidth(1.0);
+    chart->GetAxis(vtkAxis::LEFT)->SetTitle("Intensity");
+    chart->GetAxis(vtkAxis::BOTTOM)->SetTitle("Distance (mm)");
+    
+    this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems();
+    this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer());
+    ProfileWidget->show();
+    
+    QApplication::restoreOverrideCursor();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::cancelPoints()
+{ 
+  if (mPoint1Selected)
+    mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P1", mPoint1[3]);
+  if (mPoint2Selected)
+    mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P2", mPoint2[3]);
+  ProfileWidget->hide();
+  vtkSmartPointer<vtkChartXY> chart = vtkSmartPointer<vtkChartXY>::New();
+  chart->SetAutoSize(false);
+  chart->SetRenderEmpty(true);
+  mView->GetScene()->ClearItems();
+  mView->GetScene()->AddItem(chart);
+  this->ProfileWidget->GetRenderWindow()->GetRenderers()->RemoveAllItems();
+  this->ProfileWidget->GetRenderWindow()->AddRenderer(mView->GetRenderer());
+  ProfileWidget->show();
+  
+  QString position = "";
+  mPosPoint1Label->setText(position);
+  mPosPoint2Label->setText(position);
+  mPoint1Selected = false;
+  mPoint2Selected = false;
+  mSaveProfileButton->setEnabled(false);
+  isPointsSelected();
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::RemoveVTKObjects()
+{ 
+  for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->GetRenderer()->RemoveActor(mLineActors[i]);
+  }
+
+  if (mPoint1Selected)
+    mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P1", mPoint1[3]);
+  if (mPoint2Selected)
+    mCurrentSlicerManager->GetLandmarks()->RemoveLandmarkWithLabel("P2", mPoint2[3]);
+
+    
+  if (mCurrentSlicerManager)
+    mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+bool vvToolProfile::close()
+{ 
+  //RemoveVTKObjects();
+  
+  connect(mCurrentSlicerManager, SIGNAL(callAddLandmark(float,float,float,float)), mCurrentSlicerManager, SLOT(AddLandmark(float,float,float,float)));
+  return vvToolWidgetBase::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::closeEvent(QCloseEvent *event)
+{ 
+  RemoveVTKObjects();
+  event->accept();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::reject()
+{ 
+  // DD("vvToolProfile::reject");
+  RemoveVTKObjects();
+  return vvToolWidgetBase::reject();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::InputIsSelected(vvSlicerManager * m)
+{ 
+  mCurrentSlicerManager = m;
+
+  mPoint1 = new double[4];
+  mPoint1[0] = mPoint1[1] = mPoint1[2] = mPoint1[3] = 0;
+  mPoint2 = new double[4];
+  mPoint2[0] = mPoint2[1] = mPoint2[2] = mPoint2[3] = 0;
+  
+  mSaveProfileButton->setEnabled(false);
+  mTextFileName = "Profile.txt";
+  InitializeLine();
+  
+  disconnect(mCurrentSlicerManager, SIGNAL(callAddLandmark(float,float,float,float)), mCurrentSlicerManager, SLOT(AddLandmark(float,float,float,float)));
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::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_clitkProfileImage_init(&mArgsInfo); // Initialisation to default
+
+  mArgsInfo.verbose_flag = false;
+  
+  mArgsInfo.point1_arg = mPoint1;
+  mArgsInfo.point2_arg = mPoint2;
+  mArgsInfo.point1_given = mCurrentSlicerManager->GetImage()->GetNumberOfDimensions();
+  mArgsInfo.point2_given = mCurrentSlicerManager->GetImage()->GetNumberOfDimensions();
+  
+  // Required (even if not used)
+  mArgsInfo.input_given = 0;
+  mArgsInfo.output_given = 0;
+
+  mArgsInfo.input_arg = new char;
+  mArgsInfo.output_arg = new char;
+  
+
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::apply()
+{ 
+  close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::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 || !isPointsSelected()) {
+            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<vtkFloatArray> arrX = vtkSmartPointer<vtkFloatArray>::New();
+        vtkSmartPointer<vtkFloatArray> arrY = vtkSmartPointer<vtkFloatArray>::New();
+        vtkSmartPointer<vtkFloatArray> coords = vtkSmartPointer<vtkFloatArray>::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 (i<arrX->GetNumberOfTuples()) {
+            fileOpen << i << "\t" << arrY->GetTuple(i)[0] << "\t" ;
+      
+            coords->GetTuple(i, tuple);
+            for (int j=0; j<mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() ; ++j) {
+                fileOpen << tuple[j] << "\t" ;
+            }
+            int j(0);
+            while (j<mCurrentSlicerManager->GetImage()->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;
+
+        fileOpen.close();
+        QApplication::restoreOverrideCursor();
+    } else {
+      QString error = fileformat.c_str();
+      error += " format unknown !!!\n";
+      QMessageBox::information(this,tr("Saving Problem"),error);
+      SaveAs();
+    }
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::DeleteLine(int slicer)
+{
+  if (!mPoint1Selected && !mPoint2Selected)
+    return;
+  
+  if(mCurrentSlicerManager) {
+      if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
+          mCurrentSlicerManager->GetSlicer(slicer)->GetRenderer()->RemoveActor(mLineActors[slicer]);
+      }
+   }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::DisplayLine(int slicer)
+{ 
+  if (!mPoint1Selected && !mPoint2Selected)
+    return;
+  
+  if(mCurrentSlicerManager) {
+      if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
+          double currentSlice = (mCurrentSlicerManager->GetSlicer(slicer)->GetSlice()*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetSpacing()[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetInput()->GetOrigin()[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()] - mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()] )/ mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()];
+          if (std::min(mPoint1[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()],mPoint2[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]) <= currentSlice && std::max(mPoint1[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()],mPoint2[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]) >= currentSlice) {
+            vtkSmartPointer<vtkBox> clippingBox = vtkSmartPointer<vtkBox>::New();
+            double extent[6];
+            for (int j=0; j<6; ++j) {
+                extent[j] = mCurrentSlicerManager->GetSlicer(slicer)->GetExtent()[j];
+            }
+            extent[2*mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()] = mCurrentSlicerManager->GetSlicer(slicer)->GetImageActor()->GetBounds()[ mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()*2 ]-fabs(mCurrentSlicerManager->GetSlicer(slicer)->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]);
+            extent[2*mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()+1] = mCurrentSlicerManager->GetSlicer(slicer)->GetImageActor()->GetBounds()[ mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()*2+1 ]+fabs(mCurrentSlicerManager->GetSlicer(slicer)->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[mCurrentSlicerManager->GetSlicer(slicer)->GetOrientation()]);
+            clippingBox->SetBounds(extent);
+            
+            vtkSmartPointer<vtkClipPolyData> clipper = vtkSmartPointer<vtkClipPolyData>::New();
+            clipper->SetClipFunction(clippingBox);
+#if VTK_MAJOR_VERSION <= 5
+            clipper->SetInput(mLinesPolyData);
+#else
+            mLineTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
+            mLineTransform->SetInputData(mLinesPolyData);
+            mLineTransform->SetTransform(mCurrentSlicerManager->GetSlicer(slicer)->GetConcatenatedTransform()->GetInverse());
+            clipper->SetInputConnection(mLineTransform->GetOutputPort());
+#endif
+            clipper->InsideOutOff();
+            clipper->Update();        
+            vtkSmartPointer<vtkPolyDataMapper> lineMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+#if VTK_MAJOR_VERSION <= 5
+            lineMapper->SetInput(clipper->GetOutput());
+#else
+            lineMapper->SetInputData(clipper->GetOutput());
+#endif 
+            
+            mLineActors[slicer]->SetMapper(lineMapper);
+            mLineActors[slicer]->GetProperty()->SetOpacity(0.995);
+
+            mCurrentSlicerManager->GetSlicer(slicer)->GetRenderer()->AddActor(mLineActors[slicer]);
+         }
+      }
+  }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::InitializeLine()
+{ 
+  if(mCurrentSlicerManager) {
+      
+      mLinesPolyData = vtkSmartPointer<vtkPolyData>::New();
+      
+      vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New();
+      double pos[4];
+      pos[0] = pos[1] = pos[2] = pos[3] = 0;
+      pts->InsertNextPoint(pos);
+      pts->InsertNextPoint(pos);
+      mLinesPolyData->SetPoints(pts);
+      
+      vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
+      vtkSmartPointer<vtkLine> line = vtkSmartPointer<vtkLine>::New();
+      line->GetPointIds()->SetId(0, 0); // the second 0 is the index of the 1st point in mLinesPolyData's points (pts)
+      line->GetPointIds()->SetId(1, 1); // the second 1 is the index of the 2nd point in mLinesPolyData's points (pts)
+      lines->InsertNextCell(line);
+      mLinesPolyData->SetLines(lines);
+       
+      unsigned char red[3] = { 255, 0, 0 };
+      vtkSmartPointer<vtkUnsignedCharArray> colors = vtkSmartPointer<vtkUnsignedCharArray>::New();
+      colors->SetNumberOfComponents(3);
+      colors->InsertNextTupleValue(red);
+      mLinesPolyData->GetCellData()->SetScalars(colors);
+      
+      for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+        mLineActors.push_back(vtkSmartPointer<vtkActor>::New());
+      }
+   }       
+}    
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolProfile::SetPoints()
+{ 
+  if (!mPoint1Selected && !mPoint2Selected)
+    return;
+  
+  if(mCurrentSlicerManager) {
+      if(mCurrentSlicerManager->GetSelectedSlicer() != -1) {
+          /*double *pos;
+          pos = new double [4];
+          pos[0] = pos[1] = pos[2] = pos[3] = 0;
+          
+          int i(0);
+          while (i<3) {
+            pos[i] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetCursorPosition()[i];
+            ++i;
+          }
+          if (mCurrentSlicerManager->GetImage()->GetNumberOfDimensions() == 4) {
+            pos[3] = mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetTSlice();
+          } */
+          
+          double p0[4], p1[4];
+          p0[0] = mPoint1[0]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[0] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[0];
+          p0[1] = mPoint1[1]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[1] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[1];
+          p0[2] = mPoint1[2]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[2] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[2];
+          p0[3] = mPoint1[3];
+
+          p1[0] = mPoint2[0]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[0] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[0];
+          p1[1] = mPoint2[1]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[1] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[1];
+          p1[2] = mPoint2[2]*mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetSpacing()[2] + mCurrentSlicerManager->GetSlicer(mCurrentSlicerManager->GetSelectedSlicer())->GetImage()->GetVTKImages()[mCurrentSlicerManager->GetTSlice()]->GetOrigin()[2];
+          p1[3] = mPoint2[3];
+              
+          vtkSmartPointer<vtkPoints> pts = mLinesPolyData->GetPoints();
+          pts->SetPoint(0,p0);
+          pts->SetPoint(1,p1);
+    }
+  }
+}
+//------------------------------------------------------------------------------
+
+
diff --git a/vv/vvToolProfile.h b/vv/vvToolProfile.h
new file mode 100644 (file)
index 0000000..2f64bb3
--- /dev/null
@@ -0,0 +1,94 @@
+/*=========================================================================
+  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 VVTOOLPROFILE_H
+#define VVTOOLPROFILE_H
+
+#include <QtGlobal>
+#include <QtDesigner/QDesignerExportWidget>
+
+#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
+#include "vvImageContour.h"
+#include "vvLandmarks.h"
+#include "ui_vvToolProfile.h"
+#include "vvBinaryImageOverlayActor.h"
+
+#include "clitkProfileImage_ggo.h"
+#include "clitkProfileImageGenericFilter.h"
+#include <vtkTable.h>
+#include <vtkContextView.h>
+#include <vtkContextScene.h>
+#include <vtkTransformPolyDataFilter.h>
+
+//------------------------------------------------------------------------------
+class vvToolProfile:
+  public vvToolWidgetBase,
+  public vvToolBase<vvToolProfile>, 
+  private Ui::vvToolProfile
+{
+  Q_OBJECT
+    public:
+  vvToolProfile(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+  ~vvToolProfile();
+
+  //-----------------------------------------------------
+  static void Initialize();
+  void InitializeLine();
+  void GetArgsInfoFromGUI();
+  virtual void InputIsSelected(vvSlicerManager * m);
+
+  bool isPointsSelected();
+  void computeProfile();
+  void SetPoints();
+
+  //-----------------------------------------------------
+  public slots:
+  virtual void apply();
+  virtual bool close();
+  virtual void reject();
+  
+  void selectPoint1();
+  void selectPoint2();
+  void cancelPoints();
+  void SaveAs();
+  void DisplayLine(int);
+  void DeleteLine(int);
+
+ protected:
+  void RemoveVTKObjects();
+  virtual void closeEvent(QCloseEvent *event);
+  Ui::vvToolProfile ui;
+  args_info_clitkProfileImage mArgsInfo;
+  
+  double* mPoint1;
+  double* mPoint2;
+  bool mPoint1Selected;
+  bool mPoint2Selected;
+  vtkSmartPointer<vtkContextView> mView;
+  clitk::ProfileImageGenericFilter::Pointer mFilter;
+  std::string mTextFileName;
+  std::vector<vtkSmartPointer<vtkActor> > mLineActors;
+  vtkSmartPointer<vtkPolyData> mLinesPolyData;
+  vtkSmartPointer<vtkTransformPolyDataFilter> mLineTransform;
+
+
+}; // end class vvToolProfile
+//------------------------------------------------------------------------------
+
+#endif
+
index c02516f94dde6c9cca9cff898d4543ab1cdfccb7..791db06f8922e537dc45409373bbf6884b49468d 100644 (file)
@@ -22,7 +22,6 @@
 #include "vvImageWriter.h"
 #include "vvROIActor.h"
 #include "vvSlicer.h"
-#include "vvROIActor.h"
 #include "vvMeshReader.h"
 #include "vvStructSelector.h"
 #include "vvToolManager.h"
@@ -38,7 +37,7 @@
 #include <QColorDialog>
 #include <QAbstractEventDispatcher>
 #include <QXmlStreamReader>
+
 // vtk
 #include <vtkLookupTable.h>
 #include <vtkRenderWindow.h>
 ADD_TOOL(vvToolROIManager);
 //------------------------------------------------------------------------------
 
+int vvToolROIManager::nbTotalROI = 0;
+
 //------------------------------------------------------------------------------
 vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f):
-  QWidget(parent->GetTab()), 
+  QWidget(parent->GetTab()),
   vvToolBase<vvToolROIManager>(parent),
   Ui::vvToolROIManager()
-{
+{ 
   // Store parent
   mMainWindow = parent;
-  
+
   // Assume the initial tab ROI index is 2
   mIndexFirstTab = 2;
 
@@ -67,7 +68,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f)
   mTree->clear();
   mTree->header()->resizeSection(0, 30);
   mGroupBoxROI->setEnabled(false);
-  
+
   // Disable "Load dicom" button -> not useful
   frame_4->hide();
 
@@ -94,7 +95,7 @@ vvToolROIManager::vvToolROIManager(vvMainWindowBase * parent, Qt::WindowFlags f)
 
 //------------------------------------------------------------------------------
 vvToolROIManager::~vvToolROIManager()
-{
+{ 
   mROIActorsList.clear();
 }
 //------------------------------------------------------------------------------
@@ -102,7 +103,8 @@ vvToolROIManager::~vvToolROIManager()
 
 //------------------------------------------------------------------------------
 // STATIC
-void vvToolROIManager::Initialize() {
+void vvToolROIManager::Initialize()
+{ 
   SetToolName("ROIManager");
   SetToolMenuName("Open ROI (binary image or RT-STRUCT)");
   SetToolIconFilename(":/common/icons/tool-roi.png");
@@ -114,8 +116,8 @@ void vvToolROIManager::Initialize() {
 
 
 //------------------------------------------------------------------------------
-void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag) 
-{
+void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
+{ 
   // Check if we need to start a new tool or read in the state file to load
   if (ReadStateFlag == false) {
     // Select the current image as the target
@@ -132,21 +134,21 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
 
     // Read all information in the XML
     ReadXMLInformation();
-    
-    // Check that a ROI is not already present 
+
+    // Check that a ROI is not already present
     mInitialImageIndex += mImageIndex;
     if (mInitialImageIndex >= mMainWindow->GetSlicerManagers().size()) {
       QMessageBox::warning(this, "ROIManager tool", QString("Image index %1 not found, abort.").arg(mInitialImageIndex));
       close();
       return;
     }
-    
+
     // Set the attached image
     mCurrentSlicerManager = mMainWindow->GetSlicerManagers()[mInitialImageIndex];
   }
 
   // Tab insertion, check that another tool does not already exist for this image
-  std::vector<vvToolBaseBase*> & tools = 
+  std::vector<vvToolBaseBase*> & tools =
     vvToolManager::GetInstance()->GetToolCreatorFromName(GetToolName())->GetListOfTool();
   if (tools.size() > 0) {
     for(uint i=0; i<tools.size()-1; i++) { // current tool is last
@@ -160,12 +162,12 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
   }
 
   // Display tool in the correct tab
-  QWidget * tab = qFindChild<QWidget*>(mMainWindow->GetTab(), "ROItab");
+  QWidget * tab = mMainWindow->GetTab()->findChild<QWidget*>("ROItab");
   tab->layout()->addWidget(this);
+
   // If not read in a file we start automatically the browser to load
   // a roi file (binary image)
-  if (ReadStateFlag) {    
+  if (ReadStateFlag) {
     mOpenFileBrowserFlag = false;
     InputIsSelected(mCurrentSlicerManager);
     mOpenFileBrowserFlag = true;
@@ -188,18 +190,18 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
                         roi->GetROI()->GetDisplayColor()[2]*255));
     brush.setStyle(Qt::SolidPattern);
     w->setBackground(2, brush);
-    w->setText(3, QString("%1").arg(roi->GetDepth()));  
+    w->setText(3, QString("%1").arg(roi->GetDepth()));
     roi->UpdateColor();
   }
 
   // Display the ROI
   UpdateAllContours();
-  UpdateAllROIStatus(); 
+  UpdateAllROIStatus();
 
   // Connect event from mainwindow to this widget
-  connect(mMainWindow, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)), 
+  connect(mMainWindow, SIGNAL(AnImageIsBeingClosed(vvSlicerManager *)),
           this, SLOT(AnImageIsBeingClosed(vvSlicerManager *)));
-  connect(mMainWindow, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)), 
+  connect(mMainWindow, SIGNAL(SelectedImageHasChanged(vvSlicerManager *)),
           this, SLOT(SelectedImageHasChanged(vvSlicerManager *)));
   connect(mOpenBinaryButton, SIGNAL(clicked()), this, SLOT(Open()));
   //  connect(mOpenDicomButton, SIGNAL(clicked()), this, SLOT(OpenDicomImage()));
@@ -207,36 +209,30 @@ void  vvToolROIManager::InitializeNewTool(bool ReadStateFlag)
   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
   connect(mReloadButton, SIGNAL(clicked()), this, SLOT(ReloadCurrentROI()));
   connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
-  connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  connect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int)));
   connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
+  connect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI()));
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
-{
+{ 
   // Initialization
   mCurrentSlicerManager = m;
   mCurrentImage = mCurrentSlicerManager->GetImage();
 
-  // Refuse if non 3D image
-  if (mCurrentImage->GetNumberOfDimensions() != 3) {
-    QMessageBox::information(this,tr("Sorry only 3D yet"), tr("Sorry only 3D yet"));
-    close();
-    return;
-  }
-
   // Change gui
   mLabelInputInfo->setText(QString("%1").arg(m->GetFileName().c_str()));
 
-  // Auto display browser to select new contours 
+  // Auto display browser to select new contours
   if (mOpenFileBrowserFlag) Open();
 }
 //------------------------------------------------------------------------------
@@ -244,26 +240,64 @@ void vvToolROIManager::InputIsSelected(vvSlicerManager *m)
 
 //------------------------------------------------------------------------------
 void vvToolROIManager::AnImageIsBeingClosed(vvSlicerManager * m)
-{
-  if (m == mCurrentSlicerManager) { 
+{ 
+  if (m == mCurrentSlicerManager) {
     close();
     return;
   }
 }
 //------------------------------------------------------------------------------
 
+void vvToolROIManager::RemoveROI()
+{ 
+
+  // Search the indice of the selected ROI
+  QList<QTreeWidgetItem *> l = mTree->selectedItems();
+  if (l.size() == 0)
+    return;
+
+  QTreeWidgetItem * w = l[0];
+  if (w == NULL) return;
+  if (w == 0) return;
+  if (mMapTreeWidgetToROI.find(w) == mMapTreeWidgetToROI.end()) {
+    return;
+  }
+  
+  clitk::DicomRT_ROI * roi = mMapTreeWidgetToROI[w];
+  if (roi == NULL) return;
+
+  // Get selected roi actor
+  int n = roi->GetROINumber();
+  
+  disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
+  mROIActorsList[n]->RemoveActors();
+  mROIActorsList.erase(mROIActorsList.begin()+n);
+  mROIList.erase(mROIList.begin()+n);
+  mTreeWidgetList.erase(mTreeWidgetList.begin()+n);
+
+  for (int i = n; i < mROIActorsList.size(); ++i) {
+    mROIList[i]->SetROINumber(i);
+    mTreeWidgetList[i].data()->setText(0, QString("%1").arg(mROIList[i]->GetROINumber()));
+  }
+  connect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
+  for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->Render();
+  }
+}
+//------------------------------------------------------------------------------
 
 //------------------------------------------------------------------------------
 void vvToolROIManager::close()
-{
+{ 
   disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
   disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+  disconnect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI()));
 
   // Remove actors
   for (unsigned int i = 0; i < mROIActorsList.size(); i++) {
@@ -280,11 +314,11 @@ void vvToolROIManager::close()
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
-
+void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m)
+{ 
   if (mCurrentSlicerManager == NULL) return;
   if (m == NULL) return;
-  if (m != mCurrentSlicerManager) hide(); 
+  if (m != mCurrentSlicerManager) hide();
   else {
     show();
   }
@@ -293,8 +327,8 @@ void vvToolROIManager::SelectedImageHasChanged(vvSlicerManager * m) {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::Open() 
-{
+void vvToolROIManager::Open()
+{ 
   // Open images
   QString Extensions = "Images or Dicom-Struct files ( *.mha *.mhd *.hdr *.his *.dcm RS*)";
   Extensions += ";;All Files (*)";
@@ -314,16 +348,16 @@ void vvToolROIManager::Open()
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::OpenBinaryImage(QStringList & filename) 
-{
+void vvToolROIManager::OpenBinaryImage(QStringList & filename)
+{ 
   if (filename.size() == 0) return;
+
   vvProgressDialog p("Reading ROI ...", true);
   p.SetCancelButtonEnabled(false);
   QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-  
+
   // For each selected file, open the image
-  for(int i=0; i<filename.size(); i++) { 
+  for(int i=0; i<filename.size(); i++) {
     p.SetProgress(i, filename.size());
 
     // Open Image
@@ -332,7 +366,7 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename)
     filenames.push_back(filename[i].toStdString());
     reader->SetInputFilenames(filenames);
     reader->Update(vvImageReader::IMAGE);
-  
+
     if (reader->GetLastError().size() != 0) {
       std::cerr << "Error while reading " << filename[i].toStdString() << std::endl;
       QString error = "Cannot open file \n";
@@ -352,23 +386,23 @@ void vvToolROIManager::OpenBinaryImage(QStringList & filename)
   QApplication::restoreOverrideCursor();
 
   // Update the contours
-  UpdateAllContours(); 
+  UpdateAllContours();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::OpenDicomImage(std::string filename) 
-{
+void vvToolROIManager::OpenDicomImage(std::string filename)
+{ 
   // GUI selector of roi
   vvMeshReader reader;
   reader.SetFilename(filename);
-  
+
   vvStructSelector selector;
   selector.SetStructures(reader.GetROINames());
   selector.SetPropagationCheckBoxFlag(false);
-  
-  if (selector.exec()) { 
+
+  if (selector.exec()) {
     vvProgressDialog p("Reading ROI...", true);
     p.SetCancelButtonEnabled(false);
     QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@@ -380,19 +414,19 @@ void vvToolROIManager::OpenDicomImage(std::string filename)
     // Loop on selected struct
     std::vector<int> list = selector.getSelectedItems();
     for (uint i=0; i<list.size(); i++) {
-      p.SetProgress(i, list.size());      
-       
+      p.SetProgress(i, list.size());
+
       clitk::DicomRTStruct2ImageFilter filter;
       filter.SetCropMaskEnabled(true);
       filter.SetImage(mCurrentImage);
-      filter.SetROI(s->GetROIFromROINumber(list[i])); 
+      filter.SetROI(s->GetROIFromROINumber(list[i]));
       filter.SetWriteOutputFlag(false);
-      filter.Update();  
+      filter.Update();
 
       // Get image
       vvImage::Pointer binaryImage = vvImage::New();
       binaryImage->AddVtkImage(filter.GetOutput());
-    
+
       // Add to gui
       AddImage(binaryImage, s->GetROIFromROINumber(list[i])->GetName(), "", 0, true); // "" = no filename
       mOpenedBinaryImageFilenames.push_back(filename.c_str());
@@ -401,17 +435,17 @@ void vvToolROIManager::OpenDicomImage(std::string filename)
     QApplication::restoreOverrideCursor();
   }
   // Update the contours
-  UpdateAllContours(); 
+  UpdateAllContours();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::AddImage(vvImage * binaryImage, 
-                                std::string name, 
-                                std::string filename, 
-                                double BG, bool modeBG) 
-{
+void vvToolROIManager::AddImage(vvImage * binaryImage,
+                                std::string name,
+                                std::string filename,
+                                double BG, bool modeBG)
+{ 
   // Check Dimension
   int dim = mCurrentImage->GetNumberOfDimensions();
   int bin_dim = binaryImage->GetNumberOfDimensions();
@@ -422,15 +456,16 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
     QMessageBox::information(this,tr("Reading problem"),os.str().c_str());
     return;
   }
-  
+
   // Compute roi index
-  int n = mROIList.size();
   
+  int n = nbTotalROI;
+  ++nbTotalROI;
   // Compute the name of the new ROI
   // std::ostringstream oss;
   // oss << vtksys::SystemTools::GetFilenameName(vtksys::SystemTools::GetFilenameWithoutLastExtension(filename));
   // std::string name = oss.str();
-  
+
   // Set color
   std::vector<double> color;
   color.push_back(1);
@@ -439,23 +474,23 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
 
   // Create ROI
   clitk::DicomRT_ROI::Pointer roi = clitk::DicomRT_ROI::New();
-  roi->SetFromBinaryImage(binaryImage, n, name, color, filename);
+  roi->SetFromBinaryImage(binaryImage, mROIList.size(), name, color, filename);
 
   // Add a new roi to the list
   mROIList.push_back(roi);
+
   // Set BG or FG mode
-  if (modeBG) 
+  if (modeBG)
     roi->SetBackgroundValueLabelImage(BG);
-  else 
+  else
     roi->SetForegroundValueLabelImage(BG);
-  
+
   // Change color
   if (n<mDefaultLUTColor->GetNumberOfTableValues ()) {
     double * color = mDefaultLUTColor->GetTableValue(n % mDefaultLUTColor->GetNumberOfTableValues ());
     roi->SetDisplayColor(color[0], color[1], color[2]);
   }
-  
+
   // Add a new roi actor
   QSharedPointer<vvROIActor> actor = QSharedPointer<vvROIActor>(new vvROIActor);
   actor->SetBGMode(modeBG);
@@ -463,19 +498,20 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
   actor->SetSlicerManager(mCurrentSlicerManager);
   actor->Initialize(n+1); // depth is n+1 to start at 1
   mROIActorsList.push_back(actor);
-  
+
   // CheckBox for "All"
   if (actor->IsVisible()) mNumberOfVisibleROI++;
   if (actor->IsContourVisible()) mNumberOfVisibleContourROI++;
+  AllVisibleContourROIToggled(1);
   
   // Add ROI in tree
   mTreeWidgetList.push_back(QSharedPointer<QTreeWidgetItem>(new QTreeWidgetItem(mTree)));
   QTreeWidgetItem * w = mTreeWidgetList.back().data();
   w->setText(0, QString("%1").arg(roi->GetROINumber()));
   w->setText(1, QString("%1").arg(roi->GetName().c_str()));
-  w->setText(3, QString("%1").arg(actor->GetDepth()));  
-  QBrush brush(QColor(roi->GetDisplayColor()[0]*255, 
-                      roi->GetDisplayColor()[1]*255, 
+  w->setText(3, QString("%1").arg(actor->GetDepth()));
+  QBrush brush(QColor(roi->GetDisplayColor()[0]*255,
+                      roi->GetDisplayColor()[1]*255,
                       roi->GetDisplayColor()[2]*255));
   brush.setStyle(Qt::SolidPattern);
   w->setBackground(2, brush);
@@ -484,51 +520,81 @@ void vvToolROIManager::AddImage(vvImage * binaryImage,
   mTree->resizeColumnToContents(0);
   mTree->resizeColumnToContents(1);
 
-  // Update 
-  UpdateAllROIStatus(); 
+  // Update
+  UpdateAllROIStatus();
+  
+  if (mCurrentImage->GetNumberOfDimensions() > 3) {
+      
+    //Modifications to avoid display bug with a 4D image
+    QSharedPointer<vvROIActor> CurrentROIActorTemp;
+    CurrentROIActorTemp = mCurrentROIActor;
+    mCurrentROIActor = actor;
+  
+    int VisibleInWindow(0);
+    mCurrentSlicerManager->GetSlicer(VisibleInWindow)->SetCurrentPosition(-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,-VTK_DOUBLE_MAX,mCurrentSlicerManager->GetSlicer(VisibleInWindow)->GetMaxCurrentTSlice());
+    mCurrentSlicerManager->GetSlicer(VisibleInWindow)->Render();
+  
+    VisibleROIToggled(false);
+    VisibleROIToggled(true);
+  
+    mCurrentROIActor = CurrentROIActorTemp;
+  
+  }
+  
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::UpdateAllContours() 
-{
+void vvToolROIManager::UpdateAllContours()
+{ 
   if (mCurrentSlicerManager == NULL) return;
   // Render loaded ROIs (the first is sufficient)
   for(unsigned int i=0; i<mROIList.size(); i++) {
     mROIActorsList[i]->Update();
   }
-  mCurrentSlicerManager->Render();
+  //mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::UpdateAllROIStatus() {
+void vvToolROIManager::UpdateAllROIStatus()
+{ 
   int nbVisible = 0;
+  int nbContourVisible = 0;
   int nb = mROIList.size();
   for(int i=0; i<nb; i++) {
     if (mROIActorsList[i]->IsVisible()) {
       nbVisible++;
     }
+    if (mROIActorsList[i]->IsContourVisible()) {
+      nbContourVisible++;
+    }
   }
 
   // change the states
-  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));  
-  disconnect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
+  disconnect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int)));
   if (nbVisible == nb) mCheckBoxShowAll->setCheckState(Qt::Checked);
   else {
     if (nbVisible == 0) mCheckBoxShowAll->setCheckState(Qt::Unchecked);
     else mCheckBoxShowAll->setCheckState(Qt::PartiallyChecked);
   }
-  connect(mContourCheckBoxShowAll, SIGNAL(toggled(bool)), this, SLOT(AllVisibleContourROIToggled(bool)));
+  if (nbContourVisible == nb) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
+  else {
+    if (nbContourVisible == 0) mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
+    else mContourCheckBoxShowAll->setCheckState(Qt::PartiallyChecked);
+  }
+  connect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int)));
   connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::SelectedItemChangedInTree() {
+void vvToolROIManager::SelectedItemChangedInTree()
+{ 
   // Search which roi is selected
   QList<QTreeWidgetItem *> l = mTree->selectedItems();
   if (l.size() == 0) {
@@ -556,16 +622,17 @@ void vvToolROIManager::SelectedItemChangedInTree() {
   mCurrentROI = roi;
   mCurrentROIActor = actor;
 
-  // Warning -> avoid unuseful Render here by disconnect slider 
+  // Warning -> avoid unuseful Render here by disconnect slider
   // Update GUI
   disconnect(mTree, SIGNAL(itemSelectionChanged()), this, SLOT(SelectedItemChangedInTree()));
   disconnect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   disconnect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   disconnect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  disconnect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   disconnect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   disconnect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   disconnect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+  disconnect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI()));
 
   mROInameLabel->setText(roi->GetName().c_str());
   mCheckBoxShow->setChecked(actor->IsVisible());
@@ -580,12 +647,13 @@ void vvToolROIManager::SelectedItemChangedInTree() {
   connect(mCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleROIToggled(bool)));
   connect(mOpacitySlider, SIGNAL(valueChanged(int)), this, SLOT(OpacityChanged(int)));
   connect(mChangeColorButton, SIGNAL(clicked()), this, SLOT(ChangeColor()));
-  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));  
+  connect(mContourCheckBoxShow, SIGNAL(toggled(bool)), this, SLOT(VisibleContourROIToggled(bool)));
   connect(mChangeContourColorButton, SIGNAL(clicked()), this, SLOT(ChangeContourColor()));
   connect(mContourWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeContourWidth(int)));
   connect(mDepthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(ChangeDepth(int)));
+  connect(mRemoveButton, SIGNAL(clicked()), this, SLOT(RemoveROI()));
+
 
-  
   // Set the current color to the selected ROI name
   mROInameLabel->setAutoFillBackground(true);// # This is important!!
   // mROInameLabel->setStyleSheet("QLabel { background-color : red; color : blue; }");
@@ -601,7 +669,7 @@ void vvToolROIManager::SelectedItemChangedInTree() {
                           (1-mCurrentROI->GetDisplayColor()[2])*255);
   palette->setColor(QPalette::WindowText,colorFG);
   palette->setColor(QPalette::Background, color);
-  mROInameLabel->setPalette(*palette); 
+  mROInameLabel->setPalette(*palette);
 
   // Enable the group box (in case no selection before)
   mGroupBoxROI->setEnabled(true);
@@ -610,39 +678,45 @@ void vvToolROIManager::SelectedItemChangedInTree() {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::VisibleROIToggled(bool b) {
+void vvToolROIManager::VisibleROIToggled(bool b)
+{ 
   if (mCurrentROIActor == NULL) return;
   if (b == mCurrentROIActor->IsVisible()) return; // nothing to do
   mCurrentROIActor->SetVisible(b);
   UpdateAllROIStatus();
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::VisibleContourROIToggled(bool b) {
+void vvToolROIManager::VisibleContourROIToggled(bool b)
+{ 
   if (mCurrentROIActor == NULL) return;
   if (mCurrentROIActor->IsContourVisible() == b) return; // nothing to do
   mCurrentROIActor->SetContourVisible(b);
   mCurrentROIActor->UpdateColor();
-  mCurrentSlicerManager->Render(); 
+  UpdateAllROIStatus(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::OpacityChanged(int v) {
+void vvToolROIManager::OpacityChanged(int v)
+{ 
   if (mCurrentROIActor == NULL) return;
   mCurrentROIActor->SetOpacity((double)v/100.0);
   mCurrentROIActor->UpdateColor();
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::AllVisibleROIToggled(int b) {
+void vvToolROIManager::AllVisibleROIToggled(int b)
+{ 
+  disconnect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
   bool status = false;
   if ((mCheckBoxShowAll->checkState() == Qt::Checked) ||
       (mCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
@@ -653,17 +727,20 @@ void vvToolROIManager::AllVisibleROIToggled(int b) {
   if (status) mCheckBoxShowAll->setCheckState(Qt::Checked);
   else  mCheckBoxShowAll->setCheckState(Qt::Unchecked);
   mCheckBoxShow->setChecked(status);
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
+  connect(mCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleROIToggled(int)));
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
+void vvToolROIManager::AllVisibleContourROIToggled(int b)
+{ 
+  disconnect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int)));
   bool status = false;
   if ((mContourCheckBoxShowAll->checkState() == Qt::Checked) ||
       (mContourCheckBoxShowAll->checkState() == Qt::PartiallyChecked))  status = true;
-  // Update current 
+  // Update current
   for(uint i=0; i<mROIActorsList.size(); i++) {
     mROIActorsList[i]->SetContourVisible(status);
   }
@@ -671,13 +748,15 @@ void vvToolROIManager::AllVisibleContourROIToggled(bool b) {
   if (status) mContourCheckBoxShowAll->setCheckState(Qt::Checked);
   else  mContourCheckBoxShowAll->setCheckState(Qt::Unchecked);
   mContourCheckBoxShow->setChecked(status);
-  mCurrentSlicerManager->Render(); 
+  mCurrentSlicerManager->Render();
+  connect(mContourCheckBoxShowAll, SIGNAL(stateChanged(int)), this, SLOT(AllVisibleContourROIToggled(int)));
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ChangeColor() {
+void vvToolROIManager::ChangeColor()
+{ 
   if (mCurrentROIActor == NULL) return;
   QColor color;
   color.setRgbF(mCurrentROIActor->GetROI()->GetDisplayColor()[0],
@@ -702,11 +781,12 @@ void vvToolROIManager::ChangeColor() {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ChangeContourColor() {
+void vvToolROIManager::ChangeContourColor()
+{ 
   if (mCurrentROIActor == NULL) return;
   QColor color;
-  color.setRgbF(mCurrentROIActor->GetContourColor()[0], 
-               mCurrentROIActor->GetContourColor()[1], 
+  color.setRgbF(mCurrentROIActor->GetContourColor()[0],
+               mCurrentROIActor->GetContourColor()[1],
                mCurrentROIActor->GetContourColor()[2]);
   //  QColorDialog d(color);
   QColor c = QColorDialog::getColor(color, this, "Choose the contour color");
@@ -719,7 +799,8 @@ void vvToolROIManager::ChangeContourColor() {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ChangeContourWidth(int n) {
+void vvToolROIManager::ChangeContourWidth(int n)
+{ 
   if (mCurrentROIActor == NULL) return;
   mCurrentROIActor->SetContourWidth(n);
   mCurrentROIActor->UpdateColor();
@@ -729,10 +810,11 @@ void vvToolROIManager::ChangeContourWidth(int n) {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ChangeDepth(int n) {
+void vvToolROIManager::ChangeDepth(int n)
+{ 
   if (mCurrentROIActor == NULL) return;
   mCurrentROIActor->SetDepth(n);
-  // mCurrentROIActor->UpdateImage(); // FIXME  
+  // mCurrentROIActor->UpdateImage(); // FIXME
   mCurrentSlicerManager->Render();
   QList<QTreeWidgetItem *> l = mTree->selectedItems();
   QTreeWidgetItem * w = l[0];
@@ -742,7 +824,8 @@ void vvToolROIManager::ChangeDepth(int n) {
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ReloadCurrentROI() {
+void vvToolROIManager::ReloadCurrentROI()
+{ 
   if (mCurrentROI->GetFilename() == "") {
     return; // do nothing (contour from rt struct do not reload)
   }
@@ -753,14 +836,14 @@ void vvToolROIManager::ReloadCurrentROI() {
   mCurrentROIActor->SetVisible(false);
   mCurrentROIActor->SetContourVisible(false);
   mCurrentSlicerManager->Render();
-  
+
   // Reload image
   vvImageReader::Pointer reader = vvImageReader::New();
   reader->SetInputFilename(mCurrentROI->GetFilename());
   reader->Update(vvImageReader::IMAGE);
   if (reader->GetLastError() != "") {
     // No message just ignore (because can be from dicom)
-    // QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"), 
+    // QMessageBox::information(mMainWindowBase, tr("Sorry, error. Could not reload"),
     //                          reader->GetLastError().c_str());
     return;
   }
@@ -776,14 +859,14 @@ void vvToolROIManager::ReloadCurrentROI() {
   mCurrentROIActor->UpdateImage();
   mCurrentROIActor->SetVisible(visible);
   mCurrentROIActor->SetContourVisible(cvisible);
-  mCurrentSlicerManager->Render();    
+  mCurrentSlicerManager->Render();
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void  vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
-{
+{ 
   // Get index of the image
   int n = mMainWindow->GetSlicerManagers().size();
   int index=-1;
@@ -812,7 +895,7 @@ void  vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
     m_XmlWriter->writeAttribute("Opacity", QString("%1").arg(roi->GetOpacity()));
     m_XmlWriter->writeAttribute("Depth", QString("%1").arg(roi->GetDepth()));
     m_XmlWriter->writeEndElement();
-   
+
     m_XmlWriter->writeStartElement("Contour");
     m_XmlWriter->writeAttribute("Red",  QString("%1").arg(roi->GetContourColor()[0]));
     m_XmlWriter->writeAttribute("Green",QString("%1").arg(roi->GetContourColor()[1]));
@@ -828,21 +911,21 @@ void  vvToolROIManager::SaveState(std::auto_ptr<QXmlStreamWriter> & m_XmlWriter)
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ReadXMLInformation() 
-{
+void vvToolROIManager::ReadXMLInformation()
+{ 
   std::string value="";
   mInitialImageIndex = -1;
-  while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) { 
+  while (!(m_XmlReader->isEndElement() && value == GetToolName().toStdString())) {
     m_XmlReader->readNext();
     value = m_XmlReader->qualifiedName().toString().toStdString();
-    
-    if (value == "Image_Index") 
+
+    if (value == "Image_Index")
       mInitialImageIndex = m_XmlReader->readElementText().toInt();
-    
+
     if (m_XmlReader->isStartElement()) {
       if (value == "ROI") {
         ReadXMLInformation_ROI();
-      }      
+      }
     }
   }
 }
@@ -850,8 +933,8 @@ void vvToolROIManager::ReadXMLInformation()
 
 
 //------------------------------------------------------------------------------
-void vvToolROIManager::ReadXMLInformation_ROI() 
-{
+void vvToolROIManager::ReadXMLInformation_ROI()
+{ 
   QString s;
   std::string value="";
   QSharedPointer<vvROIActor> param = QSharedPointer<vvROIActor>(new vvROIActor);
@@ -868,13 +951,13 @@ void vvToolROIManager::ReadXMLInformation_ROI()
   int width = 1;
   int depth=1;
 
-  while (!(m_XmlReader->isEndElement() && value == "ROI")) { 
+  while (!(m_XmlReader->isEndElement() && value == "ROI")) {
     m_XmlReader->readNext();
     value = m_XmlReader->qualifiedName().toString().toStdString();
     if (value == "Image") {
       s = m_XmlReader->readElementText();
     }
-    
+
     if (value == "Overlay" && m_XmlReader->isStartElement()) {
       QXmlStreamAttributes attributes = m_XmlReader->attributes();
       if (!m_XmlReader->hasError())
@@ -907,8 +990,8 @@ void vvToolROIManager::ReadXMLInformation_ROI()
     }
     param->SetOverlayColor(r,g,b);
     param->SetVisible(visible);
-    param->SetOpacity(opacity); 
-    param->SetDepth(depth); 
+    param->SetOpacity(opacity);
+    param->SetDepth(depth);
 
     param->SetContourColor(cr,cg,cb);
     param->SetContourVisible(cvisible);
index 8ad4a1c65ece4c5393460804b03715f18248cbae..9cb993ad6f57dac5ab5b6185c54e64189bf487b9 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef VVTOOLROIMANAGER_H
 #define VVTOOLROIMANAGER_H
 
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include <QSharedPointer>
 
@@ -64,9 +65,10 @@ class vvToolROIManager:
   void ChangeContourWidth(int n);
   void ChangeDepth(int n);
   void AllVisibleROIToggled(int b);
-  void AllVisibleContourROIToggled(bool b);
+  void AllVisibleContourROIToggled(int b);
   void ReloadCurrentROI();  
   void close();
+  void RemoveROI();
   vvSlicerManager * GetCurrentSlicerManager() { return mCurrentSlicerManager; }
 
 protected:
@@ -79,6 +81,7 @@ protected:
   
   int mNumberOfVisibleROI;
   int mNumberOfVisibleContourROI;
+  static int nbTotalROI;
 
   vtkSmartPointer<vtkLookupTable> mDefaultLUTColor;
 
index 46d54efbca948587d3f995825dade7391e9822b5..64b3768bed771352d5c70ef44ce5d5dea84c500f 100644 (file)
@@ -538,6 +538,7 @@ void vvToolResample::apply()
   // Go !
   mFilter->Update();
   mOutput = mFilter->GetOutputVVImage();
+  mOutput->GetTransform()[0]->SetMatrix(mCurrentSlicerManager->GetSlicer(0)->GetConcatenatedTransform()->GetMatrix());
   AddImage(mOutput,GetOutputFileName());
   close();
 }
index 29481651e21aad16311963d9557ea74155e107a1..8c2909e888158ce01eafe027126a32406dc8ed43 100644 (file)
 // vv
 #include "vvToolRigidReg.h"
 #include "vvSlicer.h"
+#include <vvBlendImageActor.h>
 
 // vtk
 #include <vtkImageData.h>
 #include <vtkSmartPointer.h>
+#include <vtkInformation.h>
 #include <vtkTransform.h>
+#include <vtkImageActor.h>
+#include <vtkImageMapper3D.h>
+#include <vtkOpenGLImageSliceMapper.h>
 
 // itk
 #include <itkEuler3DTransform.h>
@@ -373,7 +378,21 @@ void vvToolRigidReg::SetTransform(vtkMatrix4x4 *matrix)
   itk::Euler3DTransform<double>::Pointer euler;
   euler = itk::Euler3DTransform<double>::New();
   euler->SetCenter(center);
-  euler->SetMatrix(rotMat);
+  try {
+#if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR > 6)
+    euler->SetMatrix(rotMat,0.00001);
+#else
+    euler->SetMatrix(rotMat);
+#endif
+  } catch (itk::ExceptionObject) {
+    QString warning = "The matrice is a non-orthogonal rotation matrix.\nThe manual registration doesn't work.";
+    QMessageBox msgBox(QMessageBox::Warning, tr("Reset transform"),warning, 0, this);
+    msgBox.addButton(tr("OK"), QMessageBox::AcceptRole);
+    if (msgBox.exec() == QMessageBox::AcceptRole) {
+        //SetTransform(mInitialMatrix);
+        vvToolWidgetBase::close();
+    }
+  }
   euler->SetOffset(transVec);
 
   // Modify GUI according to the new parameters
@@ -393,7 +412,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<double,double>(angleDiff/(2*itk::Math::pi));
-    if(angleDiff>1.e-4) {
+    if(abs(angleDiff)>1.e-4) {
       rotSBs[i]->blockSignals(true);
       rotSBs[i]->setValue( euler->GetParameters()[i]*rad );
       rotSBs[i]->blockSignals(false);
@@ -431,14 +450,34 @@ void vvToolRigidReg::GetSlidersAndSpinBoxes(std::vector<QSlider *>&transSliders,
 }
 //------------------------------------------------------------------------------
 
+//------------------------------------------------------------------------------
+void vvToolRigidReg::ExtentMax(const double pointExtent[8][4], double maxExtent[2][3])
+{
+    double max, min;
+    for (int i=0; i<3; ++i) {
+        max = pointExtent[0][i];
+        min = pointExtent[0][i];
+        for (int j=1; j<8; ++j) {
+            if (pointExtent[j][i] > max) {
+                max = pointExtent[j][i];
+            }
+            if (pointExtent[j][i] < min) {
+                min = pointExtent[j][i];
+            }
+        }
+        maxExtent[0][i] = min;
+        maxExtent[1][i] = max;
+    }
+}
+//------------------------------------------------------------------------------
+
 //------------------------------------------------------------------------------
 void vvToolRigidReg::Render()
 {
-  for (int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++)
-    {
+for (int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
     mCurrentSlicerManager->GetSlicer(i)->ForceUpdateDisplayExtent();
     mCurrentSlicerManager->GetSlicer(i)->Render();
-    }
+}
 }
 //------------------------------------------------------------------------------
 
index 559aca5bfecb83ee3abe41c501d9648d61b9aae1..02d679b41ac033baa89b962c621e92791fc9128b 100644 (file)
@@ -55,6 +55,7 @@ protected:
   Ui::vvToolRigidReg ui;
   vvSlicerManager * mInput;
   vtkSmartPointer<vtkMatrix4x4> mInitialMatrix;
+  void ExtentMax(const double [8][4], double [2][3]);
   void SetTransform(vtkMatrix4x4 * matrix);
   void GetSlidersAndSpinBoxes(std::vector<QSlider *>&transSliders, std::vector<QSlider *>&rotSliders,
                               std::vector<QDoubleSpinBox *>&transSBs, std::vector<QDoubleSpinBox *>&rotSBs);
index 341084df8a4792c316ef0533d6b98a64c45190d1..63ff9b150f6cac958826bb87e83b9473310b9c0a 100644 (file)
@@ -34,6 +34,9 @@
 #include <QMessageBox>
 
 // vtk
+#include <vtkVersion.h>
+#include <vtkStreamingDemandDrivenPipeline.h>
+#include <vtkInformation.h>
 #include "vtkImageContinuousErode3D.h"
 #include "vtkImageContinuousDilate3D.h"
 #include "vtkRenderWindow.h"
@@ -399,10 +402,18 @@ void vvToolSegmentation::Erode()
   vtkImageContinuousErode3D* erode = vtkImageContinuousErode3D::New();
   erode->SetKernelSize(mKernelValue,mKernelValue,mKernelValue);
   vtkImageData* image = mCurrentMaskImage->GetVTKImages()[0];
+#if VTK_MAJOR_VERSION <= 5
   erode->SetInput(image);
+#else
+  erode->SetInputData(image);
+#endif
   erode->Update();
   image->DeepCopy(erode->GetOutput());
+#if VTK_MAJOR_VERSION <= 5
   image->Update();
+#else
+  //image->Update();
+#endif
   UpdateAndRenderNewMask();
   erode->Delete();
   QApplication::restoreOverrideCursor();
@@ -420,10 +431,18 @@ void vvToolSegmentation::Dilate()
   vtkImageContinuousDilate3D* dilate = vtkImageContinuousDilate3D::New();
   dilate->SetKernelSize(mKernelValue,mKernelValue,mKernelValue);
   vtkImageData* image = mCurrentMaskImage->GetVTKImages()[0];
+#if VTK_MAJOR_VERSION <= 5
   dilate->SetInput(image);
+#else
+  dilate->SetInputData(image);
+#endif
   dilate->Update();
   image->DeepCopy(dilate->GetOutput());
+#if VTK_MAJOR_VERSION <= 5
   image->Update();
+#else
+  //image->Update();
+#endif
   UpdateAndRenderNewMask();
   dilate->Delete();
   QApplication::restoreOverrideCursor();
@@ -557,7 +576,7 @@ void vvToolSegmentation::MousePositionChanged(int slicer)
   // mCurrentMousePositionInPixel[1] = Yover;
   // mCurrentMousePositionInPixel[2] = Zover;
   // DDV(mCurrentMousePositionInPixel, 3);
-
+#if VTK_MAJOR_VERSION <= 5
   if (Xover >= image->GetWholeExtent()[0] &&
       Xover <= image->GetWholeExtent()[1] &&
       Yover >= image->GetWholeExtent()[2] &&
@@ -579,6 +598,29 @@ void vvToolSegmentation::MousePositionChanged(int slicer)
     // DD("out of mask");
     mCurrentLabelUnderMousePointer = 0; // BG is always 0 in CCL
   }
+#else
+  if (Xover >= image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] &&
+      Xover <= image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] &&
+      Yover >= image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] &&
+      Yover <= image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] &&
+      Zover >= image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] &&
+      Zover <= image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]) {
+    if (mCurrentState == State_Default) { // inside the mask
+      mCurrentLabelUnderMousePointer = 1;
+      return; 
+    }
+    else { // inside the label image
+      vtkImageData * image = mCurrentCCLImage->GetFirstVTKImageData();
+      mCurrentLabelUnderMousePointer = 
+        mCurrentSlicerManager->GetSlicer(0)->GetScalarComponentAsDouble(image, Xover, Yover, Zover, ix, iy, iz, 0);
+      return;
+    }
+  }
+  else {
+    // DD("out of mask");
+    mCurrentLabelUnderMousePointer = 0; // BG is always 0 in CCL
+  }
+#endif
 }
 //------------------------------------------------------------------------------
 
index 5cd6e404b81d952b4237bd280b9378459a5b9521..25bf6d018ba19ae57c943ed0c6564c7034671021 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef VVTOOLSEGMENTATION_H
 #define VVTOOLSEGMENTATION_H
 
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 
 #include "vvToolBase.h"
index 3cbc63e80de88f3371edcb4262decc042e003da6..dfc83b14b5806453486bed7712419d7e863a7af3 100644 (file)
@@ -17,6 +17,8 @@
 ===========================================================================**/
 #ifndef VVTOOLSIMPLEINPUTSELECTORWIDGET_H
 #define VVTOOLSIMPLEINPUTSELECTORWIDGET_H
+
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include <QDialog>
 #include "ui_vvToolSimpleInputSelectorWidget.h"
diff --git a/vv/vvToolTest.cxx b/vv/vvToolTest.cxx
new file mode 100644 (file)
index 0000000..b364d8b
--- /dev/null
@@ -0,0 +1,331 @@
+/*=========================================================================
+  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
+  ===========================================================================**/
+
+// vv
+#include "vvToolTest.h"
+#include "vvSlicerManager.h"
+#include "vvSlicer.h"
+#include "vvToolInputSelectorWidget.h"
+
+// clitk
+#include "clitkBinarizeImageGenericFilter.h"
+
+// vtk
+#include <vtkImageActor.h>
+#include <vtkCamera.h>
+#include <vtkImageClip.h>
+#include <vtkRenderWindow.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkRenderer.h>
+#include <vtkSphereSource.h>
+#include <vtkProperty.h>
+
+#include <itkGDCMImageIO.h>
+
+//------------------------------------------------------------------------------
+// Create the tool and automagically (I like this word) insert it in
+// the main window menu.
+ADD_TOOL(vvToolTest);
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::Initialize()
+{ cout << __func__ << endl;
+  SetToolName("Test");
+  SetToolMenuName("Test");
+  SetToolIconFilename(":/common/icons/binarize.png");
+  SetToolTip("try to display a sphere.");
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolTest::vvToolTest(vvMainWindowBase * parent, Qt::WindowFlags f)
+  :vvToolWidgetBase(parent,f),
+   vvToolBase<vvToolTest>(parent),
+   Ui::vvToolTest()
+{ cout << __func__ << endl;
+  // GUI Initialization
+
+  // Connect signals & slots
+  
+  // Main filter
+  mFilter = clitk::BinarizeImageGenericFilter::New();
+
+  // Set how many inputs are needed for this tool
+  AddInputSelector("Select one image", mFilter);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+vvToolTest::~vvToolTest()
+{ cout << __func__ << endl;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+/*
+void vvToolTest::InteractiveDisplayToggled(bool b)
+{ cout << __func__ << endl;
+  mInteractiveDisplayIsEnabled = b;
+  if (!mInteractiveDisplayIsEnabled) {
+    RemoveVTKObjects();
+  } else {
+    for(unsigned int i=0; i<mImageContour.size(); i++) {
+      mImageContour[i]->ShowActors();
+      if (mRadioButtonLowerThan->isChecked())
+        mImageContourLower[i]->ShowActors();
+    }
+    if (mCurrentSlicerManager)
+      mCurrentSlicerManager->Render();
+  }
+}
+*/
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+bool vvToolTest::close()
+{ cout << __func__ << endl;
+  return vvToolWidgetBase::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::reject()
+{ cout << __func__ << endl;
+  // DD("vvToolBinarize::reject");
+  return vvToolWidgetBase::reject();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+
+void vvToolTest::InputIsSelected(vvSlicerManager * m)
+{ cout << __func__ << endl;
+  mCurrentSlicerManager = m;
+
+
+  vtkSmartPointer<vtkSphereSource> sphereSource = 
+      vtkSmartPointer<vtkSphereSource>::New();
+  sphereSource->SetCenter(0, 0, 0);
+  //sphereSource->SetCenter(235.351, 175.781, 141.0);
+  sphereSource->SetRadius(10.0);
+  sphereSource->Update();
+  vtkSmartPointer<vtkPolyDataMapper> sphereMapper =
+      vtkSmartPointer<vtkPolyDataMapper>::New();
+  sphereMapper->SetInputConnection(sphereSource->GetOutputPort());
+  vtkSmartPointer<vtkActor> sphereActor = 
+      vtkSmartPointer<vtkActor>::New();
+  sphereActor->SetMapper(sphereMapper);
+  sphereActor->GetProperty()->SetColor(1.0, 0.0, 0.0);
+  sphereActor->GetProperty()->SetOpacity(0.995);
+  sphereActor->SetPosition(235.351, 175.781, -10);
+  
+  
+  // VTK Renderer
+  vtkSmartPointer<vtkRenderer> sphereRenderer = 
+      vtkSmartPointer<vtkRenderer>::New();
+  // Add Actor to renderer
+  for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    mCurrentSlicerManager->GetSlicer(i)->GetRenderer()->AddActor(sphereActor);
+  }
+  //sphereRenderer->AddActor(sphereActor); //mettre le vvSlicer
+   
+  // VTK/Qt wedded
+  //this->qvtkWidgetLeft->GetRenderWindow()->AddRenderer(leftRenderer);
+
+  // VTK objects for interactive display
+  valueChangedT1();
+
+  //connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1()));
+
+  connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int)));
+  
+  connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateSlice(int, int)));
+
+  //  connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int)));
+  //InteractiveDisplayToggled(mInteractiveDisplayIsEnabled);
+  
+  
+  
+typedef signed short InputPixelType;
+const unsigned int Dimension = 3;
+typedef itk::Image< InputPixelType, Dimension > InputImageType;
+typedef itk::ImageFileReader< InputImageType > ReaderType;
+ReaderType::Pointer reader = ReaderType::New();
+reader->SetFileName( "/home/tbaudier/BJ13/RTSTRUCT/1.2.840.113704.1.111.4140.1439902720.30/20160201/160325.000000_/2.16.840.1.113669.1919.1454339005/2.16.840.1.113669.1919.1454339005/1.2.840.10008.5.1.4.1.1.481.3.1454339000.dcm" );
+typedef itk::GDCMImageIO ImageIOType;
+ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
+reader->SetImageIO( gdcmImageIO ); 
+try
+{
+reader->Update();
+}
+catch (itk::ExceptionObject & e)
+{
+std::cerr << "exception in file reader " << std::endl;
+std::cerr << e.GetDescription() << std::endl;
+std::cerr << e.GetLocation() << std::endl;
+return;
+}
+  
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+// void vvToolBinarize::LeftButtonReleaseEvent(int slicer) {
+//   DD("LeftButtonReleaseEvent");
+//   for(int i=0; i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+//     if (i == slicer);
+//     mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render();
+//   }
+// }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolTest::apply()
+{ cout << __func__ << endl;
+  if (!mCurrentSlicerManager) close();
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  //GetArgsInfoFromGUI();  
+  
+  // Main filter
+
+
+
+  // Output
+  QApplication::restoreOverrideCursor();
+  close();
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolTest::UpdateSlice(int slicer,int slices)
+{ cout << __func__ << endl;
+  Update(slicer);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolTest::Update(int slicer)
+{ cout << __func__ << endl;
+  if (!mCurrentSlicerManager) close();
+  mCurrentSlicerManager->Render();
+  //mImageContour[slicer]->Update(mThresholdSlider1->GetValue());
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/* void vvToolTest::GetArgsInfoFromGUI()
+{ cout << __func__ << endl;
+
+  /* //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_clitkBinarizeImage_init(&mArgsInfo); // Initialisation to default
+  bool inverseBGandFG = false;
+
+  mArgsInfo.lower_given = 1;
+  mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
+  if (mRadioButtonLowerThan->isChecked()) {
+    mArgsInfo.upper_given = 1;
+    mArgsInfo.upper_arg = mThresholdSlider2->GetValue();
+    if (mArgsInfo.upper_arg<mArgsInfo.lower_arg) {
+      mArgsInfo.upper_given = 0;
+      DD("TODO : lower thres greater than greater thres ! Ignoring ");
+    }
+  }
+
+  mArgsInfo.fg_arg = mFGSlider->GetValue();
+  mArgsInfo.bg_arg = mBGSlider->GetValue();
+
+  if (inverseBGandFG) {
+    mArgsInfo.fg_arg = mFGSlider->GetValue();
+    mArgsInfo.bg_arg = mBGSlider->GetValue();
+  }
+  mArgsInfo.fg_given = 1;
+  mArgsInfo.bg_given = 1;
+
+  if (mCheckBoxUseBG->isChecked()) {
+    if (mCheckBoxUseFG->isChecked()) mArgsInfo.mode_arg = (char*)"both";
+    else mArgsInfo.mode_arg = (char*)"BG";
+  } else mArgsInfo.mode_arg = (char*)"FG";
+
+  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 vvToolTest::valueChangedT1()
+{ cout << __func__ << endl;
+  //  DD("valueChangedT1");
+  if (!mCurrentSlicerManager) close();
+  for(int i=0;i<mCurrentSlicerManager->GetNumberOfSlicers(); i++) {
+    //mImageContour[i]->Update(v);
+  }
+  mCurrentSlicerManager->Render();
+}
+//------------------------------------------------------------------------------
diff --git a/vv/vvToolTest.h b/vv/vvToolTest.h
new file mode 100644 (file)
index 0000000..f28a181
--- /dev/null
@@ -0,0 +1,62 @@
+/*=========================================================================
+  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 VVTOOLTEST_H
+#define VVTOOLTEST_H
+
+#include <QtUiPlugin/QDesignerExportWidget>
+
+#include "vvToolBase.h"
+#include "vvToolWidgetBase.h"
+#include "vvImageContour.h"
+#include "ui_vvToolTest.h"
+
+
+//------------------------------------------------------------------------------
+class vvToolTest:
+  public vvToolWidgetBase,
+  public vvToolBase<vvToolTest>,
+  private Ui::vvToolTest 
+{
+  Q_OBJECT
+    public:
+  vvToolTest(vvMainWindowBase * parent=0, Qt::WindowFlags f=0);
+  ~vvToolTest();
+
+  //-----------------------------------------------------
+  static void Initialize();
+  //void GetArgsInfoFromGUI();
+  virtual void InputIsSelected(vvSlicerManager * m);
+
+  //-----------------------------------------------------
+  public slots:
+  virtual bool close();
+  virtual void reject();
+  virtual void apply();
+  void UpdateSlice(int slicer,int slices);
+  void valueChangedT1();
+
+ protected:
+  Ui::vvToolTest ui;
+  
+  void Update(int slicer);
+
+}; // end class vvToolTest
+//------------------------------------------------------------------------------
+
+#endif
+
index 6abc741ac47917b8fe6f671492a2b0398e957300..9c85336e2ab4f9a174b693850af92908b85f3710 100644 (file)
@@ -38,7 +38,7 @@ bool vvToolWidgetBase::mIsAnotherToolWaitInput = false;
 vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f, bool initialize):
   QWidget(parent, f),
   Ui::vvToolWidgetBase()
-{
+{ 
   mMainWindow = parent;
   setAttribute(Qt::WA_DeleteOnClose);
   if (initialize) Initialization();
@@ -116,7 +116,7 @@ vvToolWidgetBase::vvToolWidgetBase(vvMainWindowBase * parent, Qt::WindowFlags f,
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::Initialization() 
-{
+{ 
   mCurrentSlicerManager = 0;
   mIsInitialized = false;
   mFilter = 0;
@@ -139,14 +139,14 @@ void vvToolWidgetBase::Initialization()
 
 //------------------------------------------------------------------------------
 vvToolWidgetBase::~vvToolWidgetBase()
-{
+{ 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::keyPressEvent(QKeyEvent *event) 
-{
+{ 
   if (event->key() == Qt::Key_Escape) {
     reject();
     event->accept();
@@ -164,7 +164,7 @@ void vvToolWidgetBase::keyPressEvent(QKeyEvent *event)
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::accept()
-{
+{ 
   apply();
 }
 //------------------------------------------------------------------------------
@@ -172,7 +172,7 @@ void vvToolWidgetBase::accept()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::reject()
-{
+{ 
   close();
 }
 //------------------------------------------------------------------------------
@@ -180,7 +180,7 @@ void vvToolWidgetBase::reject()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::AddInputSelector(QString s, clitk::ImageToImageGenericFilterBase * f, bool allowSkip)
-{
+{ 
   int j=0;
   mFilter = f;
   mSlicerManagersCompatible.clear();
@@ -219,7 +219,7 @@ void vvToolWidgetBase::AddInputSelector(QString s, clitk::ImageToImageGenericFil
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::AddInputSelector(QString s, bool allowSkip)
-{
+{ 
   mSlicerManagersCompatible.clear();
   for(unsigned int i=0; i<mMainWindow->GetSlicerManagers().size(); i++) {
     mSlicerManagersCompatible.push_back(mMainWindow->GetSlicerManagers()[i]);
@@ -245,7 +245,7 @@ void vvToolWidgetBase::AddInputSelector(QString s, bool allowSkip)
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::HideInputSelector()
-{
+{ 
   mToolInputSelectionWidget->hide();
 }
 //------------------------------------------------------------------------------
@@ -253,7 +253,7 @@ void vvToolWidgetBase::HideInputSelector()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::show()
-{
+{ 
   if (!mIsInitialized) {
     mToolInputSelectionWidget->Initialize();
     mIsInitialized = true;
@@ -265,7 +265,7 @@ void vvToolWidgetBase::show()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::closeEvent(QCloseEvent *event) 
-{
+{ 
   mIsAnotherToolWaitInput = false;
   if (isWindow()) {
     event->accept();//return QWidget::close();
@@ -292,7 +292,7 @@ void vvToolWidgetBase::closeEvent(QCloseEvent *event)
 
 //------------------------------------------------------------------------------
 bool vvToolWidgetBase::close()
-{
+{ 
   QApplication::restoreOverrideCursor();
   return QWidget::close();
 }
@@ -301,7 +301,7 @@ bool vvToolWidgetBase::close()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m)
-{
+{ 
   mToolInputSelectionWidget->AnImageIsBeingClosed(m);
   if (m == mCurrentSlicerManager) {
     close();
@@ -312,7 +312,7 @@ void vvToolWidgetBase::AnImageIsBeingClosed(vvSlicerManager * m)
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::SwapCurrentWidget()
-{
+{ 
   mStaticWidgetForTab->setUpdatesEnabled(false);
   QList<QObject*> l =mStaticWidgetForTab->children(); 
   for(int i=1; i<l.size(); i++) {
@@ -331,7 +331,7 @@ void vvToolWidgetBase::SwapCurrentWidget()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::SelectedImageHasChanged(vvSlicerManager * m)
-{
+{ 
   if (!isWindow()) { // When the tool is not in a window, it is in a tab : we only display if needed
     if (mCurrentSlicerManager == NULL) return;
     if (mToolWidget == NULL) return;
@@ -349,14 +349,14 @@ void vvToolWidgetBase::SelectedImageHasChanged(vvSlicerManager * m)
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::InitializeInputs()
-{
+{ 
 }
 //------------------------------------------------------------------------------
 
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::InputIsSelected()
-{
+{ 
   mMainButtonBox->setEnabled(true);
   std::vector<vvSlicerManager*> & l = mToolInputSelectionWidget->GetSelectedInputs();
   mCurrentSlicerManager = l[0];
@@ -372,7 +372,7 @@ void vvToolWidgetBase::InputIsSelected()
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::InputIsSelected(vvSlicerManager * m)
-{
+{ 
   std::cerr << "You MUST overwrite this method vvToolWidgetBase::InputIsSelected(vvSlicerManager * m) if you use one single input" << std::endl;
   exit(0);
 }
@@ -381,7 +381,7 @@ void vvToolWidgetBase::InputIsSelected(vvSlicerManager * m)
 
 //------------------------------------------------------------------------------
 void vvToolWidgetBase::InputIsSelected(std::vector<vvSlicerManager*> & l)
-{
+{ 
   mMainButtonBox->setEnabled(true);
   if (l.size() == 1) InputIsSelected(l[0]);
   else {
index 2f33110aa9f0103712e1645d5031db98595eb6e5..8e5405a674e69111748a5a6fe1697b3a81f02249 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef VVTOOLWIDGETBASE_H
 #define VVTOOLWIDGETBASE_H
 
+#include <QtGlobal>
 #include <QtDesigner/QDesignerExportWidget>
 #include "ui_vvToolWidgetBase.h"
 #include "clitkImageToImageGenericFilter.h"
index 4a7ffce79713c35e0976970666390c87d4204f94..9a8046265a7810f506d734b2a12a4c7ce9034544 100644 (file)
@@ -52,7 +52,7 @@ std::string getDicomClientAETitle();
 int getDicomClientPort();
 
 // get the directory where the dicom files will be stored during c-move action.
-std::string getCMoveDirectory()
+std::string getCMoveDirectory();
 
 std::map <std::string,std::string > getDicomServer(QString nickname);
 #endif