]> Creatis software - gdcm.git/commitdiff
* CLEANUP_ROUND (3) for gdcmPixelConvert (nightmare stage)
authorfrog <frog>
Wed, 6 Oct 2004 09:58:08 +0000 (09:58 +0000)
committerfrog <frog>
Wed, 6 Oct 2004 09:58:08 +0000 (09:58 +0000)
    - src/gdcmRLEFramesInfo.[cxx|h], gdcmRLEFrame.h added
    - src/gdcmDocument.[cxx|h] ::Parse7FE0 now sets up the RLEInfo.
    - src/CMakeLists.txt: alphabetic order reodering + new entries.

ChangeLog
src/CMakeLists.txt
src/gdcmDocument.cxx
src/gdcmDocument.h
src/gdcmRLEFrame.h [new file with mode: 0644]
src/gdcmRLEFramesInfo.cxx [new file with mode: 0644]
src/gdcmRLEFramesInfo.h [new file with mode: 0644]

index 24c8c10e8ab96861c33bb3b5eb76521ace62a2c2..790a23ba8c17f8b04aad616b205edb8eeafba2c0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-10-06 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
+  * CLEANUP_ROUND (3) for gdcmPixelConvert (nightmare stage)
+    - src/gdcmRLEFramesInfo.[cxx|h], gdcmRLEFrame.h added
+    - src/gdcmDocument.[cxx|h] ::Parse7FE0 now sets up the RLEInfo.
+    - src/CMakeLists.txt: alphabetic order reodering + new entries.
+
 2004-10-01 Eric Boix <Eric.Boix@creatis.insa-lyon.fr>
   * Added documentation of vtkgdcmReader on Website:
      - testvtkGdcmReader.cxx renamed to vtkGdcmDemo.cxx (to be compatible
index f007aca0d262a92f679ab410ad81918838651b15..fc0272297983320c358c4a9e67340cbb6f535478 100644 (file)
@@ -11,41 +11,42 @@ INCLUDE_DIRECTORIES(
 )
 
 SET(libgdcm_la_SOURCES
-   gdcmDirList.cxx
+   gdcmBinEntry.cxx
    gdcmDebug.cxx
+   gdcmDicomDir.cxx
+   gdcmDicomDirElement.cxx
+   gdcmDicomDirImage.cxx
+   gdcmDicomDirMeta.cxx
+   gdcmDicomDirObject.cxx
+   gdcmDicomDirPatient.cxx
+   gdcmDicomDirSerie.cxx
+   gdcmDicomDirStudy.cxx
    gdcmDict.cxx
    gdcmDictEntry.cxx
    gdcmDictSet.cxx
+   gdcmDirList.cxx
+   gdcmDocEntry.cxx
+   gdcmDocEntrySet.cxx
+   gdcmDocument.cxx
+   gdcmElementSet.cxx
    gdcmException.cxx
+   gdcmFile.cxx
    gdcmGlobal.cxx
+   gdcmHeader.cxx
+   gdcmHeaderHelper.cxx
    gdcmJpeg12.cxx
    gdcmJpeg2000.cxx
    gdcmJpeg.cxx
-   gdcmTS.cxx
-   gdcmUtil.cxx
-   gdcmVR.cxx
-   gdcmFile.cxx
-   gdcmHeader.cxx
-   gdcmHeaderHelper.cxx
    gdcmParsePixels.cxx
+   gdcmPixelConvert.cxx
    gdcmRLE.cxx
-   gdcmDocEntry.cxx
-   gdcmDocEntrySet.cxx
-   gdcmBinEntry.cxx
+   gdcmRLEFramesInfo.cxx
    gdcmSeqEntry.cxx
    gdcmSQItem.cxx
-   gdcmElementSet.cxx
+   gdcmTS.cxx
+   gdcmUtil.cxx
    gdcmValEntry.cxx   
-   gdcmDicomDirElement.cxx
-   gdcmDocument.cxx
-   gdcmDicomDir.cxx
-   gdcmDicomDirMeta.cxx
-   gdcmDicomDirPatient.cxx
-   gdcmDicomDirStudy.cxx
-   gdcmDicomDirSerie.cxx
-   gdcmDicomDirImage.cxx
-   gdcmDicomDirObject.cxx
-   gdcmPixelConvert.cxx
+   gdcmVR.cxx
    )
 
 ADD_LIBRARY(gdcm ${libgdcm_la_SOURCES} )
index 773f154cbf80e44a4b70c99d90d3ef6f1aa1625e..6e76b45c55da304592282a2c7d446550a0256004 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.cxx,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:06 $
-  Version:   $Revision: 1.92 $
+  Date:      $Date: 2004/10/06 09:58:08 $
+  Version:   $Revision: 1.93 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -20,7 +20,6 @@
 #include "gdcmValEntry.h"
 #include "gdcmBinEntry.h"
 #include "gdcmSeqEntry.h"
-
 #include "gdcmGlobal.h"
 #include "gdcmUtil.h"
 #include "gdcmDebug.h"
@@ -1458,7 +1457,7 @@ long gdcmDocument::ParseDES(gdcmDocEntrySet *set,
          if (newDocEntry->GetGroup()   == 0x7fe0 && 
              newDocEntry->GetElement() == 0x0010 )
          {
-             if (newDocEntry->GetReadLength()==0xffffffff)
+             if ( newDocEntry->GetReadLength()==0xffffffff ) 
              {
                 // Broken US.3405.1.dcm
                 Parse7FE0(); // to skip the pixels 
@@ -2838,22 +2837,38 @@ void gdcmDocument::Parse7FE0 ()
       return;
    }
 
-   // ---------------- for Parsing : Position on begining of Jpeg/RLE Pixels 
+   // Encoded pixel data: for the time being we are only concerned with
+   // Jpeg or RLE Pixel data encodings.
+   // As stated in ps-3.3, 8.2:
+   // "If sent in Encapsulated Format (i.e. other than the Narive Format) the
+   //  value representation OB is used".
+   // Hence we expect an OB value representation. Concerning OB VR,
+   // the section PS3.3, A.4.c (p58 and p59), states:
+   // "For the Value Representations OB and OW, the encoding shall meet the
+   //   following specifications depending on the Data element tag:"
+   //   [...snip...]
+   //    - the first item in the sequence of items before the encoded pixel
+   //      data stream shall be basic offset table item. The basic offset table
+   //      item value, however, is not required to be present"
 
    //// Read the Basic Offset Table Item Tag length...
    uint32_t itemLength = ReadTagLength(0xfffe, 0xe000);
 
-   //// ... and then read length[s] itself[themselves]. We don't use
-   // the values read (BTW  what is the purpous of those lengths ?)
+   // When present, read the basic offset table itself.
+   // Notes: - since the presence of this basic offset table is optional
+   //          we can't rely on it for the implementation, and we will simply
+   //          trash it's content (when present).
+   //        - still, when present, we could add some further checks on the
+   //          lengths, but not bother with such fuses for the time being.
    if ( itemLength != 0 )
    {
-      // BTW, what is the purpous of those length anyhow !? 
       char* basicOffsetTableItemValue = new char[itemLength + 1];
       fread(basicOffsetTableItemValue, itemLength, 1, Fp);
 
       for (unsigned int i=0; i < itemLength; i += 4 )
       {
-         uint32_t individualLength = str2num(&basicOffsetTableItemValue[i],uint32_t);
+         uint32_t individualLength = str2num( &basicOffsetTableItemValue[i],
+                                              uint32_t);
          std::ostringstream s;
          s << "   Read one length: ";
          s << std::hex << individualLength << std::endl;
@@ -2874,25 +2889,37 @@ void gdcmDocument::Parse7FE0 ()
    }
    else
    {
-      // RLE Image
-      long ftellRes;
-      long rleSegmentLength[15], fragmentLength;
-
-      // While we find some items:
-      while ( (fragmentLength = ReadTagLength(0xfffe, 0xe000)) )
+      // Encapsulated RLE Compressed Images (see PS-3.3, Annex G).
+      // Loop on the frame[s] and store the parsed information in a
+      // gdcmRLEFramesInfo.
+      long frameLength;
+
+      // Loop on the individual frame[s] and store the information
+      // on the RLE fragments in a gdcmRLEFramesInfo.
+      // Note: - when only a single frame is present, this is a
+      //         classical image.
+      //       - when more than one frame are present, then we are in 
+      //         the case of a multi-frame image.
+      while ( (frameLength = ReadTagLength(0xfffe, 0xe000)) )
       { 
-         // Parse fragments of the current Fragment (Frame)    
-         //------------------ scanning (not reading) fragment pixels
+         // Parse the RLE Header and store the corresponding RLE Segment
+         // Offset Table information on fragments of this current Frame.
+         // Note that the fragment pixels themselves are not loaded
+         // (but just skipped).
          uint32_t nbRleSegments = ReadInt32();
  
-         //// Reading RLE Segments Offset Table
          uint32_t rleSegmentOffsetTable[15];
-         for(int k=1; k<=15; k++)
+         long ftellRes;
+         for( int k = 1; k <= 15; k++ )
          {
             ftellRes = ftell(Fp);
             rleSegmentOffsetTable[k] = ReadInt32();
          }
 
+         // Deduce from both the RLE Header and the frameLength the
+         // fragment length, and again store this infor in a
+         // gdcmRLEFramesInfo.
+         long rleSegmentLength[15];
          // skipping (not reading) RLE Segments
          if ( nbRleSegments > 1)
          {
@@ -2905,10 +2932,20 @@ void gdcmDocument::Parse7FE0 ()
              }
           }
 
-          rleSegmentLength[nbRleSegments] = fragmentLength 
-                                          - rleSegmentOffsetTable[nbRleSegments];
+          rleSegmentLength[nbRleSegments] = frameLength 
+                                         - rleSegmentOffsetTable[nbRleSegments];
           ftellRes = ftell(Fp);
           SkipBytes(rleSegmentLength[nbRleSegments]);
+
+          // Store the collected info
+          gdcmRLEFrame* newFrameInfo = new gdcmRLEFrame;
+          newFrameInfo->NumberFragments = nbRleSegments;
+          for( unsigned int k = 1; k <= nbRleSegments; k++ )
+          {
+             newFrameInfo->Offset[k] = rleSegmentOffsetTable[k];
+             newFrameInfo->Length[k] = rleSegmentLength[k];
+          }
+          RLEInfo.Frames.push_back( newFrameInfo );
       }
 
       // Make sure that at the end of the item we encounter a 'Sequence
index 319b48cf3f9f51df32227db2b1b6335a9a0ede3b..8a56ecd2448fa2cd0822c45ec67324f419f6de6d 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDocument.h,v $
   Language:  C++
-  Date:      $Date: 2004/09/27 08:39:07 $
-  Version:   $Revision: 1.44 $
+  Date:      $Date: 2004/10/06 09:58:08 $
+  Version:   $Revision: 1.45 $
  
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -25,6 +25,7 @@
 #include "gdcmException.h"
 #include "gdcmDictSet.h"
 #include "gdcmDocEntry.h"
+#include "gdcmRLEFramesInfo.h"
 
 class gdcmValEntry;
 class gdcmBinEntry;
@@ -91,8 +92,8 @@ protected:
    ///       \ref gdcmDocument::SetMaxSizePrintEntry()
    static const unsigned int MAX_SIZE_PRINT_ELEMENT_VALUE;
 
-   /// Will be set 1 if user asks to 'go inside' the 'sequences' (VR = "SQ")
-   int EnableSequences;
+   /// Store the RLE frames info obtained during parsing of pixels.
+   gdcmRLEFramesInfo RLEInfo;
 
    /// \brief Amount of printed details for each Header Entry (Dicom Element):
    /// 0 : stands for the least detail level.
diff --git a/src/gdcmRLEFrame.h b/src/gdcmRLEFrame.h
new file mode 100644 (file)
index 0000000..9b6ba02
--- /dev/null
@@ -0,0 +1,52 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmRLEFrame.h,v $
+  Language:  C++
+  Date:      $Date: 2004/10/06 09:58:08 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+
+#ifndef GDCMRLEFRAME_H
+#define GDCMRLEFRAME_H
+
+#include "gdcmCommon.h"
+
+/**
+ * \brief Utility class for summerizing the informations of a SINGLE RLE
+ *        frame of an "Encapsulated RLE Compressed Image" (see PS-3.3 annex G).
+ *        This information is a mix of:
+ *        - the RLE Header (see PS-3.3 section G5) and
+ *        - the lengths of each RLE segment [ which can be decuded from
+ *          both the above RLE Header and the itemlength of the frame).
+ *
+ *        Each instance of this class (they can be as many instances for
+ *        a given gdcmDocument as they are frames and they are collected in
+ *        a \ref gdcmRLEFramesInfo ) describes :
+ *        - the total number of segments (up to 15),
+ *        - the offsets of each segment of the frame,
+ *        - the (corresponding) lengths of each segment of the frame.
+ */
+class GDCM_EXPORT gdcmRLEFrame
+{
+friend class gdcmDocument;
+friend class gdcmFile;
+   int     NumberFragments;
+   uint8_t Offset[15];
+   long    Length[15];
+   gdcmRLEFrame() { NumberFragments = 0; }
+   
+};
+
+//-----------------------------------------------------------------------------
+#endif
diff --git a/src/gdcmRLEFramesInfo.cxx b/src/gdcmRLEFramesInfo.cxx
new file mode 100644 (file)
index 0000000..0c3d1ba
--- /dev/null
@@ -0,0 +1,28 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmRLEFramesInfo.cxx,v $
+  Language:  C++
+  Date:      $Date: 2004/10/06 09:58:08 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+#include "gdcmRLEFramesInfo.h"
+
+gdcmRLEFramesInfo::~gdcmRLEFramesInfo()
+{
+   for(RLEFrameList::iterator it = Frames.begin(); it != Frames.end(); ++it)
+   {
+      delete (*it);
+   }
+   Frames.clear();
+}
diff --git a/src/gdcmRLEFramesInfo.h b/src/gdcmRLEFramesInfo.h
new file mode 100644 (file)
index 0000000..3bc1058
--- /dev/null
@@ -0,0 +1,50 @@
+/*=========================================================================
+                                                                                
+  Program:   gdcm
+  Module:    $RCSfile: gdcmRLEFramesInfo.h,v $
+  Language:  C++
+  Date:      $Date: 2004/10/06 09:58:08 $
+  Version:   $Revision: 1.1 $
+                                                                                
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notices for more information.
+                                                                                
+=========================================================================*/
+
+
+#ifndef GDCMRLEFRAMESINFO_H
+#define GDCMRLEFRAMESINFO_H
+
+#include "gdcmRLEFrame.h"
+#include <list>
+
+/**
+ * \brief Utility class for gathering the informations of the collection
+ *        of RLE frame[s] (see \ref gdcmRLEFrame)  when handling
+ *        "Encapsulated RLE Compressed Images" (see PS-3.3 annex G). 
+ *        Note: a classical image can be considered as the degenerated case
+ *              of a multiframe image. In this case the collection is limited
+ *              to a single individual frame.
+ *        The informations on each frame are obtained during the parsing
+ *        of a gdcmDocument (refer to \ref gdcmDocument::Parse7FE0() ).
+ *        They shall be used when (if necessary) decoding the frames.
+ *
+ *        This class is simply a stl list<> of \ref gdcmRLEFrame.
+ */
+class GDCM_EXPORT gdcmRLEFramesInfo
+{
+   typedef std::list< gdcmRLEFrame* > RLEFrameList;
+friend class gdcmDocument;
+friend class gdcmFile;
+   RLEFrameList Frames;
+public:
+   ~gdcmRLEFramesInfo();
+};
+
+//-----------------------------------------------------------------------------
+#endif