]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdVectorFilterDouble.cxx
#3492 SaveLstPoints
[bbtk.git] / packages / std / src / bbstdVectorFilterDouble.cxx
index 59f0fe17abb3d45b0968676330a3441c440db4ce..95dae0ad3136fcea027f57d4af94e299783ffab1 100644 (file)
@@ -118,7 +118,7 @@ void VectorFilterDouble::Process()
                int             ipLstvec2;
                double  iLine;
                int     sizeLines       = (*pLstVec[0]).size();
-               double  step            = (double)sizeLines/((double)bbGetInputk1()-1);
+               double  step            = (double)sizeLines/((double)bbGetInputk1()[0]-1);
                for (iLine=0 ; iLine<sizeLines ; iLine=iLine+step)
                {
                        for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
@@ -158,7 +158,7 @@ void VectorFilterDouble::Process()
        } // Type==2
 
 
-       if (bbGetInputType()==3) // Addition  k1
+       if (bbGetInputType()==3) // Addition  k1[0]
        {
                int             ipLstvec;
                int     i;
@@ -169,13 +169,13 @@ void VectorFilterDouble::Process()
                        size=(*pLstVec[ipLstvec]).size();
                        for (i=0;i<size;i++)
                        {
-                               result= (*pLstVec[ipLstvec])[i] + bbGetInputk1() ;
+                               result= (*pLstVec[ipLstvec])[i] + bbGetInputk1()[0] ;
                                (*pLstVecOut[ipLstvec]).push_back( result );                            
                        }// for size
                } // for pLstVec                
        } // Type==3
 
-       if (bbGetInputType()==4) // Substraction  k1
+       if (bbGetInputType()==4) // Substraction  k1[0]
        {
                int             ipLstvec;
                int     i;
@@ -186,13 +186,13 @@ void VectorFilterDouble::Process()
                        size=(*pLstVec[ipLstvec]).size();
                        for (i=0;i<size;i++)
                        {
-                               result= (*pLstVec[ipLstvec])[i] - bbGetInputk1() ;
+                               result= (*pLstVec[ipLstvec])[i] - bbGetInputk1()[0] ;
                                (*pLstVecOut[ipLstvec]).push_back( result );                            
                        }// for size
                } // for pLstVec                
        } // Type==4
 
-       if (bbGetInputType()==5) // Multiplication  k1
+       if (bbGetInputType()==5) // Multiplication  k1[0]
        {
                int     ipLstvec;
                int     i;
@@ -203,15 +203,13 @@ void VectorFilterDouble::Process()
                        size=(*pLstVec[ipLstvec]).size();
                        for (i=0;i<size;i++)
                        {
-                               result= (*pLstVec[ipLstvec])[i] * bbGetInputk1() ;
+                               result= (*pLstVec[ipLstvec])[i] * bbGetInputk1()[0] ;
                                (*pLstVecOut[ipLstvec]).push_back( result );                            
                        }// for size
                } // for pLstVec                
        } // Type==5
 
-       if (bbGetInputType()==6) // Division  k1ng gadget (node check, owner GtkCheckButton)
-
-
+       if (bbGetInputType()==6) // Division  k1
        {
                int     ipLstvec;
                int     i;
@@ -222,9 +220,9 @@ void VectorFilterDouble::Process()
                        size=(*pLstVec[ipLstvec]).size();
                        for (i=0;i<size;i++)
                        {
-                               if (bbGetInputk1()!=0)
+                               if (bbGetInputk1()[0]!=0)
                                {
-                                       result= (*pLstVec[ipLstvec])[i] / bbGetInputk1() ;
+                                       result= (*pLstVec[ipLstvec])[i] / bbGetInputk1()[0] ;
                                        (*pLstVecOut[ipLstvec]).push_back( result );                            
                                } else {
                                        printf("EED VectorFilterDouble::Process  Warning!! Div by 0 in Type 6 \n");
@@ -345,12 +343,11 @@ void VectorFilterDouble::Process()
        } // Type 9
 
 
-       if (bbGetInputType()==10)   // Invert vectors
+       if (bbGetInputType()==10)   // Nearest point in vector
        {
                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;
@@ -387,6 +384,103 @@ void VectorFilterDouble::Process()
        } // Type 10
 
 
+    if (bbGetInputType()==11)   // Nearest point in vector
+    {
+        int i;
+        int    sizeLstX    =    In0.size();   // lstX
+        int    sizeLstY    =    In1.size();   // lstY
+        int    sizeLstZ    =    In2.size();   // lstZ
+        std::vector<double> spc = bbGetInputk1();
+        if (spc.size()>=1)
+        {
+            for (i=0;i<sizeLstX; i++)
+            {
+                Out0.push_back( In0[i]*spc[0] );
+            } // for i
+        } 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++)
+            {
+                Out1.push_back( In1[i]*spc[1] );
+            } // for i
+        } 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++)
+            {
+                Out2.push_back( In2[i]*spc[2] );
+            } // for i
+        } 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;
+        int    sizeLstX    =    In0.size();   // lstX
+        int    sizeLstY    =    In1.size();   // lstY
+        int    sizeLstZ    =    In2.size();   // lstZ
+        std::vector<double> spc = bbGetInputk1();
+        if (spc.size()>=1)
+        {
+            if (spc[0]!=0)
+            {
+                for (i=0;i<sizeLstX; i++)
+                {
+                    Out0.push_back( In0[i]/spc[0] );
+                } // for i
+            } // if spc !=0
+        } 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)
+            {
+                for (i=0;i<sizeLstY; i++)
+                {
+                    Out1.push_back( In1[i]/spc[1] );
+                } // for i
+            } // if spc !=0
+        } 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)
+            {
+                for (i=0;i<sizeLstZ; i++)
+                {
+                    Out2.push_back( In2[i]/spc[2] );
+                } // for i
+            } // if spc !=0
+        } else {
+            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)
+        {
+            double x = In0[0] - In1[0];
+            double y = In0[1] - In1[1];
+            double z = In0[2] - In1[2];
+            Out0.push_back( sqrt( x*x +y*y +z*z ) );
+        }
+     } // Type 13
 
        bbSetOutputOut0( Out0 );
        bbSetOutputOut1( Out1 );
@@ -399,44 +493,42 @@ void VectorFilterDouble::Process()
        bbSetOutputOut8( Out8 );
        bbSetOutputOut9( Out9 );
 }
+
 //===== 
 // 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 VectorFilterDouble::bbUserSetDefaultValues()
 {
-
 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
 //    Here we initialize the input 'In' to 0
-   bbSetInputType(0);
-   bbSetInputk1(0);
-  
+    bbSetInputType(0);
+    std::vector<double> k1;
+    k1.push_back(0);
+    bbSetInputk1(k1);
 }
+
 //===== 
 // 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 VectorFilterDouble::bbUserInitializeProcessing()
 {
-
 //  THE INITIALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should allocate the internal/output pointers 
-//    if any 
-
-  
+//    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)
 //===== 
 void VectorFilterDouble::bbUserFinalizeProcessing()
 {
-
 //  THE FINALIZATION METHOD BODY :
 //    Here does nothing 
 //    but this is where you should desallocate the internal/output pointers 
 //    if any
-  
-}
 }
-// EO namespace bbstd
+
+}// EO namespace bbstd