]> Creatis software - gdcm.git/blob - Example/PrintHeader.cxx
49cd54e7ba7937ed4738189eebebbda60ce38161
[gdcm.git] / Example / PrintHeader.cxx
1 #include <iostream>
2 #include "gdcm.h"
3
4 int main(int argc, char* argv[])
5
6    bool dropPriv = false;
7    bool showSeq  = true; 
8    std::string fileName;   
9
10    if (argc == 1) {
11       std::cout << argv[0] <<
12       " fileName" << std::endl <<
13       "    [nopriv]  if you don't want to print Shadow groups"  << std::endl <<
14       "    [noseq]   if you don't want to 'go inside' the SQ's" << std::endl;
15    }
16
17    if (argc > 1) {
18       fileName=argv[1];
19    } else {
20       fileName += GDCM_DATA_ROOT;
21       fileName += "/test.acr";
22    }
23    
24    for (int j=0;j<argc;j++) {
25       if (strcmp(argv[j],"nopriv")==0)
26          dropPriv=true;
27       else if (strcmp(argv[j],"noseq")==0)
28          showSeq=false;
29    }
30    
31    gdcmFile *e2 = new gdcmFile(fileName.c_str(),false, showSeq, dropPriv);
32    gdcmHeader *e1 = e2->GetHeader();  
33         
34    if (argc > 2) {
35       int level = atoi(argv[2]);   
36       e1->SetPrintLevel(level);
37    }
38
39   e1->Print();   
40       
41   std::cout << "\n\n" << std::endl;      
42   std::string transferSyntaxName = e1->GetTransfertSyntaxName();
43   std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
44    
45    if (  transferSyntaxName != "Implicit VR - Little Endian"
46       && transferSyntaxName != "Explicit VR - Little Endian"     
47       && transferSyntaxName != "Deflated Explicit VR - Little Endian"      
48       && transferSyntaxName != "Explicit VR - Big Endian"
49       && transferSyntaxName != "Uncompressed ACR-NEMA"     )
50   {
51   std::cout << std::endl << "==========================================="
52                   << std::endl; 
53         e2->ParsePixelData();
54   std::cout << std::endl << "==========================================="
55                   << std::endl; 
56   }
57    
58    if(e1->IsReadable())
59       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
60    else
61       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
62    std::cout<<std::flush;
63    delete e1;
64
65    return 0;
66    
67 }