Skip to content
Snippets Groups Projects
Commit c818cf85 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

MRG

parents 23dc28c8 93e66a5a
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,7 @@ namespace otb
typedef itk::Transform<double, 2, 2> GenericTransformType;
typedef typename GenericTransformType::Pointer GenericTransformPointerType;
typedef otb::CompositeTransform<GenericTransformType, GenericTransformType> TransformType;
typedef typename TransformType::Pointer TransformPointerType;
// typedef itk::MetaDataDictionary MetaDataDictionary;
// typedef itk::SmartPointer<MetaDataDictionary> MetaDataDictionaryPointer;
......@@ -111,46 +112,37 @@ namespace otb
const itk::MetaDataDictionary& GetInputDictionary() const
{
return *m_InputDictionary;
return m_InputDictionary;
}
void SetInputDictionary(const itk::MetaDataDictionary & dictionary)
{
if(m_InputDictionary==NULL)
{
m_InputDictionary=new itk::MetaDataDictionary;
}
*m_InputDictionary = dictionary;
m_InputDictionary = dictionary;
this->Modified();
}
const itk::MetaDataDictionary& GetOutputDictionary() const
{
return *m_OutputDictionary;
return m_OutputDictionary;
}
void SetOutputDictionary(itk::MetaDataDictionary & dictionary)
{
if(m_OutputDictionary==NULL)
{
m_OutputDictionary=new itk::MetaDataDictionary;
}
*m_OutputDictionary = dictionary;
m_OutputDictionary = dictionary;
this->Modified();
}
itkGetMacro(InputKeywordList,ImageKeywordlist);
void SetInputKeywordList(ImageKeywordlist kwl)
void SetInputKeywordList(const ImageKeywordlist& kwl)
{
this->m_InputKeywordList = kwl;
this->Modified();
}
itkGetMacro(OutputKeywordList,ImageKeywordlist);
void SetOutputKeywordList(ImageKeywordlist kwl)
void SetOutputKeywordList(const ImageKeywordlist& kwl)
{
this->m_OutputKeywordList = kwl;
this->Modified();
......@@ -192,7 +184,7 @@ namespace otb
itkGetConstReferenceMacro(OutputSpacing, SpacingType);
/** Methods prototypes */
virtual const TransformType* GetTransform() const;
virtual const TransformType * GetTransform() const;
OutputPointType TransformPoint(const InputPointType &point) const;
......@@ -202,10 +194,13 @@ namespace otb
protected:
GenericRSTransform();
virtual ~GenericRSTransform()
{};
virtual void Modified()
{
delete m_InputDictionary;
delete m_OutputDictionary;
};
this->Superclass::Modified();
m_TransformUpToDate = false;
}
private :
GenericRSTransform(const Self&); //purposely not implemented
......@@ -214,8 +209,8 @@ namespace otb
ImageKeywordlist m_InputKeywordList;
ImageKeywordlist m_OutputKeywordList;
itk::MetaDataDictionary* m_InputDictionary;
itk::MetaDataDictionary* m_OutputDictionary;
itk::MetaDataDictionary m_InputDictionary;
itk::MetaDataDictionary m_OutputDictionary;
std::string m_InputProjectionRef;
std::string m_OutputProjectionRef;
......@@ -226,11 +221,11 @@ namespace otb
SpacingType m_OutputSpacing;
OriginType m_OutputOrigin;
TransformType* m_Transform;
TransformPointerType m_Transform;
GenericTransformPointerType m_InputTransform;
GenericTransformPointerType m_OutputTransform;
bool reinstanciateTransform;
bool m_TransformUpToDate;
};
......
......@@ -43,9 +43,7 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
m_Transform = NULL;
m_InputTransform = NULL;
m_OutputTransform = NULL;
m_InputDictionary = NULL;
m_OutputDictionary = NULL;
reinstanciateTransform=true;
m_TransformUpToDate = false;
}
......@@ -197,7 +195,7 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
::GetTransform() const
{
itkDebugMacro("returning MapProjection address " << this->m_Transform );
if ((reinstanciateTransform) || (m_Transform == NULL))
if ((!m_TransformUpToDate) || (m_Transform.IsNull()))
{
itkExceptionMacro(<<"m_Transform not up-to-date, call InstanciateTransform() first");
}
......@@ -217,10 +215,6 @@ void
GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
::InstanciateTransform(void)
{
assert(m_InputDictionary != NULL);
assert(m_OutputDictionary != NULL);
m_Transform = TransformType::New();
//If the information was not specified by the user, it is filled from the metadata
......@@ -230,12 +224,12 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
if (m_InputKeywordList.GetSize() == 0)
{
ossimKeywordlist kwl;
itk::ExposeMetaData<ossimKeywordlist>(*m_InputDictionary, MetaDataKey::OSSIMKeywordlistKey, kwl );
itk::ExposeMetaData<ossimKeywordlist>(m_InputDictionary, MetaDataKey::OSSIMKeywordlistKey, kwl );
m_InputKeywordList.SetKeywordlist(kwl);
}
if (m_InputProjectionRef.empty())
{
itk::ExposeMetaData<std::string>(*m_InputDictionary, MetaDataKey::ProjectionRefKey, m_InputProjectionRef );
itk::ExposeMetaData<std::string>(m_InputDictionary, MetaDataKey::ProjectionRefKey, m_InputProjectionRef );
}
......@@ -351,6 +345,8 @@ GenericRSTransform<TScalarType, NInputDimensions, NOutputDimensions>
m_Transform->SetFirstTransform(m_InputTransform);
m_Transform->SetSecondTransform(m_OutputTransform);
m_TransformUpToDate = true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment