Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

gdcm::RLEFrame Class Reference

Utility class for summerizing the informations of a SINGLE RLE frame of an "Encapsulated RLE Compressed Image" (refer to PS 3.5-2003 annex G). This information is a mix of: -the RLE Header (see PS 3.5-2003 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). More...

#include <gdcmRLEFrame.h>

List of all members.

Public Member Functions

 RLEFrame ()
void Print (std::ostream &os=std::cout, std::string indent="")
 Print self.

void SetNumberOfFragments (unsigned int number)
unsigned int GetNumberOfFragments ()
void SetOffset (unsigned int id, long offset)
long GetOffset (unsigned int id)
void SetLength (unsigned int id, long length)
long GetLength (unsigned int id)
uint8_t * ReadAndDecompressRLEFrame (uint8_t *subRaw, long rawSegmentSize, std::ifstream *fp)
bool ReadAndDecompressRLEFragment (uint8_t *subRaw, long fragmentSize, long rawSegmentSize, std::ifstream *fp)
 Implementation of the RLE decoding algorithm for decompressing a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86].


Private Attributes

unsigned int NumberOfFragments
long Offset [15]
long Length [15]


Detailed Description

Utility class for summerizing the informations of a SINGLE RLE frame of an "Encapsulated RLE Compressed Image" (refer to PS 3.5-2003 annex G). This information is a mix of: -the RLE Header (see PS 3.5-2003 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 Document as they are frames and they are collected in a RLEFramesInfo ) describes :

Definition at line 46 of file gdcmRLEFrame.h.


Constructor & Destructor Documentation

gdcm::RLEFrame::RLEFrame  )  [inline]
 

Definition at line 49 of file gdcmRLEFrame.h.

00049 { NumberOfFragments = 0; }


Member Function Documentation

long gdcm::RLEFrame::GetLength unsigned int  id  ) 
 

Definition at line 47 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro.

00048 {
00049    gdcmAssertMacro(id<15);
00050    return Length[id];
00051 }

unsigned int gdcm::RLEFrame::GetNumberOfFragments  )  [inline]
 

Definition at line 53 of file gdcmRLEFrame.h.

00053 { return NumberOfFragments; };

long gdcm::RLEFrame::GetOffset unsigned int  id  ) 
 

Definition at line 35 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro.

00036 {
00037    gdcmAssertMacro(id<15);
00038    return Offset[id];
00039 }

void gdcm::RLEFrame::Print std::ostream &  os = std::cout,
std::string  indent = ""
 

Print self.

Parameters:
indent Indentation string to be prepended during printing.
os Stream to print to.

Definition at line 143 of file gdcmRLEFrame.cxx.

References NumberOfFragments.

00144 {
00145    os << indent
00146       << "--- fragments"
00147       << std::endl;
00148    for ( unsigned int i = 0; i < NumberOfFragments; i++ )
00149    {
00150       os << indent
00151          << "   offset : " <<  Offset[i]
00152          << "   length : " <<  Length[i]
00153          << std::endl;
00154    }
00155 }

bool gdcm::RLEFrame::ReadAndDecompressRLEFragment uint8_t *  subRaw,
long  fragmentSize,
long  rawSegmentSize,
std::ifstream *  fp
 

Implementation of the RLE decoding algorithm for decompressing a RLE fragment. [refer to PS 3.5-2003, section G.3.2 p 86].

Parameters:
subRaw Sub region where the decoded fragment should be placed.
fragmentSize The length of the binary fragment as found on the disk.
rawSegmentSize The expected length of the fragment ONCE Raw.
fp File Pointer: on entry the position should be the one of the fragment to be decoded.

Definition at line 79 of file gdcmRLEFrame.cxx.

References gdcmWarningMacro.

Referenced by ReadAndDecompressRLEFrame().

00083 {
00084    int8_t count;
00085    long numberOfOutputBytes = 0;
00086    long numberOfReadBytes = 0;
00087 
00088 
00089    while( numberOfOutputBytes < rawSegmentSize )
00090    {
00091       fp->read( (char*)&count, 1 );
00092       numberOfReadBytes += 1;
00093       if ( count >= 0 )
00094       // Note: count <= 127 comparison is always true due to limited range
00095       //       of data type int8_t [since the maximum of an exact width
00096       //       signed integer of width N is 2^(N-1) - 1, which for int8_t
00097       //       is 127].
00098       {
00099          fp->read( (char*)subRaw, count + 1);
00100          numberOfReadBytes   += count + 1;
00101          subRaw     += count + 1;
00102          numberOfOutputBytes += count + 1;
00103       }
00104       else
00105       {
00106          if ( count <= -1 && count >= -127 )
00107          {
00108             int8_t newByte;
00109             fp->read( (char*)&newByte, 1);
00110             numberOfReadBytes += 1;
00111             for( int i = 0; i < -count + 1; i++ )
00112             {
00113                subRaw[i] = newByte;
00114             }
00115             subRaw     += -count + 1;
00116             numberOfOutputBytes += -count + 1;
00117          }
00118       }
00119       // if count = 128 output nothing
00120                                                                                 
00121       if ( numberOfReadBytes > fragmentSize )
00122       {
00123          gdcmWarningMacro( "Read more bytes than the segment size.");
00124          return false;
00125       }
00126    }
00127    return true;
00128 }

uint8_t * gdcm::RLEFrame::ReadAndDecompressRLEFrame uint8_t *  subRaw,
long  rawSegmentSize,
std::ifstream *  fp
 

Definition at line 53 of file gdcmRLEFrame.cxx.

References NumberOfFragments, and ReadAndDecompressRLEFragment().

00056 {
00057    // Loop on the fragments
00058    for( unsigned int k = 1; k <= NumberOfFragments; k++ )
00059    {
00060       // First thing need to reset file to proper position:
00061       fp->seekg(Offset[k], std::ios::beg);
00062       ReadAndDecompressRLEFragment(subRaw, Length[k],
00063                                    rawSegmentSize, fp);
00064       subRaw += rawSegmentSize;
00065    }
00066 
00067    return subRaw;
00068 }

void gdcm::RLEFrame::SetLength unsigned int  id,
long  length
 

Definition at line 41 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro.

Referenced by gdcm::File::ComputeRLEInfo().

00042 {
00043    gdcmAssertMacro(id<15);
00044    Length[id] = length;
00045 }

void gdcm::RLEFrame::SetNumberOfFragments unsigned int  number  )  [inline]
 

Definition at line 52 of file gdcmRLEFrame.h.

Referenced by gdcm::File::ComputeRLEInfo().

00052 { NumberOfFragments = number; };   

void gdcm::RLEFrame::SetOffset unsigned int  id,
long  offset
 

Definition at line 29 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro.

Referenced by gdcm::File::ComputeRLEInfo().

00030 {
00031    gdcmAssertMacro(id<15);
00032    Offset[id] = offset;
00033 }


Member Data Documentation

long gdcm::RLEFrame::Length[15] [private]
 

Definition at line 67 of file gdcmRLEFrame.h.

unsigned int gdcm::RLEFrame::NumberOfFragments [private]
 

Definition at line 65 of file gdcmRLEFrame.h.

Referenced by Print(), and ReadAndDecompressRLEFrame().

long gdcm::RLEFrame::Offset[15] [private]
 

Definition at line 66 of file gdcmRLEFrame.h.


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:18:10 2005 for gdcm by doxygen 1.3.6