From eb66d4bc89824a1548c838863a06e5900097f12d Mon Sep 17 00:00:00 2001 From: Patrick Imbo <patrick.imbo@c-s.fr> Date: Wed, 3 Nov 2010 12:53:52 +0100 Subject: [PATCH] ENH: add DEMFunction and suppress DEMHandler in SensorModelBase --- Code/Projections/otbSensorModelBase.h | 29 ++++++++++++++++++------- Code/Projections/otbSensorModelBase.txx | 4 ---- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Code/Projections/otbSensorModelBase.h b/Code/Projections/otbSensorModelBase.h index 5589d71ea6..78a0615eb3 100644 --- a/Code/Projections/otbSensorModelBase.h +++ b/Code/Projections/otbSensorModelBase.h @@ -22,7 +22,9 @@ #include "otbMacro.h" #include "otbImageKeywordlist.h" -#include "otbDEMHandler.h" + +#include "itkFunctionBase.h" +#include "otbElevDatabaseHeightAboveMSLFunction.h" #include "projection/ossimProjection.h" @@ -51,18 +53,22 @@ class ITK_EXPORT SensorModelBase : public itk::Transform<TScalarType, public: /** Standard class typedefs. */ - typedef SensorModelBase Self; + typedef SensorModelBase Self; typedef itk::Transform<TScalarType, NInputDimensions, - NOutputDimensions> Superclass; + NOutputDimensions> Superclass; typedef itk::SmartPointer<Self> Pointer; typedef itk::SmartPointer<const Self> ConstPointer; typedef itk::Point<TScalarType, NInputDimensions> InputPointType; typedef itk::Point<TScalarType, NOutputDimensions> OutputPointType; - typedef DEMHandler DEMHandlerType; - typedef typename DEMHandlerType::Pointer DEMHandlerPointerType; + typedef TScalarType PixelType; + typedef itk::FunctionBase< OutputPointType, PixelType> DEMFunctionBaseType; + typedef typename DEMFunctionBaseType::Pointer DEMFunctionBasePointer; + typedef otb::ElevDatabaseHeightAboveMSLFunction<PixelType, + typename OutputPointType::ValueType> SRTMFunctionType; + /** Method for creation through the object factory. */ itkNewMacro(Self); @@ -90,9 +96,16 @@ public: itkSetMacro(AverageElevation, TScalarType); itkGetMacro(AverageElevation, TScalarType); + /** Set/Get the DEM Function. */ + itkSetObjectMacro(DEMFunction, DEMFunctionBaseType); + itkGetConstObjectMacro(DEMFunction, DEMFunctionBaseType); + + virtual void SetDEMDirectory(const std::string& directory) { - m_DEMHandler->OpenDEMDirectory(directory.c_str()); + typename SRTMFunctionType::Pointer srtmFunction = SRTMFunctionType::New(); + srtmFunction->OpenDEMDirectory(directory); + this->SetDEMFunction( srtmFunction.GetPointer() ); m_DEMIsLoaded = true; this->EnableDEM(); } @@ -127,8 +140,8 @@ protected: /** Specify if DEM is used in Point Transformation */ bool m_UseDEM; - /** Object that read and use DEM */ - DEMHandlerPointerType m_DEMHandler; + /** DEM Function : evaluate the height value from a DEM */ + DEMFunctionBasePointer m_DEMFunction; /** Specify an average elevation to use */ TScalarType m_AverageElevation; diff --git a/Code/Projections/otbSensorModelBase.txx b/Code/Projections/otbSensorModelBase.txx index 125d85f200..0ca33e3daa 100644 --- a/Code/Projections/otbSensorModelBase.txx +++ b/Code/Projections/otbSensorModelBase.txx @@ -40,13 +40,9 @@ SensorModelBase<TScalarType, NInputDimensions, NOutputDimensions> ::SensorModelBase() : Superclass(OutputSpaceDimension, 0) { m_Model = NULL; - m_DEMHandler = DEMHandlerType::New(); m_UseDEM = false; m_DEMIsLoaded = false; m_AverageElevation = 0.0; - // Ensure that Elev manager never returns default nan value - m_DEMHandler->SetDefaultHeightAboveEllipsoid(0.); - } template <class TScalarType, -- GitLab