]> Creatis software - gdcm.git/blob - Testing/TestFileAccessors.cxx
New gdcm2 style syntax for Load()
[gdcm.git] / Testing / TestFileAccessors.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestFileAccessors.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/07/08 13:39:57 $
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 "gdcmFileHelper.h"
26 #include "gdcmUtil.h"
27 #include "gdcmCommon.h"
28 #include "gdcmBinEntry.h"  
29 #include "gdcmDocEntry.h" 
30 #include "gdcmDocEntrySet.h"           
31 #include "gdcmDocument.h"          
32 #include "gdcmElementSet.h"        
33 #include "gdcmSeqEntry.h" 
34 #include "gdcmSQItem.h" 
35 #include "gdcmValEntry.h" 
36
37 #include <iostream>
38
39 //Generated file:
40 #include "gdcmDataImages.h"
41
42 int TestFileAccessors(int, char *[])
43 {
44    int i = 0;
45
46    float iop[6];
47
48    while( gdcmDataImages[i] != 0 )
49    {
50       std::string filename = GDCM_DATA_ROOT;
51       filename += "/";  //doh!
52       filename += gdcmDataImages[i];
53       
54       gdcm::File *f= new gdcm::File( );
55       f->SetFileName( filename );
56       f->Load( );
57
58 // We don't check the returned values
59 // We just want to be sure no accessor seg faults on any image  ...
60 // And this will improve test coverage ;-)
61
62       std::cout << "GetSwapCode()"      << f->GetSwapCode()      << std::endl;
63       std::cout << "GetImageNumber()"   << f->GetImageNumber()   << std::endl;
64       std::cout << "GetModality()"      << f->GetModality()      << std::endl;
65       std::cout << "GetXSize()"         << f->GetXSize()         << std::endl;
66       std::cout << "GetYSize()"         << f->GetYSize()         << std::endl;
67       std::cout << "GetZSize()"         << f->GetZSize()         << std::endl;
68       std::cout << "GetXSpacing()"      << f->GetXSpacing()      << std::endl;
69       std::cout << "GetYSpacing()"      << f->GetYSpacing()      << std::endl;
70       std::cout << "GetZSpacing()"      << f->GetZSpacing()      << std::endl;
71       std::cout << "GetXOrigin()"       << f->GetXOrigin()       << std::endl;
72       std::cout << "GetYOrigin()"       << f->GetYOrigin()       << std::endl;
73       std::cout << "GetZOrigin()"       << f->GetZOrigin()       << std::endl;
74       std::cout << "GetBitsStored()"    << f->GetBitsStored()    << std::endl;
75       std::cout << "GetBitsAllocated()" << f->GetBitsAllocated() << std::endl;
76       std::cout << "GetHighBitPosition()" << f->GetHighBitPosition()  << std::endl;
77       std::cout << "GetSamplesPerPixel()" << f->GetSamplesPerPixel()  << std::endl;
78       std::cout << "GetPlanarConfiguration()" << f->GetPlanarConfiguration()    << std::endl;
79       std::cout << "GetPixelSize()"        << f->GetPixelSize()        << std::endl;
80       std::cout << "GetPixelType()"        << f->GetPixelType()        << std::endl;
81       std::cout << "GetLUTNbits()"         << f->GetLUTNbits()         << std::endl;
82       std::cout << "GetRescaleIntercept()" << f->GetRescaleIntercept() << std::endl;
83       std::cout << "GetRescaleSlope()"     << f->GetRescaleSlope()     << std::endl;
84       std::cout << "GetGrPixel()"  << std::hex << f->GetGrPixel()  << std::endl;
85       std::cout << "GetNumPixel()" << std::hex << f->GetNumPixel() << std::endl;
86       std::cout << "GetPixelOffset()" << f->GetPixelOffset() << std::endl;
87
88       std::cout << "GetPixelAreaLength()"     << f->GetPixelAreaLength()<< std::endl;
89       std::cout << "GetNumberOfScalarComponents()"    << f->GetNumberOfScalarComponents()<< std::endl;
90       std::cout << "GetNumberOfScalarComponentsRaw()" << f->GetNumberOfScalarComponentsRaw()<< std::endl;
91       std::cout << "IsSignedPixelData()"      << f->IsSignedPixelData()<< std::endl;
92       std::cout << "IsMonochrome()"           << f->IsMonochrome()     << std::endl;
93       std::cout << "IsPaletteColor()"         << f->IsPaletteColor()   << std::endl;
94       std::cout << "IsYBRFull()"              << f->IsYBRFull()        << std::endl;
95       std::cout << "HasLut()   "              << f->HasLUT()           << std::endl;
96       std::cout << "GetTransferSyntax()"      << f->GetTransferSyntax()      << std::endl;
97       std::cout << "GetTransferSyntaxName()"  << f->GetTransferSyntaxName()  << std::endl;
98       std::cout << "GetFileType()"            << f->GetFileType()            << std::endl;
99       std::cout << "GetFileName()"            << f->GetFileName()            << std::endl;
100
101       f->GetImageOrientationPatient( iop );
102       for (int j=0; j<6; j++)
103          std::cout << "iop[" << j << "] = " << iop[j] << std::endl;
104
105       if( f->IsReadable() )
106       {
107          std::cout <<filename   << " is Readable" 
108                    << std::endl << std::endl;
109
110          gdcm::FileHelper *fh= new gdcm::FileHelper( f );   
111
112          // TODO : Newbe user would appreciate any comment !
113  
114          std::cout << "GetImageDataSize()"    << fh->GetImageDataSize()    << std::endl;
115          std::cout << "GetImageDataRawSize()" << fh->GetImageDataRawSize() << std::endl;
116          // User Data
117          std::cout << "GetRGBDataSize()"      << fh->GetRGBDataSize()      << std::endl;
118          std::cout << "GetRawDataSize()"      << fh->GetRawDataSize()      << std::endl;
119          std::cout << "GetUserDataSize()"     << fh->GetUserDataSize()     << std::endl;
120
121          std::cout << "GetWriteType()"        << fh->GetWriteType()        << std::endl;
122  
123          delete fh;
124       }
125       else
126       {
127          std::cout << filename << " is NOT Readable" 
128                    << std::endl << std::endl;
129          delete f;
130          return 1;
131       }
132
133       delete f;
134       i++;
135    }
136    return 0;
137 }