1 /*=========================================================================
4 Module: $RCSfile: TestFileAccessors.cxx,v $
6 Date: $Date: 2005/11/28 11:54:46 $
7 Version: $Revision: 1.7 $
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 << "() : " << mode << obj->name() << std::endl; \
47 std::cout << " --> Can't access to the '" << #name << "' method !" << std::endl; \
53 int TestFileAccessors(int, char *[])
59 while( gdcmDataImages[i] != 0 )
62 if (gdcmDataImages[i] == "00191113.dcm" )
63 gdcm::Debug::DebugOn();
65 gdcm::Debug::DebugOff();
67 std::string filename = GDCM_DATA_ROOT;
68 filename += "/"; //doh!
69 filename += gdcmDataImages[i];
71 std::cout << "Begin with " << filename << std::endl;
72 gdcm::File *f= gdcm::File::New( );
73 f->SetFileName( filename );
76 // We don't check the returned values
77 // We just want to be sure no accessor seg faults on any image ...
78 // And this will improve test coverage ;-)
80 TestMethodMacro(std::dec,f,GetSwapCode)
81 TestMethodMacro(std::dec,f,GetImageNumber)
82 TestMethodMacro(std::dec,f,GetModality)
83 TestMethodMacro(std::dec,f,GetXSize)
84 TestMethodMacro(std::dec,f,GetYSize)
85 TestMethodMacro(std::dec,f,GetZSize)
86 TestMethodMacro(std::dec,f,GetXSpacing)
87 TestMethodMacro(std::dec,f,GetYSpacing)
88 TestMethodMacro(std::dec,f,GetZSpacing)
89 TestMethodMacro(std::dec,f,GetXOrigin)
90 TestMethodMacro(std::dec,f,GetYOrigin)
91 TestMethodMacro(std::dec,f,GetZOrigin)
92 TestMethodMacro(std::dec,f,GetBitsStored)
93 TestMethodMacro(std::dec,f,GetBitsAllocated)
94 TestMethodMacro(std::dec,f,GetHighBitPosition)
95 TestMethodMacro(std::dec,f,GetSamplesPerPixel)
96 TestMethodMacro(std::dec,f,GetPlanarConfiguration)
97 TestMethodMacro(std::dec,f,GetPixelSize)
98 TestMethodMacro(std::dec,f,GetPixelType)
99 TestMethodMacro(std::dec,f,GetLUTNbits)
100 TestMethodMacro(std::dec,f,GetRescaleIntercept)
101 TestMethodMacro(std::dec,f,GetRescaleSlope)
102 TestMethodMacro(std::hex,f,GetGrPixel)
103 TestMethodMacro(std::hex,f,GetNumPixel)
104 TestMethodMacro(std::dec,f,GetPixelOffset)
106 TestMethodMacro(std::dec,f,GetPixelAreaLength)
107 TestMethodMacro(std::dec,f,GetNumberOfScalarComponents)
108 TestMethodMacro(std::dec,f,GetNumberOfScalarComponentsRaw)
109 TestMethodMacro(std::dec,f,IsSignedPixelData)
110 TestMethodMacro(std::dec,f,IsMonochrome)
111 TestMethodMacro(std::dec,f,IsPaletteColor)
112 TestMethodMacro(std::dec,f,IsYBRFull)
113 TestMethodMacro(std::dec,f,HasLUT)
114 TestMethodMacro(std::dec,f,GetTransferSyntax)
115 TestMethodMacro(std::dec,f,GetTransferSyntaxName)
116 TestMethodMacro(std::dec,f,GetFileType)
117 TestMethodMacro(std::dec,f,GetFileName)
119 f->GetImageOrientationPatient( iop );
120 std::cout << " Orientation:" << std::endl;
121 for (int j=0; j<6; j++)
122 std::cout << " iop[" << j << "] = " << iop[j] << std::endl;
124 if( f->IsReadable() )
126 std::cout << " " << filename << " is Readable" << std::endl;
128 gdcm::FileHelper *fh= gdcm::FileHelper::New( f );
130 TestMethodMacro(std::dec,fh,GetImageDataSize)
131 TestMethodMacro(std::dec,fh,GetImageDataRawSize)
132 TestMethodMacro(std::dec,fh,GetRGBDataSize)
133 TestMethodMacro(std::dec,fh,GetRawDataSize)
134 TestMethodMacro(std::dec,fh,GetUserDataSize)
135 TestMethodMacro(std::dec,fh,GetWriteType)
141 std::cout << filename << " is NOT Readable"
142 << std::endl << std::endl;
148 std::cout << "End with " << filename << std::endl;