]> Creatis software - gdcm.git/blob - Example/PrintDocument.cxx
* Rename the NO_SEQ, NO_SHADOW, NO_SHADOWSEQ to
[gdcm.git] / Example / PrintDocument.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintDocument.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/08/30 14:40:28 $
7   Version:   $Revision: 1.18 $
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 "gdcmFile.h"
19 #include "gdcmDebug.h"
20 #include "gdcmCommon.h"
21
22 #include <iostream>
23 #include <stdlib.h> //for atoi
24
25 int main(int argc, char *argv[])
26 {
27  
28    gdcm::File *e1= new gdcm::File();;
29    std::string fileName;   
30
31    if (argc == 1) {
32       std::cout << " Usage : "
33                 << argv[0] 
34                 << " filename"
35                 << " printLevel debug "
36                 << "short (=NOSEQ + NOSHADOW)" 
37                 << std::endl;
38        return 0;
39    }
40
41    if (argc > 1) {
42       fileName=argv[1];
43    } else {
44       fileName += GDCM_DATA_ROOT;
45       fileName += "/test.acr";
46    }
47
48    if (argc > 2) 
49    {
50       int level = atoi(argv[2]);   
51       e1->SetPrintLevel(level);
52    }
53
54    if (argc > 3)
55       gdcm::Debug::DebugOn(); 
56
57    if (argc > 4)
58       e1->SetLoadMode(GDCM_LD_NOSEQ | GDCM_LD_NOSHADOW);
59    e1->SetFileName( fileName.c_str() );
60    e1->Load( );
61
62 // we use PrintDocument, because we want to print what we get
63
64 //   if ( !e1->IsReadable() )
65 //   {
66 //      delete e1;
67 //      return 0;
68 //   }
69
70    e1->Print();
71       
72    std::cout << "\n\n" << std::endl; 
73
74    if ( e1->GetEntryValue(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) 
75    {
76       std::cout << "Transfer Syntax not loaded. " << std::endl
77                 << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
78                 << std::endl;
79       return 0;
80    }       
81    
82    if(e1->IsReadable())
83       std::cout <<std::endl<<fileName<<" is 'file Readable'"<<std::endl;
84    else
85       std::cout <<std::endl<<fileName<<" is NOT 'file Readable'"<<std::endl;
86    std::cout<<std::flush;
87    delete e1;
88
89    return 0;
90    
91 }