2 // Don't edit this file. This file is generated from xml description..
4 #include "bbvtkRescaleSlopeIntercept.h"
5 #include "bbvtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,RescaleSlopeIntercept)
10 BBTK_BLACK_BOX_IMPLEMENTATION(RescaleSlopeIntercept,bbtk::AtomicBlackBox);
12 // Don't edit this file. This file is generated from xml description..
14 void RescaleSlopeIntercept::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')
28 // bbSetOutputOut( bbGetInputIn() );
29 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
38 double A=bbGetInputA();
39 double B=bbGetInputB();
41 if (bbGetInputIn()!=0)
43 if (bbGetInputOutputFormat()=="SAME") outputformat = bbGetInputIn()->GetScalarType();
44 else if (bbGetInputOutputFormat()=="VTK_BIT") outputformat = VTK_BIT;
45 else if (bbGetInputOutputFormat()=="VTK_CHAR") outputformat = VTK_CHAR;
46 else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR;
47 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR;
48 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT;
49 else if (bbGetInputOutputFormat()=="VTK_INT") outputformat = VTK_INT;
50 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT;
51 else if (bbGetInputOutputFormat()=="VTK_LONG") outputformat = VTK_LONG;
52 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG;
53 else if (bbGetInputOutputFormat()=="VTK_FLOAT") outputformat = VTK_FLOAT;
54 else if (bbGetInputOutputFormat()=="VTK_DOUBLE") outputformat = VTK_DOUBLE;
56 imageoutput->Initialize();
57 imageoutput->SetScalarType( outputformat );
58 bbGetInputIn()->GetScalarRange(range);
59 bbGetInputIn()->GetSpacing(spc);
60 imageoutput->SetSpacing( spc );
61 bbGetInputIn()->GetWholeExtent(ext);
62 dim[0]=ext[1]-ext[0]+1;
63 dim[1]=ext[3]-ext[2]+1;
64 dim[2]=ext[5]-ext[4]+1;
65 imageoutput->SetDimensions( dim[0] , dim[1], dim[2] );
66 imageoutput->AllocateScalars();
68 double range0plusrange1 = range[0]+range[1];
69 double difrange = range[1]-range[0];
70 double newdifrange = B-A;
73 for (i=0; i<dim[0]; i++)
75 for (j=0; j<dim[1]; j++)
77 for (k=0; k<dim[2]; k++)
79 value = bbGetInputIn()->GetScalarComponentAsDouble(i,j,k,0);
81 if (bbGetInputType()==0) // Rescale Slope/Intercept
86 if (bbGetInputType()==1) // Invert
88 newValue = value*(-1) + (range0plusrange1);
91 if (bbGetInputType()==2) // Redimension
93 newValue = ((value-range[0])/difrange)*newdifrange + A;
96 if (bbGetInputType()==3) // Invert redimension
98 newValue = ((value*(-1)+range[1])/difrange)*newdifrange + A;
101 imageoutput->SetScalarComponentFromDouble (i,j,k, 0, newValue);
106 bbSetOutputOut(imageoutput);
111 // Don't edit this file. This file is generated from xml description..
113 void RescaleSlopeIntercept::bbUserSetDefaultValues()
116 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
117 // Here we initialize the input 'In' to 0
122 bbSetInputOutputFormat("SAME");
126 // Don't edit this file. This file is generated from xml description..
128 void RescaleSlopeIntercept::bbUserInitializeProcessing()
131 // THE INITIALIZATION METHOD BODY :
133 // but this is where you should allocate the internal/output pointers
136 imageoutput = vtkImageData::New();
140 // Don't edit this file. This file is generated from xml description..
142 void RescaleSlopeIntercept::bbUserFinalizeProcessing()
145 // THE FINALIZATION METHOD BODY :
147 // but this is where you should desallocate the internal/output pointers
152 // EO namespace bbvtk