]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkLstOfVoxels.cxx
#3437creaVtkFeatureNewNormalConnectivity Filter (s) box and LstOfVoxels box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkLstOfVoxels.cxx
1 //===== 
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)
3 //===== 
4 #include "bbcreaVtkLstOfVoxels.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include "creaVtk_MACROS.h"
8
9 namespace bbcreaVtk
10 {
11
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,LstOfVoxels)
13 BBTK_BLACK_BOX_IMPLEMENTATION(LstOfVoxels,bbtk::AtomicBlackBox);
14 //===== 
15 // 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)
16 //===== 
17 void LstOfVoxels::Process() 
18 {
19
20 // THE MAIN PROCESSING METHOD BODY
21 //   Here we simply set the input 'In' value to the output 'Out'
22 //   And print out the output value
23 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
24 //    void bbSet{Input|Output}NAME(const TYPE&)
25 //    const TYPE& bbGet{Input|Output}NAME() const 
26 //    Where :
27 //    * NAME is the name of the input/output
28 //      (the one provided in the attribute 'name' of the tag 'input')
29 //    * TYPE is the C++ type of the input/output
30 //      (the one provided in the attribute 'type' of the tag 'input')
31   
32         if (bbGetInputIn()!=NULL) 
33         {
34                 DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn())                                            \
35                 std::vector<int> lstX;
36                 std::vector<int> lstY;
37                 std::vector<int> lstZ;
38                 std::vector<double> lstValues;
39                 int ext[6];
40                 bbGetInputIn()->GetExtent(ext);
41                 int dim[3];
42                 dim[0]=ext[1]-ext[0]+1;
43                 dim[1]=ext[3]-ext[2]+1;
44                 dim[2]=ext[5]-ext[4]+1;
45                 int i,j,k;
46                 long int index=0;
47
48
49                 int rangeType=0;
50                 if (bbGetInputRange().size()==2) 
51                 {
52                         rangeType=1;
53                 }
54                 bool addPoint;
55         
56
57                 for (k=0 ; k<dim[2] ; k++) 
58                 {
59                         for (j=0 ; j<dim[1] ; j++) 
60                         {
61                                 for (i=0 ; i<dim[0] ; i++) 
62                                 {
63                                         addPoint=false;
64                                         GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
65                                         if (rangeType==0) 
66                                         {
67                                                 if (vIn!=0) 
68                                                 {       
69                                                         addPoint=true;
70                                                 } // if vIn ==0
71                                         } else {
72                                                 if ( (vIn>=bbGetInputRange()[0]) && (vIn<=bbGetInputRange()[1]) ) 
73                                                 {       
74                                                         addPoint=true;
75                                                 } // if vIn ==0
76                                         } // if rangeType 
77
78
79                                         if (addPoint==true) 
80                                         {       
81                                                 lstX.push_back(i);
82                                                 lstY.push_back(j);
83                                                 lstZ.push_back(k);
84                                                 lstValues.push_back(vIn);
85                                         } // if vIn ==0
86
87                                         index++;
88                                 } // for i
89                         } // for j
90                 } // for k
91                 bbSetOutputLstX( lstX );
92                 bbSetOutputLstY( lstY );
93                 bbSetOutputLstZ( lstZ );
94                 bbSetOutputLstValues( lstValues );
95         } else {
96                 printf("EED Warning!!   LstOfVoxels image not set.\n");
97         }// In
98
99 }
100 //===== 
101 // 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)
102 //===== 
103 void LstOfVoxels::bbUserSetDefaultValues()
104 {
105
106 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
107 //    Here we initialize the input 'In' to 0
108    bbSetInputIn(NULL);
109   
110 }
111 //===== 
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)
113 //===== 
114 void LstOfVoxels::bbUserInitializeProcessing()
115 {
116
117 //  THE INITIALIZATION METHOD BODY :
118 //    Here does nothing 
119 //    but this is where you should allocate the internal/output pointers 
120 //    if any 
121
122   
123 }
124 //===== 
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)
126 //===== 
127 void LstOfVoxels::bbUserFinalizeProcessing()
128 {
129
130 //  THE FINALIZATION METHOD BODY :
131 //    Here does nothing 
132 //    but this is where you should desallocate the internal/output pointers 
133 //    if any
134   
135 }
136 }
137 // EO namespace bbcreaVtk
138
139