]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkMultipleOperations.cxx
#3353 creaVtk Feature New Normal - box MultipleOperations
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkMultipleOperations.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 "bbcreaVtkMultipleOperations.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,MultipleOperations)
13 BBTK_BLACK_BOX_IMPLEMENTATION(MultipleOperations,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 MultipleOperations::Process()
18 {
19 printf("EED MultipleOperations::Process Start\n");
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 ( bbGetInputInLst().size()>0 )
33         {
34                 int                     extImage[6];
35                 vtkImageData    *resultImage=NULL;
36                 bbGetInputInLst()[0]->GetExtent( extImage );
37                 int dimXImage   = extImage[1]-extImage[0]+1;
38                 int dimYImage   = extImage[3]-extImage[2]+1;
39                 int dimZImage   = extImage[5]-extImage[4]+1;
40                 int iLst,sizeLst= bbGetInputInLst().size();
41                 if (bbGetOutputOut()!=NULL) 
42                 {
43                         bbGetOutputOut()->Delete();
44                 }       
45                 resultImage = vtkImageData::New();
46                 resultImage->Initialize();
47                 resultImage->SetSpacing( bbGetInputInLst()[0]->GetSpacing() );
48                 resultImage->SetDimensions(  dimXImage, dimYImage, dimZImage );
49                 resultImage->AllocateScalars( bbGetInputInLst()[0]->GetScalarType(),1 );
50                 long int index,size=dimXImage*dimYImage*dimZImage;
51                 if (bbGetInputType()==20)
52                 {
53                         DEF_POINTER_IMAGE_VTK_CREA(vIn ,ssIn ,pIn ,stIn ,bbGetInputInLst()[0] )
54                         DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,resultImage )
55                         double vInBack,acumDiff;
56 //  #pragma omp parallel for
57                         for (index=0;index<size;index++)
58                         {
59                                 acumDiff=0;
60                                 for (iLst=0;iLst<sizeLst;iLst++) // volumes
61                                 {
62                                         pIn=(char*)( bbGetInputInLst()[iLst]->GetScalarPointer() );
63                                         GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
64                                         if (iLst!=0)
65                                         {
66                                                 acumDiff = acumDiff+abs(vIn-vInBack);
67                                         } 
68                                         vInBack=vIn;
69                                 } // for iLst
70                                 acumDiff = acumDiff/sizeLst;
71                                 SETVALUE2_VTK_CREA(acumDiff,pOut,stOut,index)
72                         } // for index
73                 } // if Type==20
74                 bbSetOutputOut( resultImage );
75         } // if InLst size
76 printf("EED MultipleOperations::Process End\n");
77
78 }
79 //===== 
80 // 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)
81 //===== 
82 void MultipleOperations::bbUserSetDefaultValues()
83 {
84
85 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
86 //    Here we initialize the input 'In' to 0
87   
88    bbSetInputType(0);
89    bbSetOutputOut(NULL);
90
91 }
92 //===== 
93 // 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)
94 //===== 
95 void MultipleOperations::bbUserInitializeProcessing()
96 {
97
98 //  THE INITIALIZATION METHOD BODY :
99 //    Here does nothing 
100 //    but this is where you should allocate the internal/output pointers 
101 //    if any 
102
103   
104 }
105 //===== 
106 // 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)
107 //===== 
108 void MultipleOperations::bbUserFinalizeProcessing()
109 {
110
111 //  THE FINALIZATION METHOD BODY :
112 //    Here does nothing 
113 //    but this is where you should desallocate the internal/output pointers 
114 //    if any
115   
116 }
117 }
118 // EO namespace bbcreaVtk
119
120