]> Creatis software - gdcm.git/blob - Example/PrintHeader.cxx
68b09261ebb3e710191d970cba064e86cb6179b0
[gdcm.git] / Example / PrintHeader.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintHeader.cxx,v $
5   Language:  C++
6   Date:      $Date: 2004/12/03 20:16:55 $
7   Version:   $Revision: 1.12 $
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 "gdcmHeader.h"
19 #include <iostream>
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::Header *e1 = new gdcm::Header( fileName.c_str() );  
41
42    if (argc > 2) 
43    {
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    {
54       std::cout << "Transfert Syntax not loaded. " << std::endl
55                 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
56                 << std::endl;
57       return 0;
58    }
59
60    std::string transferSyntaxName = e1->GetTransfertSyntaxName();
61    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl;
62
63    if(e1->IsReadable())
64       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
65    else
66       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
67    std::cout<<std::flush;
68    delete e1;
69
70    return 0;
71 }