]> Creatis software - bbtk.git/blob - packages/vtk/src/bbvtkMetaImageReader.cxx
e035419cae47190b387bbaf2201cce774aacaa35
[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().substr(bbGetInputIn().size()-5) == ".mhdb")  
44         { 
45                 Read_mhdb( bbGetInputIn() );
46         } else {
47                 FILE *ff = fopen( bbGetInputIn().c_str() , "r" );
48                 if (ff)
49                 {
50                         fclose(ff);
51                         vtkMetaImageReader *reader = vtkMetaImageReader::New();
52                         reader->SetFileName( bbGetInputIn().c_str() );
53                         reader->Update();
54                         bbSetOutputOut( reader->GetOutput() );
55                 } else {
56                         bbSetOutputOut(NULL);
57                 } // ff
58         }// .mhdb
59 }
60
61 //===== 
62 // 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)
63 //===== 
64 void MetaImageReader::bbUserSetDefaultValues()
65 {
66
67 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
68 //    Here we initialize the input 'In' to 0
69    bbSetInputIn("");
70   
71 }
72 //===== 
73 // 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)
74 //===== 
75 void MetaImageReader::bbUserInitializeProcessing()
76 {
77
78 //  THE INITIALIZATION METHOD BODY :
79 //    Here does nothing 
80 //    but this is where you should allocate the internal/output pointers 
81 //    if any 
82
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 MetaImageReader::bbUserFinalizeProcessing()
89 {
90
91 //  THE FINALIZATION METHOD BODY :
92 //    Here does nothing 
93 //    but this is where you should desallocate the internal/output pointers 
94 //    if any
95   
96 }
97 }
98 // EO namespace bbvtk
99
100