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 // THE MAIN PROCESSING METHOD BODY
20 // Here we simply set the input 'In' value to the output 'Out'
21 // And print out the output value
22 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
23 // void bbSet{Input|Output}NAME(const TYPE&)
24 // const TYPE& bbGet{Input|Output}NAME() const
26 // * NAME is the name of the input/output
27 // (the one provided in the attribute 'name' of the tag 'input')
28 // * TYPE is the C++ type of the input/output
29 // (the one provided in the attribute 'type' of the tag 'input')
31 if ( bbGetInputInLst().size()>0 )
34 vtkImageData *resultImage=NULL;
35 bbGetInputInLst()[0]->GetExtent( extImage );
36 int dimXImage = extImage[1]-extImage[0]+1;
37 int dimYImage = extImage[3]-extImage[2]+1;
38 int dimZImage = extImage[5]-extImage[4]+1;
39 if (bbGetOutputOut()!=NULL)
41 bbGetOutputOut()->Delete();
43 resultImage = vtkImageData::New();
44 resultImage->Initialize();
45 resultImage->SetSpacing( bbGetInputInLst()[0]->GetSpacing() );
46 resultImage->SetDimensions( dimXImage, dimYImage, dimZImage );
47 resultImage->AllocateScalars( bbGetInputInLst()[0]->GetScalarType(),1 );
48 long int index,size=dimXImage*dimYImage*dimZImage;
49 DEF_POINTER_IMAGE_VTK_CREA(vOut,ssOut,pOut,stOut,resultImage )
50 if ((bbGetInputType()==20) || (bbGetInputType()==21) )
53 long int k1omp=(double)(size-1)*0.0;
54 long int k2omp=(double)(size-1)*0.2;
55 long int k3omp=(double)(size-1)*0.4;
56 long int k4omp=(double)(size-1)*0.6;
57 long int k5omp=(double)(size-1)*0.8;
58 long int k6omp=(double)(size-1)*1.0;
60 printf("EED MultipleOperations::Process (with openmp)\n");
61 #pragma omp parallel for
63 for (index=0;index<size;index++)
65 if ( (k1omp==index) || (k2omp==index) || (k3omp==index) ||
66 (k4omp==index) || (k5omp==index) || (k6omp==index) ) { printf(" %d%\n", (int)(((double)index/(double)(size-1))*100 )); }
68 DEF_POINTER_IMAGE_VTK_CREA(vIn ,ssIn ,pIn ,stIn ,bbGetInputInLst()[0] )
70 int iLst,sizeLst= bbGetInputInLst().size();
75 for ( iLst=0 ; iLst < sizeLst ; iLst++ ) // volumes
77 pIn=(char*)( bbGetInputInLst()[iLst]->GetScalarPointer() );
78 GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
81 if (bbGetInputType()==20)
83 acumDiff = acumDiff+abs(vIn-vInBack);
86 if (bbGetInputType()==21)
88 acumDiff = acumDiff+vIn;
92 acumDiff = acumDiff/sizeLst;
93 SETVALUE2_VTK_CREA(acumDiff,pOut,stOut,index)
96 bbSetOutputOut( resultImage );
100 // 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 void MultipleOperations::bbUserSetDefaultValues()
105 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
106 // Here we initialize the input 'In' to 0
109 bbSetOutputOut(NULL);
113 // 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 void MultipleOperations::bbUserInitializeProcessing()
118 // THE INITIALIZATION METHOD BODY :
120 // but this is where you should allocate the internal/output pointers
126 // 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)
128 void MultipleOperations::bbUserFinalizeProcessing()
131 // THE FINALIZATION METHOD BODY :
133 // but this is where you should desallocate the internal/output pointers
138 // EO namespace bbcreaVtk