]> Creatis software - gdcm.git/blob - Testing/TestFileAccessors.cxx
To improve test coverage
[gdcm.git] / Testing / TestFileAccessors.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: TestFileAccessors.cxx,v $
5   Language:  C++
6   Date:      $Date: 2005/02/03 09:51:53 $
7   Version:   $Revision: 1.1 $
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 *e1= new gdcm::File( filename );
55
56 // We don't check the returned values
57 // We just want to be sure no accessor seg faults on any image  ...
58 // And this will improve test coverage ;-)
59
60       std::cout << "GetSwapCode()"      << e1->GetSwapCode()      << std::endl;
61       std::cout << "GetImageNumber()"   << e1->GetImageNumber()   << std::endl;
62       std::cout << "GetModality()"      << e1->GetModality()      << std::endl;
63       std::cout << "GetXSize()"         << e1->GetXSize()         << std::endl;
64       std::cout << "GetYSize()"         << e1->GetYSize()         << std::endl;
65       std::cout << "GetZSize()"         << e1->GetZSize()         << std::endl;
66       std::cout << "GetXSpacing()"      << e1->GetXSpacing()      << std::endl;
67       std::cout << "GetYSpacing()"      << e1->GetYSpacing()      << std::endl;
68       std::cout << "GetZSpacing()"      << e1->GetZSpacing()      << std::endl;
69       std::cout << "GetXOrigin()"       << e1->GetXOrigin()       << std::endl;
70       std::cout << "GetYOrigin()"       << e1->GetYOrigin()       << std::endl;
71       std::cout << "GetZOrigin()"       << e1->GetZOrigin()       << std::endl;
72       std::cout << "GetBitsStored()"    << e1->GetBitsStored()    << std::endl;
73       std::cout << "GetBitsAllocated()" << e1->GetBitsAllocated() << std::endl;
74       std::cout << "GetHighBitPosition()" << e1->GetHighBitPosition()  << std::endl;
75       std::cout << "GetSamplesPerPixel()" << e1->GetSamplesPerPixel()  << std::endl;
76       std::cout << "GetPlanarConfiguration()" << e1->GetPlanarConfiguration()    << std::endl;
77       std::cout << "GetPixelSize()"        << e1->GetPixelSize()        << std::endl;
78       std::cout << "GetPixelType()"        << e1->GetPixelType()        << std::endl;
79       std::cout << "GetLUTNbits()"         << e1->GetLUTNbits()         << std::endl;
80       std::cout << "GetRescaleIntercept()" << e1->GetRescaleIntercept() << std::endl;
81       std::cout << "GetRescaleSlope()"     << e1->GetRescaleSlope()     << std::endl;
82       std::cout << "GetGrPixel()"  << std::hex << e1->GetGrPixel()  << std::endl;
83       std::cout << "GetNumPixel()" << std::hex << e1->GetNumPixel() << std::endl;
84       std::cout << "GetPixelOffset()" << e1->GetPixelOffset() << std::endl;
85
86       std::cout << "GetPixelAreaLength()"     << e1->GetPixelAreaLength()<< std::endl;
87       std::cout << "GetNumberOfScalarComponents()"    << e1->GetNumberOfScalarComponents()<< std::endl;
88       std::cout << "GetNumberOfScalarComponentsRaw()" << e1->GetNumberOfScalarComponentsRaw()<< std::endl;
89       std::cout << "IsSignedPixelData()"      << e1->IsSignedPixelData()<< std::endl;
90       std::cout << "IsMonochrome()"           << e1->IsMonochrome()     << std::endl;
91       std::cout << "IsPaletteColor()"         << e1->IsPaletteColor()   << std::endl;
92       std::cout << "IsYBRFull()"              << e1->IsYBRFull()        << std::endl;
93       std::cout << "HasLut()   "              << e1->HasLUT()           << std::endl;
94       std::cout << "GetTransferSyntax()"      << e1->GetTransferSyntax()      << std::endl;
95       std::cout << "GetTransferSyntaxName()"  << e1->GetTransferSyntaxName()  << std::endl;
96       std::cout << "GetFileType()"            << e1->GetFileType()            << std::endl;
97       std::cout << "GetFileName()"            << e1->GetFileName()            << std::endl;
98
99       e1->GetImageOrientationPatient( iop );
100       for (int j=0; j<6; j++)
101          std::cout << "iop[" << j << "] = " << iop[j] << std::endl;
102
103       if( e1->IsReadable() )
104       {
105          std::cout <<filename   << " is Readable" 
106                    << std::endl << std::endl;
107
108          gdcm::FileHelper *fh1= new gdcm::FileHelper( e1 );   
109
110          // TODO : Newbe user would appreciate any comment !
111  
112          std::cout << "GetImageDataSize()"    << fh1->GetImageDataSize()    << std::endl;
113          std::cout << "GetImageDataRawSize()" << fh1->GetImageDataRawSize() << std::endl;
114          // User Data
115          std::cout << "GetRGBDataSize()"      << fh1->GetRGBDataSize()      << std::endl;
116          std::cout << "GetRawDataSize()"      << fh1->GetRawDataSize()      << std::endl;
117          std::cout << "GetUserDataSize()"     << fh1->GetUserDataSize()     << std::endl;
118
119          std::cout << "GetWriteType()"        << fh1->GetWriteType()        << std::endl;
120  
121          delete fh1;
122       }
123       else
124       {
125          std::cout << filename << " is NOT Readable" 
126                    << std::endl << std::endl;
127          delete e1;
128          return 1;
129       }
130
131       delete e1;
132       i++;
133    }
134    return 0;
135 }