]> Creatis software - gdcm.git/blobdiff - src/gdcmFile.cxx
COMP: Fix compilation, remove warning
[gdcm.git] / src / gdcmFile.cxx
index 851fd4a25dfba476b854b3c3cb8429fa50b315fc..4ccb1e7ae0b52a14856c7b130a601333be791600 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2006/03/01 10:15:12 $
-  Version:   $Revision: 1.316 $
+  Date:      $Date: 2006/04/11 16:03:26 $
+  Version:   $Revision: 1.318 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -118,6 +118,7 @@ File::File():
    GrPixel  = 0x7fe0;  // to avoid further troubles
    NumPixel = 0x0010;
    BasicOffsetTableItemValue = 0;
+   FourthDimensionLocation = TagKey(0,0);
 }
 
 
@@ -215,6 +216,11 @@ bool File::DoTheLoadingJob( )
       // The changed DictEntry will have 
       // - a correct PixelVR OB or OW)
       // - the name to "Pixel Data"
+      
+       //==>Take it easy!
+       //==> Just change the VR !
+
+/* 
       DataEntry *oldEntry = dynamic_cast<DataEntry *>(entry);
       if (oldEntry)
       {
@@ -228,24 +234,38 @@ bool File::DoTheLoadingJob( )
 
          // Change only made if usefull
          if ( PixelVR != oldEntry->GetVR() )
-         {
-            DictEntry* newDict = DictEntry::New(GrPixel,NumPixel,
-                                                PixelVR,"1","Pixel Data");
-
-            DataEntry *newEntry = DataEntry::New(newDict);
-            newDict->Delete();
-            newEntry->Copy(entry);
-            newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
-            oldEntry->SetSelfArea(false);
-
-            RemoveEntry(oldEntry);
-            AddEntry(newEntry);
-            newEntry->Delete();
+         {       
+            //DictEntry* newDict = DictEntry::New(GrPixel,NumPixel,
+            //                                    PixelVR,"1","Pixel Data");
+            //DataEntry *newEntry = DataEntry::New(newDict);
+            //newDict->Delete();
+            //newEntry->Copy(entry);
+            //newEntry->SetBinArea(oldEntry->GetBinArea(),oldEntry->IsSelfArea());
+            //oldEntry->SetSelfArea(false);
+
+            //RemoveEntry(oldEntry);
+            //AddEntry(newEntry);
+            //newEntry->Delete();
+  
          }
       }
+*/
+         VRKey PixelVR;
+         // 8 bits allocated is a 'O Bytes' , as well as 24 (old ACR-NEMA RGB)
+         // more than 8 (i.e 12, 16) is a 'O Words'
+         if ( GetBitsAllocated() == 8 || GetBitsAllocated() == 24 ) 
+            PixelVR = "OB";
+         else
+            PixelVR = "OW";
+         // Change only made if usefull
+         if ( PixelVR != entry->GetVR() )
+         { 
+            entry->SetVR(PixelVR);  
+         }         
    }
    return true;
 }
+
 /**
  * \brief  This predicate, based on hopefully reasonable heuristics,
  *         decides whether or not the current File was properly parsed
@@ -450,6 +470,34 @@ int File::GetZSize()
    return 1;
 }
 
+/**
+ * \brief   Retrieve the -unnormalized- number of 'times' of '4D image'.
+ *          User has to tell gdcm the location of this '4th Dimension component'
+ *          using SetFourthDimensionLocation() method before.
+ * \warning The defaulted value is 1.
+ * @return  The encountered size when found, 1 by default 
+ *          (The file doesn't contain a '4D image'.).
+ */
+int File::GetTSize()
+{
+   if (FourthDimensionLocation == TagKey(0,0) )// 4D location is not set : not a 4D object
+      return 1;
+      
+   DataEntry *entry = GetDataEntry(FourthDimensionLocation.GetGroup(),
+                                   FourthDimensionLocation.GetElement() );
+   if( !entry )   
+   {
+      gdcmWarningMacro( " FourthDimensionLocation not found at : " <<
+                    std::hex << FourthDimensionLocation.GetGroup()
+                  << "|" << FourthDimensionLocation.GetElement());
+      return 1;
+   }
+   else
+   {
+      return (int)entry->GetValue(0);
+   }      
+}  
+
 /**
   * \brief gets the info from 0018,1164 : ImagerPixelSpacing
   *                      then 0028,0030 : Pixel Spacing
@@ -511,7 +559,6 @@ float File::GetXSpacing()
    {
       gdcmWarningMacro( "Unfound Pixel Spacing (0028,0030)" );
    }
-
    return xspacing;
 }
 
@@ -1510,7 +1557,7 @@ bool File::Write(std::string fileName, FileType writetype)
          // no (GrPixel, NumPixel) element
          std::string s_lgPix = Util::Format("%d", i_lgPix+12);
          s_lgPix = Util::DicomString( s_lgPix.c_str() );
-         InsertEntryString(s_lgPix,GrPixel, 0x0000);   
+         InsertEntryString(s_lgPix,GrPixel, 0x0000, "UL");   
       }
    }
    Document::WriteContent(fp, writetype);