X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDocument.cxx;h=778e9a3854189ba48174d14f91e87e3f0432157b;hb=693be63ee7a331d55d3791caa637e40679f31251;hp=d97f16bdabbf5c5e1ca91caad0af435c7cfe655e;hpb=2e1c3057561211515df8c8ccc03b3ed0df1a2fc1;p=gdcm.git diff --git a/src/gdcmDocument.cxx b/src/gdcmDocument.cxx index d97f16bd..778e9a38 100644 --- a/src/gdcmDocument.cxx +++ b/src/gdcmDocument.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDocument.cxx,v $ Language: C++ - Date: $Date: 2005/05/03 09:43:04 $ - Version: $Revision: 1.239 $ + Date: $Date: 2005/05/18 10:12:07 $ + Version: $Revision: 1.240 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1828,7 +1828,9 @@ bool Document::CheckSwap() // Position the file position indicator at first tag // (i.e. after the file preamble and the "DICM" string). - Fp->seekg(0, std::ios::beg); + + Fp->seekg(0, std::ios::beg); // FIXME : Is it usefull? + Fp->seekg ( 132L, std::ios::beg); return true; } // ------------------------------- End of DicomV3 ---------------- @@ -1837,10 +1839,43 @@ bool Document::CheckSwap() // preamble. We can reset the file position indicator to where the data // is (i.e. the beginning of the file). - gdcmWarningMacro( "Not a DICOM Version3 file"); + gdcmWarningMacro( "Not a Kosher DICOM Version3 file (no preamble)"); Fp->seekg(0, std::ios::beg); + // Let's check 'No Preamble Dicom File' : + // Should start with group 0x0002 + // and be Explicit Value Representation + + s16 = *((uint16_t *)(deb)); + SwapCode = 0; + switch ( s16 ) + { + case 0x0002 : + SwapCode = 1234; + entCur = deb + 4; + break; + case 0x0200 : + SwapCode = 4321; + entCur = deb + 6; + } + + if ( SwapCode != 0 ) + { + if( memcmp(entCur, "UL", (size_t)2) == 0 || + memcmp(entCur, "OB", (size_t)2) == 0 || + memcmp(entCur, "UI", (size_t)2) == 0 || + memcmp(entCur, "SH", (size_t)2) == 0 || + memcmp(entCur, "AE", (size_t)2) == 0 || + memcmp(entCur, "OB", (size_t)2) == 0 ) + { + Filetype = ExplicitVR; + gdcmWarningMacro( "Group 0002 : Explicit Value Representation"); + return true; + } + } +// ------------------------------- End of 'No Preamble' DicomV3 ------------- + // Our next best chance would be to be considering a 'clean' ACR/NEMA file. // By clean we mean that the length of the first group is written down. // If this is the case and since the length of the first group HAS to be