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 "bbstdVectorRescaleSlope.h"
5 #include "bbstdPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,VectorRescaleSlope)
10 BBTK_BLACK_BOX_IMPLEMENTATION(VectorRescaleSlope,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 VectorRescaleSlope::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')
30 std::vector<double> result;
33 double A=bbGetInputA();
34 double B=bbGetInputB();
37 // -------------------------------------------------
39 if (bbGetInputIn().size()>=1)
41 range[0]=bbGetInputIn()[0];
42 range[1]=bbGetInputIn()[0];
47 for (i=0; i<bbGetInputIn().size();i++)
49 if (range[0]>bbGetInputIn()[i])
51 range[0]=bbGetInputIn()[i];
53 if (range[1]<bbGetInputIn()[i])
55 range[1]=bbGetInputIn()[i];
60 // -------------------------------------------------
63 double range0plusrange1 = range[0]+range[1];
64 double difrange = range[1]-range[0];
65 double newdifrange = B-A;
69 if (bbGetInputType()==0) // Rescale Slope/Intercept
71 // newValue = value*A+B;
76 if (bbGetInputType()==1) // Invert
78 // newValue = value*(-1) + (range0plusrange1);
80 shift=range0plusrange1;
83 if (bbGetInputType()==2) // Redimension
85 // newValue = ((value-range[0])/difrange)*newdifrange + A;
86 scale=newdifrange/difrange;
87 shift= A - (range[0]*newdifrange/difrange);
90 if (bbGetInputType()==3) // Invert redimension
92 // newValue = ((value*(-1)+range[1])/difrange)*newdifrange + A;
93 scale=-newdifrange/difrange;
94 shift= A + (range[1]*newdifrange/difrange);
98 for (i=0; i<bbGetInputIn().size();i++)
100 result.push_back( bbGetInputIn()[i]*scale+shift );
103 bbSetOutputOut(result);
107 // 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)
109 void VectorRescaleSlope::bbUserSetDefaultValues()
112 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
113 // Here we initialize the input 'In' to 0
120 // 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)
122 void VectorRescaleSlope::bbUserInitializeProcessing()
125 // THE INITIALIZATION METHOD BODY :
127 // but this is where you should allocate the internal/output pointers
133 // 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)
135 void VectorRescaleSlope::bbUserFinalizeProcessing()
138 // THE FINALIZATION METHOD BODY :
140 // but this is where you should desallocate the internal/output pointers
145 // EO namespace bbstd