]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdVectorFilterDouble.cxx
#3348 BBTK Feature New Normal - VectorFilterDouble (find nearest point) WriteColumn...
[bbtk.git] / packages / std / src / bbstdVectorFilterDouble.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 );