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)
4 #include "bbcreaVtkMultipleOperations.h"
5 #include "bbcreaVtkPackage.h"
7 #include "creaVtk_MACROS.h"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MultipleOperations)
13 BBTK_BLACK_BOX_IMPLEMENTATION(MultipleOperations,bbtk::AtomicBlackBox);
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)
17 void MultipleOperations::Process()
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
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')
32 if ( bbGetInputInLst().size()>0 )
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)
43 bbGetOutputOut()->Delete();
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)
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++)
60 for (iLst=0;iLst<sizeLst;iLst++) // volumes
62 pIn=(char*)( bbGetInputInLst()[iLst]->GetScalarPointer() );
63 GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
66 acumDiff = acumDiff+abs(vIn-vInBack);
70 acumDiff = acumDiff/sizeLst;
71 SETVALUE2_VTK_CREA(acumDiff,pOut,stOut,index)
74 bbSetOutputOut( resultImage );
76 printf("EED MultipleOperations::Process End\n");
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)
82 void MultipleOperations::bbUserSetDefaultValues()
85 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
86 // Here we initialize the input 'In' to 0
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)
95 void MultipleOperations::bbUserInitializeProcessing()
98 // THE INITIALIZATION METHOD BODY :
100 // but this is where you should allocate the internal/output pointers
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)
108 void MultipleOperations::bbUserFinalizeProcessing()
111 // THE FINALIZATION METHOD BODY :
113 // but this is where you should desallocate the internal/output pointers
118 // EO namespace bbcreaVtk