From c1bce4be830f8ac990bcc9b71046431bf73e0ccb Mon Sep 17 00:00:00 2001
From: Thomas Feuvrier <thomas.feuvrier@c-s.fr>
Date: Fri, 23 Feb 2007 07:54:53 +0000
Subject: [PATCH] =?UTF-8?q?Correction=20:=20si=20le=20canal=20sp=C3=A9cifi?=
 =?UTF-8?q?=C3=A9=20n'est=20pas=20une=20valeur=20autoris=C3=A9e=20(canaux?=
 =?UTF-8?q?=20non=20pr=C3=A9sents=20dans=20l'image=20d'entr=C3=A9e)=20alor?=
 =?UTF-8?q?s=20on=20sort=20en=20erreur.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Code/Common/otbMultiChannelExtractROI.txx | 36 +++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/Code/Common/otbMultiChannelExtractROI.txx b/Code/Common/otbMultiChannelExtractROI.txx
index b17531b43c..9885c5af53 100755
--- a/Code/Common/otbMultiChannelExtractROI.txx
+++ b/Code/Common/otbMultiChannelExtractROI.txx
@@ -138,7 +138,7 @@ MultiChannelExtractROI<TInputPixelType,TOutputPixelType>
         typename Superclass::InputImageConstPointer  inputPtr = this->GetInput();
         typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
 
-        // initialise le nombre de canaux de l'image output (lié aux "channel" sélectionnés)
+        // initialise le nombre de canaux de l'image output (li� aux "channel" s�lectionn�s)
         if( m_ChannelsWorksBool == false )
         {
                 outputPtr->SetVectorLength(inputPtr->GetVectorLength() );
@@ -146,10 +146,42 @@ MultiChannelExtractROI<TInputPixelType,TOutputPixelType>
         else
         {
                 outputPtr->SetVectorLength( m_ChannelsWorks.size() );
+        		//Control validity channel value
+        		ChannelsType  m_BadChannels;
+        		m_BadChannels.clear();
+        		for(unsigned int i=0 ; i < m_ChannelsWorks.size() ; i++)
+        		{
+        			if( ( m_ChannelsWorks[i] < 1 )||(m_ChannelsWorks[i] > inputPtr->GetVectorLength()) )
+        			{
+        				m_BadChannels.push_back(m_ChannelsWorks[i]);
+        			}
+        		}
+        		if( m_BadChannels.empty() == false )
+        		{
+        			itk::OStringStream oss;
+        			oss << "otb::ExtractImageFilter::GenerateOutputInformation : ";
+        			if( m_BadChannels.size() == 1 )
+        			{
+        				oss << m_BadChannels[0];
+        				oss << "The channel " << m_BadChannels[0] << " is not authorized.";
+        			}
+        			else
+        			{
+        				oss <<  "The channels [ ";
+        				for(unsigned int i=0 ; i < m_BadChannels.size() ; i++)
+        				{
+        					oss << m_BadChannels[i] << " ";
+        				}
+        				oss << "] are not authorized.";
+        			}
+        			oss << " Values must be in [1," << inputPtr->GetVectorLength() << "].";
+ 			     	itkExceptionMacro(<< oss.str().c_str());
+ 			     }
         }
+        
 	outputPtr->SetNumberOfComponentsPerPixel( outputPtr->GetVectorLength() );
 
-        // Appel à la methode de la classe de base
+        // Appel � la methode de la classe de base
         Superclass::GenerateOutputInformation();
 
 }
-- 
GitLab