]> Creatis software - gdcm.git/blob - Example/PrintHeader.cxx
2112f0925a1e961ef9093446b52c48d760c08ad4
[gdcm.git] / Example / PrintHeader.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintHeader.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/01/12 11:40:50 $
7   Version:   $Revision: 1.15 $
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 "gdcmDebug.h"
20
21 #include <iostream>
22
23 int main(int argc, char* argv[])
24
25    std::string fileName;   
26
27    if (argc == 1)
28    {
29       std::cout << argv[0] << " fileName printLevel debug" << std::endl;
30    }
31
32    if (argc > 1)
33    {
34       fileName=argv[1];
35    }
36    else
37    {
38       fileName += GDCM_DATA_ROOT;
39       fileName += "/test.acr";
40    }
41
42    if (argc > 3)
43       gdcm::Debug::SetDebugOn();
44
45    gdcm::Header *e1 = new gdcm::Header( fileName.c_str() );  
46
47    if (argc > 2) 
48    {
49       int level = atoi(argv[2]);   
50       e1->SetPrintLevel(level);
51    }
52
53    e1->Print();   
54
55    std::cout << "\n\n" << std::endl; 
56
57    if ( e1->GetEntry(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) 
58    {
59       std::cout << "Transfer Syntax not loaded. " << std::endl
60                 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
61                 << std::endl;
62       return 0;
63    }
64
65    std::string transferSyntaxName = e1->GetTransferSyntaxName();
66    std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]"
67              << std::endl;
68    std::cout << " SwapCode= " << e1->GetSwapCode() << std::endl;
69
70    if(e1->IsReadable())
71       std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
72    else
73       std::cout <<std::endl<<fileName<<" is NOT Readable"<<std::endl;
74    std::cout<<std::flush;
75    delete e1;
76
77    return 0;
78 }