From eb65a4d27bde12c2caec1c61d4b38f99361fe37f Mon Sep 17 00:00:00 2001 From: Otmane Lahlou <otmane.lahlou@c-s.fr> Date: Fri, 17 Sep 2010 18:53:23 +0200 Subject: [PATCH] ENH : simplify the class --- .../Projections/otbOrthoRectificationFilter.h | 11 +----- .../otbOrthoRectificationFilter.txx | 38 ++++++------------- 2 files changed, 14 insertions(+), 35 deletions(-) diff --git a/Code/Projections/otbOrthoRectificationFilter.h b/Code/Projections/otbOrthoRectificationFilter.h index 7e01fad891..34008c1281 100644 --- a/Code/Projections/otbOrthoRectificationFilter.h +++ b/Code/Projections/otbOrthoRectificationFilter.h @@ -76,7 +76,7 @@ public: itkNewMacro(Self); /** Run-time type information (and related methods). */ - itkTypeMacro(OrthoRectificationFilter, StreamingResampleImageFilter); + itkTypeMacro(OrthoRectificationFilter, GenericRSResampleImageFilter); /** Accessors */ virtual void SetMapProjection(MapProjectionType* arg) @@ -84,7 +84,6 @@ public: if (this->m_MapProjection != arg) { this->m_MapProjection = arg; - m_IsComputed = false; this->Modified(); } } @@ -100,19 +99,13 @@ protected: OrthoRectificationFilter(); virtual ~OrthoRectificationFilter(); void PrintSelf(std::ostream& os, itk::Indent indent) const; - + virtual void GenerateInputRequestedRegion(); virtual void GenerateOutputInformation(void); private: OrthoRectificationFilter(const Self &); //purposely not implemented void operator =(const Self&); //purposely not implemented - - /** Calculate transformation model from sensor model and map projection composition */ - void ComputeResampleTransformationModel(); - - /** Boolean used to know if transformation model computation is needed */ - bool m_IsComputed; /** Map Projection used to transform cartographic coordinates in geographic coordinates */ MapProjectionPointerType m_MapProjection; diff --git a/Code/Projections/otbOrthoRectificationFilter.txx b/Code/Projections/otbOrthoRectificationFilter.txx index 34f724b08c..a0602e1f2e 100644 --- a/Code/Projections/otbOrthoRectificationFilter.txx +++ b/Code/Projections/otbOrthoRectificationFilter.txx @@ -26,17 +26,13 @@ namespace otb template <class TInputImage, class TOutputImage, class TMapProjection, class TInterpolatorPrecision> OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolatorPrecision> -::OrthoRectificationFilter() -{ - m_MapProjection = MapProjectionType::New(); - m_IsComputed = false; -} +::OrthoRectificationFilter(): m_MapProjection(NULL) +{} template <class TInputImage, class TOutputImage, class TMapProjection, class TInterpolatorPrecision> OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolatorPrecision> ::~OrthoRectificationFilter() -{ -} +{} template <class TInputImage, class TOutputImage, class TMapProjection, class TInterpolatorPrecision> void OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolatorPrecision> @@ -51,7 +47,6 @@ void OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolatorPrecision> ::GenerateInputRequestedRegion() { - this->ComputeResampleTransformationModel(); Superclass::GenerateInputRequestedRegion(); } @@ -62,25 +57,16 @@ OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolato { // call the superclass' implementation of this method Superclass::GenerateOutputInformation(); - - // fill up the metadata information for ProjectionRef - itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary(); - std::string projectionRef = m_MapProjection->GetWkt(); - itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, projectionRef); - - // Fill the GenericRSTransform with those information - this->SetOutputProjectionRef(projectionRef); -} - -template <class TInputImage, class TOutputImage, class TMapProjection, class TInterpolatorPrecision> -void -OrthoRectificationFilter<TInputImage, TOutputImage, TMapProjection, TInterpolatorPrecision> -::ComputeResampleTransformationModel() -{ - if (m_IsComputed == false) + + if(!m_MapProjection.IsNull() && !m_MapProjection->GetWkt().empty()) { - this->SetInputKeywordList(this->GetInput()->GetImageKeywordlist()); - m_IsComputed = true; + // fill up the metadata information for ProjectionRef + itk::MetaDataDictionary& dict = this->GetOutput()->GetMetaDataDictionary(); + std::string projectionRef = m_MapProjection->GetWkt(); + itk::EncapsulateMetaData<std::string>(dict, MetaDataKey::ProjectionRefKey, projectionRef); + + // Fill the GenericRSTransform with those information + this->SetOutputProjectionRef(projectionRef); } } -- GitLab