From ea27ec5b41b872690b6e9ec691d6ccaf41367b79 Mon Sep 17 00:00:00 2001
From: Antoine Regimbeau <antoine.regimbeau@c-s.fr>
Date: Tue, 19 Sep 2017 16:50:00 +0200
Subject: [PATCH] STYLE : changes thanks to luc review

---
 .../Filtering/Contrast/include/otbApplyGainFilter.h  |  4 ++--
 .../Contrast/include/otbApplyGainFilter.txx          | 12 +++++++-----
 Modules/Filtering/Contrast/include/otbBufferFilter.h |  4 ++--
 .../Contrast/include/otbComputeGainLutFilter.h       |  4 ++--
 .../Contrast/include/otbComputeGainLutFilter.txx     |  4 +---
 .../Contrast/include/otbComputeHistoFilter.h         |  4 ++--
 .../Contrast/include/otbComputeHistoFilter.txx       |  8 +++++---
 7 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/Modules/Filtering/Contrast/include/otbApplyGainFilter.h b/Modules/Filtering/Contrast/include/otbApplyGainFilter.h
index db1ad57bb5..ffe6f4deb2 100644
--- a/Modules/Filtering/Contrast/include/otbApplyGainFilter.h
+++ b/Modules/Filtering/Contrast/include/otbApplyGainFilter.h
@@ -110,8 +110,8 @@ protected :
                        typename InputImageType::IndexType index);
 
 private :
-  ApplyGainFilter(const Self &); //purposely not implemented
-  void operator =(const Self&); //purposely not implemented
+  ApplyGainFilter(const Self &) = delete ;
+  void operator =(const Self&) = delete ; 
 
   InputPixelType m_NoData;
   InputPixelType m_Min;
diff --git a/Modules/Filtering/Contrast/include/otbApplyGainFilter.txx b/Modules/Filtering/Contrast/include/otbApplyGainFilter.txx
index 9633c250b4..139a444a1d 100644
--- a/Modules/Filtering/Contrast/include/otbApplyGainFilter.txx
+++ b/Modules/Filtering/Contrast/include/otbApplyGainFilter.txx
@@ -131,20 +131,22 @@ void ApplyGainFilter < TInputImage , TLut , TOutputImage >
 
   unsigned int pixelLutValue(0);
   float gain(0.0);
+  InputPixelType currentPixel(0);
   while ( !oit.IsAtEnd() )
     {
-    if( ( it.Get() == m_NoData && m_NoDataFlag ) ||
-          it.Get() > m_Max || it.Get() < m_Min )
+    currentPixel = it.Get();
+    if( !(( currentPixel == m_NoData && m_NoDataFlag ) ||
+              currentPixel > m_Max || currentPixel < m_Min ))
       {
-      oit.Set( static_cast<OutputPixelType>( it.Get() ) );
+      oit.Set( static_cast<OutputPixelType>( currentPixel ) );
       ++it;
       ++oit;
       continue;
       }
     pixelLutValue =  static_cast< unsigned int > (
-                    std::round( ( it.Get() - m_Min ) / m_Step ) );
+                    std::round( ( currentPixel - m_Min ) / m_Step ) );
     gain = InterpolateGain( lut , pixelLutValue , it.GetIndex() );
-    oit.Set( static_cast<OutputPixelType>( gain * it.Get() ) );
+    oit.Set( static_cast<OutputPixelType>( gain * currentPixel ) );
     ++it;
     ++oit;
     }
diff --git a/Modules/Filtering/Contrast/include/otbBufferFilter.h b/Modules/Filtering/Contrast/include/otbBufferFilter.h
index f7196a81a3..48add3f73f 100644
--- a/Modules/Filtering/Contrast/include/otbBufferFilter.h
+++ b/Modules/Filtering/Contrast/include/otbBufferFilter.h
@@ -69,8 +69,8 @@ protected:
       itk::ThreadIdType itkNotUsed(threadId) ) override{}
 
 private:
-  BufferFilter(const Self &); //purposely not implemented
-  void operator =(const Self&); //purposely not implemented
+  BufferFilter(const Self &) = delete ;
+  void operator =(const Self&) = delete ;
 
 };
 
diff --git a/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.h b/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.h
index 6cc9fc8285..7a28050b84 100644
--- a/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.h
+++ b/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.h
@@ -107,8 +107,8 @@ protected:
   bool IsValid(const HistoType & inputHisto ) ;
 
 private:
-  ComputeGainLutFilter(const Self &) ; //purposely not implemented
-  void operator =(const Self&) ; //purposely not implemented
+  ComputeGainLutFilter(const Self &) = delete ;
+  void operator =(const Self&) = delete ;
 
   double m_Min;
   double m_Max;
diff --git a/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.txx b/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.txx
index bd2d10dc4e..0d77a93474 100644
--- a/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.txx
+++ b/Modules/Filtering/Contrast/include/otbComputeGainLutFilter.txx
@@ -173,9 +173,7 @@ bool ComputeGainLutFilter < TInputImage , TOutputImage >
   {
     acc+= inputHisto[i] ;
   }
-  if ( acc < 0.5 * m_NbPixel )
-    return false;
-  return true;
+  return acc >= (0.5 * m_NbPixel);
 }
 
 /**
diff --git a/Modules/Filtering/Contrast/include/otbComputeHistoFilter.h b/Modules/Filtering/Contrast/include/otbComputeHistoFilter.h
index 1eb8294447..bc278dcc81 100644
--- a/Modules/Filtering/Contrast/include/otbComputeHistoFilter.h
+++ b/Modules/Filtering/Contrast/include/otbComputeHistoFilter.h
@@ -133,8 +133,8 @@ protected:
        unsigned int total );
 
 private:
-  ComputeHistoFilter(const Self &); //purposely not implemented
-  void operator =(const Self&); //purposely not implemented
+  ComputeHistoFilter(const Self &) = delete ;
+  void operator =(const Self&) = delete ;
 
   std::vector< typename OutputImageType::PixelType > m_HistoThread;
   InputPixelType m_Min;
diff --git a/Modules/Filtering/Contrast/include/otbComputeHistoFilter.txx b/Modules/Filtering/Contrast/include/otbComputeHistoFilter.txx
index 76933bd8a3..91aa53b0ac 100644
--- a/Modules/Filtering/Contrast/include/otbComputeHistoFilter.txx
+++ b/Modules/Filtering/Contrast/include/otbComputeHistoFilter.txx
@@ -268,17 +268,19 @@ void ComputeHistoFilter < TInputImage , TOutputImage >
     typename itk::ImageRegionConstIterator < InputImageType > 
       it( input ,region );
     it.GoToBegin();
+    InputPixelType currentPixel(0);
 
     while ( !it.IsAtEnd() )
       {
-      if( ( it.Get() == m_NoData && m_NoDataFlag ) || 
-            it.Get() > m_Max || it.Get() < m_Min )
+      currentPixel = it.Get();
+      if( ( currentPixel == m_NoData && m_NoDataFlag ) || 
+            currentPixel > m_Max || currentPixel < m_Min )
         {
         ++it;
         continue;
         }
       pixel = static_cast< unsigned int >( 
-        std::round( ( it.Get() - m_Min ) / m_Step ) );
+        std::round( ( currentPixel - m_Min ) / m_Step ) );
       ++m_HistoThread[threadIndex + nthHisto][pixel];
       ++it;
       }
-- 
GitLab