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 "bbcreaVtkWriteLstImages.h"
5 #include "bbcreaVtkPackage.h"
7 #include "vtkMetaImageWriter.h"
8 #include <vtkNIFTIImageWriter.h>
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,WriteLstImages)
13 BBTK_BLACK_BOX_IMPLEMENTATION(WriteLstImages,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 WriteLstImages::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 WriteLstImages::Process Start\n");
38 int i,size=bbGetInputLstImages().size();
41 printf(" EED WriteLstImages::Process i=%d\n",i );
43 txtNum=std::to_string(i);
44 while (txtNum.length()<=5)
49 inImg=bbGetInputLstImages()[i];
50 if (bbGetInputType()==0) // mhd
52 vtkMetaImageWriter* w = vtkMetaImageWriter::New();
53 w->SetInputData( inImg );
54 w->SetCompression( bbGetInputCompression() );
55 w->SetFileDimensionality(inImg->GetDataDimension()); // NTU
56 std::string filename = bbGetInputOutputDir()+"/"+bbGetInputFileName()+"-"+txtNum+".mhd";
57 w->SetFileName(filename.c_str());
62 if (bbGetInputType()==1) // NIFTI
64 vtkNIFTIImageWriter* w = vtkNIFTIImageWriter::New();
65 w->SetInputData( inImg );
66 std::string filename = bbGetInputOutputDir()+"/"+bbGetInputFileName()+"-"+txtNum+".nii";
67 w->SetFileName(filename.c_str());
75 printf("EED WriteLstImages::Process END\n");
79 // 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)
81 void WriteLstImages::bbUserSetDefaultValues()
84 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
85 // Here we initialize the input 'In' to 0
87 bbSetInputCompression(false);
88 bbSetInputFileName("void");
89 bbSetInputOutputDir(".");
92 // 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)
94 void WriteLstImages::bbUserInitializeProcessing()
97 // THE INITIALIZATION METHOD BODY :
99 // but this is where you should allocate the internal/output pointers
105 // 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)
107 void WriteLstImages::bbUserFinalizeProcessing()
110 // THE FINALIZATION METHOD BODY :
112 // but this is where you should desallocate the internal/output pointers
117 // EO namespace bbcreaVtk