]> Creatis software - bbtk.git/commitdiff
#3348 BBTK Feature New Normal - VectorFilterDouble (find nearest point) WriteColumn...
authorEduardo DAVILA <davila@ei-ed-606.univ-lyon1.fr>
Fri, 24 Jan 2020 15:22:03 +0000 (16:22 +0100)
committerEduardo DAVILA <davila@ei-ed-606.univ-lyon1.fr>
Fri, 24 Jan 2020 15:22:03 +0000 (16:22 +0100)
packages/std/src/bbstdVectorFilterDouble.cxx
packages/std/src/bbstdVectorFilterDouble.h
packages/std/src/bbstdWriteColumnsString.cxx
packages/vtk/src/bbvtkTemporalPicker.cxx

index ffed94ac2ef729909a3aec9b4459d736abe7cd15..812f6469d399f802bc97db34172ee1609e9789f3 100644 (file)
@@ -3,6 +3,8 @@
 //===== 
 #include "bbstdVectorFilterDouble.h"
 #include "bbstdPackage.h"
+#include "math.h"
+
 namespace bbstd
 {
 
@@ -339,6 +341,52 @@ void VectorFilterDouble::Process()
                } // for i
        } // Type 9
 
+
+printf("EED VectorFilterDouble::Process() start\n");
+       if (bbGetInputType()==10)   // Invert vectors
+       {
+               int     sizeLstX        =       In0.size();   // lstX
+               int     sizeLstY        =       In1.size();   // lstY
+               int     sizeLstZ        =       In2.size();   // lstZ
+               printf("EED Warnning VectorFilterDouble::Process() %d  %d  %d  %d\n", sizeLstX,sizeLstY,sizeLstZ,In3.size() );
+               if ( (sizeLstX==sizeLstY) && (sizeLstY==sizeLstZ) && (sizeLstX>0) && (In3.size()==3) )
+               {
+                       int i;
+                       double x1               =       In3[0];  // pointX of pointXYZ
+                       double y1               =       In3[1];  // pointY of pointXYZ
+                       double z1               =       In3[2];  // pointZ of pointXYZ
+                       double distMin  =       100000;
+                       double dist;
+                       double x2;
+                       double y2;
+                       double z2;
+                       Out0.push_back( -1 ); 
+                       Out1.push_back( -999 ); 
+                       Out1.push_back( -999 ); 
+                       Out1.push_back( -999 ); 
+                       for (i=0;i<sizeLstX; i++)
+                       {
+                               x2 = In0[i];    // lstX
+                               y2 = In1[i];    // lstY
+                               z2 = In2[i];    // lstZ
+                               dist = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2) );
+                               if (dist<distMin) 
+                               {
+                                       distMin = dist;
+                                       Out0[0] = i;
+                                       Out1[0] = x2;
+                                       Out1[1] = y2;
+                                       Out1[2] = z2;
+                               }
+                       } // for i
+               } else {
+                       printf("EED Warnning VectorFilterDouble::Process()   For Type 10 the size of the vectors are not coherent.\n");
+               }// if size
+       } // Type 10
+
+printf("EED VectorFilterDouble::Process() end\n");
+
+
        bbSetOutputOut0( Out0 );
        bbSetOutputOut1( Out1 );
        bbSetOutputOut2( Out2 );
index f08a2e3fb4f44059c8907aa38ba94f7a19d36251..909854ba9d57f6d6e26a88f9056835b6020eee8c 100644 (file)
@@ -52,7 +52,7 @@ BBTK_BEGIN_DESCRIBE_BLACK_BOX(VectorFilterDouble,bbtk::AtomicBlackBox);
   BBTK_AUTHOR("InfoDev");
   BBTK_DESCRIPTION("No Description.");
   BBTK_CATEGORY("empty");
-  BBTK_INPUT(VectorFilterDouble,Type,"default (0)  0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition, 4=Substraction, 5=Multilication, 6=Division, 7=Connect mesh X1,Y1,Z1,idxs1,X2,X2,X2,idx2, 8=Order All vectors with the logic of In0 , 9=Invert Vectors",int,"");
+  BBTK_INPUT(VectorFilterDouble,Type,"default (0)  0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition, 4=Substraction, 5=Multilication, 6=Division, 7=Connect mesh X1,Y1,Z1,idxs1,X2,X2,X2,idx2, 8=Order All vectors with the logic of In0 , 9=Invert Vectors, 10=Nearest Point in the vector. In0-lstX In1-lstY In2-lstZ In3-PointXYZ (Out0-index Out1-PointXYZ)",int,"");
   BBTK_INPUT(VectorFilterDouble,k1,"default (0)  nothing (Type0), k1=new size vectors (Type 1) , nothing (Type2), k1 = Addition const. (Type 3), k1 = Substraction const. (Type 4), k1 = Multiplication const. (Type 5) , k1 = Division const. (Type 6) ,  ",double,"");
   BBTK_INPUT(VectorFilterDouble,In0,"Input vector",std::vector<double>,"");
   BBTK_INPUT(VectorFilterDouble,In1,"Input vector",std::vector<double>,"");
index 229601c7e93e29a9983bcfec98ad9a432603e2de..3c5d8d529fad22996977b50262ce561d00cd0421 100644 (file)
@@ -18,16 +18,19 @@ void WriteColumnsString::Process()
        std::vector<std::string> headers = bbGetInputHeaders(); //Headers Input
        bool onHeaders = bbGetInputOnHeaders();
        std::vector<std::vector<std::string> > values;
-       values.push_back(bbGetInputlstData1());
-       values.push_back(bbGetInputlstData2());
-       values.push_back(bbGetInputlstData3());
-       values.push_back(bbGetInputlstData4());
-       values.push_back(bbGetInputlstData5());
-       values.push_back(bbGetInputlstData6());
-       values.push_back(bbGetInputlstData7());
-       values.push_back(bbGetInputlstData8());
-       values.push_back(bbGetInputlstData9());
+       values.push_back( bbGetInputlstData1() );
+       values.push_back( bbGetInputlstData2() );
+       values.push_back( bbGetInputlstData3() );
+       values.push_back( bbGetInputlstData4() );
+       values.push_back( bbGetInputlstData5() );
+       values.push_back( bbGetInputlstData6() );
+       values.push_back( bbGetInputlstData7() );
+       values.push_back( bbGetInputlstData8() );
+       values.push_back( bbGetInputlstData9() );
        std::vector<std::vector<std::string> >::iterator it;
+
+       
+
        for(it = values.begin() ; it != values.end() ; )
        {
                if((*it).empty())
@@ -36,44 +39,63 @@ void WriteColumnsString::Process()
                }else
                {
                        it++;
-               }
-       }
-       if(write_fi.is_open())
-       {       
-               if(onHeaders == true) // If onHeaders is true, the file is write with Headers.
+               } // if 
+       } // for it
+
+
+       bool ok         = true;
+       int i,size      = values.size();
+       for ( i=0 ; i<size-1 ; i++ )
+       {
+               if ( values[i].size() != values[i+1].size() )
                {
-                       //Add each header input write to file
-                       for(unsigned int i=0 ;i< headers.size(); i++ )
+                       ok=false;
+               } // if
+       } // for
+
+
+       if (ok==true)
+       {
+               if(write_fi.is_open())
+               {       
+                       if(onHeaders == true) // If onHeaders is true, the file is write with Headers.
                        {
-                               if(i==(headers.size()-1))
+                               //Add each header input write to file
+                               for(unsigned int i=0 ;i< headers.size(); i++ )
                                {
-                                       write_fi << headers[i] << "\n";
-                               }else{
-                                       write_fi << headers[i] << "\t";
-                               }
-
-                       }//for headersSize
-               }
-               unsigned int colSize = values[0].size();
-               for(unsigned int j=0;j<colSize;j++)
-               {
-                       for(unsigned int i=0;i<values.size();i++)
+                                       if(i==(headers.size()-1))
+                                       {
+                                               write_fi << headers[i] << "\n";
+                                       }else{
+                                               write_fi << headers[i] << "\t";
+                                       } // if
+                               }//for headersSize
+                       }
+                       unsigned int colSize = values[0].size();
+                       for(unsigned int j=0 ; j<colSize ; j++)
                        {
-                               if(i==(values.size()-1))
+                               for(unsigned int i=0;i<values.size();i++)
                                {
-                                       write_fi << values[i][j] << "\n";
-                               }else{
-                                       write_fi << values[i][j] << "\t";
-                               }
-                       }
-               }
-       }// if write_fi.is_open()
-       else
-       {
-               std::cout<<"No es posible abrir"<<std::endl;
-       }//else
+                                       if(i==(values.size()-1))
+                                       {
+                                               write_fi << values[i][j] << "\n";
+                                       }else{
+                                               write_fi << values[i][j] << "\t";
+                                       } // if
+                               } // for
+                       } // for
+               } else { // if write_fi.is_open()
+                       std::cout<<"EED WriteColumnsString::Process   Imposible to open file."<<std::endl;
+               }//if open
+
+       } else {
+               printf("EED WriteColumnsString::Process   Warning!   The size of the vectors are not equal. \n");
+       }// if ok
+
        write_fi.close();
        bbSetOutputOutFileName(bbGetInputFileName().c_str());  
+
+
 }
 //===== 
 // 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)
@@ -85,7 +107,6 @@ void WriteColumnsString::bbUserSetDefaultValues()
 //    Here we initialize the input 'In' to 0
    bbSetInputFileName("");     
    bbSetInputFileName("true");
-  
 }
 //===== 
 // 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)
@@ -97,8 +118,6 @@ void WriteColumnsString::bbUserInitializeProcessing()
 //    Here does nothing 
 //    but this is where you should allocate the internal/output pointers 
 //    if any 
-
-  
 }
 //===== 
 // 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 0afbc5d7fe318878f5302c457afabe9d8b357043..4623084756dc99a685102535e5d30ac3445153db 100644 (file)
@@ -96,7 +96,6 @@ void TemporalPicker::Process()
                                int numElem;
                                double acum;
 
-
                                long int index          = px+py*sizeX;
                                long int stepIndex      = sizeX*sizeY;
                                DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn() )
@@ -124,9 +123,6 @@ void TemporalPicker::Process()
                                        } // for i
                                        
 */
-
-
-
                                        if (numElem>0) 
                                        {
                                                result.push_back( acum/numElem );