From 6ba3ae42db97a5367507312b4d086e006081d8ed Mon Sep 17 00:00:00 2001 From: dsarrut Date: Wed, 7 Jul 2010 06:58:37 +0000 Subject: [PATCH] add "havesamespacing" utility --- common/clitkImageCommon.h | 13 +++++++++++-- common/clitkImageCommon.txx | 30 ++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/common/clitkImageCommon.h b/common/clitkImageCommon.h index 294c19a..e734d21 100644 --- a/common/clitkImageCommon.h +++ b/common/clitkImageCommon.h @@ -96,13 +96,22 @@ namespace clitk { //-------------------------------------------------------------------- template - bool HasSameSizeAndSpacing(typename ImageType1::ConstPointer A, + bool HaveSameSizeAndSpacing(typename ImageType1::ConstPointer A, typename ImageType2::ConstPointer B); template - bool HasSameSizeAndSpacing(typename ImageType1::Pointer A, + bool HaveSameSizeAndSpacing(typename ImageType1::Pointer A, typename ImageType2::Pointer B); + //-------------------------------------------------------------------- + template + bool HaveSameSpacing(typename ImageType1::ConstPointer A, + typename ImageType2::ConstPointer B); + + template + bool HaveSameSpacing(typename ImageType1::Pointer A, + typename ImageType2::Pointer B); + #include "clitkImageCommon.txx" } // end namespace diff --git a/common/clitkImageCommon.txx b/common/clitkImageCommon.txx index 7b6badf..ca8206e 100644 --- a/common/clitkImageCommon.txx +++ b/common/clitkImageCommon.txx @@ -319,7 +319,7 @@ void ComputeWeightsOfEachClasses(const typename InputImageType::Pointer & input, //-------------------------------------------------------------------- template -bool HasSameSizeAndSpacing(typename ImageType1::ConstPointer A, +bool HaveSameSizeAndSpacing(typename ImageType1::ConstPointer A, typename ImageType2::ConstPointer B) { if (A->GetImageDimension() != B->GetImageDimension()) return false; @@ -333,7 +333,7 @@ bool HasSameSizeAndSpacing(typename ImageType1::ConstPointer A, //-------------------------------------------------------------------- template -bool HasSameSizeAndSpacing(typename ImageType1::Pointer A, +bool HaveSameSizeAndSpacing(typename ImageType1::Pointer A, typename ImageType2::Pointer B) { if (A->GetImageDimension() != B->GetImageDimension()) return false; @@ -345,5 +345,31 @@ bool HasSameSizeAndSpacing(typename ImageType1::Pointer A, } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +bool HaveSameSpacing(typename ImageType1::ConstPointer A, + typename ImageType2::ConstPointer B) +{ + if (A->GetImageDimension() != B->GetImageDimension()) return false; + for(unsigned int i=0; iGetImageDimension(); i++) { + if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false; + } + return true; +} +//-------------------------------------------------------------------- + +//-------------------------------------------------------------------- +template +bool HaveSameSpacing(typename ImageType1::Pointer A, + typename ImageType2::Pointer B) +{ + if (A->GetImageDimension() != B->GetImageDimension()) return false; + for(unsigned int i=0; iGetImageDimension(); i++) { + if (A->GetSpacing()[i] != B->GetSpacing()[i]) return false; + } + return true; +} +//-------------------------------------------------------------------- + #endif /* end #define CLITKIMAGECOMMON_TXX */ -- 2.47.1