]> Creatis software - bbtk.git/blob - packages/gdcmvtk/src/bbgdcmvtkGetInfoGdcmReader.cxx
7877be5bf9c37f6e977cf9d33e778827aad47080
[bbtk.git] / packages / gdcmvtk / src / bbgdcmvtkGetInfoGdcmReader.cxx
1 #include "bbgdcmvtkGetInfoGdcmReader.h"
2 #include "bbgdcmvtkPackage.h"
3
4 #include "gdcmFile.h"
5 #include "gdcmFileHelper.h"
6 #include "vtkImageData.h"
7 #include "vtkGdcmReader.h"
8 #include <vtkIndent.h>
9
10 namespace bbgdcmvtk
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(gdcmvtk,GetInfoGdcmReader)
14 BBTK_BLACK_BOX_IMPLEMENTATION(GetInfoGdcmReader,bbtk::AtomicBlackBox);
15 void GetInfoGdcmReader::Process()
16 {
17     
18    f = GDCM_NAME_SPACE::File::New();
19    f->SetFileName( bbGetInputIn() );
20    bool res = f->Load();  
21    if ( !res )
22    {
23       
24       f->Delete();
25       bbSetOutputOut(0);
26       return;
27    }
28
29    int i;
30    std::vector<double> v_iop;
31    float iop[6];
32    f->GetImageOrientationPatient(iop);
33    for(i=0; i< 6; i++)
34       v_iop.push_back(iop[i]);
35    bbSetOutputIOP(v_iop );
36  
37    std::vector<double> v_ipp;
38    float ipp[3];
39    f->GetImagePositionPatient(ipp);
40    for(i=0; i< 3; i++)
41       v_ipp.push_back(ipp[i]);
42    bbSetOutputIPP(v_ipp );
43
44    std::vector<double> v_pixelspacing;
45    v_pixelspacing.push_back(f->GetXSpacing());
46    v_pixelspacing.push_back(f->GetYSpacing());
47    if (f->GetZSize() != 1) {
48       v_pixelspacing.push_back(f->GetZSpacing());
49    }
50    bbSetOutputPixelSpacing(v_pixelspacing);
51    
52    //double interslice;
53     bbSetOutputInterSlice(f->GetZSpacing());
54    
55    reader = vtkGdcmReader::New();
56    reader->SetFileName( bbGetInputIn().c_str() );
57    reader->Update();
58    reader->GetOutput();
59
60    vtkIndent indent ;
61    reader->GetOutput()->PrintSelf(std::cout, indent);
62    bbSetOutputOut( reader->GetOutput() );
63 }
64
65 void GetInfoGdcmReader::bbUserConstructor()
66 {
67 std::cout << "entree ds GetInfoGdcmReader::bbUserConstructor()" << std::endl;
68     bbSetInputIn("");  
69 }
70
71 void GetInfoGdcmReader::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
72 {
73   
74 }
75 void GetInfoGdcmReader::bbUserDestructor()
76 {
77    if(reader)
78       reader->Delete();
79    if(f)
80       f->Delete();
81 }
82
83 }
84 // EO namespace bbgdcmvtk
85
86