1 /*=========================================================================
4 Module: $RCSfile: TestFileAccessors.cxx,v $
6 Date: $Date: 2005/07/08 13:39:57 $
7 Version: $Revision: 1.2 $
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 "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"
40 #include "gdcmDataImages.h"
42 int TestFileAccessors(int, char *[])
48 while( gdcmDataImages[i] != 0 )
50 std::string filename = GDCM_DATA_ROOT;
51 filename += "/"; //doh!
52 filename += gdcmDataImages[i];
54 gdcm::File *f= new gdcm::File( );
55 f->SetFileName( filename );
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 ;-)
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;
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;
101 f->GetImageOrientationPatient( iop );
102 for (int j=0; j<6; j++)
103 std::cout << "iop[" << j << "] = " << iop[j] << std::endl;
105 if( f->IsReadable() )
107 std::cout <<filename << " is Readable"
108 << std::endl << std::endl;
110 gdcm::FileHelper *fh= new gdcm::FileHelper( f );
112 // TODO : Newbe user would appreciate any comment !
114 std::cout << "GetImageDataSize()" << fh->GetImageDataSize() << std::endl;
115 std::cout << "GetImageDataRawSize()" << fh->GetImageDataRawSize() << std::endl;
117 std::cout << "GetRGBDataSize()" << fh->GetRGBDataSize() << std::endl;
118 std::cout << "GetRawDataSize()" << fh->GetRawDataSize() << std::endl;
119 std::cout << "GetUserDataSize()" << fh->GetUserDataSize() << std::endl;
121 std::cout << "GetWriteType()" << fh->GetWriteType() << std::endl;
127 std::cout << filename << " is NOT Readable"
128 << std::endl << std::endl;