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 "bbcreaVtkGrayLevel.h"
5 #include "bbcreaVtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,GrayLevel)
10 BBTK_BLACK_BOX_IMPLEMENTATION(GrayLevel,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 GrayLevel::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 // vtkImageData *m_image = vtkImageData::New();
30 // m_image = bbGetInputImage();
32 double grayLevel = -9999;
33 std::vector<double> coord = bbGetInputCoordinate();
35 if (bbGetInputImage()!=NULL)
38 bbGetInputImage()->GetSpacing(spc);
41 if (bbGetInputWithSpacing()==true)
43 px = round(coord[0]/spc[0]);
44 py = round(coord[1]/spc[1]);
45 pz = round(coord[2]/spc[2]);
51 grayLevel = bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0);
53 std::vector<double> lstGL;
54 std::vector<double> lstX = bbGetInputLstPointsX();
55 std::vector<double> lstY = bbGetInputLstPointsY();
56 std::vector<double> lstZ = bbGetInputLstPointsZ();
57 if ( (lstX.size()==lstY.size()) && (lstY.size()==lstZ.size()) )
59 long int i,size=lstX.size();
62 if (bbGetInputWithSpacing()==true)
64 px = round(lstX[i]/spc[0]);
65 py = round(lstY[i]/spc[1]);
66 pz = round(lstZ[i]/spc[2]);
72 lstGL.push_back( bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0) );
74 bbSetOutputLstGrayLevel(lstGL);
77 bbSetOutputGrayLevel(grayLevel);
81 // 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)
83 void GrayLevel::bbUserSetDefaultValues()
85 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
86 // Here we initialize the input 'In' to 0
87 bbSetInputImage(NULL);
88 bbSetInputWithSpacing(false);
91 // 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)
93 void GrayLevel::bbUserInitializeProcessing()
96 // THE INITIALIZATION METHOD BODY :
98 // but this is where you should allocate the internal/output pointers
104 // 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)
106 void GrayLevel::bbUserFinalizeProcessing()
109 // THE FINALIZATION METHOD BODY :
111 // but this is where you should desallocate the internal/output pointers
116 // EO namespace bbcreaVtk