]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
* src/gdcmDocument.[h|cxx], gdcmFile.[h|cxx], gdcmHeader.[h|cxx]:
[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( fileName.c_str(), false );
22
23    f1 = new gdcmFile(e1);
24
25    e1->SetPrintLevel(2);
26    
27    e1->Print();
28       
29    std::cout << "\n\n" << std::endl; 
30
31    int dataSize = f1->GetImageDataSize();
32    std::cout <<std::endl <<" dataSize " << dataSize << std::endl;
33    int nX,nY,nZ,sPP,planarConfig;
34    std::string pixelType;
35    nX=e1->GetXSize();
36    nY=e1->GetYSize();
37    nZ=e1->GetZSize();
38    std::cout << " DIMX=" << nX << " DIMY=" << nY << " DIMZ=" << nZ << std::endl;
39
40    pixelType    = e1->GetPixelType();
41    sPP          = e1->GetSamplesPerPixel();
42    planarConfig = e1->GetPlanarConfiguration();
43    
44    std::cout << " pixelType="           << pixelType 
45              << " SampleserPixel="      << sPP
46              << " PlanarConfiguration=" << planarConfig 
47              << std::endl 
48              << " PhotometricInterpretation=" 
49                                 << e1->GetEntryByNumber(0x0028,0x0004)
50              << std::endl;
51
52    int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
53    std::cout << " NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
54
55    std::string transferSyntaxName = e1->GetTransfertSyntaxName();
56    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
57    
58    if (  transferSyntaxName != "Implicit VR - Little Endian"
59       && transferSyntaxName != "Explicit VR - Little Endian"     
60       && transferSyntaxName != "Deflated Explicit VR - Little Endian"      
61       && transferSyntaxName != "Explicit VR - Big Endian"
62       && transferSyntaxName != "Uncompressed ACR-NEMA"     )
63   {
64       std::cout << std::endl << "==========================================="
65                   << std::endl; 
66          f1->ParsePixelData();
67       std::cout << std::endl << "==========================================="
68                   << std::endl; 
69    }      
70    
71    if(e1->IsReadable())
72       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
73    else
74       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
75    std::cout<<std::flush;
76    delete e1;
77
78    return 0;
79    
80 }