]> Creatis software - bbtk.git/commitdiff
#3495 box VectorFilterString with EraseDuplicateLines option
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 13 Jan 2023 20:15:41 +0000 (21:15 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Fri, 13 Jan 2023 20:15:41 +0000 (21:15 +0100)
packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.cxx
packages/gdcmvtk/src/bbgdcmvtkGetXCoherentInfoGdcmReader.h
packages/std/src/bbstdVectorFilterDouble.cxx
packages/std/src/bbstdVectorFilterString.cxx
packages/std/src/bbstdVectorFilterString.h

index a094ff7755079e1bac4ebe2a4c10ddce853e38e0..25700ecdd80ce3d34c415c07e44265ced2a230d2 100644 (file)
@@ -85,6 +85,33 @@ vtkImageData* GetXCoherentInfoGdcmReader::CreateDefaultImage()
 
 
 #if defined USE_GDCM
+
+void GetXCoherentInfoGdcmReader::Process2()
+{
+    printf("EED GetXCoherentInfoGdcmReader::Process >>>>>> \n" );
+    GDCM_NAME_SPACE::FileList   lstFiles;
+    int i,size=bbGetInputIn().size();
+    for (i=0;i<size;i++)
+    {
+        printf("a: %s\n",bbGetInputIn()[i].c_str() );
+        f = GDCM_NAME_SPACE::File::New();
+        f->SetFileName( bbGetInputIn()[i] );
+        bool res = f->Load();
+        if ( res==true )
+        {
+            lstFiles.push_back(f);
+        }
+    } // for
+    sh = GDCM_NAME_SPACE::SerieHelper::New();
+    sh->ImagePositionPatientOrdering( &lstFiles );
+    size=lstFiles.size();
+    for (i=0;i<size;i++)
+    {
+        printf("d:  %s\n", lstFiles[i]->GetFileName().c_str() );
+    } // for
+}
+
+
 void GetXCoherentInfoGdcmReader::Process()
 {
  // Read the *first* image file (a SET of file names is given as input) 
@@ -128,25 +155,45 @@ void GetXCoherentInfoGdcmReader::Process()
 //     } // for i
 //   bbSetOutputIPP(v_ipp );
 
-// Add *all the files* to the SerieHelper
-   sh = GDCM_NAME_SPACE::SerieHelper::New();
-   std::vector<std::string> gii = bbGetInputIn();
-   for(std::vector<std::string>::iterator it = gii.begin();
-                                          it != gii.end();
-                                        ++it)
-   {
-      sh->AddFileName(*it);
-   } //for vector
-
-   GDCM_NAME_SPACE::FileList::const_iterator it;
-   GDCM_NAME_SPACE::FileList *l;
-   // Should only contain one!
-   l = sh->GetFirstSingleSerieUIDFileSet();
-       if (l==NULL)
-       {       
-               return;
-       }
+// EED 2023-01-13
+    GDCM_NAME_SPACE::FileList   lstFiles;
+    GDCM_NAME_SPACE::FileList   *l;
 
+    if (bbGetInputRespectSerieUID()==false)
+    {
+        int i,size=bbGetInputIn().size();
+        for (i=0;i<size;i++)
+        {
+            f = GDCM_NAME_SPACE::File::New();
+            f->SetFileName( bbGetInputIn()[i] );
+            bool res = f->Load();
+            if ( res==true )
+            {
+                lstFiles.push_back(f);
+            }
+        } // for i
+        sh = GDCM_NAME_SPACE::SerieHelper::New();
+        l = &lstFiles;
+        sh->ImagePositionPatientOrdering( l );
+    } else{
+    // Add *all the files* to the SerieHelper
+       sh = GDCM_NAME_SPACE::SerieHelper::New();
+       std::vector<std::string> gii = bbGetInputIn();
+       for(std::vector<std::string>::iterator it = gii.begin();
+                                              it != gii.end();
+                                            ++it)
+       {
+          sh->AddFileName(*it);
+       } //for vector
+       GDCM_NAME_SPACE::FileList::const_iterator it;
+       // Should only contain one!
+       l = sh->GetFirstSingleSerieUIDFileSet();
+        if (l==NULL)
+        {
+            return;
+        }
+    } // if  bbGetInputForceRead
+    
    double zspacing = 0.;
    sh->OrderFileList(l); // this one should compute the *actual* Z Spacing!
    zspacing            = sh->GetZSpacing();
@@ -168,8 +215,11 @@ void GetXCoherentInfoGdcmReader::Process()
        GDCM_NAME_SPACE::FileList::const_iterator iitt = l->begin();
     float px,py,pz;
     
+    std::vector<std::string> lstFileNames;
+    
     for ( ; iitt != l->end(); ++iitt)
        {
+        lstFileNames.push_back( (*iitt)->GetFileName() );
         // EED 2022-12-15
         if ( iitt == l->begin() )   // The first ordered element IPP
         {
@@ -185,7 +235,7 @@ void GetXCoherentInfoGdcmReader::Process()
             v_ipp.push_back( (double)pz );
             bbSetOutputIPP(v_ipp );
         } // if first elemetn  get IPP
-        
+     
                MapInfoDicom mapinfodicom;
                for (iTag=0; iTag<sizeDicomTagsVector; iTag++)
                {
@@ -201,6 +251,7 @@ void GetXCoherentInfoGdcmReader::Process()
                vectormapinfodicom.push_back( mapinfodicom );
    } // for iitt
    bbSetOutputDicomInfo( vectormapinfodicom );
+   bbSetOutputOutFileNames( lstFileNames );
 
        if (bbGetInputReadRaw()==true)
        {
@@ -222,6 +273,7 @@ void GetXCoherentInfoGdcmReader::Process()
 #endif
 // endif USE_GDCM
 
+
 #if defined USE_GDCM2
 void GetXCoherentInfoGdcmReader::Process()
 {
@@ -310,6 +362,7 @@ void GetXCoherentInfoGdcmReader::bbUserSetDefaultValues()
    init.push_back("");
    bbSetInputIn(init);  
    bbSetInputReadRaw(true);  
+   bbSetInputRespectSerieUID(true);
    //reader=NULL;   /// \TODO fixme JPR
 }
 
index 41c2ea756824024f8b2690bb4c45777b33475353..da22dc0151a897ec2d34e01fd76941ec0e8963fc 100644 (file)
@@ -61,15 +61,19 @@ class bbgdcmvtk_EXPORT GetXCoherentInfoGdcmReader
   BBTK_DECLARE_INPUT(IPPSort           , bool);
   BBTK_DECLARE_INPUT(DicomTags         , std::vector<std::string>);
   BBTK_DECLARE_INPUT(ReadRaw           , bool);
-  
+  BBTK_DECLARE_INPUT(RespectSerieUID, bool);
+
   BBTK_DECLARE_OUTPUT(Out                      , vtkImageData *);
+  BBTK_DECLARE_OUTPUT(OutFileNames  , std::vector<std::string>);
   BBTK_DECLARE_OUTPUT(IPP                      , std::vector<double>);
   BBTK_DECLARE_OUTPUT(IOP                      , std::vector<double>);
   BBTK_DECLARE_OUTPUT(PixelSpacing     , std::vector<double>);
   BBTK_DECLARE_OUTPUT(DicomInfo                , VectorMapInfoDicom);
-       
+
   BBTK_PROCESS(Process);
   void Process();
+    
+  void Process2();
   
        vtkImageData* CreateDefaultImage();
 
@@ -97,13 +101,15 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(GetXCoherentInfoGdcmReader,bbtk::AtomicBlackBox);
   BBTK_INPUT(GetXCoherentInfoGdcmReader,In                             ,"List of Dicom image file names", std::vector<std::string>,"");
   BBTK_INPUT(GetXCoherentInfoGdcmReader,IPPSort                        ,"Sort on Image Position Patient", bool,"");
   BBTK_INPUT(GetXCoherentInfoGdcmReader,DicomTags              ,"Dicom Tags (vector of Dicom tags ex: D0028_0030  D0020_0037)", std::vector<std::string>,"");
-  BBTK_INPUT(GetXCoherentInfoGdcmReader,ReadRaw                ,"(default true) false: not read raw just dicom tags", bool,"");
-
-  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,Out                   ,"Output image"                                 , vtkImageData *,"");
-  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,IPP                   ,"Image Position (Patient)"             , std::vector<double>,"");
-  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,IOP                   ,"Image Orientation (Patient)"  , std::vector<double>,"");
-  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,PixelSpacing  ,"Pixel Spacing"                                , std::vector<double>,"");
-  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,DicomInfo             ,"vector of maps of Dicom tags" , VectorMapInfoDicom,"");
+  BBTK_INPUT(GetXCoherentInfoGdcmReader,ReadRaw                    ,"(default true) false: not read raw just dicom tags", bool,"");
+  BBTK_INPUT(GetXCoherentInfoGdcmReader,RespectSerieUID ,"(default true) Respect Serie UID to be read", bool,"");
+
+  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,Out                   ,"Output image"                                         , vtkImageData *,"");
+  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,OutFileNames   ,"List of the files in the good order"  , std::vector<std::string>,"");
+  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,IPP                   ,"Image Position (Patient)"                     , std::vector<double>,"");
+  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,IOP                   ,"Image Orientation (Patient)"          , std::vector<double>,"");
+  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,PixelSpacing  ,"Pixel Spacing"                                        , std::vector<double>,"");
+  BBTK_OUTPUT(GetXCoherentInfoGdcmReader,DicomInfo             ,"vector of maps of Dicom tags"         , VectorMapInfoDicom,"");
 BBTK_END_DESCRIBE_BLACK_BOX(GetXCoherentInfoGdcmReader);
 } // EO namespace bbgdcmvtk
 
index 95dae0ad3136fcea027f57d4af94e299783ffab1..2258e8190a78bad6cd17b7cf3ab849e0f80a5dcd 100644 (file)
@@ -15,7 +15,6 @@ BBTK_BLACK_BOX_IMPLEMENTATION(VectorFilterDouble,bbtk::AtomicBlackBox);
 //===== 
 void VectorFilterDouble::Process()
 {
-
 // THE MAIN PROCESSING METHOD BODY
 //   Here we simply set the input 'In' value to the output 'Out'
 //   And print out the output value
@@ -27,7 +26,6 @@ void VectorFilterDouble::Process()
 //      (the one provided in the attribute 'name' of the tag 'input')
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
-
        std::vector< std::vector<double> * >  pLstVec;  
        std::vector< std::vector<double> * >  pLstVecOut;  
        std::vector<double> In0 = bbGetInputIn0();
@@ -40,7 +38,6 @@ void VectorFilterDouble::Process()
        std::vector<double> In7 = bbGetInputIn7();
        std::vector<double> In8 = bbGetInputIn8();
        std::vector<double> In9 = bbGetInputIn9();
-
        if (bbGetInputIn0().size()!=0) { pLstVec.push_back( &In0 ); }
        if (bbGetInputIn1().size()!=0) { pLstVec.push_back( &In1 ); }
        if (bbGetInputIn2().size()!=0) { pLstVec.push_back( &In2 ); }
@@ -51,7 +48,6 @@ void VectorFilterDouble::Process()
        if (bbGetInputIn7().size()!=0) { pLstVec.push_back( &In7 ); }
        if (bbGetInputIn8().size()!=0) { pLstVec.push_back( &In8 ); }
        if (bbGetInputIn9().size()!=0) { pLstVec.push_back( &In9 ); }
-
        std::vector<double> Out0;
        std::vector<double> Out1;
        std::vector<double> Out2;
@@ -62,7 +58,6 @@ void VectorFilterDouble::Process()
        std::vector<double> Out7;
        std::vector<double> Out8;
        std::vector<double> Out9;
-
        pLstVecOut.push_back( &Out0 );
        pLstVecOut.push_back( &Out1 );
        pLstVecOut.push_back( &Out2 );
@@ -73,8 +68,6 @@ void VectorFilterDouble::Process()
        pLstVecOut.push_back( &Out7 );
        pLstVecOut.push_back( &Out8 );
        pLstVecOut.push_back( &Out9 );
-
-
        if (bbGetInputType()==0)  // Erase duplicate lines
        {
                if (bbGetInputIn0().size()!=0)  // At least one element 
@@ -111,8 +104,6 @@ void VectorFilterDouble::Process()
                        } // if okSizeVec
                } // bbGetInputIn0()  size
        } // Type==0
-
-
        if (bbGetInputType()==1) // Resize vector
        {
                int             ipLstvec2;
@@ -126,15 +117,12 @@ void VectorFilterDouble::Process()
                                (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[(int)iLine] );
                        } // for                        
                } // for ipLstVec
-
                // adding the lastone
                for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
                {
                        (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[(int)(sizeLines-1)] );
-               } // for                        
-
+               } // for
        } // Type==1
-
        if (bbGetInputType()==2) // Insert intermediate points
        {
                int             ipLstvec;
@@ -156,8 +144,6 @@ void VectorFilterDouble::Process()
                        } // if size>=2
                } // for pLstVec                
        } // Type==2
-
-
        if (bbGetInputType()==3) // Addition  k1[0]
        {
                int             ipLstvec;
@@ -174,7 +160,6 @@ void VectorFilterDouble::Process()
                        }// for size
                } // for pLstVec                
        } // Type==3
-
        if (bbGetInputType()==4) // Substraction  k1[0]
        {
                int             ipLstvec;
@@ -191,7 +176,6 @@ void VectorFilterDouble::Process()
                        }// for size
                } // for pLstVec                
        } // Type==4
-
        if (bbGetInputType()==5) // Multiplication  k1[0]
        {
                int     ipLstvec;
@@ -208,7 +192,6 @@ void VectorFilterDouble::Process()
                        }// for size
                } // for pLstVec                
        } // Type==5
-
        if (bbGetInputType()==6) // Division  k1
        {
                int     ipLstvec;
@@ -231,9 +214,6 @@ void VectorFilterDouble::Process()
                        }// for size
                } // for pLstVec                
        } // Type==6
-
-
-
        if (bbGetInputType()==7) 
        {
                int i,j;
@@ -243,18 +223,13 @@ void VectorFilterDouble::Process()
                        Out1.push_back( In5[j] );
                        Out2.push_back( In6[j] );
                } //
-
-
                int iGeneral=0,sizeI,sizeLst1Indexes=In3.size();
                for (i=0; i<sizeLst1Indexes-1;i++) { iGeneral=iGeneral+In3[i]; }
                sizeI=iGeneral+In3[ sizeLst1Indexes-1 ];
-
                int jGeneral = 0;
                int sizeJ        = In7[ 0 ];
-
                double dist2,dist2Min,dx,dy,dz;
                int iBack;
-
                for (j=jGeneral;j<sizeJ;j++) 
                {
                        dist2Min=1000000;
@@ -274,19 +249,12 @@ void VectorFilterDouble::Process()
                        Out1[j]=In1[iBack]; 
                        Out2[j]=In2[iBack]; 
                } // for i
-
-
        }       // Type 7
-
-
-
        if (bbGetInputType()==8)   // order all vectors using as base the vector In0
        {
                double tmp;
                int i,j,ii,sizeII;
                sizeII=pLstVec.size();
-
-
                int size=In0.size();
                for (i=0;i<size; i++)
                {
@@ -300,8 +268,7 @@ void VectorFilterDouble::Process()
                        for (j=i;j<size;j++)
                        {
                                if ((*pLstVecOut[0])[j] <= (*pLstVecOut[0])[i] ) 
-                               {       
-                                       
+                               {
                                        for (ii=0;ii<sizeII;ii++)
                                        {
                                                tmp = (*pLstVecOut[ii])[i]; 
@@ -312,14 +279,11 @@ void VectorFilterDouble::Process()
                        } // for j
                } // for i
        } // Type 8
-
-
        if (bbGetInputType()==9)   // Invert vectors
        {
                double tmp;
                int i,j,ii,sizeII;
                sizeII=pLstVec.size();
-
                int size=In0.size();
                int size2=size/2;
                for (i=0;i<size; i++)
@@ -329,7 +293,6 @@ void VectorFilterDouble::Process()
                                 (*pLstVecOut[ii]).push_back( (*pLstVec[ii])[i] ); 
                        } // for ii
                } // i
-
                for (i=0;i<size2;i++)
                {
                        for (ii=0;ii<sizeII;ii++)
@@ -341,8 +304,6 @@ void VectorFilterDouble::Process()
                        } // for ii
                } // for i
        } // Type 9
-
-
        if (bbGetInputType()==10)   // Nearest point in vector
        {
                int     sizeLstX        =       In0.size();   // lstX
@@ -382,8 +343,6 @@ void VectorFilterDouble::Process()
                        printf("EED Warnning VectorFilterDouble::Process()   For Type 10 the size of the vectors are not coherent.\n");
                }// if size
        } // Type 10
-
-
     if (bbGetInputType()==11)   // Nearest point in vector
     {
         int i;
@@ -400,7 +359,6 @@ void VectorFilterDouble::Process()
         } else {
             printf("EED Warnning VectorFilterDouble::Process()   For Type 11 the K1 vector (spacing) is not coherent.\n");
         }// if size
-
         if (spc.size()>=2)
         {
             for (i=0;i<sizeLstY; i++)
@@ -410,7 +368,6 @@ void VectorFilterDouble::Process()
         } else {
             printf("EED Warnning VectorFilterDouble::Process()   For Type 11 the K1 vector (spacing) is not coherent.\n");
         }// if size
-
         if (spc.size()>=3)
         {
             for (i=0;i<sizeLstZ; i++)
@@ -420,10 +377,7 @@ void VectorFilterDouble::Process()
         } else {
             printf("EED Warnning VectorFilterDouble::Process()   For Type 11 the K1 vector (spacing) is not coherent.\n");
         }// if size
-
      } // Type 11
-
-
     if (bbGetInputType()==12)   // Nearest point in vector
     {
         int i;
@@ -443,7 +397,6 @@ void VectorFilterDouble::Process()
         } else {
             printf("EED Warnning VectorFilterDouble::Process()   For Type 12 the K1 vector (spacing) is not coherent.\n");
         }// if size
-
         if (spc.size()>=2)
         {
             if (spc[0]!=0)
@@ -456,7 +409,6 @@ void VectorFilterDouble::Process()
         } else {
             printf("EED Warnning VectorFilterDouble::Process()   For Type 12 the K1 vector (spacing) is not coherent.\n");
         }// if size
-
         if (spc.size()>=3)
         {
             if (spc[0]!=0)
@@ -470,7 +422,6 @@ void VectorFilterDouble::Process()
             printf("EED Warnning VectorFilterDouble::Process()   For Type 12 the K1 vector (spacing) is not coherent.\n");
         }// if size
      } // Type 12
-
     if (bbGetInputType()==13)   // Distance point 3D between In0 and In1
     {
         if ( In0.size()==3 and In1.size()==3)
@@ -481,7 +432,6 @@ void VectorFilterDouble::Process()
             Out0.push_back( sqrt( x*x +y*y +z*z ) );
         }
      } // Type 13
-
        bbSetOutputOut0( Out0 );
        bbSetOutputOut1( Out1 );
        bbSetOutputOut2( Out2 );
index ee02ef6d2436fcfff7323b9e218aab7ebbe505a7..19953563937501163d5efc1e3a603583311855a5 100644 (file)
@@ -15,6 +15,40 @@ BBTK_BLACK_BOX_IMPLEMENTATION(VectorFilterString,bbtk::AtomicBlackBox);
 // 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)
 //===== 
 
+void VectorFilterString::CountConnectedRepetitions()
+{
+    std::vector<std::string> vOut0;
+    std::vector<std::string> vOut1;
+    std::vector<std::string> vOut2;
+    std::vector<std::string> vOut3;
+    std::vector<std::string> vOut4;
+    std::vector<std::string> vOut5;
+    std::vector<std::string> vOut6;
+    std::vector<std::string> vOut7;
+    std::vector<std::string> vOut8;
+    std::vector<std::string> vOut9;
+    ConnectionRepetitions( bbGetInputIn0() , &vOut0 );
+    ConnectionRepetitions( bbGetInputIn1() , &vOut1 );
+    ConnectionRepetitions( bbGetInputIn2() , &vOut2 );
+    ConnectionRepetitions( bbGetInputIn3() , &vOut3 );
+    ConnectionRepetitions( bbGetInputIn4() , &vOut4 );
+    ConnectionRepetitions( bbGetInputIn5() , &vOut5 );
+    ConnectionRepetitions( bbGetInputIn6() , &vOut6 );
+    ConnectionRepetitions( bbGetInputIn7() , &vOut7 );
+    ConnectionRepetitions( bbGetInputIn8() , &vOut8 );
+    ConnectionRepetitions( bbGetInputIn9() , &vOut9 );
+    bbSetOutputOut0( vOut0 );
+    bbSetOutputOut1( vOut1 );
+    bbSetOutputOut2( vOut2 );
+    bbSetOutputOut3( vOut3 );
+    bbSetOutputOut4( vOut4 );
+    bbSetOutputOut5( vOut5 );
+    bbSetOutputOut6( vOut6 );
+    bbSetOutputOut7( vOut7 );
+    bbSetOutputOut8( vOut8 );
+    bbSetOutputOut9( vOut9 );
+}
+
 void VectorFilterString::ConnectionRepetitions( std::vector<std::string> vIn,std::vector<std::string> *vOut  )
 {
        int i,size=vIn.size();
@@ -273,6 +307,103 @@ void VectorFilterString::SubString()
 }
 
 
+void VectorFilterString::EraseDuplicateLines()
+{
+    std::vector< std::vector< std::string > * >  pLstVec;
+    std::vector< std::vector< std::string > * >  pLstVecOut;
+    std::vector< std::string > In0 = bbGetInputIn0();
+    std::vector< std::string > In1 = bbGetInputIn1();
+    std::vector< std::string > In2 = bbGetInputIn2();
+    std::vector< std::string > In3 = bbGetInputIn3();
+    std::vector< std::string > In4 = bbGetInputIn4();
+    std::vector< std::string > In5 = bbGetInputIn5();
+    std::vector< std::string > In6 = bbGetInputIn6();
+    std::vector< std::string > In7 = bbGetInputIn7();
+    std::vector< std::string > In8 = bbGetInputIn8();
+    std::vector< std::string > In9 = bbGetInputIn9();
+    if (bbGetInputIn0().size()!=0) { pLstVec.push_back( &In0 ); }
+    if (bbGetInputIn1().size()!=0) { pLstVec.push_back( &In1 ); }
+    if (bbGetInputIn2().size()!=0) { pLstVec.push_back( &In2 ); }
+    if (bbGetInputIn3().size()!=0) { pLstVec.push_back( &In3 ); }
+    if (bbGetInputIn4().size()!=0) { pLstVec.push_back( &In4 ); }
+    if (bbGetInputIn5().size()!=0) { pLstVec.push_back( &In5 ); }
+    if (bbGetInputIn6().size()!=0) { pLstVec.push_back( &In6 ); }
+    if (bbGetInputIn7().size()!=0) { pLstVec.push_back( &In7 ); }
+    if (bbGetInputIn8().size()!=0) { pLstVec.push_back( &In8 ); }
+    if (bbGetInputIn9().size()!=0) { pLstVec.push_back( &In9 ); }
+    std::vector< std::string > Out0;
+    std::vector< std::string > Out1;
+    std::vector< std::string > Out2;
+    std::vector< std::string > Out3;
+    std::vector< std::string > Out4;
+    std::vector< std::string > Out5;
+    std::vector< std::string > Out6;
+    std::vector< std::string > Out7;
+    std::vector< std::string > Out8;
+    std::vector< std::string > Out9;
+    pLstVecOut.push_back( &Out0 );
+    pLstVecOut.push_back( &Out1 );
+    pLstVecOut.push_back( &Out2 );
+    pLstVecOut.push_back( &Out3 );
+    pLstVecOut.push_back( &Out4 );
+    pLstVecOut.push_back( &Out5 );
+    pLstVecOut.push_back( &Out6 );
+    pLstVecOut.push_back( &Out7 );
+    pLstVecOut.push_back( &Out8 );
+    pLstVecOut.push_back( &Out9 );
+    std::string tmp1;
+    std::string tmp2;
+        if (bbGetInputIn0().size()!=0)  // At least one element
+        {
+            bool okSizeVec=true;
+            int ipLstvec;
+            for (ipLstvec=1;ipLstvec<pLstVec.size();ipLstvec++)
+            {
+                if ( (*pLstVec[ipLstvec]).size()!=(*pLstVec[0]).size() )  { okSizeVec=false; }
+            }
+            if ( okSizeVec==false)
+            {
+                printf("EED VectorFilterString::Process WARNING! vectors are not of the same size.\n");
+            } else {
+                int iLine;
+                int ipLstvec2;
+                bool okLine;
+                int size=0;
+                if (bbGetInputType()==8) { size = pLstVec.size(); }
+                if (bbGetInputType()==9) { size = 1;              }
+                for (iLine=0 ; iLine < (*pLstVec[0]).size() ; iLine++ )
+                {
+                    okLine=false;
+//                    for ( ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+//                    for ( ipLstvec2=0 ; ipLstvec2<1 ; ipLstvec2++)
+                    for ( ipLstvec2=0 ; ipLstvec2<size   ; ipLstvec2++)
+                    {
+                        tmp1=(*pLstVec[ipLstvec2])[iLine];
+                        tmp2=(*pLstVec[ipLstvec2])[iLine-1];
+                        if ( tmp1.compare(tmp2)!=0 )  { okLine=true; }
+                    } // for ipLstVec2
+                    if ( (okLine==true) || (iLine==0) )
+                    {
+                        for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+                        {
+                            (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[iLine] );
+                        } // for
+                    } // if okLine
+                } // for iLine
+            } // if okSizeVec
+        } // bbGetInputIn0()  size
+    bbSetOutputOut0( Out0 );
+    bbSetOutputOut1( Out1 );
+    bbSetOutputOut2( Out2 );
+    bbSetOutputOut3( Out3 );
+    bbSetOutputOut4( Out4 );
+    bbSetOutputOut5( Out5 );
+    bbSetOutputOut6( Out6 );
+    bbSetOutputOut7( Out7 );
+    bbSetOutputOut8( Out8 );
+    bbSetOutputOut9( Out9 );
+}
+
 
 
 void VectorFilterString::Process()
@@ -295,36 +426,7 @@ void VectorFilterString::Process()
   
        if (bbGetInputType()==0) 
        {
-               std::vector<std::string> vOut0;
-               std::vector<std::string> vOut1;
-               std::vector<std::string> vOut2;
-               std::vector<std::string> vOut3;
-               std::vector<std::string> vOut4;
-               std::vector<std::string> vOut5;
-               std::vector<std::string> vOut6;
-               std::vector<std::string> vOut7;
-               std::vector<std::string> vOut8;
-               std::vector<std::string> vOut9;
-               ConnectionRepetitions( bbGetInputIn0() , &vOut0 );
-               ConnectionRepetitions( bbGetInputIn1() , &vOut1 );
-               ConnectionRepetitions( bbGetInputIn2() , &vOut2 );
-               ConnectionRepetitions( bbGetInputIn3() , &vOut3 );
-               ConnectionRepetitions( bbGetInputIn4() , &vOut4 );
-               ConnectionRepetitions( bbGetInputIn5() , &vOut5 );
-               ConnectionRepetitions( bbGetInputIn6() , &vOut6 );
-               ConnectionRepetitions( bbGetInputIn7() , &vOut7 );
-               ConnectionRepetitions( bbGetInputIn8() , &vOut8 );
-               ConnectionRepetitions( bbGetInputIn9() , &vOut9 );
-               bbSetOutputOut0( vOut0 );
-               bbSetOutputOut1( vOut1 );
-               bbSetOutputOut2( vOut2 );
-               bbSetOutputOut3( vOut3 );
-               bbSetOutputOut4( vOut4 );
-               bbSetOutputOut5( vOut5 );
-               bbSetOutputOut6( vOut6 );
-               bbSetOutputOut7( vOut7 );
-               bbSetOutputOut8( vOut8 );
-               bbSetOutputOut9( vOut9 );
+        CountConnectedRepetitions();
        }
 
     if (bbGetInputType()==2)
@@ -351,8 +453,10 @@ void VectorFilterString::Process()
     {
         SubString();
     }
-
-
+    if ( (bbGetInputType()==8)  ||  (bbGetInputType()==9)  )
+    {
+        EraseDuplicateLines();
+    }
 }
 //===== 
 // 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)
index 877ee9a1087b59bb4170d3415c48595109aca635..98cd0525e7088293dbc7301a14019783881a1128 100644 (file)
@@ -45,6 +45,7 @@ class bbstd_EXPORT VectorFilterString
   BBTK_DECLARE_OUTPUT(Out9,std::vector<std::string>);
   BBTK_PROCESS(Process);
     void Process();
+    void CountConnectedRepetitions();
     void ConnectionRepetitions( std::vector<std::string> vIn,std::vector<std::string> *vOut );
     void FilterByFindinIn0();
     void InsertStringPos();
@@ -52,7 +53,8 @@ class bbstd_EXPORT VectorFilterString
     void SwitchElement(std::vector<std::string> *pVec, int id1, int id2 );
     void OrderLists();
     void SubString();
-
+    void EraseDuplicateLines();
+    
 //===== 
 // 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)
 //===== 
@@ -74,7 +76,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(VectorFilterString,bbtk::AtomicBlackBox);
   BBTK_INPUT(VectorFilterString,In7,"Input vector",std::vector<std::string>,"");
   BBTK_INPUT(VectorFilterString,In8,"Input vector",std::vector<std::string>,"");
   BBTK_INPUT(VectorFilterString,In9,"Input vector",std::vector<std::string>,"");
-  BBTK_INPUT(VectorFilterString,Type,"(Default 0)  0:count connected repetitions, 1:CleaningPointsConnectTwoMesh sk1 criterium, 2: Select lines contain sk1 in In0  (the other intputs In1..In9 are afected, 3: insert string:sk1 in position:sk2 for all elements ),  4: Invert input lists, 5:Order lists with (string)In0 criterius,  6:Order lists with  (double)In0 criterius  7:sub string sk1=pos sk2=len for all lists ",int,"");
+  BBTK_INPUT(VectorFilterString,Type,"(Default 0)  0:count connected repetitions, 1:CleaningPointsConnectTwoMesh sk1 criterium, 2:Select lines contain sk1 in In0  (the other intputs In1..In9 are afected, 3:insert string:sk1 in position:sk2 for all elements ),  4:Invert input lists, 5:Order lists with (string)In0 criterius,  6:Order lists with  (double)In0 criterius,  7:sub string sk1=pos sk2=len for all lists,   8:Erase duplicated lines  In0..In9  9:Erase duplicated lines based in In0   ",int,"");
   BBTK_INPUT(VectorFilterString,sk1,"constant 1",std::string,"");
   BBTK_INPUT(VectorFilterString,sk2,"constant 2",std::string,"");