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 if (bbGetInputIn()!=NULL)
39 bbGetInputIn()->GetExtent(ext);
40 dim[0] = ext[1]-ext[0]+1;
41 dim[1] = ext[3]-ext[2]+1;
42 dim[2] = ext[5]-ext[4]+1;
44 bbGetInputIn()->GetSpacing(spc);
46 vtkImageData *newImage = vtkImageData::New();
47 newImage->Initialize();
48 if (bbGetInputDir()==1)
50 newImage->SetSpacing( spc[1],spc[2],spc[0] );
51 newImage->SetDimensions( dim[1],dim[2], dim[0] );
52 } else if (bbGetInputDir()==2)
54 newImage->SetSpacing( spc[0],spc[2],spc[1] );
55 newImage->SetDimensions( dim[0],dim[2], dim[1] );
57 newImage->SetSpacing( spc[0],spc[1],spc[2] );
58 newImage->SetDimensions( dim[0],dim[1], dim[2] );
61 //EED 2017-01-01 Migration VTK7
62 #if (VTK_MAJOR_VERSION <= 5)
63 newImage->SetScalarType( bbGetInputIn()->GetScalarType() );
64 newImage->SetNumberOfScalarComponents(1);
65 newImage->AllocateScalars();
67 #if (VTK_MAJOR_VERSION >= 6)
68 newImage->AllocateScalars( bbGetInputIn()->GetScalarType(),1 );
71 DEF_POINTER_IMAGE_VTK_CREA(vIn,ssIn,pIn,stIn,bbGetInputIn())
72 DEF_POINTER_IMAGE_VTK_CREA(vNI,ssNI,pNI,stNI,newImage)
77 for (k=0;k<dim[2];k++)
79 for (j=0;j<dim[1];j++)
81 for (i=0;i<dim[0];i++)
83 GETVALUE2_VTK_CREA(vIn,pIn,stIn,index)
84 // value = bbGetInputIn()->GetScalarComponentAsDouble (i,j,k,0);
85 if (bbGetInputDir()==1)
87 SETVALUE2_VTK_CREA(vIn,pNI,stNI, j + (dim[2]-k-1)*dim[1] + i*dim[1]*dim[2] )
88 // newImage->SetScalarComponentFromDouble(j,dim[2]-k-1,i,0,value);
89 } else if (bbGetInputDir()==2)
91 SETVALUE2_VTK_CREA(vIn,pNI,stNI, i + (dim[2]-k-1)*dim[0] + j*dim[0]*dim[2] )
92 // newImage->SetScalarComponentFromDouble(i,dim[2]-k-1,j,0,value);
94 SETVALUE2_VTK_CREA(vIn,pNI,stNI,index)
95 // newImage->SetScalarComponentFromDouble(i,j,k,0,value);
101 bbSetOutputOut(newImage);
103 bbSetOutputOut(NULL);
107 // 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)
109 void TurnImage::bbUserSetDefaultValues()
112 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
113 // Here we initialize the input 'In' to 0
119 // 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)
121 void TurnImage::bbUserInitializeProcessing()
124 // THE INITIALIZATION METHOD BODY :
126 // but this is where you should allocate the internal/output pointers
132 // 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)
134 void TurnImage::bbUserFinalizeProcessing()
137 // THE FINALIZATION METHOD BODY :
139 // but this is where you should desallocate the internal/output pointers
144 // EO namespace bbcreaVtk