From 81ba07d06c6705efbfa74eb81c149a1ce5380afa Mon Sep 17 00:00:00 2001 From: Antoine Regimbeau <antoine.regimbeau@c-s.fr> Date: Thu, 2 Nov 2017 17:01:24 +0100 Subject: [PATCH] BUG : add ComputeIndexToPhysicalPointMatrices after setting the spacing --- Modules/Core/ImageBase/include/otbImage.h | 2 - Modules/Core/ImageBase/include/otbImage.txx | 40 ++----------------- .../Core/ImageBase/include/otbVectorImage.h | 1 - .../Core/ImageBase/include/otbVectorImage.txx | 40 ++----------------- 4 files changed, 8 insertions(+), 75 deletions(-) diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h index d3943b3519..caf55c470f 100644 --- a/Modules/Core/ImageBase/include/otbImage.h +++ b/Modules/Core/ImageBase/include/otbImage.h @@ -231,8 +231,6 @@ public: /** Set signed spacing */ virtual void SetSignedSpacing( SpacingType spacing ); virtual void SetSignedSpacing( double spacing[ VImageDimension ] ); - virtual void SetSignedSpacing( float spacing[ VImageDimension ] ); - /** Get image corners. */ virtual VectorType GetUpperLeftCorner(void) const; diff --git a/Modules/Core/ImageBase/include/otbImage.txx b/Modules/Core/ImageBase/include/otbImage.txx index e02892ef55..096a725960 100644 --- a/Modules/Core/ImageBase/include/otbImage.txx +++ b/Modules/Core/ImageBase/include/otbImage.txx @@ -181,48 +181,16 @@ void Image<TPixel, VImageDimension> } } this->SetSpacing(spacing); + this->ComputeIndexToPhysicalPointMatrices(); + this->Modified(); } template <class TPixel, unsigned int VImageDimension> void Image<TPixel, VImageDimension> ::SetSignedSpacing( double spacing[ VImageDimension ]) { - for ( unsigned int i = 0; i < VImageDimension; i++ ) - { - if ( spacing[i] < 0.0 ) - { - if ( this->m_Direction[i][i] > 0 ) - { - for ( unsigned j = 0; j < VImageDimension; ++j ) - { - this->m_Direction[j][i] = - this->m_Direction[j][i]; - } - } - spacing[i] = - spacing[i]; - } - } - this->SetSpacing(spacing); -} - -template <class TPixel, unsigned int VImageDimension> -void Image<TPixel, VImageDimension> -::SetSignedSpacing( float spacing[ VImageDimension ]) -{ - for ( unsigned int i = 0; i < VImageDimension; i++ ) - { - if ( spacing[i] < 0.0 ) - { - if ( this->m_Direction[i][i] > 0 ) - { - for ( unsigned j = 0; j < VImageDimension; ++j ) - { - this->m_Direction[j][i] = - this->m_Direction[j][i]; - } - } - spacing[i] = - spacing[i]; - } - } - this->SetSpacing(spacing); + SpacingType s(spacing); + this->SetSignedSpacing(s); } template <class TPixel, unsigned int VImageDimension> diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h index dd4e7760c6..2fa39e599a 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.h +++ b/Modules/Core/ImageBase/include/otbVectorImage.h @@ -150,7 +150,6 @@ public: /** Set signed spacing */ virtual void SetSignedSpacing( SpacingType spacing ); virtual void SetSignedSpacing( double spacing[ VImageDimension ] ); - virtual void SetSignedSpacing( float spacing[ VImageDimension ] ); /** Get image corners. */ virtual VectorType GetUpperLeftCorner(void) const; diff --git a/Modules/Core/ImageBase/include/otbVectorImage.txx b/Modules/Core/ImageBase/include/otbVectorImage.txx index e69a9fd14d..f6123af584 100644 --- a/Modules/Core/ImageBase/include/otbVectorImage.txx +++ b/Modules/Core/ImageBase/include/otbVectorImage.txx @@ -183,48 +183,16 @@ void VectorImage<TPixel, VImageDimension> } } this->SetSpacing(spacing); + this->ComputeIndexToPhysicalPointMatrices(); + this->Modified(); } template <class TPixel, unsigned int VImageDimension> void VectorImage<TPixel, VImageDimension> ::SetSignedSpacing( double spacing[ VImageDimension ]) { - for ( unsigned int i = 0; i < VImageDimension; i++ ) - { - if ( spacing[i] < 0.0 ) - { - if ( this->m_Direction[i][i] > 0 ) - { - for ( unsigned j = 0; j < VImageDimension; ++j ) - { - this->m_Direction[j][i] = - this->m_Direction[j][i]; - } - } - spacing[i] = - spacing[i]; - } - } - this->SetSpacing(spacing); -} - -template <class TPixel, unsigned int VImageDimension> -void VectorImage<TPixel, VImageDimension> -::SetSignedSpacing( float spacing[ VImageDimension ]) -{ - for ( unsigned int i = 0; i < VImageDimension; i++ ) - { - if ( spacing[i] < 0.0 ) - { - if ( this->m_Direction[i][i] > 0 ) - { - for ( unsigned j = 0; j < VImageDimension; ++j ) - { - this->m_Direction[j][i] = - this->m_Direction[j][i]; - } - } - spacing[i] = - spacing[i]; - } - } - this->SetSpacing(spacing); + SpacingType s(spacing); + this->SetSignedSpacing(s); } template <class TPixel, unsigned int VImageDimension> -- GitLab