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()
16 // THE MAIN PROCESSING METHOD BODY
17 // Here we simply set the input 'In' value to the output 'Out'
18 // And print out the output value
19 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
20 // void bbSet{Input|Output}NAME(const TYPE&)
21 // const TYPE& bbGet{Input|Output}NAME() const
23 // * NAME is the name of the input/output
24 // (the one provided in the attribute 'name' of the tag 'input')
25 // * TYPE is the C++ type of the input/output
26 // (the one provided in the attribute 'type' of the tag 'input')
28 // vtkImageData *m_image = vtkImageData::New();
29 // m_image = bbGetInputImage();
30 double grayLevel = -9999;
31 std::vector<double> coord = bbGetInputCoordinate();
35 if (bbGetInputImage()!=NULL)
38 bbGetInputImage()->GetSpacing(spc);
39 bbGetInputImage()->GetExtent(ext);
40 maxX = ext[1]-ext[0]+1;
41 maxY = ext[3]-ext[2]+1;
42 maxZ = ext[5]-ext[4]+1;
45 if (bbGetInputWithSpacing()==true)
58 if ( (px>=0) && (px<maxX) && (py>=0) && (py<maxY) &&(pz>=0) && (pz<maxZ) )
60 grayLevel = bbGetInputImage()->GetScalarComponentAsDouble( px,py,pz,0);
65 std::vector<double> lstGL;
66 std::vector<double> lstX = bbGetInputLstPointsX();
67 std::vector<double> lstY = bbGetInputLstPointsY();
68 std::vector<double> lstZ = bbGetInputLstPointsZ();
69 if ( (lstX.size()==lstY.size()) && (lstY.size()==lstZ.size()) )
71 long int i,size=lstX.size();
74 if (bbGetInputWithSpacing()==true)
88 if ( (px>=0) && (px<maxX) && (py>=0) && (py<maxY) &&(pz>=0) && (pz<maxZ) )
90 lstGL.push_back( bbGetInputImage()->GetScalarComponentAsDouble( px, py,pz,0) );
92 lstGL.push_back( -9991 );
95 bbSetOutputLstGrayLevel(lstGL);
98 bbSetOutputGrayLevel(grayLevel);
102 // 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)
104 void GrayLevel::bbUserSetDefaultValues()
106 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
107 // Here we initialize the input 'In' to 0
108 bbSetInputImage(NULL);
109 bbSetInputWithSpacing(false);
112 // 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)
114 void GrayLevel::bbUserInitializeProcessing()
117 // THE INITIALIZATION METHOD BODY :
119 // but this is where you should allocate the internal/output pointers
125 // 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)
127 void GrayLevel::bbUserFinalizeProcessing()
130 // THE FINALIZATION METHOD BODY :
132 // but this is where you should desallocate the internal/output pointers
137 // EO namespace bbcreaVtk