]> Creatis software - gdcm.git/blob - Testing/TestPrintAllDocument.cxx
gdcm::Orientation uses RefCounter
[gdcm.git] / Testing / TestPrintAllDocument.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestPrintAllDocument.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/11/18 11:44:33 $
7   Version:   $Revision: 1.11 $
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, char *[])
42 {
43    //std::ostringstream s;
44    int i = 0;
45    int swapC;
46    unsigned int j;
47    std::string pixelType, photomInterp;
48    int l;
49    l = strlen("PALETTE COLOR ");
50    while( gdcmDataImages[i] != 0 )
51    {
52       std::string filename = GDCM_DATA_ROOT;
53       filename += "/";  //doh!
54       filename += gdcmDataImages[i];
55
56       gdcm::File *f= gdcm::File::New( );
57       f->SetFileName( filename );
58       f->Load();
59
60       f->SetPrintLevel(2);
61       f->Print();
62       // just to be able to grep the display result, for some usefull info
63  
64       //s.setf(std::ios::left);
65       //s << std::setw(60-filename.length()) << " ";
66       //std::cout << s.str() << gdcmDataImages[i];
67
68       std::cout << gdcmDataImages[i];
69
70       unsigned int nbSpaces;
71       if (strlen(gdcmDataImages[i]) <= 60)
72          nbSpaces = 60-strlen(gdcmDataImages[i]);
73       else
74          nbSpaces = 0;
75       for (j=0; j<nbSpaces; j++)
76          std::cout << " ";    
77
78       pixelType = f->GetPixelType();
79       std::cout << " pixelType="            << pixelType;
80       if ( pixelType == "8U" || pixelType == "8S" )
81          std::cout << " ";
82       std::cout << " Smpl.P.Pix.="          << f->GetSamplesPerPixel()
83                 << " Plan.Config.="         << f->GetPlanarConfiguration();
84  
85       photomInterp =  f->GetEntryString(0x0028,0x0004);               
86       std::cout << " Photom.Interp.="       << photomInterp;
87       for (j=0; j<l-photomInterp.length(); j++)
88          std::cout << " ";
89  
90       std::cout << " TransferSyntaxName= [" << f->GetTransferSyntaxName() << "]" ;
91
92       swapC = f->GetSwapCode();
93       if ( swapC != 1234 )
94           std::cout << " SwapCode = "       << f->GetSwapCode(); 
95       if ( f->CheckIfEntryExist(0x0088,0x0200) )
96           std::cout << " Icon Image Sequence";
97
98       std::cout << std::endl;
99
100       std::string strImageOrientationPatient = 
101                                           f->GetEntryString(0x0020,0x0037);
102       if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND )
103       {
104          gdcm::Orientation *o = gdcm::Orientation::New();
105  
106          gdcm::OrientationType orient = o->GetOrientationType( f );
107          std::cout << " ---------------------- Orientation " << orient
108                    << std::endl;
109          o->gdcm::Orientation::Delete(); 
110       }
111
112       if( f->IsReadable() )
113       {
114          std::cout <<filename << " is Readable" 
115                    << std::endl << std::endl;
116       }
117       else
118       {
119          std::cout << filename << " is NOT Readable" 
120                    << std::endl << std::endl;
121          f->Delete();
122          return 1;
123       }
124       f->Delete();
125       i++;
126    }
127    return 0;
128 }