From 5d332eae2105106da042e76430b810b9efe95c81 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr> Date: Wed, 18 May 2016 07:25:38 +0200 Subject: [PATCH] #2951 BBTK Feature New Normal - Replace String box with vector functionality --- .../bbgdcmvtkGetXCoherentInfoGdcmReader.cxx | 18 +++++----- packages/std/src/bbstdReplaceString.cxx | 36 +++++++++++++++---- packages/std/src/bbstdReplaceString.h | 12 ++++--- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx index 5c309ae..105e782 100644 --- a/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx +++ b/packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx @@ -136,16 +136,19 @@ void GetXCoherentInfoGdcmReader::Process() { // Read the *first* image file (a SET of file names is given as input) gdcm::Reader *read = new gdcm::Reader(); - reader->SetFileName( bbGetInputIn()[0].c_str()); + reader->SetFileName( bbGetInputIn()[0].c_str() ); bool res = read->Read(); - if ( !res ) - { - delete read; - bbSetOutputOut(0); - return; - } + if ( !res ) + { + delete read; + printf("EED GetXCoherentInfoGdcmReader::Process resultImage NULL\n"); + bbSetOutputOut(NULL); + return; + } + + // Get info from the first image file const gdcm::File &f = read->GetFile(); int i; @@ -203,7 +206,6 @@ void GetXCoherentInfoGdcmReader::Process() } reader->SetFileNames(files); reader->Update(); - reader->GetOutput(); bbSetOutputOut( reader->GetOutput() ); } #endif diff --git a/packages/std/src/bbstdReplaceString.cxx b/packages/std/src/bbstdReplaceString.cxx index c8ea640..9975048 100644 --- a/packages/std/src/bbstdReplaceString.cxx +++ b/packages/std/src/bbstdReplaceString.cxx @@ -28,15 +28,39 @@ void ReplaceString::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " <<bbGetOutputOut() << std::endl; + - std::string subject = bbGetInputIn(); +/* + // In + std::string subjectIn = bbGetInputIn(); size_t pos = 0; - while((pos = subject.find(bbGetInputSearch(), pos)) != std::string::npos) + while((pos = subjectIn.find(bbGetInputSearch(), pos)) != std::string::npos) { - subject.replace(pos, bbGetInputSearch().length(), bbGetInputReplace()); + subjectIn.replace(pos, bbGetInputSearch().length(), bbGetInputReplace()); pos += bbGetInputReplace().length(); - } - bbSetOutputOut(subject); + } // while +*/ + + + // InVec +// std::string + std::string subjectInVec; + std::vector< std::string > tmpLst; + int i,size=bbGetInputIn().size(); + for ( i=0 ; i<size ; i++ ) + { + subjectInVec = bbGetInputIn()[i]; + size_t pos = 0; + while((pos = subjectInVec.find(bbGetInputSearch(), pos)) != std::string::npos) + { + subjectInVec.replace(pos, bbGetInputSearch().length(), bbGetInputReplace()); + pos += bbGetInputReplace().length(); + } // while + tmpLst.push_back( subjectInVec ); + } // for + +// bbSetOutputOut( subjectIn ); + bbSetOutputOut( tmpLst ); } //===== @@ -47,7 +71,7 @@ void ReplaceString::bbUserSetDefaultValues() // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX // Here we initialize the input 'In' to 0 - bbSetInputIn(""); +// bbSetInputIn(""); bbSetInputReplace(""); bbSetInputSearch(""); diff --git a/packages/std/src/bbstdReplaceString.h b/packages/std/src/bbstdReplaceString.h index 5202052..86821d9 100644 --- a/packages/std/src/bbstdReplaceString.h +++ b/packages/std/src/bbstdReplaceString.h @@ -20,10 +20,12 @@ class bbstd_EXPORT ReplaceString //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) //===== - BBTK_DECLARE_INPUT(In,std::string); +// BBTK_DECLARE_INPUT(In,std::string); + BBTK_DECLARE_INPUT(In,std::vector<std::string>); BBTK_DECLARE_INPUT(Search,std::string); BBTK_DECLARE_INPUT(Replace,std::string); - BBTK_DECLARE_OUTPUT(Out,std::string); +// BBTK_DECLARE_OUTPUT(Out,std::string); + BBTK_DECLARE_OUTPUT(Out,std::vector<std::string>); BBTK_PROCESS(Process); void Process(); //===== @@ -36,10 +38,12 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReplaceString,bbtk::AtomicBlackBox); BBTK_AUTHOR("InfoDev"); BBTK_DESCRIPTION("No Description."); BBTK_CATEGORY("empty"); - BBTK_INPUT(ReplaceString,In,"Input string",std::string,""); +// BBTK_INPUT(ReplaceString,In,"Input string",std::string,""); + BBTK_INPUT(ReplaceString,In,"Input vector of string",std::vector<std::string>,""); BBTK_INPUT(ReplaceString,Search,"Searche sub string ",std::string,""); BBTK_INPUT(ReplaceString,Replace,"Replace new string",std::string,""); - BBTK_OUTPUT(ReplaceString,Out,"Output string",std::string,""); +// BBTK_OUTPUT(ReplaceString,Out,"Output string",std::string,""); + BBTK_OUTPUT(ReplaceString,Out,"Output vector string",std::vector< std::string >,""); BBTK_END_DESCRIBE_BLACK_BOX(ReplaceString); //===== // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) -- 2.49.0