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