1.1 --- a/Code/IO/otbImageSeriesFileReader.txx Thu Jul 02 15:07:20 2009 +0200
1.2 +++ b/Code/IO/otbImageSeriesFileReader.txx Fri Jul 03 18:17:40 2009 +0200
1.3 @@ -20,7 +20,6 @@
1.4
1.5 #ifndef __otbImageSeriesFileReader__txx
1.6 #define __otbImageSeriesFileReader__txx
1.7 -
1.8 #include "otbImageSeriesFileReader.h"
1.9
1.10 namespace otb {
1.11 @@ -50,11 +49,11 @@
1.12 ImageSeriesFileReader< TImage, TInternalImage >
1.13 ::GenerateData( unsigned int idx )
1.14 {
1.15 - itk::OStringStream msg;
1.16 - msg << "Something wrong... Check the template definition of this class in the program...\n";
1.17 - msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n";
1.18 - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
1.19 - throw e;
1.20 + itk::OStringStream msg;
1.21 + msg << "Something wrong... Check the template definition of this class in the program...\n";
1.22 + msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n";
1.23 + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
1.24 + throw e;
1.25 }
1.26
1.27 /* **********************************************************
1.28 @@ -122,8 +121,6 @@
1.29 ImageSeriesFileReader< Image< TPixel, 2 >, Image< TInternalPixel, 2 > >
1.30 ::GenerateData( unsigned int idx )
1.31 {
1.32 - std::cerr << "Reading " << idx << "th image: " << this->m_ListOfFileNames[ idx ] << "\n";
1.33 -
1.34 otbMsgDebugMacro( << "Reading " << idx << "th image: " << this->m_ListOfFileNames[ idx ] );
1.35
1.36 ReaderType * reader
1.37 @@ -186,15 +183,15 @@
1.38 ImageSeriesFileReader< Image< TPixel, 2 >, VectorImage< TInternalPixel, 2 > >
1.39 ::TestBandSelection ( std::vector<unsigned int> & bands )
1.40 {
1.41 - if ( bands.size() != 1 )
1.42 - {
1.43 - itk::OStringStream msg;
1.44 - msg << "Unable to handle multicomponent file from Image<> class as output\n";
1.45 - msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n";
1.46 - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
1.47 - throw e;
1.48 - }
1.49 - return;
1.50 + if ( bands.size() != 1 )
1.51 + {
1.52 + itk::OStringStream msg;
1.53 + msg << "Unable to handle multicomponent file from Image<> class as output\n";
1.54 + msg << "\"ENVI META FILE\" FileName: " << this->m_FileName << "\n";
1.55 + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
1.56 + throw e;
1.57 + }
1.58 + return;
1.59 }
1.60
1.61 /**
1.62 @@ -276,14 +273,14 @@
1.63 ExtractSelectionType * selection
1.64 = static_cast<ExtractSelectionType*>( this->m_ExtractorList->GetNthElement( idx ) );
1.65
1.66 - selection->SetExtractionRegion( this->m_ListOfRegionSelection[ idx ] );
1.67 + selection->SetExtractionRegion( this->m_ListOfRegionSelection[ idx ] );
1.68
1.69 - for ( std::vector<unsigned int>::iterator band = this->m_ListOfBandSelection[ idx ].begin();
1.70 - band != this->m_ListOfBandSelection[ idx ].end();
1.71 - ++band )
1.72 - {
1.73 - selection->SetChannel( *band );
1.74 - }
1.75 + for ( std::vector<unsigned int>::iterator band = this->m_ListOfBandSelection[ idx ].begin();
1.76 + band != this->m_ListOfBandSelection[ idx ].end();
1.77 + ++band )
1.78 + {
1.79 + selection->SetChannel( *band );
1.80 + }
1.81
1.82 selection->SetInput( reader->GetOutput() );
1.83 selection->GraftOutput( this->m_OutputList->GetNthElement( idx ) );
2.1 --- a/Code/IO/otbImageSeriesFileReaderBase.txx Thu Jul 02 15:07:20 2009 +0200
2.2 +++ b/Code/IO/otbImageSeriesFileReaderBase.txx Fri Jul 03 18:17:40 2009 +0200
2.3 @@ -20,7 +20,6 @@
2.4
2.5 #ifndef __otbImageSeriesFileReaderBase__txx
2.6 #define __otbImageSeriesFileReaderBase__txx
2.7 -
2.8 #include "otbImageSeriesFileReaderBase.h"
2.9
2.10 namespace otb {
2.11 @@ -71,7 +70,7 @@
2.12 ::GetOutput ()
2.13 {
2.14 if ( this->GetNumberOfOutputs() < 1 )
2.15 - return 0;
2.16 + throw ImageSeriesFileReaderException (__FILE__, __LINE__,"No data to output",ITK_LOCATION);
2.17
2.18 return static_cast<OutputImageListType*>( this->m_OutputList );
2.19 }
2.20 @@ -82,10 +81,10 @@
2.21 ::GetOutput ( unsigned int idx )
2.22 {
2.23 if ( this->GetNumberOfOutputs() < 1 )
2.24 - return 0;
2.25 + throw ImageSeriesFileReaderException (__FILE__, __LINE__,"No data to output",ITK_LOCATION);
2.26
2.27 if ( idx >= m_OutputList->Size() )
2.28 - return 0;
2.29 + throw ImageSeriesFileReaderException (__FILE__, __LINE__,"Index out of bounds",ITK_LOCATION);
2.30
2.31 return static_cast<OutputImageType*>( this->m_OutputList->GetNthElement( idx ) );
2.32 }
2.33 @@ -104,9 +103,9 @@
2.34 std::string aLine;
2.35 std::ifstream inputFile ( m_FileName.c_str(), std::ios_base::in );
2.36
2.37 - inputFile >> aLine;
2.38 - if ( aLine != "ENVI" )
2.39 - {
2.40 + inputFile >> aLine;
2.41 + if ( aLine != "ENVI" )
2.42 + {
2.43 inputFile.close();
2.44 itk::OStringStream msg;
2.45 msg << "The file " << m_FileName << " is not a \"ENVI META FILE\" format\n";
2.46 @@ -116,8 +115,8 @@
2.47 }
2.48
2.49 inputFile >> aLine;
2.50 - if ( aLine != "META" )
2.51 - {
2.52 + if ( aLine != "META" )
2.53 + {
2.54 inputFile.close();
2.55 itk::OStringStream msg;
2.56 msg << "The file " << m_FileName << " is not a \"ENVI META FILE\" format\n";
2.57 @@ -138,16 +137,16 @@
2.58 }
2.59
2.60 while ( 1 )
2.61 - {
2.62 + {
2.63 /*
2.64 * Reading the filenames
2.65 */
2.66 do {
2.67 - inputFile >> aLine;
2.68 - //std::cerr << "-> '" << aLine << "'\n";
2.69 - } while ( aLine != "File" && inputFile.good() );
2.70 + inputFile >> aLine;
2.71 + //std::cerr << "-> '" << aLine << "'\n";
2.72 + } while ( aLine != "File" && inputFile.good() );
2.73
2.74 - if ( inputFile.good() )
2.75 + if ( inputFile.good() )
2.76 {
2.77 do {
2.78 inputFile >> aLine;
2.79 @@ -183,9 +182,9 @@
2.80 * Reading the Band number
2.81 */
2.82 do {
2.83 - inputFile >> aLine;
2.84 - //std::cerr << "-> '" << aLine << "'\n";
2.85 - } while ( aLine != "Bands:" && inputFile.good() );
2.86 + inputFile >> aLine;
2.87 + //std::cerr << "-> '" << aLine << "'\n";
2.88 + } while ( aLine != "Bands:" && inputFile.good() );
2.89
2.90 if ( !inputFile.good() )
2.91 {
2.92 @@ -227,28 +226,28 @@
2.93 }
2.94
2.95 // Storing band selection
2.96 - try {
2.97 - TestBandSelection( bands );
2.98 - }
2.99 - catch ( ImageSeriesFileReaderException & e )
2.100 - {
2.101 - itk::OStringStream msg;
2.102 - msg << e.GetDescription();
2.103 - msg << "Image FileName : " << imageFileName << "\n";
2.104 - e.SetDescription( msg.str().c_str() );
2.105 - throw e;
2.106 - }
2.107 - m_ListOfBandSelection.push_back( bands );
2.108 + try {
2.109 + TestBandSelection( bands );
2.110 + }
2.111 + catch ( ImageSeriesFileReaderException & e )
2.112 + {
2.113 + itk::OStringStream msg;
2.114 + msg << e.GetDescription();
2.115 + msg << "Image FileName : " << imageFileName << "\n";
2.116 + e.SetDescription( msg.str().c_str() );
2.117 + throw e;
2.118 + }
2.119 + m_ListOfBandSelection.push_back( bands );
2.120
2.121 /*
2.122 * Reading the Region selection
2.123 */
2.124 do {
2.125 - inputFile >> aLine;
2.126 - //std::cerr << "-> '" << aLine << "'\n";
2.127 - } while ( aLine != "Dims" && inputFile.good() );
2.128 + inputFile >> aLine;
2.129 + //std::cerr << "-> '" << aLine << "'\n";
2.130 + } while ( aLine != "Dims" && inputFile.good() );
2.131
2.132 - if ( inputFile.good() )
2.133 + if ( inputFile.good() )
2.134 {
2.135 do {
2.136 inputFile >> aLine;
2.137 @@ -320,11 +319,11 @@
2.138 ImageSeriesFileReaderBase< TImage, TInternalImage >
2.139 ::GenerateData( unsigned int idx )
2.140 {
2.141 - itk::OStringStream msg;
2.142 - msg << "Something wrong... Check the template definition of this class in the program...\n";
2.143 - msg << "\"ENVI META FILE\" FileName: " << m_FileName << "\n";
2.144 - ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
2.145 - throw e;
2.146 + itk::OStringStream msg;
2.147 + msg << "Something wrong... Check the template definition of this class in the program...\n";
2.148 + msg << "\"ENVI META FILE\" FileName: " << m_FileName << "\n";
2.149 + ImageSeriesFileReaderException e(__FILE__, __LINE__,msg.str().c_str(),ITK_LOCATION);
2.150 + throw e;
2.151 }
2.152
2.153 template < class TImage, class TInternalImage >
2.154 @@ -344,8 +343,8 @@
2.155 ImageSeriesFileReaderBase< TImage, TInternalImage >
2.156 ::GenerateOutput()
2.157 {
2.158 - this->Update();
2.159 - return this->GetOutput();
2.160 + this->Update();
2.161 + return this->GetOutput();
2.162 }
2.163
2.164 template < class TImage, class TInternalImage >
2.165 @@ -353,8 +352,8 @@
2.166 ImageSeriesFileReaderBase< TImage, TInternalImage >
2.167 ::GenerateOutput( unsigned int idx )
2.168 {
2.169 - this->GenerateData( idx );
2.170 - return this->GetOutput( idx );
2.171 + this->GenerateData( idx );
2.172 + return this->GetOutput( idx );
2.173 }
2.174
2.175
2.176 @@ -368,7 +367,7 @@
2.177
2.178 if ( m_ListOfFileNames.size() > 0 )
2.179 {
2.180 - std::vector< std::vector< unsigned int > >::const_iterator bandSelection = m_ListOfBandSelection.begin();
2.181 + std::vector< std::vector< unsigned int > >::const_iterator bandSelection = m_ListOfBandSelection.begin();
2.182 os << indent << "Image File(s) to be read\n";
2.183 for ( unsigned int i = 0; i < GetNumberOfOutputs(); ++i )
2.184 {
2.185 @@ -388,7 +387,7 @@
2.186 }
2.187 os << "\n";
2.188
2.189 - ++bandSelection;
2.190 + ++bandSelection;
2.191 }
2.192 }
2.193 }
2.194 @@ -416,13 +415,13 @@
2.195 }
2.196 else
2.197 {
2.198 - std::vector< std::string > fullPath;
2.199 + std::vector< std::string > fullPath;
2.200 fullPath.push_back( itksys::SystemTools::GetFilenamePath( m_FileName ) );
2.201 fullPath.push_back( "/" );
2.202 fullPath.push_back( file );
2.203
2.204 - std::string fullFileName = itksys::SystemTools::JoinPath( fullPath );
2.205 -
2.206 + std::string fullFileName = itksys::SystemTools::JoinPath( fullPath );
2.207 +
2.208 if ( !itksys::SystemTools::FileExists( fullFileName.c_str() ) )
2.209 {
2.210 ImageSeriesFileReaderException e(__FILE__, __LINE__);
2.211 @@ -438,7 +437,7 @@
2.212 else
2.213 {
2.214 // At this step, image file name is modified to add its path
2.215 - file = fullFileName;
2.216 + file = fullFileName;
2.217 }
2.218 }
2.219 }