]> Creatis software - bbtk.git/commitdiff
#2951 BBTK Feature New Normal - Replace String box with vector functionality
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 18 May 2016 05:25:38 +0000 (07:25 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Wed, 18 May 2016 05:25:38 +0000 (07:25 +0200)
packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx
packages/std/src/bbstdReplaceString.cxx
packages/std/src/bbstdReplaceString.h

index 5c309ae42f2f6e3cdf787ab2dc82596eb7852b7e..105e782da39bb023ec4b70cfa860ace18527ff23 100644 (file)
@@ -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
index c8ea640dfb4d9f996c9941a69f8dc6be68203f2a..9975048047e94798b4a89a81c7003187c3b9791c 100644 (file)
@@ -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("");
   
index 5202052805c61d0b20636fb4deb23f5a87bbaa47..86821d930b4774cd22f477b40264802922b53134 100644 (file)
@@ -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)