Commit f70f0777 authored by Victor Poughon's avatar Victor Poughon

REFAC: auto replace SetFileName calls to std::string overload

Here's what I did:

    find Modules/ Examples/ -type f -print0 | xargs -0 sed -i -E "s/SetFileName\((.*)\.c_str\(\)/SetFileName\(\1/"
parent df787dfd
......@@ -122,7 +122,7 @@ int main(int argc, char * argv[])
writer->SetInput(Izz);
outputFileName = outputPrefix + "-Izz.hdr";
writer->SetFileName(outputFileName.c_str());
writer->SetFileName(outputFileName);
writer->Update();
gc->SetDirection(1); // gc now works along Y
......@@ -135,7 +135,7 @@ int main(int argc, char * argv[])
writer->SetInput(Iyy);
outputFileName = outputPrefix + "-Iyy.hdr";
writer->SetFileName(outputFileName.c_str());
writer->SetFileName(outputFileName);
writer->Update();
gc->SetDirection(0); // gc now works along X
......@@ -148,7 +148,7 @@ int main(int argc, char * argv[])
writer->SetInput(Ixx);
outputFileName = outputPrefix + "-Ixx.hdr";
writer->SetFileName(outputFileName.c_str());
writer->SetFileName(outputFileName);
writer->Update();
ga->SetDirection(0);
......@@ -166,7 +166,7 @@ int main(int argc, char * argv[])
writer->SetInput(Iyz);
outputFileName = outputPrefix + "-Iyz.hdr";
writer->SetFileName(outputFileName.c_str());
writer->SetFileName(outputFileName);
writer->Update();
ga->SetDirection(1);
......@@ -184,7 +184,7 @@ int main(int argc, char * argv[])
writer->SetInput(Ixz);
outputFileName = outputPrefix + "-Ixz.hdr";
writer->SetFileName(outputFileName.c_str());
writer->SetFileName(outputFileName);
writer->Update();
ga->SetDirection(2);
......@@ -202,7 +202,7 @@ int main(int argc, char * argv[])
writer->SetInput(Ixy);
outputFileName = outputPrefix + "-Ixy.hdr";
writer->SetFileName(outputFileName.c_str());
writer->SetFileName(outputFileName);
writer->Update();
// Software Guide : EndCodeSnippet
......
......@@ -101,7 +101,7 @@ int main(int itkNotUsed(argc), char * argv[])
// Software Guide : BeginCodeSnippet
otb::GDALImageIO::Pointer readerGDAL = otb::GDALImageIO::New();
readerGDAL->SetFileName(inputFilename.c_str());
readerGDAL->SetFileName(inputFilename);
std::vector<std::string> vectSubdatasetNames;
std::vector<std::string> vectorSubdatasetDescriptions;
......@@ -146,7 +146,7 @@ int main(int itkNotUsed(argc), char * argv[])
// Software Guide : EndLatex
// Software Guide : BeginCodeSnippet
writer->SetFileName(outputFilename.c_str());
writer->SetFileName(outputFilename);
writer->SetInput(reader->GetOutput());
writer->Update();
......
......@@ -209,7 +209,7 @@ int main(int itkNotUsed(argc), char * argv[])
oss << outputFilenamePrefix << index << "." << outputFilenameSuffix;
writer = WriterType::New();
writer->SetInput(it.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
std::cout << oss.str() << " file written." << std::endl;
oss.str("");
......
......@@ -215,8 +215,8 @@ int main(int argc, char * argv[])
// Software Guide : BeginLatex
// Software Guide : BeginCodeSnippet
reader->SetFileName(parseResult->GetInputImage().c_str());
writer->SetFileName(parseResult->GetOutputImage().c_str());
reader->SetFileName(parseResult->GetInputImage());
writer->SetFileName(parseResult->GetOutputImage());
// Software Guide : EndCodeSnippet
// Software Guide : BeginLatex
......
......@@ -215,7 +215,7 @@ TrainVectorBase::GetStatistics(unsigned int nbFeatures)
{
StatisticsReader::Pointer statisticsReader = StatisticsReader::New();
std::string XMLfile = GetParameterString( "io.stats" );
statisticsReader->SetFileName( XMLfile.c_str() );
statisticsReader->SetFileName( XMLfile );
measurement.meanMeasurementVector = statisticsReader->GetStatisticVectorByName( "mean" );
measurement.stddevMeasurementVector = statisticsReader->GetStatisticVectorByName( "stddev" );
}
......
......@@ -117,7 +117,7 @@ int otbVectorImageToImageListFilterIterator(int itkNotUsed(argc), char * argv[])
writer->SetInput(itOutput.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->SetNumberOfDivisionsTiledStreaming(8);
writer->Update();
......@@ -135,7 +135,7 @@ int otbVectorImageToImageListFilterIterator(int itkNotUsed(argc), char * argv[])
writer->SetInput(itOutput.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
......
......@@ -110,7 +110,7 @@ int main(int argc, char * argv[])
//-----------------------------------------------------------------
//read image
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(parseResult->GetInputImage().c_str());
reader->SetFileName(parseResult->GetInputImage());
reader->UpdateOutputInformation();
///////////////////////////////////////////////////////////////////
......@@ -258,7 +258,7 @@ int main(int argc, char * argv[])
//-----------------------------------------------------------------
//write image
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(parseResult->GetOutputImage().c_str());
writer->SetFileName(parseResult->GetOutputImage());
writer->SetInput(rescaler->GetOutput());
try
......
......@@ -116,7 +116,7 @@ int otbAngularProjectionBinaryImageFilterTest ( int argc, char * argv[] )
title << outputImageName << "_" << i << ".hdr";
writers[i] = WriterType::New();
writers[i]->SetFileName( title.str().c_str() );
writers[i]->SetFileName( title.str() );
writers[i]->SetInput( filter->GetOutput(i) );
writers[i]->Update();
}
......
......@@ -81,7 +81,7 @@ int otbAngularProjectionSetImageFilterTest ( int argc, char * argv[] )
for ( unsigned int i = 0; i < nbInputImages; i++ )
{
reader->SetNthElement(i, ReaderType::New());
reader->GetNthElement(i)->SetFileName( inputImageName[i].c_str() );
reader->GetNthElement(i)->SetFileName( inputImageName[i] );
reader->GetNthElement(i)->Update();
}
......@@ -118,7 +118,7 @@ int otbAngularProjectionSetImageFilterTest ( int argc, char * argv[] )
writers->SetNthElement(i, WriterType::New());
WriterType::Pointer writer = writers->GetNthElement(i);
writer->SetFileName( title.str().c_str() );
writer->SetFileName( title.str() );
writer->SetInput( filter->GetOutput()->GetNthElement(i) );
writer->Update();
}
......
......@@ -95,7 +95,7 @@ int otbSparseWvltToAngleMapperListFilterNewTest ( int argc, char * argv[] )
for ( unsigned int i = 0; i < nbInputImages; i++ )
{
reader->SetNthElement(i, ReaderType::New());
reader->GetNthElement(i)->SetFileName( inputImageName[i].c_str() );
reader->GetNthElement(i)->SetFileName( inputImageName[i] );
reader->GetNthElement(i)->Update();
// Here, we will have 'nbInputImages' image lists of one image each only
......
......@@ -85,28 +85,28 @@ int otbMorphologicalPyramidAnalysisFilter(int itkNotUsed(argc), char * argv[])
{
oss << outputFilenamePrefix << "_an_" << i << "." << outputFilenameSuffix;
writer->SetInput(itAnalyse.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
oss << outputFilenamePrefix << "_sf_" << i << "." << outputFilenameSuffix;
writer->SetInput(itSupFilter.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
oss << outputFilenamePrefix << "_if_" << i << "." << outputFilenameSuffix;
writer->SetInput(itInfFilter.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
oss << outputFilenamePrefix << "_id_" << i << "." << outputFilenameSuffix;
writer->SetInput(itInfDeci.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
std::cout << "File " << oss.str() << " written" << std::endl;
oss.str("");
oss << outputFilenamePrefix << "_sd_" << i << "." << outputFilenameSuffix;
writer->SetInput(itSupDeci.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
++itAnalyse;
......
......@@ -87,7 +87,7 @@ int otbMorphologicalPyramidSegmentationFilter(int itkNotUsed(argc), char * argv[
oss << outputFilenamePrefix << index << "." << outputFilenameSuffix;
writer = WriterType::New();
writer->SetInput(it.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
std::cout << oss.str() << " file written." << std::endl;
oss.str("");
......
......@@ -132,7 +132,7 @@ int otbRationalTransformToDisplacementFieldSourceTest(int argc, char* argv[])
/** Write deformation field to disk. */
WriterType::Pointer writer = WriterType::New();
writer->SetInput( defGenerator->GetOutput() );
writer->SetFileName( fileName.c_str() );
writer->SetFileName( fileName );
try
{
......
......@@ -79,7 +79,7 @@ int otbSparseUnmixingImageFilterTest ( int argc, char * argv[] )
for ( unsigned int i = 0; i < nbInputImages; i++ )
{
reader->SetNthElement(i, ReaderType::New());
reader->GetNthElement(i)->SetFileName( inputImageName[i].c_str() );
reader->GetNthElement(i)->SetFileName( inputImageName[i] );
reader->GetNthElement(i)->Update();
}
......@@ -110,7 +110,7 @@ int otbSparseUnmixingImageFilterTest ( int argc, char * argv[] )
WriterType::Pointer writer = writers->GetNthElement(i);
std::string stitle = title.str();
writer->SetFileName( stitle.c_str() );
writer->SetFileName( stitle );
writer->SetInput( filter->GetOutput()->GetNthElement(i) );
writer->Update();
}
......
......@@ -354,7 +354,7 @@ MapFileProductWriter<TInputImage>
// Configure writer
m_VectorWriter = VectorWriterType::New();
m_VectorWriter->SetFileName(ossFileName.str().c_str());
m_VectorWriter->SetFileName(ossFileName.str());
m_VectorWriter->SetInput(m_VectorImageExtractROIFilter->GetOutput());
m_VectorWriter->Update();
......
......@@ -364,7 +364,7 @@ void TileMapImageIO::ReadTile(const std::string& filename, void * buffer)
if (lCanRead == true)
{
imageIO->SetFileName(filename.c_str());
imageIO->SetFileName(filename);
imageIO->ReadImageInformation();
itk::ImageIORegion ioRegion(2);
ioRegion.SetIndex(0, 0);
......@@ -695,7 +695,7 @@ void TileMapImageIO::InternalWrite(double x, double y, const void* buffer)
imageIO->SetUseCompression(1);
imageIO->SetFileName(filename.str().c_str());
imageIO->SetFileName(filename.str());
imageIO->WriteImageInformation();
itk::ImageIORegion ioRegion(2);
......
......@@ -134,7 +134,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
// Tell the ImageIO to read the file
OutputImagePixelType *buffer =
output->GetPixelContainer()->GetBufferPointer();
this->m_ImageIO->SetFileName(this->m_FileName.c_str());
this->m_ImageIO->SetFileName(this->m_FileName);
itk::ImageIORegion ioRegion(TOutputImage::ImageDimension);
......@@ -305,7 +305,7 @@ ImageFileReader<TOutputImage, ConvertPixelTraits>
// Got to allocate space for the image. Determine the characteristics of
// the image.
//
this->m_ImageIO->SetFileName(this->m_FileName.c_str());
this->m_ImageIO->SetFileName(this->m_FileName);
this->m_ImageIO->ReadImageInformation();
// Initialize the number of component per pixel
// THOMAS: This is not in ITK!
......
......@@ -571,7 +571,7 @@ ImageFileWriter<TInputImage>
/** Create Image file */
// Setup the image IO for writing.
//
m_ImageIO->SetFileName(m_FileName.c_str());
m_ImageIO->SetFileName(m_FileName);
m_ImageIO->WriteImageInformation();
}
......
......@@ -43,7 +43,7 @@ void
ImageSeriesFileReaderBase<TImage, TInternalImage>
::SetFileName(const std::string& file)
{
return SetFileName(file.c_str());
return SetFileName(file);
}
template <class TImage, class TInternalImage>
......
......@@ -235,7 +235,7 @@ KmzProductWriter<TInputImage>
castFiler->SetInput(legend);
m_VectorWriter = VectorWriterType::New();
m_VectorWriter->SetFileName(legendName.str().c_str());
m_VectorWriter->SetFileName(legendName.str());
m_VectorWriter->SetInput(castFiler->GetOutput());
m_VectorWriter->Update();
......@@ -439,7 +439,7 @@ KmzProductWriter<TInputImage>
// Configure writer
m_VectorWriter = VectorWriterType::New();
m_VectorWriter->SetFileName(ossFileName.str().c_str());
m_VectorWriter->SetFileName(ossFileName.str());
m_VectorWriter->SetInput(m_VectorImageExtractROIFilter->GetOutput());
m_VectorWriter->Update();
......
......@@ -1365,7 +1365,7 @@ int TestHelper::RegressionTestImage(int cpt, const char *testImageFilename, cons
{
itkGenericExceptionMacro(<< "Error during rescale of " << diffName.str());
}
writer->SetFileName(diffName.str().c_str());
writer->SetFileName(diffName.str());
try
{
writer->Update();
......@@ -1406,7 +1406,7 @@ int TestHelper::RegressionTestImage(int cpt, const char *testImageFilename, cons
}
try
{
writer->SetFileName(baseName.str().c_str());
writer->SetFileName(baseName.str());
writer->Update();
}
catch (...)
......@@ -1445,7 +1445,7 @@ int TestHelper::RegressionTestImage(int cpt, const char *testImageFilename, cons
}
try
{
writer->SetFileName(testName.str().c_str());
writer->SetFileName(testName.str());
writer->Update();
}
catch (...)
......
......@@ -179,7 +179,7 @@ VectorDataFileReader<TOutputVectorData>
return;
}
m_VectorDataIO->SetFileName(m_FileName.c_str());
m_VectorDataIO->SetFileName(m_FileName);
//Copy MetaDataDictionary from instantiated reader to output VectorData.
output->SetMetaDataDictionary(m_VectorDataIO->GetMetaDataDictionary());
......@@ -208,7 +208,7 @@ VectorDataFileReader<TOutputVectorData>
m_ExceptionMessage = err.GetDescription();
}
m_VectorDataIO->SetFileName(m_FileName.c_str());
m_VectorDataIO->SetFileName(m_FileName);
// Tell the VectorDataIO to read the file
//
......
......@@ -194,7 +194,7 @@ VectorDataFileWriter<TInputVectorData>
// Setup the vector data IO for writing.
//
m_VectorDataIO->SetFileName(m_FileName.c_str());
m_VectorDataIO->SetFileName(m_FileName);
typedef VectorDataAdapter<TInputVectorData, VectorData<double, 2> > AdapterType;
typename AdapterType::Pointer adapter = AdapterType::New();
......
......@@ -78,19 +78,19 @@ int otbGeodesicMorphologyIterativeDecompositionImageFilter(int itkNotUsed(argc),
oss << outputFilenamePrefix << "_leveling_" << i << "." << outputFilenameSuffix;
writer = WriterType::New();
writer->SetInput(itAnalyse.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
oss << outputFilenamePrefix << "_convMap_" << i << "." << outputFilenameSuffix;
writer = WriterType::New();
writer->SetInput(itConvexMap.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
oss << outputFilenamePrefix << "_concMap_" << i << "." << outputFilenameSuffix;
writer = WriterType::New();
writer->SetInput(itConcaveMap.Get());
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
++itAnalyse;
......
......@@ -71,7 +71,7 @@ int otbMorphologicalClosingProfileFilter(int itkNotUsed(argc), char * argv[])
writer = WriterType::New();
oss << outputFilenamePrefix << i << "." << outputFilenameSuffix;
writer->SetInput(profileFilter->GetOutput()->GetNthElement(i - 1));
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
}
......
......@@ -71,7 +71,7 @@ int otbMorphologicalOpeningProfileFilter(int itkNotUsed(argc), char * argv[])
writer = WriterType::New();
oss << outputFilenamePrefix << i << "." << outputFilenameSuffix;
writer->SetInput(profileFilter->GetOutput()->GetNthElement(i - 1));
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
}
......
......@@ -76,7 +76,7 @@ int otbProfileToProfileDerivativeFilter(int itkNotUsed(argc), char * argv[])
writer = WriterType::New();
oss << outputFilenamePrefix << i << "." << outputFilenameSuffix;
writer->SetInput(derivativeFilter->GetOutput()->GetNthElement(i - 1));
writer->SetFileName(oss.str().c_str());
writer->SetFileName(oss.str());
writer->Update();
oss.str("");
}
......
......@@ -98,7 +98,7 @@ public:
}
void SetFileName (const std::string& filename)
{
this->SetFileName(filename.c_str());
this->SetFileName(filename);
}
itkGetStringMacro(FileName);
......
......@@ -99,7 +99,7 @@ public:
}
void SetFileName (const std::string& filename)
{
this->SetFileName(filename.c_str());
this->SetFileName(filename);
}
itkGetStringMacro(FileName);
......
......@@ -86,7 +86,7 @@ public:
}
void SetFileName (const std::string& filename)
{
this->SetFileName(filename.c_str());
this->SetFileName(filename);
}
itkGetStringMacro(FileName);
......
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