]> Creatis software - gdcm.git/blob - Testing/TestPrintAllDocument.cxx
use GDCM_NAME_SPACE:: instead of gdcm::, even in Examples ...
[gdcm.git] / Testing / TestPrintAllDocument.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestPrintAllDocument.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/09/15 15:49:21 $
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
19 // TODO : check what's *actually* usefull
20
21 #include "gdcmDictEntry.h"
22 #include "gdcmDict.h"
23 #include "gdcmDictSet.h"
24 #include "gdcmFile.h"
25 #include "gdcmUtil.h"
26 #include "gdcmCommon.h"
27 #include "gdcmDocEntry.h" 
28 #include "gdcmDocEntrySet.h"           
29 #include "gdcmDocument.h"          
30 #include "gdcmElementSet.h"        
31 #include "gdcmSeqEntry.h" 
32 #include "gdcmSQItem.h" 
33 #include "gdcmOrientation.h"
34 #include <fstream>
35 #include <iostream>
36 #include <iomanip> // for std::ios::left, ...
37
38 //Generated file:
39 #include "gdcmDataImages.h"
40
41 int TestPrintAllDocument(int argc, char *argv[])
42 {
43    //std::ostringstream s;
44    int i = 0;
45    int swapC;
46    unsigned int j;
47    std::string pixelType, photomInterp;
48    unsigned int l;
49    l = strlen("PALETTE COLOR ");
50    
51    //GDCM_NAME_SPACE::Debug::DebugOn();
52    
53    while( gdcmDataImages[i] != 0 )
54    {
55       std::string filename;      
56       if (argc ==2)
57       {
58          filename = argv[1];
59       }
60       else
61       {
62          filename = GDCM_DATA_ROOT;
63          filename += "/";  //doh!      
64          filename += gdcmDataImages[i];
65       }
66       
67       std::cout << " ----------------------------------------------"
68                 << "Begin with " << filename << std::endl;
69
70       GDCM_NAME_SPACE::File *f= GDCM_NAME_SPACE::File::New( );
71       f->SetFileName( filename );
72       f->Load();
73
74       f->SetPrintLevel(2);
75       f->Print();
76       
77       //s.setf(std::ios::left);
78       //s << std::setw(60-filename.length()) << " ";
79       //std::cout << s.str() << gdcmDataImages[i];
80
81       std::cout << gdcmDataImages[i];
82
83       unsigned int nbSpaces;
84       if (strlen(gdcmDataImages[i]) <= 60)
85          nbSpaces = 60-strlen(gdcmDataImages[i]);
86       else
87          nbSpaces = 0;
88       for (j=0; j<nbSpaces; j++)
89          std::cout << " ";    
90
91       pixelType = f->GetPixelType();
92       std::cout << " pixelType="            << pixelType;
93       if ( pixelType == "8U" || pixelType == "8S" )
94          std::cout << " ";
95       std::cout << " Smpl.P.Pix.="          << f->GetSamplesPerPixel()
96                 << " Plan.Config.="         << f->GetPlanarConfiguration();
97
98       photomInterp =  f->GetEntryString(0x0028,0x0004);               
99       std::cout << " Photom.Interp.="       << photomInterp << " l : " << l <<"length : " << photomInterp.length()<< std::endl;
100       
101       if (l > photomInterp.length())
102         for (j=0; j<l-photomInterp.length(); j++)
103            std::cout << " ";
104  
105       std::cout << " TransferSyntaxName= [" << f->GetTransferSyntaxName() << "]" ;
106
107       swapC = f->GetSwapCode();
108       if ( swapC != 1234 )
109           std::cout << " SwapCode = "       << f->GetSwapCode(); 
110       if ( f->CheckIfEntryExist(0x0088,0x0200) )
111           std::cout << " Icon Image Sequence";
112
113       std::cout << std::endl;
114
115       std::string strImageOrientationPatient = 
116                                           f->GetEntryString(0x0020,0x0037);
117       if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND )
118       {
119          GDCM_NAME_SPACE::Orientation *o = GDCM_NAME_SPACE::Orientation::New();
120  
121          GDCM_NAME_SPACE::OrientationType orient = o->GetOrientationType( f );
122          std::cout << " ---------------------- Orientation " << orient
123                    << std::endl;
124          o->Delete(); 
125       }
126
127       if( f->IsReadable() )
128       {
129          std::cout <<filename << " is Readable" 
130                    << std::endl << std::endl;
131       }
132       else
133       {
134          std::cout << filename << " is NOT Readable" 
135                    << std::endl << std::endl;
136          f->Delete();
137          return 1;
138       }
139       f->Delete();
140       
141       if (argc ==2)
142          break; // user asked to check a single file.      
143       
144       i++;
145    }
146    return 0;
147 }