]> Creatis software - gdcm.git/commitdiff
* src/gdcmFileHelper.[h|cxx] : now correctly set the VR of the datas when
authorregrain <regrain>
Wed, 9 Feb 2005 16:28:40 +0000 (16:28 +0000)
committerregrain <regrain>
Wed, 9 Feb 2005 16:28:40 +0000 (16:28 +0000)
     writting the file
   -- BeNours

ChangeLog
Testing/TestWriteSimple.cxx
src/gdcmFileHelper.cxx
src/gdcmFileHelper.h

index 9fccacd1011f54b3aba1a95d69df01eda325ad59..e106decc974458df629c84699d9e273c78c666d1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-02-09 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * src/gdcmFileHelper.[h|cxx] : now correctly set the VR of the datas when 
+     writting the file
+
 2005-02-09 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * Test/VTKTestWriteSeq.cxx : add a VTK test to write sequences
 
index 249c5212b4797b649db52aaa9a22e0697eb000ad..8dc6b5a423fb3a9ad27d27f39256af5ebb178c5d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestWriteSimple.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/07 19:17:27 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2005/02/09 16:28:41 $
+  Version:   $Revision: 1.23 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -64,13 +64,13 @@ Image Images [] = {
    {256, 512, 1, 1, 16, 16, 0, 'e'},
    {256, 512, 1, 1, 16, 16, 0, 'i'},
 
-   {512, 256, 10, 1, 8,  8, 0, 'a'},
-   {512, 256, 10, 1, 8,  8, 0, 'e'},
-   {512, 256, 10, 1, 8,  8, 0, 'i'},
-   {512, 256, 10, 3, 8,  8, 0, 'a'},
-   {512, 256, 10, 3, 8,  8, 0, 'e'},
-   {512, 256, 10, 3, 8,  8, 0, 'i'},
-   {0,   0,   1,  1, 8,  8, 0, 'i'} // to find the end
+   {512, 256, 10, 1, 8, 8,  0, 'a'},
+   {512, 256, 10, 1, 8, 8,  0, 'e'},
+   {512, 256, 10, 1, 8, 8,  0, 'i'},
+   {512, 256, 10, 3, 8, 8,  0, 'a'},
+   {512, 256, 10, 3, 8, 8,  0, 'e'},
+   {512, 256, 10, 3, 8, 8,  0, 'i'},
+   {0,   0,   1,  1, 8, 8,  0, 'i'} // to find the end
 };
 
 int WriteSimple(Image &img)
@@ -103,18 +103,6 @@ int WriteSimple(Image &img)
    str << img.componentSize;
    fileToBuild->InsertValEntry(str.str(),0x0028,0x0100); // Bits Allocated
 
-   /******************************************/
-   /******************************************/
-   // Super duper kludge !!
-   if( img.componentSize == 16 )
-   {
-      // I guess by design user should know that...
-      fileToBuild->InsertBinEntry(0,0, 0x7fe0, 0x0010, "OW");
-   }
-   /******************************************/
-   /******************************************/
-   
-
    str.str("");
    str << img.componentUse;
    fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
index 700904b6f7204164494e3e04207d10663c987ea7..2e84dd276dceef68f0f90b247e6d832c6c4bb3e3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/02/05 01:37:08 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2005/02/09 16:28:41 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -681,8 +681,11 @@ void FileHelper::SetWriteToRaw()
       PixelWriteConverter->SetReadData(PixelReadConverter->GetRaw(),
                                        PixelReadConverter->GetRawSize());
 
+      std::string vr = "OB";
+      if( FileInternal->GetBitsAllocated()>8 )
+         vr = "OW";
       BinEntry *pixel = 
-         CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
+         CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
       pixel->SetValue(GDCM_BINLOADED);
       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
       pixel->SetLength(PixelWriteConverter->GetDataSize());
@@ -721,8 +724,11 @@ void FileHelper::SetWriteToRGB()
                                           PixelReadConverter->GetRawSize());
       }
 
+      std::string vr = "OB";
+      if( FileInternal->GetBitsAllocated()>8 )
+         vr = "OW";
       BinEntry *pixel = 
-         CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel());
+         CopyBinEntry(GetFile()->GetGrPixel(),GetFile()->GetNumPixel(),vr);
       pixel->SetValue(GDCM_BINLOADED);
       pixel->SetBinArea(PixelWriteConverter->GetData(),false);
       pixel->SetLength(PixelWriteConverter->GetDataSize());
@@ -906,7 +912,7 @@ ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem)
    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
    ValEntry *newE;
 
-   if(oldE)
+   if( oldE )
    {
       newE = new ValEntry(oldE->GetDictEntry());
       newE->Copy(oldE);
@@ -927,19 +933,23 @@ ValEntry *FileHelper::CopyValEntry(uint16_t group,uint16_t elem)
  * \return  pointer to the modified/created Bin Entry (NULL when creation
  *          failed).
  */ 
-BinEntry *FileHelper::CopyBinEntry(uint16_t group,uint16_t elem)
+BinEntry *FileHelper::CopyBinEntry(uint16_t group,uint16_t elem,const std::string &vr)
 {
    DocEntry *oldE = FileInternal->GetDocEntry(group, elem);
    BinEntry *newE;
 
-   if(oldE)
+   if( oldE )
+      if( oldE->GetVR()!=vr )
+         oldE = NULL;
+
+   if( oldE )
    {
       newE = new BinEntry(oldE->GetDictEntry());
       newE->Copy(oldE);
    }
    else
    {
-      newE = GetFile()->NewBinEntry(group,elem);
+      newE = GetFile()->NewBinEntry(group,elem,vr);
    }
 
    return newE;
index 1fefb4d391fc54f8fb6b6acf341d6784ea65404e..a6bc806db74ecd6f645bd0dd2bfcf87abaae1dc2 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFileHelper.h,v $
   Language:  C++
-  Date:      $Date: 2005/02/06 14:39:35 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2005/02/09 16:28:41 $
+  Version:   $Revision: 1.12 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -149,7 +149,8 @@ protected:
    void RestoreWriteOfLibido();
 
    ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
-   BinEntry *CopyBinEntry(uint16_t group, uint16_t elem);
+   BinEntry *CopyBinEntry(uint16_t group, uint16_t elem, 
+                          const std::string &vr);
 
 private:
    void Initialize();