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