]> Creatis software - gdcm.git/commitdiff
* src/gdcmDocEntryArchive.[h|cxx] : bug fix and add a method to temporary
authorregrain <regrain>
Wed, 24 Nov 2004 10:23:45 +0000 (10:23 +0000)
committerregrain <regrain>
Wed, 24 Nov 2004 10:23:45 +0000 (10:23 +0000)
     remove a DocEntry in the header (push an empty DocEntry)
   * src/gdcmFile.[h|cxx] : remove some useless variables, methods and code
     lines. Bug fix in the initialization of the PixelConvert and the
     DocEntryArchive
   * src/gdcmElementSet.[h|cxx] : add methods Initialize and GetNext to
     use in TestCopyDicom (now this test can run under windows... but fails)
   * Test/TestCopyDicom.cxx : amelioration of the test :
     - test the pixels written
     - add test points to quickly find where is the error
     - can set a file name input and output in arguments
   * Test/TestAllReadCompareDicom.cxx, TestReadWriteReadCompare.cxx :
     amelioration of the test output
   * TestCopyDicom always fails... but changes to solve it quickly
   -- BeNours

12 files changed:
ChangeLog
Example/PrintFile.cxx
Testing/TestAllReadCompareDicom.cxx
Testing/TestCopyDicom.cxx
Testing/TestReadWriteReadCompare.cxx
src/gdcmDocEntryArchive.cxx
src/gdcmDocEntryArchive.h
src/gdcmElementSet.cxx
src/gdcmElementSet.h
src/gdcmFile.cxx
src/gdcmFile.h
src/gdcmPixelConvert.cxx

index f4cff36dfee3c76910f2edd481f24e489787f24c..f540095cd6f0ee27307f95b7c838253288e5cbe6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+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)
+   * src/gdcmFile.[h|cxx] : remove some useless variables, methods and code
+     lines. Bug fix in the initialization of the PixelConvert and the 
+     DocEntryArchive
+   * src/gdcmElementSet.[h|cxx] : add methods Initialize and GetNext to
+     use in TestCopyDicom (now this test can run under windows... but fails)
+   * Test/TestCopyDicom.cxx : amelioration of the test :
+     - test the pixels written
+     - add test points to quickly find where is the error
+     - can set a file name input and output in arguments
+   * Test/TestAllReadCompareDicom.cxx, TestReadWriteReadCompare.cxx : 
+     amelioration of the test output
+
 2004-11-23 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
    * src/gdcmDocEntryArchive.cxx : complete the print function, that prints
      all replaced DocEntry's
index 9574f710db6a55da74c373efa12a657eb82eb259..9e41e49cc98b4d0ed9dda85239ab6817acf7bbe1 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: PrintFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/23 17:12:25 $
-  Version:   $Revision: 1.11 $
+  Date:      $Date: 2004/11/24 10:23:46 $
+  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
@@ -67,7 +67,9 @@ int main(int argc, char* argv[])
              << std::endl;
 
    int numberOfScalarComponents=e1->GetNumberOfScalarComponents();
-   std::cout << " NumberOfScalarComponents " << numberOfScalarComponents <<std::endl;
+   std::cout << " NumberOfScalarComponents " << numberOfScalarComponents <<std::endl
+             << " LUT=" << (e1->HasLUT() ? "TRUE" : "FALSE")
+             << std::endl;
 
   
   if ( e1->GetEntryByNumber(0x0002,0x0010) == gdcm::GDCM_NOTLOADED ) {
index 8dc649f59a6a8bc778c4485effaa9590fc0a2303..5472f477c82b1aeff35cc4d644c958036b84d7b0 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllReadCompareDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/17 10:20:06 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2004/11/24 10:23:46 $
+  Version:   $Revision: 1.17 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -83,7 +83,8 @@ int InternalTest(std::string const & filename,
 
       if (testedDataSize != referenceDataSize)
       {
-         std::cout << "      Failed: pixel areas lengths differ: "
+         std::cout << " Failed" << std::endl
+                   << "        pixel areas lengths differ: "
                    << testedDataSize << " # " << referenceDataSize
                    << std::endl;
          delete tested;
@@ -95,7 +96,8 @@ int InternalTest(std::string const & filename,
                            testedDataSize) != 0 )
       {
          (void)res;
-         std::cout << "      Failed: pixel differ (as expanded in memory)."
+         std::cout << " Failed" << std::endl
+                   << "        pixel differ (as expanded in memory)."
                    << std::endl;
          delete tested;
          delete reference;
index a1804823678ea92f6b39e5f3146c249262038794..66c2ad2214992fe18c5677a247a3a72e9449601d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestCopyDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/18 17:06:54 $
-  Version:   $Revision: 1.18 $
+  Date:      $Date: 2004/11/24 10:23:46 $
+  Version:   $Revision: 1.19 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -57,37 +57,25 @@ bool RemoveFile(const char* source)
   return unlink(source) != 0 ? false : true;
 }
 
-// Here we load a gdcmFile and then try to create from scratch a copy of it,
-// copying field by field the dicom image
-
-int TestCopyDicom(int , char* [])
+int CopyDicom(std::string const & filename, 
+              std::string const & output )
 {
-   int i =0;
-   int retVal = 0;  //by default this is an error
-   while( gdcmDataImages[i] != 0 )
-   {
-      std::string filename = GDCM_DATA_ROOT;
-      filename += "/";  //doh!
-      filename += gdcmDataImages[i];
-      std::cerr << "Filename: " << filename << std::endl;
-
-      std::string output = "../Testing/Temporary/output.dcm";
-
+      std::cout << "   Testing: " << filename << std::endl;
       if( FileExists( output.c_str() ) )
       {
         // std::cerr << "Don't try to cheat, I am removing the file anyway" << std::endl;
          if( !RemoveFile( output.c_str() ) )
          {
-            std::cerr << "Ouch, the file exist, but I cannot remove it" << std::endl;
+            std::cout << "Ouch, the file exist, but I cannot remove it" << std::endl;
             return 1;
          }
       }
 
+      //////////////// Step 1:
+      std::cout << "      1...";
       gdcm::File *original = new gdcm::File( filename );
       gdcm::File *copy = new gdcm::File( output );
 
-      const gdcm::TagDocEntryHT & Ht = original->GetHeader()->GetTagHT();
-
       size_t dataSize = original->GetImageDataSize();
       uint8_t* imageData = original->GetImageData();
       (void)dataSize;  // To use the variable and not have warnings at compil.
@@ -100,11 +88,14 @@ int TestCopyDicom(int , char* [])
       // (the user does NOT have to know the way we implemented the Header !)
       // Waiting for a 'clean' solution, I keep the method ...JPRx
 
-      gdcm::DocEntry* d;
 
-      for (gdcm::TagDocEntryHT::const_iterator tag = Ht.begin(); tag != Ht.end(); ++tag)
+      //////////////// Step 2:
+      std::cout << "2...";
+      original->GetHeader()->Initialize();
+      gdcm::DocEntry* d=original->GetHeader()->GetNextEntry();
+
+      while(d)
       {
-         d = tag->second;
          if ( gdcm::BinEntry* b = dynamic_cast<gdcm::BinEntry*>(d) )
          {
             copy->GetHeader()->ReplaceOrCreateByNumber( 
@@ -130,26 +121,133 @@ int TestCopyDicom(int , char* [])
           //          << d->GetGroup() << " " << d->GetElement()
           //  << std::endl;    
          }
+
+         d=original->GetHeader()->GetNextEntry();
       }
 
+
       // Useless to set the image datas, because it's already made when
       // copying the corresponding BinEntry that contains the pixel datas
-      //copy->SetImageData(imageData, dataSize);
-      original->GetHeader()->SetImageDataSize(dataSize);
+      copy->SetImageData(imageData, dataSize);
+//      copy->GetImageData();
+//      original->GetHeader()->SetImageDataSize(dataSize);
 
+      //////////////// Step 3:
+      std::cout << "3...";
       copy->WriteDcmExplVR( output );
 
-      delete original;
       delete copy;
 
+      //////////////// Step 4:
+      std::cout << "4...";
       copy = new gdcm::File( output );
 
       //Is the file written still gdcm parsable ?
       if ( !copy->GetHeader()->IsReadable() )
       { 
-         retVal +=1;
-         std::cout << output << " Failed" << std::endl;
+         std::cout << "=> " << output << " Failed" << std::endl;
+         delete original;
+         return(1);
+      }
+
+      //////////////// Step 5:
+      std::cout << "5...";
+      int    dataSizeWritten = copy->GetImageDataSize();
+      uint8_t* imageDataWritten = copy->GetImageData();
+
+      if (dataSize != dataSizeWritten)
+      {
+         std::cout << " Failed" << std::endl
+            << "        Pixel areas lengths differ: "
+            << dataSize << " # " << dataSizeWritten << std::endl;
+
+         delete original;
+         delete copy;
+
+         return 1;
+      }
+
+      if (int res = memcmp(imageData, imageDataWritten, dataSize) !=0)
+      {
+         (void)res;
+         std::cout << " Failed" << std::endl
+            << "        Pixel differ (as expanded in memory)." << std::endl;
+
+         delete original;
+         delete copy;
+
+         return 1;
       }
+      std::cout << "OK." << std::endl ;
+
+      delete original;
+      delete copy;
+
+      return 0;
+}
+
+// Here we load a gdcmFile and then try to create from scratch a copy of it,
+// copying field by field the dicom image
+
+int TestCopyDicom(int argc, char* argv[])
+{
+   if ( argc == 3 )
+   {
+      // The test is specified a specific filename, use it instead of looping
+      // over all images
+      const std::string input = argv[1];
+      const std::string reference = argv[2];
+      return CopyDicom( input, reference );
+   }
+   else if ( argc > 3 || argc == 2 )
+   {
+      std::cout << "   Usage: " << argv[0]
+                << " (no arguments needed)." << std::endl;
+      std::cout << "or   Usage: " << argv[0]
+                << " filename.dcm reference.dcm" << std::endl;
+      return 1;
+   }
+   // else other cases:
+
+   std::cout << "   Description (Test::TestCopyDicom): "
+             << std::endl;
+   std::cout << "   For all images in gdcmData (and not blacklisted in "
+                "Test/CMakeLists.txt)"
+             << std::endl;
+   std::cout << "   apply the following to each filename.xxx: "
+             << std::endl;
+   std::cout << "   step 1: parse the image (as gdcmHeader) and call"
+             << " IsReadable(). After that, call GetImageData() and "
+             << "GetImageDataSize() "
+             << std::endl;
+   std::cout << "   step 2: create a copy of the readed file and the new"
+             << " pixel datas are set to the copy"
+             << std::endl;
+   std::cout << "   step 3: write the copy of the image"
+             << std::endl;
+   std::cout << "   step 4: read the copy and call IsReadable()"
+             << std::endl;
+   std::cout << "   step 5: compare (in memory with memcmp) that the two "
+             << "images " << std::endl
+             << "           match (as expanded by gdcm)." << std::endl;
+   std::cout << std::endl;
+
+   int i =0;
+   int retVal = 0;  //by default this is an error
+   while( gdcmDataImages[i] != 0 )
+   {
+      std::string filename = GDCM_DATA_ROOT;
+      filename += "/";  //doh!
+      filename += gdcmDataImages[i];
+
+//      std::string output = "../Testing/Temporary/output.dcm";
+      std::string output = "output.dcm";
+
+      if( CopyDicom( filename, output ) != 0 )
+      {
+         retVal++;
+      }
+
       i++;
    }
    return retVal;
index 1559a6d11028ecfa457b7e688d79994817e7c421..5597861e49ebbafc061dd8a8e1536ddf82f64444 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestReadWriteReadCompare.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/16 04:28:20 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2004/11/24 10:23:46 $
+  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
@@ -35,7 +35,7 @@ int CompareInternal(std::string const & filename, std::string const & output)
       delete header;
       return 1;
    }
-   std::cout << "           step 1 ...";
+   std::cout << "           step 1...";
 
    //////////////// Step 2:
 
@@ -64,6 +64,7 @@ int CompareInternal(std::string const & filename, std::string const & output)
    
    file->SetImageData(imageData, dataSize);
    
+   file->SetWriteModeToRGB();
    file->WriteDcmExplVR( output );
    std::cout << "2...";
  
@@ -72,7 +73,8 @@ int CompareInternal(std::string const & filename, std::string const & output)
    gdcm::File* reread = new gdcm::File( output );
    if( !reread->GetHeader()->IsReadable() )
    {
-     std::cerr << "Test::TestReadWriteReadCompare: Could not reread image "
+     std::cerr << "Failed" << std::endl
+               << "Test::TestReadWriteReadCompare: Could not reread image "
                << "written:" << filename << std::endl;
      delete header;
      delete file;
@@ -88,7 +90,7 @@ int CompareInternal(std::string const & filename, std::string const & output)
 
    if (dataSize != dataSizeWritten)
    {
-      std::cout << std::endl
+      std::cout << "Failed" << std::endl
          << "        Pixel areas lengths differ: "
          << dataSize << " # " << dataSizeWritten << std::endl;
       delete header;
@@ -100,7 +102,7 @@ int CompareInternal(std::string const & filename, std::string const & output)
    if (int res = memcmp(imageData, imageDataWritten, dataSize) !=0)
    {
       (void)res;
-      std::cout << std::endl
+      std::cout << "Failed" << std::endl
          << "        Pixel differ (as expanded in memory)." << std::endl;
       delete header;
       delete file;
index 263f8a75a9994e07d15e80e3f49d8571aa2db277..9a5a498cee8d36921f7ae74244b29617850e8922 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntryArchive.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/23 11:14:13 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  Version:   $Revision: 1.3 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -82,9 +82,13 @@ bool DocEntryArchive::Push(DocEntry *newEntry)
       // Save the old DocEntry if any
       TagDocEntryHT::iterator it = HeaderHT.find(key);
       if( it!=HeaderHT.end() )
+      {
          Archive[key] = it->second;
+      }
       else
+      {
          Archive[key] = NULL;
+      }
 
       // Set the new DocEntry
       HeaderHT[key] = newEntry;
@@ -94,6 +98,32 @@ bool DocEntryArchive::Push(DocEntry *newEntry)
    return(false);
 }
 
+/**
+ * \brief   Replace in the Header a DocEntry by the new DocEntry. The last
+ *          DocEntry is kept in archieve
+ * @param   newEntry New entry to substitute to an other entry of the Header
+ * @return  FALSE when an other DocEntry is already archieved with the same
+ *          generalized key, TRUE otherwise
+ */
+bool DocEntryArchive::Push(uint16_t group,uint16_t element)
+{
+   std::string key = DictEntry::TranslateToKey(group,element);
+
+   if( Archive.find(key)==Archive.end() )
+   {
+      // Save the old DocEntry if any
+      TagDocEntryHT::iterator it = HeaderHT.find(key);
+      if( it!=HeaderHT.end() )
+      {
+         Archive[key] = it->second;
+         HeaderHT.erase(it);
+      }
+
+      return(true);
+   }
+   return(false);
+}
+
 /**
  * \brief   Restore in the Header the DocEntry that have the generalized key. 
  *          The old entry is destroyed.
@@ -109,13 +139,19 @@ bool DocEntryArchive::Restore(uint16_t group,uint16_t element)
    if( restoreIt!=Archive.end() )
    {
       TagDocEntryHT::iterator restorePos = HeaderHT.find(key);
-      if( restoreIt!=HeaderHT.end() )
+      if( restorePos!=HeaderHT.end() )
+      {
          delete restorePos->second;
+      }
 
       if( Archive[key] )
+      {
          HeaderHT[key] = Archive[key];
+      }
       else
+      {
          HeaderHT.erase(restorePos);
+      }
 
       Archive.erase(restoreIt);
 
index 99bdaea475814997524688740c432a982b153cdd..ae6550ab857201edf9a7366e3bcab17b017ff63e 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocEntryArchive.h,v $
   Language:  C++
-  Date:      $Date: 2004/11/19 18:49:39 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -45,6 +45,7 @@ public:
    void Print(std::ostream &os = std::cout);
 
    bool Push(DocEntry *newEntry);
+   bool Push(uint16_t group,uint16_t element);
    bool Restore(uint16_t group,uint16_t element);
 
    void ClearArchive(void);
index b485261b2e1bce54a28c26b0cd531734f9d2eac3..42639f89265d435529a3f93397bd236d102c28ee 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/16 16:20:23 $
-  Version:   $Revision: 1.30 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  Version:   $Revision: 1.31 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -146,6 +146,8 @@ bool ElementSet::RemoveEntryNoDestroy(DocEntry* entryToRemove)
 /**
  * \brief   Clear the hash table from given entry AND delete the entry.
  * @param   entryToRemove Entry to remove AND delete.
+ * \warning Some problems when using under Windows... prefer the use of
+ *          Initialize / GetNext methods
  */
 bool ElementSet::RemoveEntry( DocEntry* entryToRemove)
 {
@@ -161,4 +163,33 @@ bool ElementSet::RemoveEntry( DocEntry* entryToRemove)
    dbg.Verbose(0, "ElementSet::RemoveEntry: key not present: ");
    return false ;
 }
+
+/**
+ * \brief   Initialise the visit of the Hash table (TagHT)
+ */
+void ElementSet::Initialize()
+{
+   ItTagHT = TagHT.begin();
+}
+
+/**
+ * \brief   Get the next entry whil visiting the Hash table (TagHT)
+ * \return  The next DocEntry if found, otherwhise NULL
+ */
+DocEntry *ElementSet::GetNextEntry()
+{
+   if (ItTagHT != TagHT.end())
+   {
+      DocEntry *tmp = ItTagHT->second;
+      ++ItTagHT;
+
+      return(tmp);
+   }
+   else
+   {
+      return(NULL);
+   }
+}
+
+//-----------------------------------------------------------------------------
 } // end namespace gdcm
index 926bec2c619623727af84cdaffd471fbcd8c8994..6d93e2c056f56c1f09aec816b02da99dffad02cd 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmElementSet.h,v $
   Language:  C++
-  Date:      $Date: 2004/11/19 18:49:39 $
-  Version:   $Revision: 1.22 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  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
@@ -52,12 +52,17 @@ public:
    // A test is using it thus put it in public (matt)
    TagDocEntryHT const & GetTagHT() const { return TagHT; };
 
+   void Initialize();
+   DocEntry *GetNextEntry();
+
 protected:
     
 private:
 // Variables
    /// Hash Table (map), to provide fast access
    TagDocEntryHT TagHT; 
+   /// Hash Table (map) iterator, used to visit the TagHT variable
+   TagDocEntryHT::iterator ItTagHT; 
  
    friend class Document;
    friend class DicomDir; //For accessing private TagHT
index d198c1c96c7c1f19cfef5ac4d8a1493ab23f2540..c5219ed2f919cbfc2001a8961aef4024931fe7c5 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/23 11:14:13 $
-  Version:   $Revision: 1.159 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  Version:   $Revision: 1.160 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -75,10 +75,11 @@ File::File(std::string const & filename )
  */
 void File::Initialise()
 {
-   WriteMode = WMODE_DECOMPRESSED;
+   WriteMode = WMODE_RGB;
    WriteType = WTYPE_IMPL_VR;
-   PixelConverter = NULL; //just in case
-   Archive = NULL;
+
+   PixelConverter = new PixelConvert;
+   Archive = new DocEntryArchive( HeaderInternal );
 
    if ( HeaderInternal->IsReadable() )
    {
@@ -92,10 +93,7 @@ void File::Initialise()
          ImageDataSize = ImageDataSizeRaw;
       }
 
-      PixelConverter = new PixelConvert;
       PixelConverter->GrabInformationsFromHeader( HeaderInternal );
-
-      Archive = new DocEntryArchive( HeaderInternal );
    }
 
    SaveInitialValues();
@@ -122,8 +120,6 @@ File::~File()
       delete HeaderInternal;
    }
    HeaderInternal = 0;
-
-   DeleteInitialValues();
 }
 
 /**
@@ -133,119 +129,7 @@ File::~File()
 void File::SaveInitialValues()
 { 
    PixelRead  = -1; // no ImageData read yet.
-   LastAllocatedPixelDataLength = 0;
    Pixel_Data = 0;
-
-   InitialSpp = "";     
-   InitialPhotInt = "";
-   InitialPlanConfig = "";
-   InitialBitsAllocated = "";
-   InitialHighBit = "";
-  
-   InitialRedLUTDescr   = 0;
-   InitialGreenLUTDescr = 0;
-   InitialBlueLUTDescr  = 0;
-   InitialRedLUTData    = 0;
-   InitialGreenLUTData  = 0;
-   InitialBlueLUTData   = 0; 
-
-   if ( HeaderInternal->IsReadable() )
-   {
-      // the following values *may* be modified 
-      // by File::GetImageDataIntoVectorRaw
-      // we save their initial value.
-      InitialSpp           = HeaderInternal->GetEntryByNumber(0x0028,0x0002);
-      InitialPhotInt       = HeaderInternal->GetEntryByNumber(0x0028,0x0004);
-      InitialPlanConfig    = HeaderInternal->GetEntryByNumber(0x0028,0x0006);
-      
-      InitialBitsAllocated = HeaderInternal->GetEntryByNumber(0x0028,0x0100);
-      InitialHighBit       = HeaderInternal->GetEntryByNumber(0x0028,0x0102);
-
-      // the following entries *may* be removed from the H table
-      // (NOT deleted ...) by File::GetImageDataIntoVectorRaw  
-      // we keep a pointer on them.
-      InitialRedLUTDescr   = HeaderInternal->GetDocEntryByNumber(0x0028,0x1101);
-      InitialGreenLUTDescr = HeaderInternal->GetDocEntryByNumber(0x0028,0x1102);
-      InitialBlueLUTDescr  = HeaderInternal->GetDocEntryByNumber(0x0028,0x1103);
-
-      InitialRedLUTData    = HeaderInternal->GetDocEntryByNumber(0x0028,0x1201);
-      InitialGreenLUTData  = HeaderInternal->GetDocEntryByNumber(0x0028,0x1202);
-      InitialBlueLUTData   = HeaderInternal->GetDocEntryByNumber(0x0028,0x1203); 
-   }
-}
-
-/**
- * \brief restores some initial values
- * \warning not end user intended
- */
-void File::RestoreInitialValues()
-{   
-   if ( HeaderInternal->IsReadable() )
-   {      
-      // the following values *may* have been modified 
-      // by File::GetImageDataIntoVectorRaw
-      // we restore their initial value.
-      if ( InitialSpp != "")
-         HeaderInternal->SetEntryByNumber(InitialSpp,0x0028,0x0002);
-      if ( InitialPhotInt != "")
-         HeaderInternal->SetEntryByNumber(InitialPhotInt,0x0028,0x0004);
-      if ( InitialPlanConfig != "")
-
-         HeaderInternal->SetEntryByNumber(InitialPlanConfig,0x0028,0x0006);
-      if ( InitialBitsAllocated != "")
-          HeaderInternal->SetEntryByNumber(InitialBitsAllocated,0x0028,0x0100);
-      if ( InitialHighBit != "")
-          HeaderInternal->SetEntryByNumber(InitialHighBit,0x0028,0x0102);
-               
-      // the following entries *may* be have been removed from the H table
-      // (NOT deleted ...) by File::GetImageDataIntoVectorRaw  
-      // we restore them.
-
-      if (InitialRedLUTDescr)
-         HeaderInternal->AddEntry(InitialRedLUTDescr);
-      if (InitialGreenLUTDescr)
-         HeaderInternal->AddEntry(InitialGreenLUTDescr);
-      if (InitialBlueLUTDescr)
-         HeaderInternal->AddEntry(InitialBlueLUTDescr);
-
-      if (InitialRedLUTData)
-         HeaderInternal->AddEntry(InitialBlueLUTDescr);
-      if (InitialGreenLUTData)
-         HeaderInternal->AddEntry(InitialGreenLUTData);
-      if (InitialBlueLUTData)
-         HeaderInternal->AddEntry(InitialBlueLUTData);
-   }
-}
-
-/**
- * \brief delete initial values (il they were saved)
- *        of InitialLutDescriptors and InitialLutData
- */
-void File::DeleteInitialValues()
-{ 
-// InitialLutDescriptors and InitialLutData
-// will have to be deleted if the don't belong any longer
-// to the Header H table when the header is deleted...
-
-// FIXME 
-// We don't know if the InitialLutData are still in the header or not !
-/*   if ( InitialRedLUTDescr )
-      delete InitialRedLUTDescr;
-  
-   if ( InitialGreenLUTDescr )
-      delete InitialGreenLUTDescr;
-      
-   if ( InitialBlueLUTDescr )
-      delete InitialBlueLUTDescr;
-       
-   if ( InitialRedLUTData )
-      delete InitialRedLUTData;
-   
-   if ( InitialGreenLUTData )
-      delete InitialGreenLUTData;
-      
-   if ( InitialBlueLUTData )
-      delete InitialBlueLUTData;*/
 }
 
 //-----------------------------------------------------------------------------
@@ -651,10 +535,10 @@ bool File::Write(std::string const& fileName)
  */
 bool File::WriteBase (std::string const & fileName, FileType type)
 {
-   if ( PixelRead == -1 && type != ExplicitVR)
+/*   if ( PixelRead == -1 && type != ExplicitVR)
    {
       return false;
-   }
+   }*/
 
    std::ofstream* fp1 = new std::ofstream(fileName.c_str(), 
                               std::ios::out | std::ios::binary);
@@ -703,7 +587,7 @@ bool File::WriteBase (std::string const & fileName, FileType type)
    }
    // ----------------- End of Special Patch ----------------
       
-   uint16_t grPixel  = HeaderInternal->GetGrPixel();
+/*   uint16_t grPixel  = HeaderInternal->GetGrPixel();
    uint16_t numPixel = HeaderInternal->GetNumPixel();;
           
    DocEntry* PixelElement = 
@@ -718,7 +602,7 @@ bool File::WriteBase (std::string const & fileName, FileType type)
    {
       // we tranformed GrayLevel pixels + LUT into RGB Pixel
       PixelElement->SetLength( ImageDataSize );
-   }
+   }*/
  
    HeaderInternal->Write(fp1, type);
 
index f5ba811975455ad77d2ee9ba1a97d014b2fca570..8ed3171fe7af2834b8a043b1027ff2f5967c604a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmFile.h,v $
   Language:  C++
-  Date:      $Date: 2004/11/23 11:14:13 $
-  Version:   $Revision: 1.73 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  Version:   $Revision: 1.74 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -123,8 +123,6 @@ private:
    void Initialise();
 
    void SaveInitialValues();    // will belong to the future PixelData class
-   void RestoreInitialValues(); // will belong to the future PixelData class
-   void DeleteInitialValues();  // will belong to the future PixelData class 
    uint8_t* GetDecompressed();
    int ComputeDecompressedPixelDataSizeFromHeader();
 
@@ -178,46 +176,6 @@ private:
   ///        ==-1 if ImageData never read                       
    int PixelRead;
 
-  /// \brief length of the last allocated area devoided to receive Pixels
-  ///        ( to allow us not to (free + new) if un necessary )     
-   size_t LastAllocatedPixelDataLength; 
-
-  // Initial values of some fields that can be modified during reading process
-  // if user asked to transform gray level + LUT image into RGB image
-     
-  /// \brief Samples Per Pixel           (0x0028,0x0002), as found on disk
-   std::string InitialSpp;
-  /// \brief Photometric Interpretation  (0x0028,0x0004), as found on disk
-   std::string InitialPhotInt;
-  /// \brief Planar Configuration        (0x0028,0x0006), as found on disk   
-   std::string InitialPlanConfig;
-    
-  // Initial values of some fields that can be modified during reading process
-  // if the image was a 'strange' ACR-NEMA 
-  // (Bits Allocated=12, High Bit not equal to Bits stored +1) 
-  /// \brief Bits Allocated              (0x0028,0x0100), as found on disk
-   std::string InitialBitsAllocated;
-  /// \brief High Bit                    (0x0028,0x0102), as found on disk
-   std::string InitialHighBit;
-  
-  // some DocEntry that can be moved out of the H table during reading process
-  // if user asked to transform gray level + LUT image into RGB image
-  // We keep a pointer on them for a future use.
-     
-  /// \brief Red Palette Color Lookup Table Descriptor   0028 1101 as read
-  DocEntry* InitialRedLUTDescr;  
-  /// \brief Green Palette Color Lookup Table Descriptor 0028 1102 as read
-  DocEntry* InitialGreenLUTDescr;
-  /// \brief Blue Palette Color Lookup Table Descriptor  0028 1103 as read
-  DocEntry* InitialBlueLUTDescr;
-  
-  /// \brief Red Palette Color Lookup Table Data         0028 1201 as read
-  DocEntry* InitialRedLUTData;  
-  /// \brief Green Palette Color Lookup Table Data       0028 1202 as read
-  DocEntry* InitialGreenLUTData;
-  /// \brief Blue Palette Color Lookup Table Data        0028 1203 as read
-  DocEntry* InitialBlueLUTData;
-  
 //
 // --------------- end of future PixelData class
 //  
index 9da6c400fc5a9fce11be3ed5903ee4ac73da8f0d..05fe19d642c77f7c4cd49814c38d75b5b2dfb02a 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmPixelConvert.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/11/17 19:49:13 $
-  Version:   $Revision: 1.31 $
+  Date:      $Date: 2004/11/24 10:23:47 $
+  Version:   $Revision: 1.32 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -870,7 +870,7 @@ void PixelConvert::GrabInformationsFromHeader( Header* header )
             return;
          }
       }
-   
+
       ////// Green round:
       LutGreenData = (uint8_t*)header->GetEntryBinAreaByNumber(0x0028, 0x1202 );
       if ( ! LutGreenData)
@@ -888,7 +888,7 @@ void PixelConvert::GrabInformationsFromHeader( Header* header )
             return;
          }
       }
-                                                                                   
+
       ////// Blue round:
       LutBlueData = (uint8_t*)header->GetEntryBinAreaByNumber( 0x0028, 0x1203 );
       if ( ! LutBlueData )
@@ -907,7 +907,7 @@ void PixelConvert::GrabInformationsFromHeader( Header* header )
          }
       }
    }
-                                                                                
+
    if(fp) header->CloseFile();
 }