]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkNIFTIImageReader.cxx
#3526 Active option in HausdorffDistancePointSetFilter box
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkNIFTIImageReader.cxx
1 //===== 
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)
3 //===== 
4 #include "bbcreaVtkNIFTIImageReader.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include <vtkNIFTIImageReader.h>
8 #include <vtkStringArray.h>
9
10 namespace bbcreaVtk
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,NIFTIImageReader)
14 BBTK_BLACK_BOX_IMPLEMENTATION(NIFTIImageReader,bbtk::AtomicBlackBox);
15 //===== 
16 // 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 //===== 
18 void NIFTIImageReader::Process()
19 {
20
21 // THE MAIN PROCESSING METHOD BODY
22 //   Here we simply set the input 'In' value to the output 'Out'
23 //   And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 //    void bbSet{Input|Output}NAME(const TYPE&)
26 //    const TYPE& bbGet{Input|Output}NAME() const 
27 //    Where :
28 //    * NAME is the name of the input/output
29 //      (the one provided in the attribute 'name' of the tag 'input')
30 //    * TYPE is the C++ type of the input/output
31 //      (the one provided in the attribute 'type' of the tag 'input')
32 //    bbSetOutputOut( bbGetInputIn() );
33 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
34   
35     std::vector<vtkImageData*> lstImages;
36
37     if ( bbGetInputFileNames().size()>0 )
38     {
39         if (bbGetInputType()==0)
40         {
41             vtkNIFTIImageReader* reader=vtkNIFTIImageReader::New();
42             if ( bbGetInputFileNames().size()==1)
43             {
44                 reader->SetFileName( bbGetInputFileNames()[0].c_str() );
45                 reader->Update();
46             } else         {
47                 vtkStringArray *lstFileNames=vtkStringArray::New();
48                 int i,size=bbGetInputFileNames().size();
49                 for (i=0;i<size;i++)
50                 {
51                     lstFileNames->InsertNextValue( bbGetInputFileNames()[i].c_str() );
52                 } // for i
53                 reader->SetFileNames( lstFileNames );
54                 reader->Update();
55             } // FileNames
56             lstImages.push_back( reader->GetOutput() );
57         } // Type 0
58
59         if (bbGetInputType()==1)
60         {
61             int i,size=bbGetInputFileNames().size();
62             for (i=0;i<size;i++)
63             {
64                 vtkNIFTIImageReader* reader=vtkNIFTIImageReader::New();
65                 reader->SetFileName( bbGetInputFileNames()[i].c_str() );
66                 reader->Update();
67                 lstImages.push_back( reader->GetOutput() );
68             } // for i
69         } // Type 1
70     } // if
71         if (lstImages.size()>=1) { bbSetOutputOut( lstImages[0] ); } else {bbSetOutputOut( NULL ); }
72         bbSetOutputOutVector( lstImages );
73 }
74
75 //=====
76 // 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)
77 //===== 
78 void NIFTIImageReader::bbUserSetDefaultValues()
79 {
80 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
81 //    Here we initialize the input 'In' to 0
82    bbSetInputType(0);
83 }
84
85 //=====
86 // 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)
87 //===== 
88 void NIFTIImageReader::bbUserInitializeProcessing()
89 {
90 //  THE INITIALIZATION METHOD BODY :
91 //    Here does nothing 
92 //    but this is where you should allocate the internal/output pointers 
93 //    if any
94 }
95
96 //=====
97 // 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)
98 //===== 
99 void NIFTIImageReader::bbUserFinalizeProcessing()
100 {
101 //  THE FINALIZATION METHOD BODY :
102 //    Here does nothing 
103 //    but this is where you should desallocate the internal/output pointers 
104 //    if any
105 }
106
107 }// EO namespace bbcreaVtk
108
109