]> Creatis software - gdcm.git/blob - Example/PrintHeader.cxx
17738bc4c159a005705941a97255a760c20e2115
[gdcm.git] / Example / PrintHeader.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintHeader.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/11/16 04:26:18 $
7   Version:   $Revision: 1.9 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18 #include <iostream>
19 #include "gdcm.h"
20
21 int main(int argc, char* argv[])
22
23    std::string fileName;   
24
25    if (argc == 1)
26    {
27       std::cout << argv[0] << " fileName" << std::endl;
28    }
29
30    if (argc > 1)
31    {
32       fileName=argv[1];
33    }
34    else
35    {
36       fileName += GDCM_DATA_ROOT;
37       fileName += "/test.acr";
38    }
39    
40    gdcm::File *e2 = new gdcm::File( fileName.c_str() );
41    gdcm::Header *e1 = e2->GetHeader();  
42         
43    if (argc > 2) {
44       int level = atoi(argv[2]);   
45       e1->SetPrintLevel(level);
46    }
47
48   e1->Print();   
49       
50   std::cout << "\n\n" << std::endl; 
51   
52   if ( e1->GetEntryByNumber(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) {
53      std::cout << "Transfert Syntax not loaded. " << std::endl
54                << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
55                << std::endl;
56      return 0;
57   }
58       
59   std::string transferSyntaxName = e1->GetTransfertSyntaxName();
60   std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
61    
62    if (  transferSyntaxName != "Implicit VR - Little Endian"
63       && transferSyntaxName != "Explicit VR - Little Endian"     
64       && transferSyntaxName != "Deflated Explicit VR - Little Endian"      
65       && transferSyntaxName != "Explicit VR - Big Endian"
66       && transferSyntaxName != "Uncompressed ACR-NEMA" )
67   {
68   std::cout << std::endl << "==========================================="
69                   << std::endl; 
70         e2->GetPixelConverter()->Print();
71   std::cout << std::endl << "==========================================="
72                   << std::endl; 
73   }
74    
75    if(e1->IsReadable())
76       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
77    else
78       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
79    std::cout<<std::flush;
80    delete e1;
81
82    return 0;
83    
84 }