Commit af9c573b authored by Cyrille Valladeau's avatar Cyrille Valladeau

BUG: fix bug for no cosecutif multi baseline id. #471

parent a014ddc6
......@@ -26,6 +26,9 @@
#include <cctype>
#include <algorithm>
#include "itksys/SystemTools.hxx"
#include "itksys/Directory.hxx"
#include "otbImage.h"
#include "otbVectorImage.h"
#include "otbImageFileReader.h"
......@@ -1010,29 +1013,26 @@ 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("/");
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;
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