]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkTemporalPicker.cxx
933e2b2ca78d4d27b7016d4c1eba28f32a528203
[bbtk.git] / packages / vtk / src / bbvtkTemporalPicker.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 "bbvtkTemporalPicker.h"
5 #include "bbvtkPackage.h"
6 namespace bbvtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,TemporalPicker)
10 BBTK_BLACK_BOX_IMPLEMENTATION(TemporalPicker,bbtk::AtomicBlackBox);
11 //===== 
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)
13 //===== 
14 void TemporalPicker::Process()
15 {
16
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 
23 //    Where :
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
29         
30         std::vector<double> result;
31         if (bbGetInputIn()!=NULL)
32         {
33                 int ext[6];
34                 int sizeX,sizeY,sizeZ;
35                 bbGetInputIn()->GetWholeExtent(ext);
36                 sizeX=ext[1]-ext[0]+1;
37                 sizeY=ext[3]-ext[2]+1;
38                 sizeZ=ext[5]-ext[4]+1;
39                 
40                 if (bbGetInputPoint().size()>=2)
41                 {
42                         int px=bbGetInputPoint()[0];
43                         int py=bbGetInputPoint()[1];
44                         int pz=bbGetInputPoint()[2];
45                         
46                         if ((px>=0) && (px<sizeX)  && (py>=0) && (py<sizeY) )
47                         {
48                                 int i,j,k;
49                                 int minX,maxX,minY,maxY;
50                                 int acum,numElem;
51                                 minX=px-bbGetInputSizeRegion()-1;
52                                 maxX=px+bbGetInputSizeRegion()-1;
53                                 minY=py-bbGetInputSizeRegion()-1;
54                                 maxY=py+bbGetInputSizeRegion()-1;
55                                 for (k=0;k<sizeZ;k++)
56                                 {
57                                         acum=0;
58                                         numElem=0;
59                                         for(i=minX;i<=maxX;i++)
60                                         { 
61                                                 for(j=minY;j<=maxY;j++)
62                                                 { 
63                                                         if ((i>=0) && (i<sizeX)  && (j>=0) && (j<sizeY) )
64                                                         { 
65                                                                 acum = acum + bbGetInputIn()->GetScalarComponentAsDouble(i, j, k, 0);
66                                                                 numElem++;
67                                                         }// i j
68                                                 }// for j
69                                         } // for i
70                                         
71                                         if (numElem>0) 
72                                         {
73                                                 result.push_back( acum/numElem );
74                                         } else {
75                                                 result.push_back( 0 );
76                                         } // numElem
77                                         
78                                 } // for k
79                         } // px py
80                 } else {// bbGetInputPoint
81                         printf("ERROR:  Input:Point is not good defined in TemporalPicker Box..\n ");
82                 } // bbGetInputPoint
83         } else {// bbGetInputIn
84                 printf("ERROR:  Missing Input:In vtkImageData* in TemporalPicker Box..\n ");
85         } // bbGetInputIn
86
87         bbSetOutputOut(result);
88 }
89 //===== 
90 // 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)
91 //===== 
92 void TemporalPicker::bbUserSetDefaultValues()
93 {
94
95 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
96 //    Here we initialize the input 'In' to 0
97         bbSetInputIn(NULL);
98         bbSetInputSizeRegion(1);
99   
100 }
101 //===== 
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)
103 //===== 
104 void TemporalPicker::bbUserInitializeProcessing()
105 {
106
107 //  THE INITIALIZATION METHOD BODY :
108 //    Here does nothing 
109 //    but this is where you should allocate the internal/output pointers 
110 //    if any 
111
112   
113 }
114 //===== 
115 // 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 //===== 
117 void TemporalPicker::bbUserFinalizeProcessing()
118 {
119
120 //  THE FINALIZATION METHOD BODY :
121 //    Here does nothing 
122 //    but this is where you should desallocate the internal/output pointers 
123 //    if any
124   
125 }
126 }
127 // EO namespace bbvtk
128
129