]> Creatis software - gdcm.git/blob - Example/PrintFile.cxx
Add :
[gdcm.git] / Example / PrintFile.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: PrintFile.cxx,v $
5   Language:  C++
6   Date:      $Date: 2007/09/12 12:36:50 $
7   Version:   $Revision: 1.85 $
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 "gdcmDocument.h"
20 #include "gdcmSeqEntry.h"
21 #include "gdcmSQItem.h"
22 #include "gdcmDataEntry.h"
23
24 #include "gdcmFileHelper.h"
25 #include "gdcmDebug.h"
26 #include "gdcmDirList.h"
27 #include "gdcmGlobal.h"
28 #include "gdcmDictSet.h"
29 #include "gdcmArgMgr.h"
30 #include "gdcmOrientation.h"
31 #include <iostream>
32
33 // TODO : code factorization, for 'single file' an 'whole directory' processing
34
35 void ShowLutData(GDCM_NAME_SPACE::File *f);
36
37      // Nothing is written yet to get LUT Data user friendly
38      // The following is to be moved into a PixelReadConvert method
39      // Let here, waiting for a clever idea on the way to do it.
40
41 void ShowLutData(GDCM_NAME_SPACE::File *f)
42 {  
43    GDCM_NAME_SPACE::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
44    if ( modLutSeq !=0 )
45    {
46       GDCM_NAME_SPACE::SQItem *sqi= modLutSeq->GetFirstSQItem();
47       if ( sqi != 0 )
48       {
49          std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
50          if (   /*lutDescriptor   == GDCM_UNFOUND*/ 0 )
51          {
52             std::cout << "LUT Descriptor is missing" << std::endl;
53             return;
54          }
55          int length;   // LUT length in Bytes
56          int deb;      // Subscript of the first Lut Value
57          int nbits;    // Lut item size (in Bits)
58
59          int nbRead;    // nb of items in LUT descriptor (must be = 3)
60
61          nbRead = sscanf( lutDescriptor.c_str(),
62                            "%d\\%d\\%d",
63                               &length, &deb, &nbits );
64          std::cout << "length " << length 
65                   << " deb " << deb 
66                   << " nbits " << nbits
67                   << std::endl;
68          if ( nbRead != 3 )
69          {
70             std::cout << "Wrong LUT descriptor" << std::endl;
71          }
72          //LUT Data (CTX dependent)    
73          GDCM_NAME_SPACE::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006); 
74          if ( b != 0 )
75          { 
76             int BitsAllocated = f->GetBitsAllocated();
77             if ( BitsAllocated <= 8 )
78             { 
79                int mult;
80                if ( ( nbits == 16 ) && ( BitsAllocated == 8 ) )
81                {
82                // when LUT item size is different than pixel size
83                   mult = 2; // high byte must be = low byte
84                }
85                else
86                {
87                // See PS 3.3-2003 C.11.1.1.2 p 619
88                   mult = 1;
89                }
90                uint8_t *lut = b->GetBinArea();
91                for( int i=0; i < length; ++i )
92                {
93                   std::cout << i+deb << " : \t"
94                               << (int) (lut[i*mult + 1]) << std::endl;
95                }
96             }
97             else
98             {
99                uint16_t *lut = (uint16_t *)(b->GetBinArea());  
100                for( int i=0; i < length; ++i )
101                {
102                   std::cout << i+deb << " : \t"
103                               << (int) (((uint16_t *)lut)[i])
104                               << std::endl;
105                }             
106             }
107          }  
108          else
109             std::cout << "No LUT Data DataEntry (0x0028,0x3006) found?!? " 
110                         << std::endl;
111       }
112       else
113          std::cout << "No First SQ Item within (0x0028,0x3000) ?!? " 
114                      << std::endl;      
115    }
116    else
117       std::cout << "No LUT Data SeqEntry (0x0028,0x3000) found " 
118                   << std::endl;
119 }
120
121 int main(int argc, char *argv[])
122 {
123
124    START_USAGE(usage)
125    " \n PrintFile : \n                                                        ",
126    " Display the header of a ACR-NEMA/PAPYRUS/DICOM File                      ",
127    " usage: PrintFile {filein=inputFileName|dirin=inputDirectoryName}[level=n]",
128    "                       [forceload=listOfElementsToForceLoad] [rec] [noex] ",
129    "                       [4DLoc= ][dict= privateDirectory]                  ",
130    "                       [ { [noshadowseq] | [noshadow][noseq] } ]          ",
131    "                       [debug] [warning]                                  ",
132    "      level = 0,1,2 : depending on the amount of details user wants to see",
133    "      rec : user wants to parse recursively the directory                 ",
134    "      noex : user doen't want extra 'user friendly' info                  ",   
135    "      4DLoc: group-elem(in hexa, no space) of the DataEntry holdind 4thDim",
136    "      listOfElementsToForceLoad : group-elem,g2-e2,... (in hexa, no space)",
137    "                                of Elements to load whatever their length ",
138    "      privateDirectory : source file full path name of Shadow Group elems ",
139    "      noshadowseq: user doesn't want to load Private Sequences            ",
140    "      noshadow   : user doesn't want to load Private groups (odd number)  ",
141    "      noseq      : user doesn't want to load Sequences                    ",
142    "      debug      : user wants to run the program in 'debug mode'          ",
143    "      warning    : user wants to be warned about any oddity in the File   ",
144    "      showlut :user wants to display the Palette Color (as an int array)  ",
145    FINISH_USAGE
146
147    // Initialize Arguments Manager   
148    GDCM_NAME_SPACE::ArgMgr *am= new GDCM_NAME_SPACE::ArgMgr(argc, argv);
149   
150    if (argc == 1 || am->ArgMgrDefined("usage") )
151    {
152       am->ArgMgrUsage(usage); // Display 'usage'
153       delete am;
154       return 1;
155    }
156
157    const char *fileName = am->ArgMgrGetString("filein");
158    const char *dirName  = am->ArgMgrGetString("dirin");
159
160    if ( (fileName == 0 && dirName == 0) ||
161         (fileName != 0 && dirName != 0) )
162    {
163       std::cerr << std::endl
164         << "Either 'filein=' or 'dirin=' must be present;" 
165         << std::endl << "Not both" << std::endl;
166       am->ArgMgrUsage(usage); // Display 'usage'  
167       delete am;
168       return 1;
169    }   
170       
171    bool noex = ( 0 != am->ArgMgrDefined("noex") );
172    bool rec  = ( 0 != am->ArgMgrDefined("rec") );   
173         
174    if (am->ArgMgrDefined("debug"))
175       GDCM_NAME_SPACE::Debug::DebugOn();
176
177    if (am->ArgMgrDefined("warning"))
178       GDCM_NAME_SPACE::Debug::WarningOn();
179        
180    int loadMode = GDCM_NAME_SPACE::LD_ALL;
181    if ( am->ArgMgrDefined("noshadowseq") )
182       loadMode |= GDCM_NAME_SPACE::LD_NOSHADOWSEQ;
183    else 
184    {
185       if ( am->ArgMgrDefined("noshadow") )
186          loadMode |= GDCM_NAME_SPACE::LD_NOSHADOW;
187       if ( am->ArgMgrDefined("noseq") )
188          loadMode |= GDCM_NAME_SPACE::LD_NOSEQ;
189    }
190
191    int level = am->ArgMgrGetInt("level", 1);
192
193    int forceLoadNb;
194    uint16_t *elemsToForceLoad 
195                            = am->ArgMgrGetXInt16Enum("forceload", &forceLoadNb);
196    
197    int nbP;
198    uint16_t *FourthDimLoc;
199    if ( am->ArgMgrDefined("4DLoc") )
200    {
201       FourthDimLoc = am->ArgMgrGetXInt16Enum("4DLoc", &nbP);
202    
203       if (nbP != 1) 
204       {   
205          std::cout << "4DLoc must have 2 and only 2 components!" << std::endl;
206          delete am;
207          return 1;      
208       }
209    }
210
211    bool showlut = ( 0 != am->ArgMgrDefined("SHOWLUT") );
212
213    bool ddict = am->ArgMgrDefined("dict") ? true : false;
214    const char *dict = 0;
215
216    if (ddict)
217    {
218      dict = am->ArgMgrGetString("dict",0);
219    }
220
221    /* if unused Param we give up */
222    if ( am->ArgMgrPrintUnusedLabels() )
223    {
224       am->ArgMgrUsage(usage);
225       delete am;
226       return 1;
227    } 
228
229    delete am;  // we don't need Argument Manager any longer
230
231    // ----------- End Arguments Manager ---------
232
233  
234    if (ddict)
235    {
236       GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->AddDict(dict);   
237    }
238
239    if ( fileName != 0 ) // ====== Deal with a single file ======
240    { 
241       GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
242       f->SetLoadMode(loadMode);
243       f->SetFileName( fileName );
244
245       for (int ri=0; ri<forceLoadNb; ri++)
246       {
247          f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri], 
248                                 (uint32_t)elemsToForceLoad[2*ri+1] ); 
249       }
250 // TODO : find why such a polution
251 // To avoid polluting the output with messages 
252 // 'Last system error was : No such file or directory'
253
254 errno = 0; 
255
256
257       bool res = f->Load();
258       // GDCM_NAME_SPACE::File::IsReadable() is no usable here, because we deal with
259       // any kind of gdcm-Parsable *document* 
260       // not only GDCM_NAME_SPACE::File (as opposed to GDCM_NAME_SPACE::DicomDir)
261       if ( !res )
262       {
263          std::cout << "Cannot process file [" << fileName << "]" << std::endl;
264          std::cout << "Either it doesn't exist, or it's read protected " 
265                    << std::endl;
266          std::cout << "or it's not a Dicom File, or its 'header' is bugged" 
267                    << std::endl;
268          std::cout << "use 'PrintFile filein=... debug' to try to guess the pb"
269                    << std::endl;
270          f->Delete();
271          return 0;
272       }
273       if (nbP == 1)
274          f->SetFourthDimensionLocation(FourthDimLoc[0],FourthDimLoc[1]);
275
276       GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
277       fh->SetPrintLevel( level );
278
279       fh->Print();
280
281       std::cout << "\n\n" << std::endl; 
282
283       std::cout <<std::endl;
284       std::cout <<" dataSize    " << fh->GetImageDataSize()    << std::endl;
285       std::cout <<" dataSizeRaw " << fh->GetImageDataRawSize() << std::endl;
286 if (!noex)
287 {
288       int nX,nY,nZ,nT,sPP,planarConfig;
289       std::string pixelType;
290       nX=f->GetXSize();
291       nY=f->GetYSize();
292       nZ=f->GetZSize();
293       nT=f->GetTSize();
294       std::cout << " DIMX=" << nX << " DIMY=" << nY 
295                 << " DIMZ=" << nZ << " DIMT=" << nT
296                 << std::endl;
297
298       pixelType    = f->GetPixelType();
299       sPP          = f->GetSamplesPerPixel();
300       std::cout << " pixelType= ["            << pixelType 
301                 << "] SamplesPerPixel= ["     << sPP
302                 << "] ";
303
304       if (sPP == 3)
305       {
306          planarConfig = f->GetPlanarConfiguration();
307          std::cout << " PlanarConfiguration= [" << planarConfig 
308                 << "] "<< std::endl;
309       } 
310       std::cout << " PhotometricInterpretation= [" 
311                 << f->GetEntryString(0x0028,0x0004)
312                 << "] "<< std::endl;
313
314       int numberOfScalarComponents=f->GetNumberOfScalarComponents();
315       std::cout << " NumberOfScalarComponents = " << numberOfScalarComponents 
316                 <<std::endl
317                 << " LUT = " << (f->HasLUT() ? "TRUE" : "FALSE")
318                 << std::endl;
319
320       if ( f->GetDataEntry(0x0002,0x0010) )
321          if ( f->GetDataEntry(0x0002,0x0010)->IsNotLoaded() ) 
322          {
323             std::cout << "Transfer Syntax not loaded. " << std::endl
324                      << "Better you increase MAX_SIZE_LOAD_ELEMENT_VALUE"
325                   << std::endl;
326             f->Delete();
327             return 0;
328          }
329   
330       std::string transferSyntaxName = f->GetTransferSyntaxName();
331       std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" 
332                 << std::endl;
333       std::cout << " SwapCode= " << f->GetSwapCode() << std::endl;
334       std::cout << " ------" << std::endl;
335
336       std::cout << "\n\n" << std::endl; 
337       std::cout << "X spacing " << f->GetXSpacing() << std::endl;
338       std::cout << "Y spacing " << f->GetYSpacing() << std::endl;
339       std::cout << "Z spacing " << f->GetZSpacing() << std::endl;
340     
341 //------------------------------
342
343       // Let's get and print some usefull fields about 'Orientation'
344       // ------------------------------------------------------------
345
346       std::string strPatientPosition = 
347                                       f->GetEntryString(0x0018,0x5100);
348       if ( strPatientPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
349         && strPatientPosition != "" )  
350             std::cout << "PatientPosition (0x0010,0x5100)= [" 
351                       << strPatientPosition << "]" << std::endl;
352  
353       std::string strViewPosition = 
354                                       f->GetEntryString(0x0018,0x5101);
355       if ( strViewPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
356         && strViewPosition != "" )  
357             std::cout << "View Position (0x0018,0x5101)= [" 
358                       << strViewPosition << "]" << std::endl;
359       
360      std::string strPatientOrientation = 
361                                       f->GetEntryString(0x0020,0x0020);
362       if ( strPatientOrientation != GDCM_NAME_SPACE::GDCM_UNFOUND
363         && strPatientOrientation != "")  
364          std::cout << "PatientOrientation (0x0020,0x0020)= [" 
365                    << strPatientOrientation << "]" << std::endl;
366
367       std::string strImageOrientationPatient = 
368                                       f->GetEntryString(0x0020,0x0037);  
369       if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND
370         && strImageOrientationPatient != "" )  
371          std::cout << "ImageOrientationPatient (0x0020,0x0037)= [" 
372                    << strImageOrientationPatient << "]" << std::endl;
373
374       std::string strImageOrientationRET = 
375                                       f->GetEntryString(0x0020,0x0035);
376       if ( strImageOrientationRET != GDCM_NAME_SPACE::GDCM_UNFOUND
377         && strImageOrientationRET != "" )  
378          std::cout << "ImageOrientationRET (0x0020,0x0035)= [" 
379                    << strImageOrientationRET << "]" << std::endl;
380
381       std::string strImagePositionPatient = 
382                                       f->GetEntryString(0x0020,0x0032);  
383       if ( strImagePositionPatient != GDCM_NAME_SPACE::GDCM_UNFOUND
384         && strImagePositionPatient != "" )  
385          std::cout << "ImagePositionPatient (0x0020,0x0032)= [" 
386                    << strImagePositionPatient << "]" << std::endl;
387
388       std::string strImagePositionPatientRET = 
389                                       f->GetEntryString(0x0020,0x0030);
390       if ( strImagePositionPatientRET != GDCM_NAME_SPACE::GDCM_UNFOUND
391         && strImagePositionPatientRET != "" )  
392          std::cout << "ImagePositionPatientRET (0x0020,0x0030)= [" 
393                    << strImagePositionPatientRET << "]" << std::endl;
394   
395      float iop[6];
396      /*bool riop = */f->GetImageOrientationPatient(iop);  
397      float ipp[3];
398      /*bool ripp = */f->GetImagePositionPatient(ipp);
399
400      std::cout << "Image Position (0x0020,0x0032|0x0030) : "
401                << ipp[0] << " , " << ipp[1] << " , "<< ipp[2]
402                << std::endl;
403      std::cout << "Image Orientation (0x0020,0x0037|0x0035) : "
404                << iop[0] << " , " << iop[1] << " , "<< iop[2] << " , "
405                << iop[3] << " , " << iop[4] << " , "<< iop[5]
406                << std::endl; 
407
408
409       // Let's compute 'user friendly' results about 'Orientation'
410       // ---------------------------------------------------------
411  
412       GDCM_NAME_SPACE::Orientation *o = GDCM_NAME_SPACE::Orientation::New();
413
414       if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND ||
415            strImageOrientationRET     != GDCM_NAME_SPACE::GDCM_UNFOUND )
416       {
417   
418          GDCM_NAME_SPACE::OrientationType orient = o->GetOrientationType( f );
419  
420          std::cout << "TypeOrientation = " << orient << " (-> " 
421                    << o->GetOrientationTypeString(orient) << " )" << std::endl;
422       }
423
424       std::string ori = o->GetOrientation ( f );
425       if (ori != "\\" )
426          std::cout << "Orientation [" << ori << "]" << std::endl;
427       o->Delete();
428 }  
429 //------------------------------
430
431
432       // Display the LUT as an int array (for debugging purpose)
433       if ( f->HasLUT() && showlut )
434       {
435          uint8_t* lutrgba = fh->GetLutRGBA();
436          if ( lutrgba == 0 )
437          {
438             std::cout << "Lut RGBA (Palette Color) not built " << std::endl;
439  
440            // Nothing is written yet to get LUT Data user friendly
441            // The following is to be moved into a PixelRedaConvert method
442   
443             GDCM_NAME_SPACE::SeqEntry *modLutSeq = f->GetSeqEntry(0x0028,0x3000);
444             if ( modLutSeq !=0 )
445             {
446                GDCM_NAME_SPACE::SQItem *sqi= modLutSeq->GetFirstSQItem();
447                if ( !sqi )
448                {
449                   std::string lutDescriptor = sqi->GetEntryString(0x0028,0x3002);
450                   int length;   // LUT length in Bytes
451                   int deb;      // Subscript of the first Lut Value
452                   int nbits;    // Lut item size (in Bits)
453                   int nbRead;   // nb of items in LUT descriptor (must be = 3)
454
455                   nbRead = sscanf( lutDescriptor.c_str(),
456                                     "%d\\%d\\%d",
457                                      &length, &deb, &nbits );
458                   if ( nbRead != 3 )
459                   {
460                       std::cout << "Wrong LUT descriptor" << std::endl;
461                   }                                                  
462                   GDCM_NAME_SPACE::DataEntry *b = sqi->GetDataEntry(0x0028,0x3006);
463                   if ( b != 0 )
464                   {
465                      if ( b->GetLength() != 0 )
466                      {
467                         std::cout << "---------------------------------------"
468                                << " We should never reach this point      "
469                                << std::endl;
470                         //LoadEntryBinArea(b);    //LUT Data (CTX dependent)
471                      }   
472                  }
473               }      
474             }
475             else
476                std::cout << "No LUT Data (0x0028,0x3000) found " << std::endl;
477         }
478          else
479          {
480             if ( fh->GetLutItemSize() == 8 )
481             {
482                for (int i=0;i<fh->GetLutItemNumber();i++)
483                   std::cout << i << " : \t"
484                          << (int)(lutrgba[i*4])   << " "
485                          << (int)(lutrgba[i*4+1]) << " "
486                          << (int)(lutrgba[i*4+2]) << std::endl;
487             }
488             else // LutItemSize assumed to be = 16
489             {
490                uint16_t* lutrgba16 = (uint16_t*)lutrgba;
491                for (int i=0;i<fh->GetLutItemNumber();i++)
492                   std::cout << i << " : \t"
493                          << (int)(lutrgba16[i*4])   << " "
494                          << (int)(lutrgba16[i*4+1]) << " "
495                          << (int)(lutrgba16[i*4+2]) << std::endl;
496             }
497          }
498       }
499       else if (showlut)
500       {
501          std::cout << "Try LUT Data "<< std::endl;
502          ShowLutData(f);
503       }
504
505       // Parsability of the GDCM_NAME_SPACE::Document already checked, after Load() !
506       
507       if ( f->IsReadable() )
508       {
509          std::cout <<std::endl<<fileName<<" is Readable"<<std::endl;
510       }
511       else if ( f->GetSeqEntry(0x0041,0x1010) )
512       {
513          std::cout <<std::endl<<fileName<<" looks like a 'PAPYRUS image' file"
514                    <<std::endl;
515       }
516       else if ( f->GetSeqEntry(0x0004,0x1220) )
517       {
518          std::cout <<std::endl<<fileName<<" looks like a 'DICOMDIR file'"
519                    <<std::endl;
520       }
521       else 
522       {
523          std::cout <<std::endl<<fileName<<" doesn't look like an image file "
524              <<std::endl; 
525       }
526  
527       std::cout<<std::flush;
528       f->Delete();
529       fh->Delete();
530    }
531    else  // ====== Deal with a Directory ======
532    {
533       std::cout << "dirName [" << dirName << "]" << std::endl;
534       
535       GDCM_NAME_SPACE::DirList dirList(dirName,rec); // gets recursively (or not) the file list
536       GDCM_NAME_SPACE::DirListType fileList = dirList.GetFilenames();
537       GDCM_NAME_SPACE::File *f;
538       bool res;
539
540       for( GDCM_NAME_SPACE::DirListType::iterator it  = fileList.begin();
541                                  it != fileList.end();
542                                  ++it )
543       {
544          std::cout << std::endl<<" Start processing :[" << it->c_str() << "]"
545                    << std::endl;
546          f = GDCM_NAME_SPACE::File::New();
547          f->SetLoadMode(loadMode);
548          f->SetFileName( it->c_str() );
549
550          for (int ri=0; ri<forceLoadNb; ri++)
551          {
552             printf("%04x,%04x\n",elemsToForceLoad[2*ri], 
553                                  elemsToForceLoad[2*ri+1]);
554             f->AddForceLoadElement((uint32_t)elemsToForceLoad[2*ri], 
555                                    (uint32_t)elemsToForceLoad[2*ri+1]); 
556          }
557          res = f->Load();
558
559          if ( !res )
560          {
561             std::cout << "Cannot process file [" << it->c_str() << "]" 
562                       << std::endl;
563             std::cout << "Either it doesn't exist, or it's read protected " 
564                       << std::endl;
565             std::cout << "or it's not a Dicom File, or its 'header' is bugged" 
566                       << std::endl;
567             std::cout << "use 'PrintFile filein=... debug' "
568                       << "to try to guess the pb"
569                       << std::endl;
570             f->Delete();
571             continue;
572          }
573
574          GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f);
575          fh->SetPrintLevel( level );
576          fh->Print();
577
578 //------------------------------
579 if (!noex)
580 {
581          // Lets's get and print some usefull fields about 'Orientation'
582          // ------------------------------------------------------------
583
584          std::string strPatientPosition = 
585                                        f->GetEntryString(0x0018,0x5100);
586          if ( strPatientPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
587          && strPatientPosition != "" )  
588                std::cout << "PatientPosition (0x0010,0x5100)= [" 
589                         << strPatientPosition << "]" << std::endl;
590     
591          std::string strViewPosition = 
592                                        f->GetEntryString(0x0018,0x5101);
593          if ( strViewPosition != GDCM_NAME_SPACE::GDCM_UNFOUND 
594          && strViewPosition != "" )  
595                std::cout << "strViewPosition (0x0010,0x5101)= [" 
596                         << strViewPosition << "]" << std::endl;
597          
598          std::string strPatientOrientation = 
599                                        f->GetEntryString(0x0020,0x0020);
600          if ( strPatientOrientation != GDCM_NAME_SPACE::GDCM_UNFOUND
601          && strPatientOrientation != "")  
602             std::cout << "PatientOrientation (0x0020,0x0020)= [" 
603                       << strPatientOrientation << "]" << std::endl;
604
605          std::string strImageOrientationPatient = 
606                                        f->GetEntryString(0x0020,0x0037);  
607          if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND
608          && strImageOrientationPatient != "" )  
609             std::cout << "ImageOrientationPatient (0x0020,0x0037)= [" 
610                      << strImageOrientationPatient << "]" << std::endl;
611
612          std::string strImageOrientationRET = 
613                                        f->GetEntryString(0x0020,0x0035);
614          if ( strImageOrientationRET != GDCM_NAME_SPACE::GDCM_UNFOUND
615          && strImageOrientationRET != "" )
616          {
617             std::cout << "ImageOrientationRET (0x0020,0x0035)= [" 
618                      << strImageOrientationRET << "]" << std::endl;
619          }
620
621          // Let's compute 'user friendly' results about 'Orientation'
622          // ---------------------------------------------------------
623     
624          GDCM_NAME_SPACE::Orientation *o = GDCM_NAME_SPACE::Orientation::New(); 
625
626
627          if ( strImageOrientationPatient != GDCM_NAME_SPACE::GDCM_UNFOUND ||
628             strImageOrientationRET     != GDCM_NAME_SPACE::GDCM_UNFOUND )
629          {
630      
631             GDCM_NAME_SPACE::OrientationType orient = o->GetOrientationType( f );
632     
633             std::cout << "TypeOrientation = " << orient << " (-> " 
634                      << o->GetOrientationTypeString(orient) << " )" << std::endl;
635          }
636
637          std::string ori = o->GetOrientation ( f );
638          if (ori != "\\" )
639             std::cout << "Orientation [" << ori << "]" << std::endl;
640          o->Delete(); 
641 }
642 //------------------------------- 
643         
644          if (f->IsReadable())
645             std::cout <<std::endl<<it->c_str()<<" is Readable"<<std::endl;
646          else
647             std::cout <<std::endl<<it->c_str()<<" is NOT Readable"<<std::endl;
648          std::cout << "\n\n" << std::endl;
649          f->Delete();
650          fh->Delete();
651       }
652       std::cout<<std::flush;
653    }
654    return 0;
655 }