]> Creatis software - gdcm.git/commitdiff
FileHelper::CheckMandatoryElements() now checks as well
authorjpr <jpr>
Wed, 18 Oct 2006 13:40:18 +0000 (13:40 +0000)
committerjpr <jpr>
Wed, 18 Oct 2006 13:40:18 +0000 (13:40 +0000)
Pixel Representation (0028_0103) and defailts it as 0 (unsigned) if missing
to avoid unexpected behavior for images written by unaware users.

src/gdcmFileHelper.cxx

index 3f8bd825892d1c7a91627f6d9f9e8ad984f5bb0f..7183e58967f6c7fd83d8e7bfc12c31993673edb3 100644 (file)
@@ -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 )
    {