From: jpr Date: Wed, 18 Oct 2006 13:40:18 +0000 (+0000) Subject: FileHelper::CheckMandatoryElements() now checks as well X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=15bb1f653e38f48d30a97c026374aba5f9a2a41a;p=gdcm.git FileHelper::CheckMandatoryElements() now checks as well Pixel Representation (0028_0103) and defailts it as 0 (unsigned) if missing to avoid unexpected behavior for images written by unaware users. --- diff --git a/src/gdcmFileHelper.cxx b/src/gdcmFileHelper.cxx index 3f8bd825..7183e589 100644 --- a/src/gdcmFileHelper.cxx +++ b/src/gdcmFileHelper.cxx @@ -4,8 +4,8 @@ Module: $RCSfile: gdcmFileHelper.cxx,v $ Language: C++ - Date: $Date: 2006/08/29 15:50:05 $ - Version: $Revision: 1.109 $ + Date: $Date: 2006/10/18 13:40:18 $ + Version: $Revision: 1.110 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1587,6 +1587,24 @@ void FileHelper::CheckMandatoryElements() << " for consistency purpose"); } + // check Pixel Representation (default it as 0 -unsigned-) + + DataEntry *e_0028_0103 = FileInternal->GetDataEntry(0x0028, 0x0103); + if ( !e_0028_0103 ) + { + gdcmWarningMacro("PixelRepresentation (0028,0103) is supposed to be mandatory"); + CopyMandatoryEntry(0x0028, 0x0103,"0","US"); + } + else + { + int sign = (int)e_0028_0103->GetValue(0); + if (sign !=1 && sign !=0) + { + gdcmWarningMacro("PixelRepresentation (0028,0103) is supposed to be =1 or =0"); + CopyMandatoryEntry(0x0028, 0x0103,"0","US"); + } + } + std::string pixelSpacing = FileInternal->GetEntryString(0x0028,0x0030); if ( pixelSpacing == GDCM_UNFOUND ) {