From: schaerer Date: Wed, 13 Jan 2010 14:28:24 +0000 (+0000) Subject: upport X-Git-Tag: v1.2.0~867 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=809657ecae82ca179751ae360d7aeb5676202cdc;p=clitk.git upport --- 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 */