Commit aa422f8f authored by Cyrille Valladeau's avatar Cyrille Valladeau

BUG: fix pb with no consecutive multi baseline... again. #471

parent ad2dbef4
......@@ -26,6 +26,10 @@
#include <cctype>
#include <algorithm>
#include "itksys/SystemTools.hxx"
#include "itksys/Directory.hxx"
#include "itksys/RegularExpression.hxx"
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
......@@ -1010,29 +1014,32 @@ std::map<std::string, int> TestHelper::RegressionTestBaselines(char *baselineFil
std::map<std::string, int> baselines;
baselines[std::string(baselineFilename)] = 0;
std::string originalBaseline(baselineFilename);
std::string myPath = itksys::SystemTools::GetFilenamePath( baselineFilename );
itksys::Directory myDir;
myDir.Load( myPath.c_str() );
const unsigned int nbFiles = myDir.GetNumberOfFiles();
int x = 0;
std::string::size_type suffixPos = originalBaseline.find_last_of(".");
std::string::size_type maxPathPos = originalBaseline.find_last_of("/");
std::string suffix;
if ((suffixPos != std::string::npos) && ((suffixPos>maxPathPos) || (maxPathPos==std::string::npos)))
{
suffix = originalBaseline.substr(suffixPos, originalBaseline.length());
originalBaseline.erase(suffixPos, originalBaseline.length());
}
while (++x)
const std::string originalBaseline = itksys::SystemTools::GetFilenameWithoutLastExtension(baselineFilename);
const unsigned int sizeRef = originalBaseline.size();
myPath.append("/");
itksys::RegularExpression reg;
reg.compile( "^\\.[0-9]");
for(unsigned int i=0; i<nbFiles; i++)
{
std::ostringstream filename;
filename << originalBaseline << "." << x << suffix;
std::ifstream filestream(filename.str().c_str());
if (!filestream)
const std::string curFilename = itksys::SystemTools::GetFilenameWithoutLastExtension( myDir.GetFile( i ) );
if( curFilename.substr(0, sizeRef) == originalBaseline )
{
break;
if(reg.find( curFilename.substr(sizeRef, curFilename.size())))
{
std::string myFile = myPath;
baselines[myFile.append(myDir.GetFile( i ) )] = 0;
}
}
baselines[filename.str()] = 0;
filestream.close();
}
return baselines;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment