From ad5a183bb2c7e1e4a7b16e6aa6607547e97ae250 Mon Sep 17 00:00:00 2001
From: Patrick Imbo <patrick.imbo@c-s.fr>
Date: Wed, 20 Oct 2010 16:36:13 +0200
Subject: [PATCH] ENH: template the SetOutputParametersFromImage method for
 GenericRSResampleImageFilter

---
 .../otbGenericRSResampleImageFilter.h          | 11 ++++++++++-
 .../otbGenericRSResampleImageFilter.txx        | 18 ------------------
 2 files changed, 10 insertions(+), 19 deletions(-)

diff --git a/Code/Projections/otbGenericRSResampleImageFilter.h b/Code/Projections/otbGenericRSResampleImageFilter.h
index eeb8646556..abd3dc85e6 100644
--- a/Code/Projections/otbGenericRSResampleImageFilter.h
+++ b/Code/Projections/otbGenericRSResampleImageFilter.h
@@ -213,7 +213,16 @@ public:
   otbGetObjectMemberConstMacro(Transform,AverageElevation,double);
   
   /** Useful to set the output parameters from an existing image*/
-  void SetOutputParametersFromImage(const ImageBaseType * image);
+  template <class TImageType> void SetOutputParametersFromImage(const TImageType * image)
+    {
+    this->SetOutputOrigin ( image->GetOrigin() );
+    this->SetOutputSpacing ( image->GetSpacing() );
+    this->SetOutputStartIndex ( image->GetLargestPossibleRegion().GetIndex() );
+    this->SetOutputSize ( image->GetLargestPossibleRegion().GetSize() );
+    this->SetOutputProjectionRef(image->GetProjectionRef());
+    this->SetOutputKeywordList(image->GetImageKeywordlist());
+    }
+
 
   /** Useful to set the output parameters from an existing image*/
   void SetOutputParametersFromMap(const std::string map, const SpacingType& spacing);
diff --git a/Code/Projections/otbGenericRSResampleImageFilter.txx b/Code/Projections/otbGenericRSResampleImageFilter.txx
index a668047ffa..8846e140e8 100644
--- a/Code/Projections/otbGenericRSResampleImageFilter.txx
+++ b/Code/Projections/otbGenericRSResampleImageFilter.txx
@@ -222,24 +222,6 @@ GenericRSResampleImageFilter<TInputImage, TOutputImage>
   m_RpcEstimationUpdated = true;
 }
 
-/**
- * Method used to copy the parameters of the input image
- * 
- */
-template <class TInputImage, class TOutputImage>
-void
-GenericRSResampleImageFilter<TInputImage, TOutputImage>
-::SetOutputParametersFromImage(const ImageBaseType * image)
-{
-  const InputImageType * src = dynamic_cast<const InputImageType*>(image);
-  
-  this->SetOutputOrigin ( src->GetOrigin() );
-  this->SetOutputSpacing ( src->GetSpacing() );
-  this->SetOutputStartIndex ( src->GetLargestPossibleRegion().GetIndex() );
-  this->SetOutputSize ( src->GetLargestPossibleRegion().GetSize() );
-  this->SetOutputProjectionRef(src->GetProjectionRef());
-  this->SetOutputKeywordList(src->GetImageKeywordlist());
-}
 /**
  * Method used to copy the parameters of the input image
  * 
-- 
GitLab