GDCM_NAME_SPACE::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: More...

#include <gdcmRLEFrame.h>

Inheritance diagram for GDCM_NAME_SPACE::RLEFrame:

Inheritance graph
[legend]
Collaboration diagram for GDCM_NAME_SPACE::RLEFrame:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.
int GetPrintLevel ()
 Gets the print level for the Dicom Entries.

Protected Attributes

int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Private Member Functions

 RLEFrame ()
void Print (std::ostream &os=std::cout, std::string const &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]

Friends

class File
class RLEFramesInfo

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:

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_NAME_SPACE::RLEFrame::RLEFrame  )  [inline, private]
 

Definition at line 51 of file gdcmRLEFrame.h.

00051 { NumberOfFragments = 0; }


Member Function Documentation

long GDCM_NAME_SPACE::RLEFrame::GetLength unsigned int  id  )  [private]
 

Definition at line 47 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro, and Length.

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

unsigned int GDCM_NAME_SPACE::RLEFrame::GetNumberOfFragments  )  [inline, private]
 

Definition at line 56 of file gdcmRLEFrame.h.

00056 { return NumberOfFragments; }

long GDCM_NAME_SPACE::RLEFrame::GetOffset unsigned int  id  )  [private]
 

Definition at line 35 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro, and Offset.

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

int GDCM_NAME_SPACE::Base::GetPrintLevel  )  [inline, inherited]
 

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

void GDCM_NAME_SPACE::RLEFrame::Print std::ostream &  os = std::cout,
std::string const &  indent = ""
[private, virtual]
 

Print self.

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

Reimplemented from GDCM_NAME_SPACE::Base.

Definition at line 144 of file gdcmRLEFrame.cxx.

References Length, NumberOfFragments, and Offset.

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

bool GDCM_NAME_SPACE::RLEFrame::ReadAndDecompressRLEFragment uint8_t *  subRaw,
long  fragmentSize,
long  rawSegmentSize,
std::ifstream *  fp
[private]
 

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

uint8_t * GDCM_NAME_SPACE::RLEFrame::ReadAndDecompressRLEFrame uint8_t *  subRaw,
long  rawSegmentSize,
std::ifstream *  fp
[private]
 

Definition at line 53 of file gdcmRLEFrame.cxx.

References Length, NumberOfFragments, Offset, 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_NAME_SPACE::RLEFrame::SetLength unsigned int  id,
long  length
[private]
 

Definition at line 41 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro, and Length.

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

void GDCM_NAME_SPACE::RLEFrame::SetNumberOfFragments unsigned int  number  )  [inline, private]
 

Definition at line 54 of file gdcmRLEFrame.h.

00055                                        { NumberOfFragments = number; }   

void GDCM_NAME_SPACE::RLEFrame::SetOffset unsigned int  id,
long  offset
[private]
 

Definition at line 29 of file gdcmRLEFrame.cxx.

References gdcmAssertMacro, and Offset.

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

void GDCM_NAME_SPACE::Base::SetPrintLevel int  level  )  [inline, inherited]
 

Sets the print level for the Dicom Header Elements.

Note:
0 for Light Print; 1 for 'medium' Print, 2 for Heavy Print

Definition at line 47 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::FileHelper::Print(), and GDCM_NAME_SPACE::DicomDir::Print().

00047 { PrintLevel = level; }


Friends And Related Function Documentation

friend class File [friend]
 

Definition at line 48 of file gdcmRLEFrame.h.

friend class RLEFramesInfo [friend]
 

Definition at line 49 of file gdcmRLEFrame.h.


Member Data Documentation

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

Definition at line 69 of file gdcmRLEFrame.h.

Referenced by GetLength(), Print(), ReadAndDecompressRLEFrame(), and SetLength().

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

Definition at line 67 of file gdcmRLEFrame.h.

Referenced by Print(), and ReadAndDecompressRLEFrame().

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

Definition at line 68 of file gdcmRLEFrame.h.

Referenced by GetOffset(), Print(), ReadAndDecompressRLEFrame(), and SetOffset().

int GDCM_NAME_SPACE::Base::PrintLevel [protected, inherited]
 

Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Definition at line 55 of file gdcmBase.h.

Referenced by GDCM_NAME_SPACE::SeqEntry::Print(), GDCM_NAME_SPACE::FileHelper::Print(), GDCM_NAME_SPACE::ElementSet::Print(), GDCM_NAME_SPACE::DocEntry::Print(), GDCM_NAME_SPACE::DictEntry::Print(), GDCM_NAME_SPACE::DicomDirStudy::Print(), GDCM_NAME_SPACE::DicomDirSerie::Print(), GDCM_NAME_SPACE::DicomDirPatient::Print(), GDCM_NAME_SPACE::DicomDirMeta::Print(), GDCM_NAME_SPACE::DicomDir::Print(), and GDCM_NAME_SPACE::DataEntry::Print().


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 13:01:54 2007 for gdcm by  doxygen 1.4.6