]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkMetaImageReader.cxx
d359bd3e1fb551cf73220f751b0c7346572e5174
[bbtk.git] / packages / vtk / src / bbvtkMetaImageReader.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 "bbvtkMetaImageReader.h"
5 #include "bbvtkPackage.h"
6
7 #include "vtkMetaImageReader.h"
8
9 namespace bbvtk
10 {
11
12 BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MetaImageReader)
13 BBTK_BLACK_BOX_IMPLEMENTATION(MetaImageReader,bbtk::AtomicBlackBox);
14
15
16 void MetaImageReader::Read_mhdb( std::string filename )
17 {
18         printf("EED MetaImageReader::Read_mhdb \n");
19 }
20
21
22 //===== 
23 // 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)
24 //===== 
25 void MetaImageReader::Process()
26 {
27
28 // THE MAIN PROCESSING METHOD BODY
29 //   Here we simply set the input 'In' value to the output 'Out'
30 //   And print out the output value
31 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
32 //    void bbSet{Input|Output}NAME(const TYPE&)
33 //    const TYPE& bbGet{Input|Output}NAME() const 
34 //    Where :
35 //    * NAME is the name of the input/output
36 //      (the one provided in the attribute 'name' of the tag 'input')
37 //    * TYPE is the C++ type of the input/output
38 //      (the one provided in the attribute 'type' of the tag 'input')
39
40 //    bbSetOutputOut( bbGetInputIn() );
41 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
42
43     if (bbGetInputIn().length()!=0)
44     {
45         if (bbGetInputIn().substr(bbGetInputIn().size()-5) == ".mhdb")
46         {
47             Read_mhdb( bbGetInputIn() );
48         } else {
49             FILE *ff = fopen( bbGetInputIn().c_str() , "r" );
50             if (ff)
51             {
52                 fclose(ff);
53                 vtkMetaImageReader *reader = vtkMetaImageReader::New();
54                 reader->SetFileName( bbGetInputIn().c_str() );
55                 reader->Update();
56                 bbSetOutputOut( reader->GetOutput() );
57             } else {
58                 bbSetOutputOut(NULL);
59             } // ff
60         }// .mhdb
61     } else {
62         bbSetOutputOut(NULL);
63     } // if In.length
64 }
65
66 //===== 
67 // 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)
68 //===== 
69 void MetaImageReader::bbUserSetDefaultValues()
70 {
71
72 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
73 //    Here we initialize the input 'In' to 0
74    bbSetInputIn("");
75   
76 }
77 //===== 
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)
79 //===== 
80 void MetaImageReader::bbUserInitializeProcessing()
81 {
82
83 //  THE INITIALIZATION METHOD BODY :
84 //    Here does nothing 
85 //    but this is where you should allocate the internal/output pointers 
86 //    if any 
87
88   
89 }
90 //===== 
91 // 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)
92 //===== 
93 void MetaImageReader::bbUserFinalizeProcessing()
94 {
95
96 //  THE FINALIZATION METHOD BODY :
97 //    Here does nothing 
98 //    but this is where you should desallocate the internal/output pointers 
99 //    if any
100   
101 }
102 }
103 // EO namespace bbvtk
104
105