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 "bbcreaVtkApplyMask.h"
5 #include "bbcreaVtkPackage.h"
7 #include "creaVtk_MACROS.h"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ApplyMask)
13 BBTK_BLACK_BOX_IMPLEMENTATION(ApplyMask,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 ApplyMask::Process()
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 // bbSetOutputOut( bbGetInputIn() );
33 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35 if ((bbGetInputImage()!=NULL) && (bbGetInputMask()!=NULL))
38 bbGetInputImage()->GetExtent( extImage );
39 int dimXImage = extImage[1]-extImage[0]+1;
40 int dimYImage = extImage[3]-extImage[2]+1;
41 int dimZImage = extImage[5]-extImage[4]+1;
44 bbGetInputImage()->GetExtent( extMask );
45 int dimXMask = extMask[1]-extMask[0]+1;
46 int dimYMask = extMask[3]-extMask[2]+1;
47 int dimZMask = extMask[5]-extMask[4]+1;
50 if (bbGetOutputOut()!=NULL)
52 bbGetOutputOut()->Delete();
55 vtkImageData *resultImage=NULL;
56 resultImage = vtkImageData::New();
57 resultImage->Initialize();
58 resultImage->SetSpacing( bbGetInputImage()->GetSpacing() );
59 resultImage->SetDimensions( dimXImage, dimYImage, dimZImage );
60 resultImage->AllocateScalars( bbGetInputImage()->GetScalarType(),1 );
63 if ((dimXImage==dimXMask) &&
64 (dimYImage==dimYMask) &&
65 (dimZImage==dimZMask))
69 long int i, size = dimXImage * dimYImage * dimZImage;
70 #pragma omp parallel for
74 DEF_POINTER_IMAGE_VTK_CREA(vI,ssI,pI,stI, bbGetInputImage() );
75 DEF_POINTER_IMAGE_VTK_CREA(vM,ssM,pM,stM, bbGetInputMask() );
76 DEF_POINTER_IMAGE_VTK_CREA(vO,ssO,pO,stO, resultImage );
78 GETVALUE2_VTK_CREA(vI,pI,stI,i);
79 GETVALUE2_VTK_CREA(vM,pM,stM,i);
84 vO = bbGetInputBackground();
86 SETVALUE2_VTK_CREA(vO,pO,stO,i);
89 bbSetOutputOut( resultImage );
94 // 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)
96 void ApplyMask::bbUserSetDefaultValues()
99 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
100 // Here we initialize the input 'In' to 0
101 bbSetInputImage(NULL);
102 bbSetInputMask(NULL);
103 bbSetInputBackground(0);
104 bbSetOutputOut(NULL);
108 // 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)
110 void ApplyMask::bbUserInitializeProcessing()
113 // THE INITIALIZATION METHOD BODY :
115 // but this is where you should allocate the internal/output pointers
121 // 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)
123 void ApplyMask::bbUserFinalizeProcessing()
126 // THE FINALIZATION METHOD BODY :
128 // but this is where you should desallocate the internal/output pointers
133 // EO namespace bbcreaVtk