]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkTemporalPicker.cxx
1503 BUG
[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                         if ((px>=0) && (px<sizeX)  && (py>=0) && (py<sizeY) )
45                         {
46                                 int i,j,k;
47                                 int minX,maxX,minY,maxY;
48                                 int acum,numElem;
49                                 minX=px-bbGetInputSizeRegion()-1;
50                                 maxX=px+bbGetInputSizeRegion()-1;
51                                 minY=py-bbGetInputSizeRegion()-1;
52                                 maxY=py+bbGetInputSizeRegion()-1;
53                                 for (k=0;k<sizeZ;k++)
54                                 {
55                                         acum=0;
56                                         numElem=0;
57                                         for(i=minX;i<=maxX;i++)
58                                         { 
59                                                 for(j=minY;j<=maxY;j++)
60                                                 { 
61                                                         if ((i>=0) && (i<sizeX)  && (j>=0) && (j<sizeY) )
62                                                         { 
63                                                                 acum = acum + bbGetInputIn()->GetScalarComponentAsDouble(i, j, k, 0);
64                                                                 numElem++;
65                                                         }// i j
66                                                 }// for j
67                                         } // for i
68                                         
69                                         if (numElem>0) 
70                                         {
71                                                 result.push_back( acum/numElem );
72                                         } else {
73                                                 result.push_back( 0 );
74                                         } // numElem
75                                         
76                                 } // for k
77                         } // px py
78                         
79                 } else {// bbGetInputPoint
80                         printf("ERROR:  Input:Point is not good defined in TemporalPicker Box..\n ");
81                 } // bbGetInputPoint
82         } else {// bbGetInputIn
83                 printf("ERROR:  Missing Input:In vtkImageData* in TemporalPicker Box..\n ");
84         } // bbGetInputIn
85                 
86         bbSetOutputOut(result);
87 }
88 //===== 
89 // 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)
90 //===== 
91 void TemporalPicker::bbUserSetDefaultValues()
92 {
93
94 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
95 //    Here we initialize the input 'In' to 0
96         bbSetInputIn(NULL);
97         bbSetInputSizeRegion(1);
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 TemporalPicker::bbUserInitializeProcessing()
104 {
105
106 //  THE INITIALIZATION METHOD BODY :
107 //    Here does nothing 
108 //    but this is where you should allocate the internal/output pointers 
109 //    if any 
110
111   
112 }
113 //===== 
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)
115 //===== 
116 void TemporalPicker::bbUserFinalizeProcessing()
117 {
118
119 //  THE FINALIZATION METHOD BODY :
120 //    Here does nothing 
121 //    but this is where you should desallocate the internal/output pointers 
122 //    if any
123   
124 }
125 }
126 // EO namespace bbvtk
127
128