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 "bbcreaVtkImageToLstPoints.h"
5 #include "bbcreaVtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ImageToLstPoints)
10 BBTK_BLACK_BOX_IMPLEMENTATION(ImageToLstPoints,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 ImageToLstPoints::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<int> lstX;
30 std::vector<int> lstY;
31 std::vector<int> lstZ;
32 std::vector<double> lstValues;
33 vtkImageData *img=bbGetInputIn();
39 dim[0] = ext[1]-ext[0]+1;
40 dim[1] = ext[3]-ext[2]+1;
41 dim[2] = ext[5]-ext[4]+1;
42 std::vector<int> lstExt = bbGetInputExtent();
46 for (int i=0; i<6; i++) lstExt.push_back( ext[i] );
49 if (lstExt[0]<0) lstExt[0] = 0;
50 if (lstExt[1]>=dim[0]) lstExt[1] = dim[0]-1;
51 if (lstExt[2]<0) lstExt[2] = 0;
52 if (lstExt[3]>=dim[1]) lstExt[3] = dim[1]-1;
53 if (lstExt[4]<0) lstExt[4] = 0;
54 if (lstExt[5]>=dim[2]) lstExt[5] = dim[2]-1;
57 img->GetScalarRange(range);
58 std::vector<double> lstRange = bbGetInputRange();
59 if (lstRange.size()!=2)
62 for (int i=0; i<2; i++) lstRange.push_back( range[i] );
65 double background=bbGetInputBackground();
68 for (z=lstExt[4] ; z<=lstExt[5] ; z++)
70 for (y=lstExt[2] ; y<=lstExt[3] ; y++)
72 for (x=lstExt[0] ; x<=lstExt[1] ; x++)
74 value = img->GetScalarComponentAsDouble(x,y,z,0);
75 if ((value>=lstRange[0]) && (value<=lstRange[1]))
80 lstValues.push_back(value);
82 if ( bbGetInputType() == 1 )
87 lstValues.push_back(background);
94 } // if bbGetInputIn()
95 bbSetOutputLstPointsX( lstX );
96 bbSetOutputLstPointsY( lstY );
97 bbSetOutputLstPointsZ( lstZ );
98 bbSetOutputLstValues( lstValues );
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 ImageToLstPoints::bbUserSetDefaultValues()
106 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
107 // Here we initialize the input 'In' to 0
110 bbSetInputBackground(0);
114 // 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)
116 void ImageToLstPoints::bbUserInitializeProcessing()
119 // THE INITIALIZATION METHOD BODY :
121 // but this is where you should allocate the internal/output pointers
127 // 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)
129 void ImageToLstPoints::bbUserFinalizeProcessing()
132 // THE FINALIZATION METHOD BODY :
134 // but this is where you should desallocate the internal/output pointers
139 // EO namespace bbcreaVtk