]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
* src/gdcmDocument.cxx ftell() return properly stored in a long (i.e.
[gdcm.git] / Example / PrintFile.cxx
1 #include <iostream>
2 #include "gdcm.h"
3
4 int main(int argc, char* argv[])
5 {
6  
7    gdcm::Header *e1;
8    gdcm::File   *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 gdcm::Header( fileName.c_str() );
22
23    f1 = new gdcm::File(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   
56   if ( e1->GetEntryByNumber(0x0002,0x0010) == GDCM_NOTLOADED ) {
57      std::cout << "Transfert Syntax not loaded. " << std::endl
58                << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
59                << std::endl;
60       return 0;
61   }
62   
63    std::string transferSyntaxName = e1->GetTransfertSyntaxName();
64    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
65    
66    if (  transferSyntaxName != "Implicit VR - Little Endian"
67       && transferSyntaxName != "Explicit VR - Little Endian"     
68       && transferSyntaxName != "Deflated Explicit VR - Little Endian"      
69       && transferSyntaxName != "Explicit VR - Big Endian"
70       && transferSyntaxName != "Uncompressed ACR-NEMA"     )
71   {
72       std::cout << std::endl << "==========================================="
73                   << std::endl; 
74          f1->GetPixelConverter()->Print();
75       std::cout << std::endl << "==========================================="
76                   << std::endl; 
77    }      
78    
79    if(e1->IsReadable())
80       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
81    else
82       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
83    std::cout<<std::flush;
84    delete e1;
85
86    return 0;
87    
88 }