]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
ADD : PrintFile.cxx
[gdcm.git] / Example / PrintFile.cxx
1 #include <iostream>
2
3 #include "gdcmException.h"
4 #include "gdcmCommon.h"
5
6 #include "gdcmDictEntry.h"
7 #include "gdcmDict.h"
8 #include "gdcmDictSet.h"
9 #include "gdcmHeader.h"
10 #include "gdcmUtil.h"
11 #include "gdcmBinEntry.h"  
12 #include "gdcmDocEntry.h" 
13 #include "gdcmDocEntrySet.h"           
14 #include "gdcmDocument.h"          
15 #include "gdcmElementSet.h"        
16 #include "gdcmSeqEntry.h" 
17 #include "gdcmSQItem.h" 
18 #include "gdcmValEntry.h" 
19 #include "gdcmFile.h" 
20 int main(int argc, char* argv[])
21 {
22  
23    gdcmHeader *e1;
24    gdcmFile   *f1;
25    std::string fileName;   
26    if (argc != 2) {
27       std::cout << " usage : PrintDocument fileName" << std::endl;
28    }
29
30    if (argc > 1) {
31       fileName=argv[1];
32    } else {
33       fileName += GDCM_DATA_ROOT;
34       fileName += "/test.acr";
35    }
36    
37    e1= new gdcmHeader 
38           (fileName.c_str(),false, true);
39
40    f1 = new gdcmFile(e1);
41
42    e1->SetPrintLevel(2);
43    
44    e1->Print();
45       
46    std::cout << "\n\n" << std::endl; 
47
48    int dataSize = f1->GetImageDataSize();
49    std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
50    int nX,nY,nZ,sPP,planarConfig;
51    std::string pixelType;
52    nX=e1->GetXSize();
53    nY=e1->GetYSize();
54    nZ=e1->GetZSize();
55    std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
56
57    pixelType    = e1->GetPixelType();
58    sPP          = e1->GetSamplesPerPixel();
59    planarConfig = e1->GetPlanarConfiguration();
60    
61    std::cout << " pixelType="           << pixelType 
62              << " SampleserPixel="      << sPP
63              << " PlanarConfiguration=" << planarConfig 
64              << std::endl 
65              << " PhotometricInterpretation=" 
66                                 << e1->GetEntryByNumber(0x0028,0x0004)
67              << std::endl;
68
69    int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
70    std::cout << " NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
71
72    std::string transferSyntaxName = e1->GetTransfertSyntaxName();
73    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
74    
75    if (  transferSyntaxName != "Implicit VR - Little Endian"
76       && transferSyntaxName != "Explicit VR - Little Endian"     
77       && transferSyntaxName != "Deflated Explicit VR - Little Endian"      
78       && transferSyntaxName != "Explicit VR - Big Endian"
79       && transferSyntaxName != "Uncompressed ACR-NEMA"     )
80   {
81       std::cout << std::endl << "==========================================="
82                   << std::endl; 
83          f1->ParsePixelData();  // gdcmFile Method :-(
84       std::cout << std::endl << "==========================================="
85                   << std::endl; 
86    }      
87    
88    if(e1->IsReadable())
89       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
90    else
91       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
92    std::cout<<std::flush;
93    delete e1;
94
95    return 0;
96    
97 }