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 "bbvtkCreateImage.h"
5 #include "bbvtkPackage.h"
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,CreateImage)
10 BBTK_BLACK_BOX_IMPLEMENTATION(CreateImage,bbtk::AtomicBlackBox);
12 // 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)
14 void CreateImage::Process()
17 // THE MAIN PROCESSING METHOD BODY
18 // Here we simply set the input 'In' value to the output 'Out'
19 // And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 // void bbSet{Input|Output}NAME(const TYPE&)
22 // const TYPE& bbGet{Input|Output}NAME() const
24 // * NAME is the name of the input/output
25 // (the one provided in the attribute 'name' of the tag 'input')
26 // * TYPE is the C++ type of the input/output
27 // (the one provided in the attribute 'type' of the tag 'input')
32 int outputformat = VTK_UNSIGNED_SHORT;
34 if (bbGetInputOutputFormat()=="VTK_BIT") outputformat = VTK_BIT;
35 else if (bbGetInputOutputFormat()=="VTK_CHAR") outputformat = VTK_CHAR;
36 else if (bbGetInputOutputFormat()=="VTK_SIGNED_CHAR") outputformat = VTK_SIGNED_CHAR;
37 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_CHAR") outputformat = VTK_UNSIGNED_CHAR;
38 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_SHORT") outputformat = VTK_UNSIGNED_SHORT;
39 else if (bbGetInputOutputFormat()=="VTK_INT") outputformat = VTK_INT;
40 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_INT") outputformat = VTK_UNSIGNED_INT;
41 else if (bbGetInputOutputFormat()=="VTK_LONG") outputformat = VTK_LONG;
42 else if (bbGetInputOutputFormat()=="VTK_UNSIGNED_LONG") outputformat = VTK_UNSIGNED_LONG;
43 else if (bbGetInputOutputFormat()=="VTK_FLOAT") outputformat = VTK_FLOAT;
44 else if (bbGetInputOutputFormat()=="VTK_DOUBLE") outputformat = VTK_DOUBLE;
46 spc[0] = bbGetInputSpacing()[0];
47 spc[1] = bbGetInputSpacing()[1];
48 spc[2] = bbGetInputSpacing()[2];
50 dim[0] = bbGetInputDimensions()[0];
51 dim[1] = bbGetInputDimensions()[1];
52 dim[2] = bbGetInputDimensions()[2];
54 imageoutput->Initialize();
55 imageoutput->SetScalarType( outputformat );
56 imageoutput->SetSpacing( spc );
57 imageoutput->SetDimensions( dim[0], dim[1], dim[2] );
58 imageoutput->AllocateScalars();
62 for (i=0; i<dim[0]; i++)
64 for (j=0; j<dim[1]; j++)
66 for (k=0; k<dim[2]; k++)
68 imageoutput->SetScalarComponentFromDouble(i,j,k, 0, bbGetInputInitialValue() );
73 bbSetOutputOut(imageoutput);
78 // 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)
80 void CreateImage::bbUserSetDefaultValues()
84 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
89 std::vector<double> spc;
94 bbSetInputDimensions(dim);
95 bbSetInputSpacing(spc);
96 bbSetInputOutputFormat("VTK_UNSIGNED_SHORT");
97 bbSetInputInitialValue(0);
101 // 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)
103 void CreateImage::bbUserInitializeProcessing()
106 // THE INITIALIZATION METHOD BODY :
108 // but this is where you should allocate the internal/output pointers
111 imageoutput = vtkImageData::New();
116 // 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)
118 void CreateImage::bbUserFinalizeProcessing()
121 // THE FINALIZATION METHOD BODY :
123 // but this is where you should desallocate the internal/output pointers
125 imageoutput->Delete();
129 // EO namespace bbvtk