]> Creatis software - bbtk.git/commitdiff
#3461 Bug box VectorDoubleFilter with empty vectors
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 3 May 2021 09:48:44 +0000 (11:48 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 3 May 2021 09:48:44 +0000 (11:48 +0200)
packages/std/src/bbstdVectorFilterDouble.cxx

index 30798dffb8d168dd85123b3f04c2f38627fae647..c9b6fecda62a3e8e653e7e1f422da557d70fed4f 100644 (file)
@@ -28,6 +28,8 @@ void VectorFilterDouble::Process()
 //    * TYPE is the C++ type of the input/output
 //      (the one provided in the attribute 'type' of the tag 'input')
 
+printf("EED VectorFilterDouble::Process  bbGetInputType()=%d\n", bbGetInputType() );
+
        std::vector< std::vector<double> * >  pLstVec;  
        std::vector< std::vector<double> * >  pLstVecOut;  
        std::vector<double> In0 = bbGetInputIn0();
@@ -77,36 +79,39 @@ void VectorFilterDouble::Process()
 
        if (bbGetInputType()==0)  // Erase duplicate lines
        {
-               bool okSizeVec=true;
-               int ipLstvec; 
-               for (ipLstvec=1;ipLstvec<pLstVec.size();ipLstvec++)
-               {
-                       if ( (*pLstVec[ipLstvec]).size()!=(*pLstVec[0]).size() )  { okSizeVec=false; }
-               }
-               if ( okSizeVec==false)
+               if (bbGetInputIn0().size()!=0)  // At least one element 
                {
-                       printf("EED VectorFilterDouble::Process WARNING! vectors are not of the same size.\n");
-               } else {
-                       int iLine;
-                       int ipLstvec2; 
-                       bool okLine;
-                       for (iLine=0 ; iLine < (*pLstVec[0]).size() ; iLine++ ) 
+                       bool okSizeVec=true;
+                       int ipLstvec; 
+                       for (ipLstvec=1;ipLstvec<pLstVec.size();ipLstvec++)
                        {
-                               okLine=false;
-                               for ( ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
-                               {
-                                       if ( (*pLstVec[ipLstvec2])[iLine]!=(*pLstVec[ipLstvec2])[iLine-1] )  { okLine=true; }
-                               } // for ipLstVec2
-                                               
-                               if ( (okLine==true) || (iLine==0) ) 
+                               if ( (*pLstVec[ipLstvec]).size()!=(*pLstVec[0]).size() )  { okSizeVec=false; }
+                       }
+                       if ( okSizeVec==false)
+                       {
+                               printf("EED VectorFilterDouble::Process WARNING! vectors are not of the same size.\n");
+                       } else {
+                               int iLine;
+                               int ipLstvec2; 
+                               bool okLine;
+                               for (iLine=0 ; iLine < (*pLstVec[0]).size() ; iLine++ ) 
                                {
-                                       for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+                                       okLine=false;
+                                       for ( ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+                                       {
+                                               if ( (*pLstVec[ipLstvec2])[iLine]!=(*pLstVec[ipLstvec2])[iLine-1] )  { okLine=true; }
+                                       } // for ipLstVec2
+                                                       
+                                       if ( (okLine==true) || (iLine==0) ) 
                                        {
-                                               (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[iLine] );
-                                       } // for
-                               } // if okLine
-                       } // for iLine
-               } // if okSizeVec
+                                               for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
+                                               {
+                                                       (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[iLine] );
+                                               } // for
+                                       } // if okLine
+                               } // for iLine
+                       } // if okSizeVec
+               } // bbGetInputIn0()  size
        } // Type==0