]> Creatis software - gdcm.git/commitdiff
* Amelioration of code, remove some code copy. For the loading of
authorregrain <regrain>
Wed, 24 Nov 2004 11:17:46 +0000 (11:17 +0000)
committerregrain <regrain>
Wed, 24 Nov 2004 11:17:46 +0000 (11:17 +0000)
     BinEntry (in gdcmDocument), add the test to verify if the file is already
     opened or not.
   -- BeNours

ChangeLog
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmFile.cxx

index f540095cd6f0ee27307f95b7c838253288e5cbe6..6e84dc2832e1835694202bfafb846f117085c11a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-11-24 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+   * Amelioration of code, remove some code copy. For the loading of
+     BinEntry (in gdcmDocument), add the test to verify if the file is already
+     opened or not.
+
 2004-11-24 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * src/gdcmDocEntryArchive.[h|cxx] : bug fix and add a method to temporary
      remove a DocEntry in the header (push an empty DocEntry)
index 306354a4e999f089d03cbdb37fd425940bf697cd..c5d391396cc11c60b7b040b24e07c9d19869ce90 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/19 12:44:00 $
-  Version:   $Revision: 1.135 $
+  Date:      $Date: 2004/11/24 11:17:47 $
+  Version:   $Revision: 1.136 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -1065,7 +1065,12 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
    if ( !docElement )
       return;
 
-   size_t o =(size_t)docElement->GetOffset();
+   BinEntry *binElement = dynamic_cast<BinEntry *>(docElement);
+   if( !binElement )
+      return;
+
+   LoadEntryBinArea(binElement);
+/*   size_t o =(size_t)docElement->GetOffset();
    Fp->seekg( o, std::ios_base::beg);
    size_t l = docElement->GetLength();
    uint8_t* a = new uint8_t[l];
@@ -1088,8 +1093,9 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
    {
       delete[] a;
       dbg.Verbose(0, "Document::LoadEntryBinArea setting failed.");
-   }
+   }*/
 }
+
 /**
  * \brief         Loads (from disk) the element content 
  *                when a string is not suitable
@@ -1097,8 +1103,13 @@ void Document::LoadEntryBinArea(uint16_t group, uint16_t elem)
  */
 void Document::LoadEntryBinArea(BinEntry* element) 
 {
+   bool openFile = !Fp;
+   if(openFile)
+      OpenFile();
+
    size_t o =(size_t)element->GetOffset();
    Fp->seekg(o, std::ios_base::beg);
+
    size_t l = element->GetLength();
    uint8_t* a = new uint8_t[l];
    if( !a )
@@ -1116,6 +1127,9 @@ void Document::LoadEntryBinArea(BinEntry* element)
    }
 
    element->SetBinArea(a);
+
+   if(openFile)
+      CloseFile();
 }
 
 /**
index 1ad9350d4b8aed916efefa0fc8c21d2e6f4618cd..c36efc15712b7cbf330489e3f5d82afc9f801e8f 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2004/11/17 19:49:13 $
-  Version:   $Revision: 1.61 $
+  Date:      $Date: 2004/11/24 11:17:47 $
+  Version:   $Revision: 1.62 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -277,9 +277,6 @@ public:
    /// 'Swap code' accessor (see \ref SwapCode )
    int GetSwapCode() { return SwapCode; }
    
-   /// File pointer
-   std::ifstream * GetFP() { return Fp; }
-
    bool operator<(Document &document);
 
 };
index c5219ed2f919cbfc2001a8961aef4024931fe7c5..666a8e96f5fdd0245ddfb14ec1d15cb82937732e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/24 10:23:47 $
-  Version:   $Revision: 1.160 $
+  Date:      $Date: 2004/11/24 11:17:47 $
+  Version:   $Revision: 1.161 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -209,6 +209,22 @@ uint8_t* File::GetImageData()
       return 0;
    }
                                                                                 
+   if ( HeaderInternal->HasLUT() && PixelConverter->BuildRGBImage() )
+   {
+      return PixelConverter->GetRGB();
+   }
+   else
+   {
+      // When no LUT or LUT conversion fails, return the decompressed
+      return PixelConverter->GetDecompressed();
+   }
+   
+/*   if ( ! GetDecompressed() )
+   {
+      // If the decompression failed nothing can be done.
+      return 0;
+   }
+                                                                                
    uint8_t* pixelData;
    if ( HeaderInternal->HasLUT() && PixelConverter->BuildRGBImage() )
    {
@@ -220,7 +236,7 @@ uint8_t* File::GetImageData()
       pixelData = PixelConverter->GetDecompressed();
    }
 
-/*// PIXELCONVERT CLEANME
+// PIXELCONVERT CLEANME
    // Restore the header in a disk-consistent state
    // (if user asks twice to get the pixels from disk)
    if ( PixelRead != -1 ) // File was "read" before
@@ -275,9 +291,9 @@ uint8_t* File::GetImageData()
 
    // We say the value *is* loaded.
    SetPixelData(pixelData);
-// END PIXELCONVERT CLEANME*/
+// END PIXELCONVERT CLEANME
 
-   return pixelData;
+   return pixelData;*/
 }
 
 /**
@@ -351,13 +367,14 @@ size_t File::GetImageDataIntoVector (void* destination, size_t maxSize)
  */
 uint8_t* File::GetImageDataRaw ()
 {
-   uint8_t* decompressed = GetDecompressed();
+   return GetDecompressed();
+/*   uint8_t* decompressed = GetDecompressed();
    if ( ! decompressed )
    {
       return 0;
    }
 
-/*// PIXELCONVERT CLEANME
+// PIXELCONVERT CLEANME
    // Restore the header in a disk-consistent state
    // (if user asks twice to get the pixels from disk)
    if ( PixelRead != -1 ) // File was "read" before
@@ -387,9 +404,9 @@ uint8_t* File::GetImageDataRaw ()
    SetPixelData(decompressed);
  
    PixelRead = 1; // PixelRaw
-// END PIXELCONVERT CLEANME*/
+// END PIXELCONVERT CLEANME
 
-   return decompressed;
+   return decompressed;*/
 }
 
 uint8_t* File::GetDecompressed()