From 809657ecae82ca179751ae360d7aeb5676202cdc Mon Sep 17 00:00:00 2001 From: schaerer Date: Wed, 13 Jan 2010 14:28:24 +0000 Subject: [PATCH] upport --- common/clitkCommon.h | 13 ++++++++++++- common/clitkCommon.txx | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/common/clitkCommon.h b/common/clitkCommon.h index 1c5f9a0..5831d7b 100644 --- a/common/clitkCommon.h +++ b/common/clitkCommon.h @@ -24,6 +24,8 @@ #include "itkMacro.h" #include +#include +#include //-------------------------------------------------------------------- namespace clitk { @@ -41,6 +43,11 @@ namespace clitk { #define DD(a) std::cout << #a " = [ " << a << " ]" << std::endl; #define DDV(a,n) { std::cout << #a " = [ "; for(unsigned int _i_=0; _i_ + void CloneImage(const typename ImageType::Pointer & input, typename ImageType::Pointer & output); + #include "clitkCommon.txx" } // end namespace diff --git a/common/clitkCommon.txx b/common/clitkCommon.txx index 984ef76..4d16648 100644 --- a/common/clitkCommon.txx +++ b/common/clitkCommon.txx @@ -128,5 +128,25 @@ std::string GetTypeAsString() { } //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +void CloneImage(const typename ImageType::Pointer & input, typename ImageType::Pointer & output) { + output->SetRegions(input->GetLargestPossibleRegion()); + output->SetSpacing(input->GetSpacing()); + output->Allocate(); + typedef itk::ImageRegionConstIterator ConstIteratorType; + ConstIteratorType pi(input,input->GetLargestPossibleRegion()); + pi.GoToBegin(); + typedef itk::ImageRegionIterator IteratorType; + IteratorType po(output,input->GetLargestPossibleRegion()); + po.GoToBegin(); + while (!pi.IsAtEnd()) { + po.Set(pi.Get()); + ++pi; + ++po; + } +} +//-------------------------------------------------------------------- + #endif /* end #define CLITKCOMMON_TXX */ -- 2.46.1