]> Creatis software - gdcm.git/blob - Testing/TestLoadAllDocumentsNoPrivNoSeq.cxx
b10a018a2b4222be6bbca816819fd05e830237f8
[gdcm.git] / Testing / TestLoadAllDocumentsNoPrivNoSeq.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestLoadAllDocumentsNoPrivNoSeq.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/09/22 14:42:37 $
7   Version:   $Revision: 1.2 $
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 #include "gdcmOrientation.h"
36 #include <fstream>
37 #include <iostream>
38 #include <iomanip> // for std::ios::left, ...
39
40 //Generated file:
41 #include "gdcmDataImages.h"
42
43 int TestLoadAllDocumentsNoPrivNoSeq(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 *f= new gdcm::File( );
59       f->SetFileName( filename );
60       // just to improve coverage
61       f->SetLoadMode (gdcm::LD_NOSEQ|gdcm::LD_NOSHADOW);
62       f->Load();
63
64 /*
65       f->SetPrintLevel(2);
66       f->Print();
67       // just to be able to grep the display result, for some usefull info
68  
69       //s.setf(std::ios::left);
70       //s << std::setw(60-filename.length()) << " ";
71       //std::cout << s.str() << gdcmDataImages[i];
72
73       std::cout << gdcmDataImages[i];
74
75       unsigned int nbSpaces;
76       if (strlen(gdcmDataImages[i]) <= 60)
77          nbSpaces = 60-strlen(gdcmDataImages[i]);
78       else
79          nbSpaces = 0;
80       for (j=0; j<nbSpaces; j++)
81          std::cout << " ";    
82
83       pixelType = f->GetPixelType();
84       std::cout << " pixelType="            << pixelType;
85       if ( pixelType == "8U" || pixelType == "8S" )
86          std::cout << " ";
87       std::cout << " Smpl.P.Pix.="          << f->GetSamplesPerPixel()
88                 << " Plan.Config.="         << f->GetPlanarConfiguration();
89  
90       photomInterp =  f->GetEntryValue(0x0028,0x0004);               
91       std::cout << " Photom.Interp.="       << photomInterp;
92       for (j=0; j<l-photomInterp.length(); j++)
93          std::cout << " ";
94  
95       std::cout << " TransferSyntaxName= [" << f->GetTransferSyntaxName() << "]" ;
96
97       swapC = f->GetSwapCode();
98       if ( swapC != 1234 )
99           std::cout << " SwapCode = "       << f->GetSwapCode(); 
100       if ( f->CheckIfEntryExist(0x0088,0x0200) )
101           std::cout << " Icon Image Sequence";
102
103       std::cout << std::endl;
104
105       std::string strImageOrientationPatient = 
106                                           f->GetEntryValue(0x0020,0x0037);
107       if ( strImageOrientationPatient != gdcm::GDCM_UNFOUND )
108       {
109          gdcm::Orientation o;
110          double orient = o.TypeOrientation( f );
111          std::cout << " ---------------------- Orientation " << orient
112                    << std::endl;
113       }
114
115       if( f->IsReadable() )
116       {
117          std::cout <<filename << " is Readable" 
118                    << std::endl << std::endl;
119       }
120       else
121       {
122          std::cout << filename << " is NOT Readable" 
123                    << std::endl << std::endl;
124          delete f;
125          return 1;
126       }
127  */
128       delete f;
129       i++;
130    }
131    return 0;
132 }