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 "bbcreaVtkTurnImage.h"
5 #include "bbcreaVtkPackage.h"
7 #include "creaVtk_MACROS.h"
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,TurnImage)
13 BBTK_BLACK_BOX_IMPLEMENTATION(TurnImage,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 TurnImage::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')
31 // bbSetOutputOut( bbGetInputIn() );
32 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35 printf("EED TurnImage::Proces Start\n");
38 if (bbGetInputIn()!=NULL)
42 bbGetInputIn()->GetExtent(ext);
43 dim[0] = ext[1]-ext[0]+1;
44 dim[1] = ext[3]-ext[2]+1;
45 dim[2] = ext[5]-ext[4]+1;
47 bbGetInputIn()->GetSpacing(spc);
49 vtkImageData *newImage = vtkImageData::New();
50 newImage->Initialize();
51 if (bbGetInputDir()==1)
53 newImage->SetSpacing( spc[1],spc[2],spc[0] );
54 newImage->SetDimensions( dim[1],dim[2], dim[0] );
55 } else if (bbGetInputDir()==2)
57 newImage->SetSpacing( spc[0],spc[2],spc[1] );
58 newImage->SetDimensions( dim[0],dim[2], dim[1] );
60 newImage->SetSpacing( spc[0],spc[1],spc[2] );
61 newImage->SetDimensions( dim[0],dim[1], dim[2] );
64 //EED 2017-01-01 Migration VTK7
65 #if (VTK_MAJOR_VERSION <= 5)
66 newImage->SetScalarType( bbGetInputIn()->GetScalarType() );
67 newImage->SetNumberOfScalarComponents(1);
68 newImage->AllocateScalars();
70 #if (VTK_MAJOR_VERSION >= 6)
71 newImage->AllocateScalars( bbGetInputIn()->GetScalarType(),1 );
74 DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn())
75 DEF_POINTER_IMAGE_VTK_CREA(vNI,ssNI,pNI,stNI,newImage)
80 for (k=0;k<dim[2];k++)
82 for (j=0;j<dim[1];j++)
84 for (i=0;i<dim[0];i++)
86 GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
87 // value = bbGetInputIn()->GetScalarComponentAsDouble (i,j,k,0);
88 if (bbGetInputDir()==1)
90 SETVALUE2_VTK_CREA(vIn,pNI,stNI, j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2] )
91 // newImage->SetScalarComponentFromDouble(j,dim[2]-k-1,i,0,value);
92 } else if (bbGetInputDir()==2)
94 SETVALUE2_VTK_CREA(vIn,pNI,stNI, i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2] )
95 // newImage->SetScalarComponentFromDouble(i,dim[2]-k-1,j,0,value);
97 SETVALUE2_VTK_CREA(vIn,pNI,stNI,index)
98 // newImage->SetScalarComponentFromDouble(i,j,k,0,value);
104 bbSetOutputOut(newImage);
106 bbSetOutputOut(NULL);
109 printf("EED TurnImage::Proces End\n");
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 TurnImage::bbUserSetDefaultValues()
118 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
119 // Here we initialize the input 'In' to 0
125 // 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)
127 void TurnImage::bbUserInitializeProcessing()
130 // THE INITIALIZATION METHOD BODY :
132 // but this is where you should allocate the internal/output pointers
138 // 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)
140 void TurnImage::bbUserFinalizeProcessing()
143 // THE FINALIZATION METHOD BODY :
145 // but this is where you should desallocate the internal/output pointers
150 // EO namespace bbcreaVtk