]> Creatis software - bbtk.git/blob - packages/gdcmvtk/src/bbgdcmvtkGetInfoGdcmReader.cxx
Try to get more accurate info from SerieHelper
[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       f->Delete();
24       bbSetOutputOut(0);
25       return;
26    }
27  // Get info from the image file
28    int i;
29    std::vector<double> v_iop;
30    float iop[6];
31    f->GetImageOrientationPatient(iop);
32    for(i=0; i< 6; i++)
33       v_iop.push_back(iop[i]);
34    bbSetOutputIOP(v_iop );
35  
36    std::vector<double> v_ipp;
37    float ipp[3];
38    f->GetImagePositionPatient(ipp);
39    for(i=0; i< 3; i++)
40       v_ipp.push_back(ipp[i]);
41    bbSetOutputIPP(v_ipp );
42
43    std::vector<double> v_pixelspacing;
44    v_pixelspacing.push_back(f->GetXSpacing());
45    v_pixelspacing.push_back(f->GetYSpacing());
46    if (f->GetZSize() != 1) {
47       v_pixelspacing.push_back(f->GetZSpacing());
48    }
49    bbSetOutputPixelSpacing(v_pixelspacing);
50    
51    //double interslice;
52     bbSetOutputInterSlice(f->GetZSpacing());
53    
54    reader = vtkGdcmReader::New();
55    reader->SetFileName( bbGetInputIn().c_str() );
56    reader->Update();
57    reader->GetOutput();
58
59    vtkIndent indent ;
60    reader->GetOutput()->PrintSelf(std::cout, indent);
61    bbSetOutputOut( reader->GetOutput() );
62 }
63
64 void GetInfoGdcmReader::bbUserConstructor()
65 {
66     bbSetInputIn("");  
67 }
68
69 void GetInfoGdcmReader::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
70 {
71   
72 }
73 void GetInfoGdcmReader::bbUserDestructor()
74 {
75    if(reader)
76       reader->Delete();
77    if(f)
78       f->Delete();
79 }
80
81 }
82 // EO namespace bbgdcmvtk
83
84