2 // 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)
4 #include "bbstdVectorFilterDouble.h"
5 #include "bbstdPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,VectorFilterDouble)
10 BBTK_BLACK_BOX_IMPLEMENTATION(VectorFilterDouble,bbtk::AtomicBlackBox);
12 // 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)
14 void VectorFilterDouble::Process()
17 // THE MAIN PROCESSING METHOD BODY
18 // Here we simply set the input 'In' value to the output 'Out'
19 // And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 // void bbSet{Input|Output}NAME(const TYPE&)
22 // const TYPE& bbGet{Input|Output}NAME() const
24 // * NAME is the name of the input/output
25 // (the one provided in the attribute 'name' of the tag 'input')
26 // * TYPE is the C++ type of the input/output
27 // (the one provided in the attribute 'type' of the tag 'input')
29 std::vector< std::vector<double> * > pLstVec;
30 std::vector< std::vector<double> * > pLstVecOut;
31 std::vector<double> In0 = bbGetInputIn0();
32 std::vector<double> In1 = bbGetInputIn1();
33 std::vector<double> In2 = bbGetInputIn2();
34 std::vector<double> In3 = bbGetInputIn3();
35 std::vector<double> In4 = bbGetInputIn4();
36 std::vector<double> In5 = bbGetInputIn5();
37 std::vector<double> In6 = bbGetInputIn6();
38 std::vector<double> In7 = bbGetInputIn7();
39 std::vector<double> In8 = bbGetInputIn8();
40 std::vector<double> In9 = bbGetInputIn9();
42 if (bbGetInputIn0().size()!=0) { pLstVec.push_back( &In0 ); }
43 if (bbGetInputIn1().size()!=0) { pLstVec.push_back( &In1 ); }
44 if (bbGetInputIn2().size()!=0) { pLstVec.push_back( &In2 ); }
45 if (bbGetInputIn3().size()!=0) { pLstVec.push_back( &In3 ); }
46 if (bbGetInputIn4().size()!=0) { pLstVec.push_back( &In4 ); }
47 if (bbGetInputIn5().size()!=0) { pLstVec.push_back( &In5 ); }
48 if (bbGetInputIn6().size()!=0) { pLstVec.push_back( &In6 ); }
49 if (bbGetInputIn7().size()!=0) { pLstVec.push_back( &In7 ); }
50 if (bbGetInputIn8().size()!=0) { pLstVec.push_back( &In8 ); }
51 if (bbGetInputIn9().size()!=0) { pLstVec.push_back( &In9 ); }
53 std::vector<double> Out0;
54 std::vector<double> Out1;
55 std::vector<double> Out2;
56 std::vector<double> Out3;
57 std::vector<double> Out4;
58 std::vector<double> Out5;
59 std::vector<double> Out6;
60 std::vector<double> Out7;
61 std::vector<double> Out8;
62 std::vector<double> Out9;
64 pLstVecOut.push_back( &Out0 );
65 pLstVecOut.push_back( &Out1 );
66 pLstVecOut.push_back( &Out2 );
67 pLstVecOut.push_back( &Out3 );
68 pLstVecOut.push_back( &Out4 );
69 pLstVecOut.push_back( &Out5 );
70 pLstVecOut.push_back( &Out6 );
71 pLstVecOut.push_back( &Out7 );
72 pLstVecOut.push_back( &Out8 );
73 pLstVecOut.push_back( &Out9 );
76 if (bbGetInputType()==0) // Erase duplicate lines
80 for (ipLstvec=1;ipLstvec<pLstVec.size();ipLstvec++)
82 if ( (*pLstVec[ipLstvec]).size()!=(*pLstVec[0]).size() ) { okSizeVec=false; }
84 if ( okSizeVec==false)
86 printf("EED VectorFilterDouble::Process WARNING! vectors are not of the same size.\n");
91 for (iLine=0 ; iLine < (*pLstVec[0]).size() ; iLine++ )
94 for ( ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
96 if ( (*pLstVec[ipLstvec2])[iLine]!=(*pLstVec[ipLstvec2])[iLine-1] ) { okLine=true; }
99 if ( (okLine==true) || (iLine==0) )
101 for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
103 (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[iLine] );
111 if (bbGetInputType()==1) // Resize vector
115 int sizeLines = (*pLstVec[0]).size();
116 double step = (double)sizeLines/(double)bbGetInputk1();
117 for (iLine=0 ; iLine<sizeLines ; iLine=iLine+step)
119 for (ipLstvec2=0 ; ipLstvec2<pLstVec.size() ; ipLstvec2++)
121 (*pLstVecOut[ipLstvec2]).push_back( (*pLstVec[ipLstvec2])[(int)iLine] );
126 if (bbGetInputType()==2) // Insert intermediate points
132 for (ipLstvec=0 ; ipLstvec<pLstVec.size() ; ipLstvec++)
134 size=(*pLstVec[ipLstvec]).size();
137 for (i=0;i<size-1;i++)
139 (*pLstVecOut[ipLstvec]).push_back( (*pLstVec[ipLstvec])[i] ); // First item
140 result=((*pLstVec[ipLstvec])[i] + (*pLstVec[ipLstvec])[i+1] ) / 2;
141 (*pLstVecOut[ipLstvec]).push_back( result );
143 (*pLstVecOut[ipLstvec]).push_back( (*pLstVec[ipLstvec])[size-1] ); // Last item
149 if (bbGetInputType()==3) // Addition k1
155 for (ipLstvec=0 ; ipLstvec<pLstVec.size() ; ipLstvec++)
157 size=(*pLstVec[ipLstvec]).size();
160 result= (*pLstVec[ipLstvec])[i] + bbGetInputk1() ;
161 (*pLstVecOut[ipLstvec]).push_back( result );
166 if (bbGetInputType()==4) // Substraction k1
172 for (ipLstvec=0 ; ipLstvec<pLstVec.size() ; ipLstvec++)
174 size=(*pLstVec[ipLstvec]).size();
177 result= (*pLstVec[ipLstvec])[i] - bbGetInputk1() ;
178 (*pLstVecOut[ipLstvec]).push_back( result );
183 if (bbGetInputType()==5) // Multiplication k1
189 for (ipLstvec=0 ; ipLstvec<pLstVec.size() ; ipLstvec++)
191 size=(*pLstVec[ipLstvec]).size();
194 result= (*pLstVec[ipLstvec])[i] * bbGetInputk1() ;
195 (*pLstVecOut[ipLstvec]).push_back( result );
200 if (bbGetInputType()==6) // Division k1
206 for (ipLstvec=0 ; ipLstvec<pLstVec.size() ; ipLstvec++)
208 size=(*pLstVec[ipLstvec]).size();
211 if (bbGetInputk1()!=0)
213 result= (*pLstVec[ipLstvec])[i] / bbGetInputk1() ;
214 (*pLstVecOut[ipLstvec]).push_back( result );
216 printf("EED VectorFilterDouble::Process Warning!! Div by 0 in Type 6 \n");
217 (*pLstVecOut[ipLstvec]).push_back( -1 );
223 bbSetOutputOut0( Out0 );
224 bbSetOutputOut1( Out1 );
225 bbSetOutputOut2( Out2 );
226 bbSetOutputOut3( Out3 );
227 bbSetOutputOut4( Out4 );
228 bbSetOutputOut5( Out5 );
229 bbSetOutputOut6( Out6 );
230 bbSetOutputOut7( Out7 );
231 bbSetOutputOut8( Out8 );
232 bbSetOutputOut9( Out9 );
235 // 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)
237 void VectorFilterDouble::bbUserSetDefaultValues()
240 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
241 // Here we initialize the input 'In' to 0
247 // 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)
249 void VectorFilterDouble::bbUserInitializeProcessing()
252 // THE INITIALIZATION METHOD BODY :
254 // but this is where you should allocate the internal/output pointers
260 // 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)
262 void VectorFilterDouble::bbUserFinalizeProcessing()
265 // THE FINALIZATION METHOD BODY :
267 // but this is where you should desallocate the internal/output pointers
272 // EO namespace bbstd