1 /*=========================================================================
4 Module: $RCSfile: TestFileAccessors.cxx,v $
6 Date: $Date: 2006/04/07 10:58:51 $
7 Version: $Revision: 1.9 $
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.
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.
17 =========================================================================*/
19 // TODO : check what's *actually* usefull
21 #include "gdcmDictEntry.h"
23 #include "gdcmDictSet.h"
25 #include "gdcmFileHelper.h"
27 #include "gdcmCommon.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"
38 #include "gdcmDataImages.h"
40 #define TestMethodMacro(mode,obj,name) \
43 std::cout <<" "<< #name << "() : " \
46 << mode << obj->name() << std::endl; \
50 std::cout << " --> Can't access to the '" \
51 << #name << "' method !" << std::endl;\
56 int TestFileAccessors(int argc, char *argv[])
62 // gdcm::Debug::DebugOn();
64 while( gdcmDataImages[i] != 0 )
67 // Keep the comment to be able to track a bug on a given image
70 // if (gdcmDataImages[i] == "00191113.dcm" )
71 // gdcm::Debug::DebugOn();
73 // gdcm::Debug::DebugOff();
82 filename = GDCM_DATA_ROOT;
83 filename += "/"; //doh!
84 filename += gdcmDataImages[i];
87 std::cout << " ----------------------------------------------"
88 << "Begin with " << filename << std::endl;
90 gdcm::File *f= gdcm::File::New( );
91 f->SetFileName( filename );
94 // We don't check the returned values
95 // We just want to be sure no accessor seg faults on any image ...
96 // And this will improve test coverage ;-)
98 TestMethodMacro(std::dec,f,GetSwapCode)
99 TestMethodMacro(std::dec,f,GetImageNumber)
100 TestMethodMacro(std::dec,f,GetModality)
101 TestMethodMacro(std::dec,f,GetXSize)
102 TestMethodMacro(std::dec,f,GetYSize)
103 TestMethodMacro(std::dec,f,GetZSize)
104 TestMethodMacro(std::dec,f,GetXSpacing)
105 TestMethodMacro(std::dec,f,GetYSpacing)
106 TestMethodMacro(std::dec,f,GetZSpacing)
107 TestMethodMacro(std::dec,f,GetXOrigin)
108 TestMethodMacro(std::dec,f,GetYOrigin)
109 TestMethodMacro(std::dec,f,GetZOrigin)
110 TestMethodMacro(std::dec,f,GetBitsStored)
111 TestMethodMacro(std::dec,f,GetBitsAllocated)
112 TestMethodMacro(std::dec,f,GetHighBitPosition)
113 TestMethodMacro(std::dec,f,GetSamplesPerPixel)
114 TestMethodMacro(std::dec,f,GetPlanarConfiguration)
115 TestMethodMacro(std::dec,f,GetPixelSize)
116 TestMethodMacro(std::dec,f,GetPixelType)
117 TestMethodMacro(std::dec,f,GetLUTNbits)
118 TestMethodMacro(std::dec,f,GetRescaleIntercept)
119 TestMethodMacro(std::dec,f,GetRescaleSlope)
120 TestMethodMacro(std::hex,f,GetGrPixel)
121 TestMethodMacro(std::hex,f,GetNumPixel)
122 TestMethodMacro(std::dec,f,GetPixelOffset)
124 TestMethodMacro(std::dec,f,GetPixelAreaLength)
125 TestMethodMacro(std::dec,f,GetNumberOfScalarComponents)
126 TestMethodMacro(std::dec,f,GetNumberOfScalarComponentsRaw)
127 TestMethodMacro(std::dec,f,IsSignedPixelData)
128 TestMethodMacro(std::dec,f,IsMonochrome)
129 TestMethodMacro(std::dec,f,IsPaletteColor)
130 TestMethodMacro(std::dec,f,IsYBRFull)
131 TestMethodMacro(std::dec,f,HasLUT)
132 TestMethodMacro(std::dec,f,GetTransferSyntax)
133 TestMethodMacro(std::dec,f,GetTransferSyntaxName)
134 TestMethodMacro(std::dec,f,GetFileType)
135 TestMethodMacro(std::dec,f,GetFileName)
137 f->GetImageOrientationPatient( iop );
138 std::cout << " Orientation:" << std::endl;
139 for (int j=0; j<6; j++)
140 std::cout << " iop[" << j << "] = " << iop[j] << std::endl;
142 if( f->IsReadable() )
144 std::cout << " " << filename << " is Readable" << std::endl;
146 gdcm::FileHelper *fh= gdcm::FileHelper::New( f );
148 TestMethodMacro(std::dec,fh,GetImageDataSize)
149 TestMethodMacro(std::dec,fh,GetImageDataRawSize)
150 TestMethodMacro(std::dec,fh,GetRGBDataSize)
151 TestMethodMacro(std::dec,fh,GetRawDataSize)
152 TestMethodMacro(std::dec,fh,GetUserDataSize)
153 TestMethodMacro(std::dec,fh,GetWriteType)
159 std::cout << filename << " is NOT Readable"
160 << std::endl << std::endl;
167 break; // user asked to check a single file.