]> Creatis software - gdcm.git/blob - Testing/TestPrintAllDocument.cxx
2122494fec91e46b6d52df44ba212cac1ada708b
[gdcm.git] / Testing / TestPrintAllDocument.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestPrintAllDocument.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/09/07 08:48:28 $
7   Version:   $Revision: 1.6 $
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 "gdcmBinEntry.h"  
28 #include "gdcmDocEntry.h" 
29 #include "gdcmDocEntrySet.h"           
30 #include "gdcmDocument.h"          
31 #include "gdcmElementSet.h"        
32 #include "gdcmSeqEntry.h" 
33 #include "gdcmSQItem.h" 
34 #include "gdcmValEntry.h" 
35
36 #include <fstream>
37 #include <iostream>
38 #include <iomanip> // for std::ios::left, ...
39
40 //Generated file:
41 #include "gdcmDataImages.h"
42
43 int TestPrintAllDocument(int, char *[])
44 {
45    //std::ostringstream s;
46    int i = 0;
47    int swapC;
48    unsigned int j;
49    std::string pixelType, photomInterp;
50    int l;
51    l = strlen("PALETTE COLOR ");
52    while( gdcmDataImages[i] != 0 )
53    {
54       std::string filename = GDCM_DATA_ROOT;
55       filename += "/";  //doh!
56       filename += gdcmDataImages[i];
57
58       gdcm::File *e1= new gdcm::File( );
59       e1->SetFileName( filename );
60       e1->Load();
61
62       e1->SetPrintLevel(2);
63       e1->Print();
64       // just to be able to grep the display result, for some usefull info
65  
66       //s.setf(std::ios::left);
67       //s << std::setw(60-filename.length()) << " ";
68       //std::cout << s.str() << gdcmDataImages[i];
69
70       std::cout << gdcmDataImages[i];
71
72       unsigned int nbSpaces;
73       if (strlen(gdcmDataImages[i]) <= 60)
74          nbSpaces = 60-strlen(gdcmDataImages[i]);
75       else
76          nbSpaces = 0;
77       for (j=0; j<nbSpaces; j++)
78          std::cout << " ";    
79
80       pixelType = e1->GetPixelType();
81       std::cout << " pixelType="            << pixelType;
82       if ( pixelType == "8U" || pixelType == "8S" )
83          std::cout << " ";
84       std::cout << " Smpl.P.Pix.="          << e1->GetSamplesPerPixel()
85                 << " Plan.Config.="         << e1->GetPlanarConfiguration();
86  
87       photomInterp =  e1->GetEntryValue(0x0028,0x0004);               
88       std::cout << " Photom.Interp.="       << photomInterp;
89       for (j=0; j<l-photomInterp.length(); j++)
90          std::cout << " ";
91  
92       std::cout << " TransferSyntaxName= [" << e1->GetTransferSyntaxName() << "]" ;
93
94       swapC = e1->GetSwapCode();
95       if ( swapC != 1234 )
96           std::cout << " SwapCode = "       << e1->GetSwapCode(); 
97       if ( e1->CheckIfEntryExist(0x0088,0x0200) )
98           std::cout << " Icon Image Sequence";
99
100        std::cout << std::endl;
101    
102       if( e1->IsReadable() )
103       {
104          std::cout <<filename << " is Readable" 
105                    << std::endl << std::endl;
106       }
107       else
108       {
109          std::cout << filename << " is NOT Readable" 
110                    << std::endl << std::endl;
111          delete e1;
112          return 1;
113       }
114       delete e1;
115       i++;
116    }
117    return 0;
118 }