]> Creatis software - bbtk.git/commitdiff
#3488 VectorFilterDouble Spacing Mul Div
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 13 Jul 2022 10:36:59 +0000 (12:36 +0200)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Wed, 13 Jul 2022 10:36:59 +0000 (12:36 +0200)
packages/std/src/bbstdVectorFilterDouble.cxx
packages/std/src/bbstdVectorFilterDouble.h

index 88370e28fa392ebd62d14121e3afddb1f0a6323d..9d59c393d98c5929a85685bcb023e201b3e7dde0 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");
@@ -386,6 +384,95 @@ 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 11
+
+    
 
        bbSetOutputOut0( Out0 );
        bbSetOutputOut1( Out1 );
@@ -406,9 +493,10 @@ 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)
index 8f2110af35be05c592d2a74817ec19715891901a..e807839a6a5aaeaf644410b44504160b1a2e17f5 100644 (file)
@@ -18,29 +18,29 @@ class bbstd_EXPORT VectorFilterDouble
 //===== 
 // 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)
 //===== 
-  BBTK_DECLARE_INPUT(Type,int);
-  BBTK_DECLARE_INPUT(k1,double);
-  BBTK_DECLARE_INPUT(In0,std::vector<double>);
-  BBTK_DECLARE_INPUT(In1,std::vector<double>);
-  BBTK_DECLARE_INPUT(In2,std::vector<double>);
-  BBTK_DECLARE_INPUT(In3,std::vector<double>);
-  BBTK_DECLARE_INPUT(In4,std::vector<double>);
-  BBTK_DECLARE_INPUT(In5,std::vector<double>);
-  BBTK_DECLARE_INPUT(In6,std::vector<double>);
-  BBTK_DECLARE_INPUT(In7,std::vector<double>);
-  BBTK_DECLARE_INPUT(In8,std::vector<double>);
-  BBTK_DECLARE_INPUT(In9,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out0,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out1,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out2,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out3,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out4,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out5,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out6,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out7,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out8,std::vector<double>);
-  BBTK_DECLARE_OUTPUT(Out9,std::vector<double>);
-  BBTK_PROCESS(Process);
+    BBTK_DECLARE_INPUT(Type,int);
+    BBTK_DECLARE_INPUT(k1,std::vector<double>);
+    BBTK_DECLARE_INPUT(In0,std::vector<double>);
+    BBTK_DECLARE_INPUT(In1,std::vector<double>);
+    BBTK_DECLARE_INPUT(In2,std::vector<double>);
+    BBTK_DECLARE_INPUT(In3,std::vector<double>);
+    BBTK_DECLARE_INPUT(In4,std::vector<double>);
+    BBTK_DECLARE_INPUT(In5,std::vector<double>);
+    BBTK_DECLARE_INPUT(In6,std::vector<double>);
+    BBTK_DECLARE_INPUT(In7,std::vector<double>);
+    BBTK_DECLARE_INPUT(In8,std::vector<double>);
+    BBTK_DECLARE_INPUT(In9,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out0,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out1,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out2,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out3,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out4,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out5,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out6,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out7,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out8,std::vector<double>);
+    BBTK_DECLARE_OUTPUT(Out9,std::vector<double>);
+    BBTK_PROCESS(Process);
   void Process();
 //===== 
 // 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)
@@ -52,8 +52,8 @@ 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 k1, 4=Substraction k1, 5=Multilication k1, 6=Division k1, 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. In3PointXYZ In0LstX In1LstY In2LstZ  (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,Type,"default (0)  0=Erase duplicated lines, 1=Redimention Vectors, 2=Insert intermediat points,3=Adition k1, 4=Substraction k1, 5=Multilication k1, 6=Division k1, 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. In3PointXYZ In0LstX In1LstY In2LstZ  (Out0-index Out1-PointXYZ), 11=Mul Spacing (K1[spcX,spcY,spcZ]=Spacing), 12=Div Spacing (K1[spcX,spcY,spcZ]=Spacing)",int,"");
+  BBTK_INPUT(VectorFilterDouble,k1,"(default [0])  nothing (Type0), k1[0]=new size vectors (Type 1) , nothing (Type2), k1[0] = Addition const. (Type 3), k1[0] = Substraction const. (Type 4), k1[0] = Multiplication const. (Type 5) , k1[0] = Division const. (Type 6)  , k1[spcX,spcY,spcZ] MulSpc In0_X,In1_Y,In2_Z (type 11),  k1[spcX,spcY,spcZ] DivSpc In0_X,In1_Y,In2_Z (type 12)  ",std::vector<double>,"");
   BBTK_INPUT(VectorFilterDouble,In0,"Input vector",std::vector<double>,"");
   BBTK_INPUT(VectorFilterDouble,In1,"Input vector",std::vector<double>,"");
   BBTK_INPUT(VectorFilterDouble,In2,"Input vector",std::vector<double>,"");