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

gdcm::DataEntry Class Reference

Any Dicom Document (File or DicomDir, or ...) contains a set of DocEntry - Dicom entries - (when successfuly parsed against a given Dicom dictionary) DataEntry is an elementary DocEntry (as opposed to SeqEntry). Depending on the type of its content,. More...

#include <gdcmDataEntry.h>

Inheritance diagram for gdcm::DataEntry:

Inheritance graph
[legend]
Collaboration diagram for gdcm::DataEntry:

Collaboration graph
[legend]
List of all members.

Public Types

enum  TValueState { STATE_LOADED = 0x00, STATE_NOTLOADED = 0x01, STATE_UNFOUND = 0x02, STATE_UNREAD = 0x03 }
 values for current state of a DataEntry (internal use only) More...
enum  TValueFlag { FLAG_NONE = 0x00, FLAG_PIXELDATA = 0x01 }
 values for current pixel status of a DataEntry (internal use only) More...

Public Member Functions

void Print (std::ostream &os=std::cout, std::string const &indent="")
 Prints a DataEntry (Dicom entry).
virtual void WriteContent (std::ofstream *fp, FileType filetype)
 Writes the 'value' area of a DataEntry.
uint32_t ComputeFullLength ()
 Compute the full length of the elementary DataEntry (not only value length) depending on the VR.
uint8_t * GetBinArea ()
 Returns the 'Value' (e.g. "Dupond^Marcel") converted into a 'string', event if it's physically stored on disk as an integer (e.g. : 0x000c returned as "12") Returns the area value of the current Dicom Entry when it's not string-translatable (e.g : LUT table, overlay, icon).
void SetBinArea (uint8_t *area, bool self=true)
 Sets the value (non string) of the current Dicom Header Entry.
void CopyBinArea (uint8_t *area, uint32_t length)
 Inserts the value (non string) into the current Dicom Header Entry.
void SetValue (const uint32_t &id, const double &val)
double GetValue (const uint32_t &id) const
 returns, as a double (?!?) one of the values (when entry is multivaluated), identified by its index. Returns 0.0 if index is wrong FIXME : warn the user there was a problem !
uint32_t GetValueCount (void) const
 returns the number of elementary values
bool IsValueCountValid () const
 Checks if the multiplicity of the value follows Dictionary VM.
void SetString (std::string const &value)
 Sets the 'value' of an Entry, passed as a std::string.
std::string const & GetString () const
 returns as a string (when possible) the value of the DataEntry
void SetSelfArea (bool area)
 Sets SelfArea.
bool IsSelfArea ()
 True if Entry owns its BinArea.
void SetState (const TValueState &state)
const TValueStateGetState () const
bool IsNotLoaded ()
 true when value Entry not loaded
bool IsUnfound ()
 true if Entry not found
bool IsUnread ()
 true if Entry not read
bool IsGoodValue ()
 true if Entry value properly loaded
void SetFlag (const TValueFlag &flag)
 sets the 'pixel data flag'
const TValueFlagGetFlag () const
 returns the 'pixel data flag'
bool IsPixelData ()
 true id Entry is a Pixel Data entry
void Copy (DocEntry *doc)
 Copies all the attributes from an other DocEntry.
DictEntryGetDictEntry ()
 Gets the DicEntry of the current Dicom entry.
const uint16_t & GetGroup () const
 Returns the Dicom Group number of the current Dicom entry.
const uint16_t & GetElement () const
 Returns the Dicom Element number of the current Dicom entry.
TagKey GetKey () const
 Returns the 'key' of the current Dicom entry.
std::string const & GetName () const
 Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom Dictionnary of the current Dicom Header Entry.
VRKey const & GetVR () const
 Returns the 'Value Representation' (e.g. "PN" : Person Name, "SL" : Signed Long), found in the Dicom header or in the Dicom Dictionnary, of the current Dicom entry.
std::string const & GetVM () const
 Returns the 'Value Multiplicity' (e.g. "1", 6", "1-n", "3-n"), found in the Dicom entry or in the Dicom Dictionnary of the current Dicom entry.
void SetVM (TagName const &v)
 Sets the 'Value Multiplicity' of the current Dicom entry.
const size_t & GetOffset () const
 Returns offset (since the beginning of the file, including the File Preamble, if any) of the value of the current Dicom entry.
void SetReadLength (uint32_t l)
 Sets only 'Read Length' (*not* 'Usable Length') of the current Dicom entry.
const uint32_t & GetReadLength () const
 Returns the 'read length' of the current Dicom entry.
virtual void SetLength (uint32_t l)
 Sets both 'Read Length' and 'Usable Length' of the current Dicom entry.
const uint32_t & GetLength () const
 Returns the actual value length of the current Dicom entry.
uint32_t GetFullLength ()
 Gets the full length of the elementary DocEntry (not only value length) depending on the VR.
void SetOffset (size_t of)
 Sets the offset of the Dicom entry.
void SetImplicitVR ()
 Sets to TRUE the ImplicitVr flag of the current Dicom entry.
bool IsImplicitVR () const
 Tells us if the current Dicom entry was checked as ImplicitVr.
bool IsVRUnknown () const
 Tells us if the VR of the current Dicom entry is Unknown.
bool IsVMUnknown () const
 Tells us if the VM of the current Dicom entry is Unknown.
bool IsItemDelimitor ()
 tells us if entry is the last one of a 'no length' SequenceItem (fffe,e00d)
bool IsItemStarter ()
 tells us if entry is the first one of an Item (fffe,e000)
bool IsSequenceDelimitor ()
 tells us if entry is the last one of a 'no length' Sequence (fffe,e0dd)
void Delete ()
 Delete the object.
void Register ()
 Register the object.
void Unregister ()
 Unregister the object.
const unsigned long & GetRefCount () const
 Get the reference counting.
void SetPrintLevel (int level)
 Sets the print level for the Dicom Header Elements.
int GetPrintLevel ()
 Gets the print level for the Dicom Entries.

Static Public Member Functions

static DataEntryNew (DictEntry *e)
static DataEntryNew (DocEntry *d)
static const uint32_t & GetMaxSizePrintEntry ()
 returns the size threshold above which an element value will NOT be *printed* in order no to polute the screen output
static void SetMaxSizePrintEntry (const uint32_t &size)
 Header Elements too long will not be printed.

Protected Member Functions

 DataEntry (DictEntry *e)
 Constructor for a given DictEntry.
 DataEntry (DocEntry *d)
 Constructor for a given DocEntry.
 ~DataEntry ()
 Canonical destructor.
void NewBinArea (void)
void DeleteBinArea (void)

Protected Attributes

uint8_t * BinArea
 memory area to hold 'non std::string' representable values (ie : Lookup Tables, overlays, icons)
bool SelfArea
 Whether DataEntry has its own BinArea or not.
std::string StrArea
 std::string representable value of the Entry. Parts of a multivaluated data are separated by back-slash
DictEntryDicomDict
 pointer to the underlying Dicom dictionary element
uint32_t Length
 Correspond to the real length of the data This length might always be even.
uint32_t ReadLength
 Length to read in the file to obtain data.
bool ImplicitVR
 Even when reading explicit vr files, some elements happen to be implicit. Flag them here since we can't use the entry->vr without breaking the underlying dictionary.
size_t Offset
 Offset from the beginning of file for direct user access.
int PrintLevel
 Amount of printed details for each Dicom Entries : 0 : stands for the least detail level.

Private Member Functions

 gdcmTypeMacro (DataEntry)

Private Attributes

TValueFlag Flag
 0 for straight entries, FLAG_PIXELDATA for Pixel Data entries
TValueState State
 Entry status:STATE_NOTLOADED,STATE_UNFOUND,STATE_UNREAD,STATE_LOADED.

Static Private Attributes

static uint32_t MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE
 Size threshold above which an element val By default, this upper bound is fixed to 64 bytes.

Detailed Description

Any Dicom Document (File or DicomDir, or ...) contains a set of DocEntry - Dicom entries - (when successfuly parsed against a given Dicom dictionary) DataEntry is an elementary DocEntry (as opposed to SeqEntry). Depending on the type of its content,.

Definition at line 36 of file gdcmDataEntry.h.


Member Enumeration Documentation

enum gdcm::DataEntry::TValueFlag
 

values for current pixel status of a DataEntry (internal use only)

Enumerator:
FLAG_NONE 
FLAG_PIXELDATA 

Definition at line 88 of file gdcmDataEntry.h.

00089    {
00090       FLAG_NONE       = 0x00,
00091       FLAG_PIXELDATA  = 0x01
00092    };

enum gdcm::DataEntry::TValueState
 

values for current state of a DataEntry (internal use only)

Enumerator:
STATE_LOADED 
STATE_NOTLOADED 
STATE_UNFOUND 
STATE_UNREAD 

Definition at line 79 of file gdcmDataEntry.h.

00080    {
00081       STATE_LOADED    = 0x00,
00082       STATE_NOTLOADED = 0x01,
00083       STATE_UNFOUND   = 0x02,
00084       STATE_UNREAD    = 0x03
00085    };


Constructor & Destructor Documentation

gdcm::DataEntry::DataEntry DictEntry e  )  [protected]
 

Constructor for a given DictEntry.

Parameters:
e Pointer to existing dictionary entry

Definition at line 40 of file gdcmDataEntry.cxx.

References BinArea, Flag, FLAG_NONE, SelfArea, State, and STATE_LOADED.

00041             : DocEntry(e)
00042 {
00043    State = STATE_LOADED;
00044    Flag = FLAG_NONE;
00045 
00046    BinArea = 0;
00047    SelfArea = true;
00048 }

gdcm::DataEntry::DataEntry DocEntry e  )  [protected]
 

Constructor for a given DocEntry.

Parameters:
e Pointer to existing Doc entry

Definition at line 54 of file gdcmDataEntry.cxx.

References BinArea, Copy(), Flag, FLAG_NONE, and SelfArea.

00055             : DocEntry(e->GetDictEntry())
00056 {
00057    Flag = FLAG_NONE;
00058    BinArea = 0;
00059    SelfArea = true;
00060 
00061    Copy(e);
00062 }

gdcm::DataEntry::~DataEntry  )  [protected]
 

Canonical destructor.

Definition at line 67 of file gdcmDataEntry.cxx.

References DeleteBinArea().

00068 {
00069    DeleteBinArea();
00070 }


Member Function Documentation

uint32_t gdcm::DataEntry::ComputeFullLength  )  [virtual]
 

Compute the full length of the elementary DataEntry (not only value length) depending on the VR.

Implements gdcm::DocEntry.

Definition at line 570 of file gdcmDataEntry.cxx.

References gdcm::DocEntry::GetFullLength().

00571 {
00572    return GetFullLength();
00573 }

void gdcm::DataEntry::Copy DocEntry doc  )  [virtual]
 

Copies all the attributes from an other DocEntry.

Parameters:
doc entry to copy from

Reimplemented from gdcm::DocEntry.

Definition at line 459 of file gdcmDataEntry.cxx.

References BinArea, gdcm::DocEntry::Copy(), CopyBinArea(), Flag, gdcm::DocEntry::GetLength(), and State.

Referenced by gdcm::FileHelper::CopyDataEntry(), DataEntry(), gdcm::File::DoTheLoadingJob(), and gdcm::FileHelper::SetWriteToLibido().

00460 {
00461    DocEntry::Copy(doc);
00462 
00463    DataEntry *entry = dynamic_cast<DataEntry *>(doc);
00464    if ( entry )
00465    {
00466       State = entry->State;
00467       Flag = entry->Flag;
00468       CopyBinArea(entry->BinArea,entry->GetLength());
00469    }
00470 }

void gdcm::DataEntry::CopyBinArea uint8_t *  area,
uint32_t  length
 

Inserts the value (non string) into the current Dicom Header Entry.

Definition at line 92 of file gdcmDataEntry.cxx.

References BinArea, DeleteBinArea(), NewBinArea(), gdcm::DocEntry::SetLength(), State, and STATE_LOADED.

Referenced by Copy(), and gdcm::DicomDirMeta::WriteContent().

00093 {
00094    DeleteBinArea();
00095 
00096    uint32_t lgh = length + length%2;
00097    SetLength(lgh);
00098 
00099    if( area && length > 0 )
00100    {
00101       NewBinArea();
00102       memcpy(BinArea,area,length);
00103       if( length!=lgh )
00104          BinArea[length]=0;
00105 
00106       State = STATE_LOADED;
00107    }
00108 }

void gdcm::RefCounter::Delete  )  [inline, inherited]
 

Delete the object.

Remarks:
The object is deleted only if its reference counting is to zero

Definition at line 40 of file gdcmRefCounter.h.

Referenced by gdcm::SerieHelper::AddFileName(), gdcm::Document::Backtrack(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::FileHelper::CopyMandatoryEntry(), gdcm::DicomDir::CreateDicomDirChainedList(), gdcm::File::DoTheLoadingJob(), gdcm::Dict::DoTheLoadingJob(), gdcm::DicomDirObject::FillObject(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), gdcm::DocEntrySet::InsertSeqEntry(), gdcm::DicomDir::NewMeta(), gdcm::DicomDirStudy::NewVisit(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::Document::ReadNextDocEntry(), gdcm::DicomDir::SetElement(), gdcm::FileHelper::SetMandatoryEntry(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), gdcm::FileHelper::SetWriteFileTypeToJPEG(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), gdcm::FileHelper::SetWriteToRaw(), gdcm::FileHelper::SetWriteToRGB(), gdcm::DicomDir::~DicomDir(), and gdcm::Global::~Global().

00040 { Unregister(); }

void gdcm::DataEntry::DeleteBinArea void   )  [protected]
 

Definition at line 585 of file gdcmDataEntry.cxx.

References BinArea, and SelfArea.

Referenced by CopyBinArea(), NewBinArea(), SetBinArea(), SetString(), and ~DataEntry().

00586 {
00587    if (BinArea && SelfArea)
00588    {
00589       delete[] BinArea;
00590       BinArea = NULL;
00591    }
00592 }

gdcm::DataEntry::gdcmTypeMacro DataEntry   )  [private]
 

uint8_t* gdcm::DataEntry::GetBinArea  )  [inline]
 

Returns the 'Value' (e.g. "Dupond^Marcel") converted into a 'string', event if it's physically stored on disk as an integer (e.g. : 0x000c returned as "12") Returns the area value of the current Dicom Entry when it's not string-translatable (e.g : LUT table, overlay, icon).

Definition at line 61 of file gdcmDataEntry.h.

Referenced by gdcm::File::DoTheLoadingJob(), gdcm::DocEntrySet::GetEntryBinArea(), gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::Document::LoadEntryBinArea(), and Print().

00061 { return BinArea; }

DictEntry* gdcm::DocEntry::GetDictEntry  )  [inline, inherited]
 

Gets the DicEntry of the current Dicom entry.

Returns:
The DicEntry of the current Dicom entry

Definition at line 48 of file gdcmDocEntry.h.

Referenced by gdcm::FileHelper::CopyDataEntry(), gdcm::DocEntryArchive::Push(), and gdcm::FileHelper::SetWriteToLibido().

00048 { return DicomDict; } 

const uint16_t& gdcm::DocEntry::GetElement  )  const [inline, inherited]
 

Returns the Dicom Element number of the current Dicom entry.

Definition at line 54 of file gdcmDocEntry.h.

Referenced by gdcm::SQItem::AddEntry(), gdcm::Document::Backtrack(), gdcm::Document::ComputeGroup0002Length(), gdcm::DicomDirMeta::ComputeGroup0002Length(), gdcm::Document::FixDocEntryFoundLength(), gdcm::Document::IsDocEntryAnInteger(), gdcm::DocEntry::IsItemDelimitor(), gdcm::DocEntry::IsItemStarter(), gdcm::DocEntry::IsSequenceDelimitor(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::ParseDES(), gdcm::DocEntry::Print(), Print(), gdcm::Document::ReadNextDocEntry(), and gdcm::DocEntry::WriteContent().

00054 { return DicomDict->GetElement();}

const TValueFlag& gdcm::DataEntry::GetFlag  )  const [inline]
 

returns the 'pixel data flag'

Definition at line 110 of file gdcmDataEntry.h.

00110 { return Flag; }

uint32_t gdcm::DocEntry::GetFullLength  )  [inherited]
 

Gets the full length of the elementary DocEntry (not only value length) depending on the VR.

Definition at line 173 of file gdcmDocEntry.cxx.

References gdcm::DocEntry::GetReadLength(), gdcm::DocEntry::GetVR(), and gdcm::DocEntry::IsImplicitVR().

Referenced by ComputeFullLength().

00174 {
00175    uint32_t l = GetReadLength();
00176    if ( IsImplicitVR() )
00177    {
00178       l = l + 8;  // 2 (gr) + 2 (el) + 4 (lgth) 
00179    }
00180    else
00181    {
00182       if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
00183       {
00184          l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
00185       }
00186       else
00187       {
00188          l = l + 8;  // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
00189       }
00190    }
00191    return l;
00192 }

const uint16_t& gdcm::DocEntry::GetGroup  )  const [inline, inherited]
 

Returns the Dicom Group number of the current Dicom entry.

Definition at line 51 of file gdcmDocEntry.h.

Referenced by gdcm::SQItem::AddEntry(), gdcm::Document::Backtrack(), gdcm::Document::ComputeGroup0002Length(), gdcm::DicomDirMeta::ComputeGroup0002Length(), gdcm::Document::FixDocEntryFoundLength(), gdcm::Document::IsDocEntryAnInteger(), gdcm::DocEntry::IsItemDelimitor(), gdcm::DocEntry::IsItemStarter(), gdcm::DocEntry::IsSequenceDelimitor(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::ParseDES(), gdcm::DocEntry::Print(), Print(), gdcm::Document::ReadNextDocEntry(), gdcm::Document::SkipToNextDocEntry(), gdcm::DocEntry::WriteContent(), and WriteContent().

00051 { return DicomDict->GetGroup();  }

TagKey gdcm::DocEntry::GetKey  )  const [inline, inherited]
 

Returns the 'key' of the current Dicom entry.

Definition at line 57 of file gdcmDocEntry.h.

Referenced by gdcm::ElementSet::AddEntry(), gdcm::Document::ParseDES(), gdcm::SQItem::RemoveEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::Validator::SetInput(), and WriteContent().

00057 { return DicomDict->GetKey(); }

const uint32_t& gdcm::DocEntry::GetLength  )  const [inline, inherited]
 

Returns the actual value length of the current Dicom entry.

Warning:
this value is not *always* the one stored in the Dicom header in case of well known bugs

Definition at line 96 of file gdcmDocEntry.h.

Referenced by gdcm::Document::Backtrack(), gdcm::Document::ComputeGroup0002Length(), gdcm::DicomDirMeta::ComputeGroup0002Length(), Copy(), gdcm::Document::DoTheLoadingDocumentJob(), gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::DocEntrySet::GetEntryLength(), gdcm::File::GetPixelAreaLength(), GetString(), GetValue(), GetValueCount(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), NewBinArea(), Print(), gdcm::Document::SkipDocEntry(), gdcm::DocEntry::WriteContent(), and WriteContent().

00096 { return Length; }

static const uint32_t& gdcm::DataEntry::GetMaxSizePrintEntry  )  [inline, static]
 

returns the size threshold above which an element value will NOT be *printed* in order no to polute the screen output

Definition at line 118 of file gdcmDataEntry.h.

Referenced by Print().

00118 { return MaxSizePrintEntry; }

std::string const& gdcm::DocEntry::GetName  )  const [inline, inherited]
 

Returns the 'Name' '(e.g. "Patient's Name") found in the Dicom Dictionnary of the current Dicom Header Entry.

Definition at line 61 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::Print().

00061 { return DicomDict->GetName(); }

const size_t& gdcm::DocEntry::GetOffset  )  const [inline, inherited]
 

Returns offset (since the beginning of the file, including the File Preamble, if any) of the value of the current Dicom entry.

Warning:
offset of the *value*, not of the Dicom entry

Definition at line 79 of file gdcmDocEntry.h.

Referenced by gdcm::Document::Backtrack(), gdcm::File::DoTheLoadingJob(), gdcm::File::GetPixelOffset(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::ParseDES(), gdcm::DocEntry::Print(), gdcm::SeqEntry::SeqEntry(), and gdcm::Document::SkipToNextDocEntry().

00079 { return Offset; }

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

Gets the print level for the Dicom Entries.

Definition at line 50 of file gdcmBase.h.

00050 { return PrintLevel; }

const uint32_t& gdcm::DocEntry::GetReadLength  )  const [inline, inherited]
 

Returns the 'read length' of the current Dicom entry.

Warning:
this value is the one stored in the Dicom header but not mandatoryly the one thats's used (in case on SQ, or delimiters, the usable length is set to zero)

Definition at line 88 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::GetFullLength(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::SeqEntry::Print(), gdcm::DocEntry::Print(), gdcm::Document::SkipToNextDocEntry(), and gdcm::SeqEntry::WriteContent().

00088 { return ReadLength; }

const unsigned long& gdcm::RefCounter::GetRefCount  )  const [inline, inherited]
 

Get the reference counting.

Returns:
Reference count

Definition at line 57 of file gdcmRefCounter.h.

00058    {
00059       return RefCount;
00060    }

const TValueState& gdcm::DataEntry::GetState  )  const [inline]
 

Definition at line 96 of file gdcmDataEntry.h.

00096 { return State; }

std::string const & gdcm::DataEntry::GetString  )  const
 

returns as a string (when possible) the value of the DataEntry

Definition at line 383 of file gdcmDataEntry.cxx.

References BinArea, gdcm::DocEntry::GetLength(), GetValueCount(), gdcm::DocEntry::GetVR(), and StrArea.

Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::CheckVM(), gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::DocEntrySet::GetEntryString(), gdcm::Document::ParseDES(), Print(), gdcm::FileHelper::SetWriteToLibido(), and gdcm::FileHelper::SetWriteToNoLibido().

00384 {
00385    static std::ostringstream s;
00386    const VRKey &vr = GetVR();
00387 
00388    s.str("");
00389    StrArea="";
00390 
00391    if( !BinArea )
00392       return StrArea;
00393       
00394    // When short integer(s) are stored, convert the following (n * 2) characters 
00395    // as a displayable string, the values being separated by a back-slash
00396 
00397    if( vr == "US" || vr == "SS" )
00398    {
00399       uint16_t *data=(uint16_t *)BinArea;
00400 
00401       for (unsigned int i=0; i < GetValueCount(); i++)
00402       {
00403          if( i!=0 )
00404             s << '\\';
00405          s << data[i];
00406       }
00407       StrArea=s.str();
00408    }
00409    // See above comment on multiple short integers (mutatis mutandis).
00410    else if( vr == "UL" || vr == "SL" )
00411    {
00412       uint32_t *data=(uint32_t *)BinArea;
00413 
00414       for (unsigned int i=0; i < GetValueCount(); i++)
00415       {
00416          if( i!=0 )
00417             s << '\\';
00418          s << data[i];
00419       }
00420       StrArea=s.str();
00421    }
00422    else if( vr == "FL" )
00423    {
00424       float *data=(float *)BinArea;
00425 
00426       for (unsigned int i=0; i < GetValueCount(); i++)
00427       {
00428          if( i!=0 )
00429             s << '\\';
00430          s << data[i];
00431       }
00432       StrArea=s.str();
00433    }
00434    else if( vr == "FD" )
00435    {
00436       double *data=(double *)BinArea;
00437 
00438       for (unsigned int i=0; i < GetValueCount(); i++)
00439       {
00440          if( i!=0 )
00441             s << '\\';
00442          s << data[i];
00443       }
00444       StrArea=s.str();
00445    }
00446    else
00447    {
00448       StrArea.append((const char *)BinArea,GetLength());
00449       // to avoid gdcm propagate oddities in lengthes
00450       if ( GetLength()%2)
00451          StrArea.append(" ",1);  
00452    }
00453    return StrArea;
00454 }

double gdcm::DataEntry::GetValue const uint32_t &  id  )  const
 

returns, as a double (?!?) one of the values (when entry is multivaluated), identified by its index. Returns 0.0 if index is wrong FIXME : warn the user there was a problem !

Definition at line 158 of file gdcmDataEntry.cxx.

References BinArea, gdcmErrorMacro, gdcm::DocEntry::GetLength(), GetValueCount(), gdcm::Global::GetVR(), gdcm::DocEntry::GetVR(), and gdcm::VR::IsVROfStringRepresentable().

Referenced by gdcm::File::GetBitsAllocated(), gdcm::File::GetBitsStored(), gdcm::File::GetHighBitPosition(), gdcm::File::GetPlanarConfiguration(), gdcm::File::GetRescaleIntercept(), gdcm::File::GetRescaleSlope(), gdcm::File::GetSamplesPerPixel(), gdcm::File::GetXOrigin(), gdcm::File::GetXSize(), gdcm::File::GetXSpacing(), gdcm::File::GetYOrigin(), gdcm::File::GetYSize(), gdcm::File::GetYSpacing(), gdcm::File::GetZOrigin(), gdcm::File::GetZSize(), gdcm::File::GetZSpacing(), and gdcm::File::IsSignedPixelData().

00159 {
00160    if( !BinArea )
00161    {
00162       gdcmErrorMacro("BinArea not set. Can't get the value");
00163       return 0.0;
00164    }
00165 
00166    uint32_t count = GetValueCount();
00167    if( id > count )
00168    {
00169       gdcmErrorMacro("Index (" << id << ")is greater than the data size");
00170       return 0.0;
00171    }
00172 
00173    // FIX the API : user *knows* that entry contains a US
00174    //               and he receives a double ?!?
00175    
00176    const VRKey &vr = GetVR();
00177    if( vr == "US" || vr == "SS" )
00178       return ((uint16_t *)BinArea)[id];
00179    else if( vr == "UL" || vr == "SL" )
00180       return ((uint32_t *)BinArea)[id];
00181    else if( vr == "FL" )
00182       return ((float *)BinArea)[id];
00183    else if( vr == "FD" )
00184       return ((double *)BinArea)[id];
00185    else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
00186    {
00187       if( GetLength() )
00188       {
00189          // Don't use std::string to accelerate processing
00190          double val;
00191          char *tmp = new char[GetLength()+1];
00192          memcpy(tmp,BinArea,GetLength());
00193          tmp[GetLength()]=0;
00194 
00195          if( count == 0 )
00196          {
00197             val = atof(tmp);
00198          }
00199          else
00200          {
00201             count = id;
00202             char *beg = tmp;
00203             for(uint32_t i=0;i<GetLength();i++)
00204             {
00205                if( tmp[i] == '\\' )
00206                {
00207                   if( count == 0 )
00208                   {
00209                      tmp[i] = 0;
00210                      break;
00211                   }
00212                   else
00213                   {
00214                      count--;
00215                      beg = &(tmp[i+1]);
00216                   }
00217                }
00218             }
00219             val = atof(beg);
00220          }
00221 
00222          delete[] tmp;
00223          return val;
00224       }
00225       else 
00226          return 0.0;
00227    }
00228    else
00229       return BinArea[id];
00230 }

uint32_t gdcm::DataEntry::GetValueCount void   )  const
 

returns the number of elementary values

Definition at line 282 of file gdcmDataEntry.cxx.

References BinArea, gdcm::DocEntry::GetLength(), gdcm::Global::GetVR(), gdcm::DocEntry::GetVR(), and gdcm::VR::IsVROfStringRepresentable().

Referenced by GetString(), GetValue(), gdcm::File::GetXOrigin(), gdcm::File::GetXSpacing(), gdcm::File::GetYOrigin(), gdcm::File::GetZOrigin(), IsValueCountValid(), and SetValue().

00283 {
00284    const VRKey &vr = GetVR();
00285    if( vr == "US" || vr == "SS" )
00286       return GetLength()/sizeof(uint16_t);
00287    else if( vr == "UL" || vr == "SL" )
00288       return GetLength()/sizeof(uint32_t);
00289    else if( vr == "FL" )
00290       return GetLength()/sizeof(float);
00291    else if( vr == "FD" )
00292       return GetLength()/sizeof(double);
00293    else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
00294    {
00295       // Some element in DICOM are allowed to be empty
00296       if( !GetLength() ) return 0;
00297       // Don't use std::string to accelerate processing
00298       uint32_t count = 1;
00299       for(uint32_t i=0;i<GetLength();i++)
00300       {
00301          if( BinArea[i] == '\\')
00302             count++;
00303       }
00304       return count;
00305    }
00306 
00307    return GetLength();
00308 }

std::string const& gdcm::DocEntry::GetVM  )  const [inline, inherited]
 

Returns the 'Value Multiplicity' (e.g. "1", 6", "1-n", "3-n"), found in the Dicom entry or in the Dicom Dictionnary of the current Dicom entry.

Definition at line 71 of file gdcmDocEntry.h.

Referenced by gdcm::CheckVM(), and IsValueCountValid().

00071 { return DicomDict->GetVM(); }

VRKey const& gdcm::DocEntry::GetVR  )  const [inline, inherited]
 

Returns the 'Value Representation' (e.g. "PN" : Person Name, "SL" : Signed Long), found in the Dicom header or in the Dicom Dictionnary, of the current Dicom entry.

Definition at line 66 of file gdcmDocEntry.h.

Referenced by gdcm::CheckVM(), gdcm::Document::ComputeGroup0002Length(), gdcm::DicomDirMeta::ComputeGroup0002Length(), gdcm::FileHelper::CopyDataEntry(), gdcm::File::DoTheLoadingJob(), gdcm::Document::FixDocEntryFoundLength(), gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::DocEntry::GetFullLength(), GetString(), GetValue(), GetValueCount(), gdcm::DocEntrySet::InsertEntryBinArea(), gdcm::DocEntrySet::InsertEntryString(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), gdcm::Document::ParseDES(), gdcm::DocEntry::Print(), Print(), SetString(), SetValue(), and gdcm::DocEntry::WriteContent().

00066 { return DicomDict->GetVR(); }

bool gdcm::DataEntry::IsGoodValue  )  [inline]
 

true if Entry value properly loaded

Definition at line 104 of file gdcmDataEntry.h.

00104 { return State == STATE_LOADED; }

bool gdcm::DocEntry::IsImplicitVR  )  const [inline, inherited]
 

Tells us if the current Dicom entry was checked as ImplicitVr.

Returns:
true if the current Dicom entry was checked as ImplicitVr

Definition at line 112 of file gdcmDocEntry.h.

References gdcm::ImplicitVR.

Referenced by gdcm::DocEntry::GetFullLength(), and gdcm::SeqEntry::SeqEntry().

00112 { return ImplicitVR; }

bool gdcm::DocEntry::IsItemDelimitor  )  [inherited]
 

tells us if entry is the last one of a 'no length' SequenceItem (fffe,e00d)

Definition at line 198 of file gdcmDocEntry.cxx.

References gdcm::DocEntry::GetElement(), and gdcm::DocEntry::GetGroup().

Referenced by gdcm::Document::ParseDES().

00199 {
00200    return (GetGroup() == 0xfffe && GetElement() == 0xe00d);
00201 }

bool gdcm::DocEntry::IsItemStarter  )  [inherited]
 

tells us if entry is the first one of an Item (fffe,e000)

Definition at line 207 of file gdcmDocEntry.cxx.

References gdcm::DocEntry::GetElement(), and gdcm::DocEntry::GetGroup().

Referenced by gdcm::Document::ParseDES().

00208 {
00209    return (GetGroup() == 0xfffe && GetElement() == 0xe000);
00210 }

bool gdcm::DataEntry::IsNotLoaded  )  [inline]
 

true when value Entry not loaded

Definition at line 98 of file gdcmDataEntry.h.

Referenced by gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::DocEntrySet::GetEntryString(), and Print().

00098 { return State == STATE_NOTLOADED; }

bool gdcm::DataEntry::IsPixelData  )  [inline]
 

true id Entry is a Pixel Data entry

Definition at line 112 of file gdcmDataEntry.h.

Referenced by Print().

00112 { return (Flag &FLAG_PIXELDATA) != 0; }

bool gdcm::DataEntry::IsSelfArea  )  [inline]
 

True if Entry owns its BinArea.

Definition at line 76 of file gdcmDataEntry.h.

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

00076 { return SelfArea; }

bool gdcm::DocEntry::IsSequenceDelimitor  )  [inherited]
 

tells us if entry is the last one of a 'no length' Sequence (fffe,e0dd)

Definition at line 216 of file gdcmDocEntry.cxx.

References gdcm::DocEntry::GetElement(), and gdcm::DocEntry::GetGroup().

Referenced by gdcm::Document::ParseSQ().

00217 {
00218    return (GetGroup() == 0xfffe && GetElement() == 0xe0dd);
00219 }

bool gdcm::DataEntry::IsUnfound  )  [inline]
 

true if Entry not found

Definition at line 100 of file gdcmDataEntry.h.

Referenced by gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::DocEntrySet::GetEntryString(), gdcm::Document::ParseDES(), and Print().

00100 { return State == STATE_UNFOUND; }

bool gdcm::DataEntry::IsUnread  )  [inline]
 

true if Entry not read

Definition at line 102 of file gdcmDataEntry.h.

Referenced by gdcm::DocEntrySet::GetEntryForcedAsciiValue(), gdcm::DocEntrySet::GetEntryString(), and Print().

00102 { return State == STATE_UNREAD; }

bool gdcm::DataEntry::IsValueCountValid  )  const
 

Checks if the multiplicity of the value follows Dictionary VM.

Definition at line 235 of file gdcmDataEntry.cxx.

References GetValueCount(), and gdcm::DocEntry::GetVM().

Referenced by gdcm::File::GetXOrigin(), gdcm::File::GetYOrigin(), and gdcm::File::GetZOrigin().

00236 {
00237   uint32_t vm;
00238   const std::string &strVM = GetVM();
00239   uint32_t vc = GetValueCount();
00240   bool valid = vc == 0;
00241   if( valid )
00242     return true;
00243   
00244   // FIXME : what shall we do with VM = "2-n", "3-n", etc
00245   
00246   if( strVM == "1-n" )
00247   {
00248     // make sure there is at least one ??? FIXME
00249     valid = vc >= 1;
00250   }
00251   else
00252   {
00253     std::istringstream os;
00254     os.str( strVM );
00255     os >> vm;
00256     // Two cases:
00257     // vm respects the one from the dict
00258     // vm is 0 (we need to check if this element is allowed to be empty) FIXME
00259 
00260     // note  (JPR)
00261     // ----    
00262     // Entries whose type is 1 are mandatory, with a mandatory value.
00263     // Entries whose type is 1c are mandatory-inside-a-Sequence,
00264     //                          with a mandatory value.
00265     // Entries whose type is 2 are mandatory, with an optional value.
00266     // Entries whose type is 2c are mandatory-inside-a-Sequence,
00267     //                          with an optional value.
00268     // Entries whose type is 3 are optional.
00269 
00270     // case vc == 0 is only applicable for 'type 2' entries.
00271     // Problem : entry type may depend on the modality and/or the Sequence
00272     //           it's embedded in !
00273     //          (Get the information in the 'Conformance Statements' ...)  
00274     valid = vc == vm;
00275   }
00276   return valid;
00277 }

bool gdcm::DocEntry::IsVMUnknown  )  const [inline, inherited]
 

Tells us if the VM of the current Dicom entry is Unknown.

Returns:
true if the VM is unknown

Definition at line 120 of file gdcmDocEntry.h.

00120 { return DicomDict->IsVMUnknown(); }

bool gdcm::DocEntry::IsVRUnknown  )  const [inline, inherited]
 

Tells us if the VR of the current Dicom entry is Unknown.

Returns:
true if the VR is unknown

Definition at line 116 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::WriteContent().

00116 { return DicomDict->IsVRUnknown(); }

static DataEntry* gdcm::DataEntry::New DocEntry d  )  [inline, static]
 

Definition at line 42 of file gdcmDataEntry.h.

00042 {return new DataEntry(d);}

static DataEntry* gdcm::DataEntry::New DictEntry e  )  [inline, static]
 

Definition at line 41 of file gdcmDataEntry.h.

Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::FileHelper::CopyDataEntry(), gdcm::File::DoTheLoadingJob(), gdcm::DicomDirObject::FillObject(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DicomDir::SetElement(), gdcm::FileHelper::SetMandatoryEntry(), and gdcm::FileHelper::SetWriteToLibido().

00041 {return new DataEntry(e);}

void gdcm::DataEntry::NewBinArea void   )  [protected]
 

Definition at line 577 of file gdcmDataEntry.cxx.

References BinArea, DeleteBinArea(), gdcm::DocEntry::GetLength(), and SelfArea.

Referenced by CopyBinArea(), SetString(), and SetValue().

00578 {
00579    DeleteBinArea();
00580    if( GetLength() > 0 )
00581       BinArea = new uint8_t[GetLength()];
00582    SelfArea = true;
00583 }

void gdcm::DataEntry::Print std::ostream &  os = std::cout,
std::string const &  indent = ""
[virtual]
 

Prints a DataEntry (Dicom entry).

Parameters:
os ostream we want to print in
indent Indentation string to be prepended during printing

Reimplemented from gdcm::DocEntry.

Definition at line 604 of file gdcmDataEntry.cxx.

References BinArea, gdcm::Util::CreateCleanString(), gdcm::GDCM_BINLOADED, gdcm::GDCM_NOTLOADED, gdcm::GDCM_PIXELDATA, gdcm::GDCM_UNFOUND, gdcm::GDCM_UNREAD, GetBinArea(), gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), GetMaxSizePrintEntry(), GetString(), gdcm::Global::GetTS(), gdcm::Global::GetVR(), gdcm::DocEntry::GetVR(), gdcm::Util::IsCleanArea(), IsNotLoaded(), IsPixelData(), IsUnfound(), IsUnread(), gdcm::VR::IsVROfStringRepresentable(), gdcm::DocEntry::Print(), and gdcm::Base::PrintLevel.

00605 {
00606    os << "D ";
00607    DocEntry::Print(os);
00608 
00609    uint16_t g = GetGroup();
00610    if (g == 0xfffe) // delimiters have NO value
00611    {          
00612       return; // just to avoid identing all the remaining code 
00613    }
00614 
00615    std::ostringstream s;
00616    TSAtr v;
00617 
00618    if( BinArea )
00619    {
00620       v = GetString();
00621       const VRKey &vr = GetVR();
00622 
00623       if( vr == "US" || vr == "SS" )
00624          s << " [" << GetString() << "]";
00625       else if( vr == "UL" || vr == "SL" )
00626          s << " [" << GetString() << "]";
00627       else if ( vr == "FL" )
00628          s << " [" << GetString() << "]";
00629       else if ( vr == "FD" )
00630          s << " [" << GetString() << "]";
00631       else
00632       { 
00633          if(Global::GetVR()->IsVROfStringRepresentable(vr))
00634          {
00635             // replace non printable characters by '.'
00636             std::string cleanString = Util::CreateCleanString(v);
00637             if ( cleanString.length() <= GetMaxSizePrintEntry()
00638               || PrintLevel >= 3
00639               || IsNotLoaded() )
00640            // FIXME : when IsNotLoaded(), you create a Clean String ?!?
00641            // FIXME : PrintLevel<2 *does* print the values 
00642            //        (3 is only for extra offsets printing)
00643            // What do you wanted to do ? JPR
00644             {
00645                s << " [" << cleanString << "]";
00646             }
00647             else
00648             {
00649                s << " [gdcm::too long for print (" << cleanString.length() << ") ]";
00650             }
00651          }
00652          else
00653          {
00654             // A lot of Private elements (with no VR) contain actually 
00655             // only printable characters;
00656             // Let's deal with them as is they were VR std::string representable
00657     
00658             if ( Util::IsCleanArea( GetBinArea(), GetLength()  ) )
00659             {
00660                // FIXME : since the 'Area' *is* clean, just use
00661                //         a 'CreateString' method, to save CPU time.
00662                std::string cleanString = 
00663                      Util::CreateCleanString( BinArea,GetLength()  );
00664                s << " [" << cleanString << "]";
00665             }
00666             else
00667             {
00668                s << " [" << GDCM_BINLOADED << ";"
00669                << "length = " << GetLength() << "]";
00670             }
00671          }
00672       }
00673    }
00674    else
00675    {
00676       if( IsNotLoaded() )
00677          s << " [" << GDCM_NOTLOADED << "]";
00678       else if( IsUnfound() )
00679          s << " [" << GDCM_UNFOUND << "]";
00680       else if( IsUnread() )
00681          s << " [" << GDCM_UNREAD << "]";
00682       else if ( GetLength() == 0 )
00683          s << " []";
00684    }
00685 
00686    if( IsPixelData() )
00687       s << " (" << GDCM_PIXELDATA << ")";
00688 
00689    // Display the UID value (instead of displaying only the rough code)
00690    // First 'clean' trailing character (space or zero) 
00691    if(BinArea)
00692    {
00693       const uint16_t &gr = GetGroup();
00694       const uint16_t &elt = GetElement();
00695       TS *ts = Global::GetTS();
00696 
00697       if (gr == 0x0002)
00698       {
00699          // Any more to be displayed ?
00700          if ( elt == 0x0010 || elt == 0x0002 )
00701          {
00702             if ( v.length() != 0 )  // for brain damaged headers
00703             {
00704                if ( ! isdigit((unsigned char)v[v.length()-1]) )
00705                {
00706                   v.erase(v.length()-1, 1);
00707                }
00708             }
00709             s << "  ==>\t[" << ts->GetValue(v) << "]";
00710          }
00711       }
00712       else if (gr == 0x0008)
00713       {
00714          if ( elt == 0x0016 || elt == 0x1150 )
00715          {
00716             if ( v.length() != 0 )  // for brain damaged headers
00717             {
00718                if ( ! isdigit((unsigned char)v[v.length()-1]) )
00719                {
00720                   v.erase(v.length()-1, 1);
00721                }
00722             }
00723             s << "  ==>\t[" << ts->GetValue(v) << "]";
00724          }
00725       }
00726       else if (gr == 0x0004)
00727       {
00728          if ( elt == 0x1510 || elt == 0x1512  )
00729          {
00730             if ( v.length() != 0 )  // for brain damaged headers  
00731             {
00732                if ( ! isdigit((unsigned char)v[v.length()-1]) )
00733                {
00734                   v.erase(v.length()-1, 1);  
00735                }
00736             }
00737             s << "  ==>\t[" << ts->GetValue(v) << "]";
00738          }
00739       }
00740    }
00741 
00742    os << s.str();
00743 }

void gdcm::RefCounter::Register  )  [inline, inherited]
 

Register the object.

Remarks:
It increments the reference counting

Definition at line 45 of file gdcmRefCounter.h.

Referenced by gdcm::SQItem::AddEntry(), gdcm::ElementSet::AddEntry(), gdcm::Dict::AddEntry(), gdcm::SeqEntry::AddSQItem(), gdcm::DocEntry::DocEntry(), gdcm::FileHelper::FileHelper(), gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntryArchive::Push(), gdcm::Dict::ReplaceEntry(), and gdcm::SeqEntry::SetDelimitationItem().

00045 { RefCount++; }

void gdcm::DataEntry::SetBinArea uint8_t *  area,
bool  self = true
 

Sets the value (non string) of the current Dicom Header Entry.

Definition at line 80 of file gdcmDataEntry.cxx.

References BinArea, DeleteBinArea(), SelfArea, State, and STATE_LOADED.

Referenced by gdcm::FileHelper::CheckMandatoryElements(), gdcm::File::DoTheLoadingJob(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), gdcm::DocEntrySet::SetEntryBinArea(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().

00081 { 
00082    DeleteBinArea();
00083 
00084    BinArea = area;
00085    SelfArea = self;
00086 
00087    State = STATE_LOADED;
00088 }

void gdcm::DataEntry::SetFlag const TValueFlag flag  )  [inline]
 

sets the 'pixel data flag'

Definition at line 108 of file gdcmDataEntry.h.

Referenced by gdcm::ElementSet::Print(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().

00108 { Flag = flag; }

void gdcm::DocEntry::SetImplicitVR  )  [inline, inherited]
 

Sets to TRUE the ImplicitVr flag of the current Dicom entry.

Definition at line 108 of file gdcmDocEntry.h.

References gdcm::ImplicitVR.

Referenced by gdcm::Document::ReadNextDocEntry().

00108 { ImplicitVR = true; }

virtual void gdcm::DocEntry::SetLength uint32_t  l  )  [inline, virtual, inherited]
 

Sets both 'Read Length' and 'Usable Length' of the current Dicom entry.

Definition at line 92 of file gdcmDocEntry.h.

Referenced by gdcm::Document::Backtrack(), gdcm::FileHelper::CheckMandatoryElements(), CopyBinArea(), gdcm::Document::FixDocEntryFoundLength(), gdcm::DocEntrySet::SetEntryBinArea(), SetString(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().

00092 { Length = l; }

static void gdcm::DataEntry::SetMaxSizePrintEntry const uint32_t &  size  )  [inline, static]
 

Header Elements too long will not be printed.

Definition at line 120 of file gdcmDataEntry.h.

00121                                                  { MaxSizePrintEntry = size; }

void gdcm::DocEntry::SetOffset size_t  of  )  [inline, inherited]
 

Sets the offset of the Dicom entry.

Warning:
use with caution !
Parameters:
of offset to be set

Definition at line 105 of file gdcmDocEntry.h.

Referenced by gdcm::Document::Backtrack(), gdcm::DicomDirObject::FillObject(), gdcm::Document::ReadNextDocEntry(), and gdcm::DicomDir::SetElement().

00105 { Offset = of; }

void gdcm::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::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print().

00047 { PrintLevel = level; }

void gdcm::DocEntry::SetReadLength uint32_t  l  )  [inline, inherited]
 

Sets only 'Read Length' (*not* 'Usable Length') of the current Dicom entry.

Definition at line 83 of file gdcmDocEntry.h.

Referenced by gdcm::Document::FixDocEntryFoundLength().

00083 { ReadLength = l; }

void gdcm::DataEntry::SetSelfArea bool  area  )  [inline]
 

Sets SelfArea.

Definition at line 74 of file gdcmDataEntry.h.

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

00074 { SelfArea = area; }

void gdcm::DataEntry::SetState const TValueState state  )  [inline]
 

Definition at line 95 of file gdcmDataEntry.h.

Referenced by gdcm::Document::LoadDocEntry(), and gdcm::Document::LoadEntryBinArea().

00095 { State = state; }

void gdcm::DataEntry::SetString std::string const &  value  ) 
 

Sets the 'value' of an Entry, passed as a std::string.

Parameters:
value string representation of the value to be set

Definition at line 313 of file gdcmDataEntry.cxx.

References BinArea, DeleteBinArea(), gdcm::DocEntry::GetVR(), NewBinArea(), gdcm::DocEntry::SetLength(), State, STATE_LOADED, and gdcm::Util::Tokenize().

Referenced by gdcm::DicomDir::Anonymize(), gdcm::FileHelper::CheckMandatoryElements(), gdcm::FileHelper::CheckMandatoryEntry(), gdcm::FileHelper::CopyMandatoryEntry(), gdcm::DicomDirObject::FillObject(), gdcm::DicomDir::SetElement(), gdcm::DocEntrySet::SetEntryString(), gdcm::FileHelper::SetMandatoryEntry(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), gdcm::FileHelper::SetWriteFileTypeToJPEG(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), gdcm::FileHelper::SetWriteToRaw(), gdcm::FileHelper::SetWriteToRGB(), gdcm::File::Write(), and gdcm::DicomDirMeta::WriteContent().

00314 {
00315    DeleteBinArea();
00316 
00317    const VRKey &vr = GetVR();
00318    if ( vr == "US" || vr == "SS" )
00319    {
00320       std::vector<std::string> tokens;
00321       Util::Tokenize (value, tokens, "\\");
00322       SetLength(tokens.size()*sizeof(uint16_t));
00323       NewBinArea();
00324 
00325       uint16_t *data = (uint16_t *)BinArea;
00326       for (unsigned int i=0; i<tokens.size();i++)
00327          data[i] = atoi(tokens[i].c_str());
00328       tokens.clear();
00329    }
00330    else if ( vr == "UL" || vr == "SL" )
00331    {
00332       std::vector<std::string> tokens;
00333       Util::Tokenize (value, tokens, "\\");
00334       SetLength(tokens.size()*sizeof(uint32_t));
00335       NewBinArea();
00336 
00337       uint32_t *data = (uint32_t *)BinArea;
00338       for (unsigned int i=0; i<tokens.size();i++)
00339          data[i] = atoi(tokens[i].c_str());
00340       tokens.clear();
00341    }
00342    else if ( vr == "FL" )
00343    {
00344       std::vector<std::string> tokens;
00345       Util::Tokenize (value, tokens, "\\");
00346       SetLength(tokens.size()*sizeof(float));
00347       NewBinArea();
00348 
00349       float *data = (float *)BinArea;
00350       for (unsigned int i=0; i<tokens.size();i++)
00351          data[i] = (float)atof(tokens[i].c_str());
00352       tokens.clear();
00353    }
00354    else if ( vr == "FD" )
00355    {
00356       std::vector<std::string> tokens;
00357       Util::Tokenize (value, tokens, "\\");
00358       SetLength(tokens.size()*sizeof(double));
00359       NewBinArea();
00360 
00361       double *data = (double *)BinArea;
00362       for (unsigned int i=0; i<tokens.size();i++)
00363          data[i] = atof(tokens[i].c_str());
00364       tokens.clear();
00365    }
00366    else
00367    {
00368       if( value.size() > 0 )
00369       {
00370          size_t l =  value.size();    
00371          SetLength(l + l%2);
00372          NewBinArea();
00373          memcpy(BinArea, value.c_str(), l);
00374          if (l%2)
00375             BinArea[l] = '\0';
00376       }
00377    }
00378    State = STATE_LOADED;
00379 }

void gdcm::DataEntry::SetValue const uint32_t &  id,
const double &  val
 

Definition at line 110 of file gdcmDataEntry.cxx.

References BinArea, gdcmErrorMacro, GetValueCount(), gdcm::Global::GetVR(), gdcm::DocEntry::GetVR(), gdcm::VR::IsVROfStringRepresentable(), NewBinArea(), State, and STATE_LOADED.

00111 {
00112    if( !BinArea )
00113       NewBinArea();
00114    State = STATE_LOADED;
00115 
00116    if( id > GetValueCount() )
00117    {
00118       gdcmErrorMacro("Index (" << id << ")is greater than the data size");
00119       return;
00120    }
00121 
00122    const VRKey &vr = GetVR();
00123    if( vr == "US" || vr == "SS" )
00124    {
00125       uint16_t *data = (uint16_t *)BinArea;
00126       data[id] = (uint16_t)val;
00127    }
00128    else if( vr == "UL" || vr == "SL" )
00129    {
00130       uint32_t *data = (uint32_t *)BinArea;
00131       data[id] = (uint32_t)val;
00132    }
00133    else if( vr == "FL" )
00134    {
00135       float *data = (float *)BinArea;
00136       data[id] = (float)val;
00137    }
00138    else if( vr == "FD" )
00139    {
00140       double *data = (double *)BinArea;
00141       data[id] = (double)val;
00142    }
00143    else if( Global::GetVR()->IsVROfStringRepresentable(vr) )
00144    {
00145       gdcmErrorMacro("SetValue on String representable not implemented yet");
00146    }
00147    else
00148    {
00149       BinArea[id] = (uint8_t)val;
00150    }
00151 }

void gdcm::DocEntry::SetVM TagName const &  v  )  [inline, inherited]
 

Sets the 'Value Multiplicity' of the current Dicom entry.

Definition at line 74 of file gdcmDocEntry.h.

00074 { DicomDict->SetVM(v); } 

void gdcm::RefCounter::Unregister  )  [inline, inherited]
 

Unregister the object.

Remarks:
It decrements the reference counting

Definition at line 49 of file gdcmRefCounter.h.

Referenced by gdcm::SeqEntry::ClearSQItem(), gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewDataEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::Document::ReadNextDocEntry(), gdcm::SQItem::RemoveEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::SeqEntry::SetDelimitationItem(), gdcm::DocEntry::~DocEntry(), and gdcm::FileHelper::~FileHelper().

00050    {
00051       RefCount--;
00052       if(RefCount<=0)
00053          delete this;
00054    }

void gdcm::DataEntry::WriteContent std::ofstream *  fp,
FileType  filetype
[virtual]
 

Writes the 'value' area of a DataEntry.

Parameters:
fp already open ofstream pointer
filetype type of the file (ACR, ImplicitVR, ExplicitVR, ...)

Reimplemented from gdcm::DocEntry.

Definition at line 476 of file gdcmDataEntry.cxx.

References BinArea, gdcm::binary_write(), gdcmDebugMacro, gdcm::VR::GetAtomicElementLength(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetKey(), gdcm::DocEntry::GetLength(), gdcm::Global::GetVR(), and gdcm::DocEntry::WriteContent().

00477 { 
00478    DocEntry::WriteContent(fp, filetype);
00479 
00480    if ( GetGroup() == 0xfffe )
00481    {
00482       return; //delimitors have NO value
00483    }
00484    
00485    // --> We only deal with Little Endian writting
00486    // --> forget Big Endian Transfer Syntax writting!
00487    //     Next DICOM version will give it up ...
00488  
00489    // WARNING - For Implicit VR private element,
00490    //           we have *no choice* but considering them as
00491    //           something like 'OB' values.
00492    //           we rewrite them as we found them on disc.
00493    //           Some trouble will occur if element was 
00494    //           *actually* OW, if image was produced 
00495    //           on Big endian based processor, read and writen 
00496    //           on Little endian based processor
00497    //           and, later on, somebody needs
00498    //           this 'OW' Implicit VR private element (?!?)
00499    //           (Same stuff, mutatis mutandis, for Little/Big)
00500  
00501    // 8/16 bits Pixels problem should be solved automatiquely,
00502    // since we ensure the VR (OB vs OW) is conform to Pixel size.
00503         
00504    uint8_t *data = BinArea; //safe notation
00505    size_t l = GetLength(); 
00506    gdcmDebugMacro ("in DataEntry::WriteContent " << GetKey() 
00507              << " : " << Global::GetVR()->GetAtomicElementLength(this->GetVR())
00508              );
00509    if (BinArea) // the binArea was *actually* loaded
00510    {
00511 #if defined(GDCM_WORDS_BIGENDIAN) || defined(GDCM_FORCE_BIGENDIAN_EMULATION)
00512       unsigned short vrLgth = 
00513                         Global::GetVR()->GetAtomicElementLength(this->GetVR());
00514       unsigned int i;
00515       switch(vrLgth)
00516       {
00517          case 1:
00518          {
00519             binary_write (*fp, data, l );           
00520             break;
00521          }     
00522          case 2:
00523          {
00524 gdcmDebugMacro ("AtomicLength = 2 found; lgt =" << l); 
00525             uint16_t *data16 = (uint16_t *)data;
00526             for(i=0;i<l/vrLgth;i++)
00527                binary_write( *fp, data16[i]);
00528             break;
00529          }
00530          case 4:
00531          {
00532             uint32_t *data32 = (uint32_t *)data;
00533             for(i=0;i<l/vrLgth;i++)
00534                binary_write( *fp, data32[i]);
00535             break;
00536          }
00537          case 8:
00538          {
00539             double *data64 = (double *)data;
00540             for(i=0;i<l/vrLgth;i++)
00541                binary_write( *fp, data64[i]);
00542             break;
00543          }
00544       }
00545 #else
00546    binary_write (*fp, data, l );
00547 #endif //GDCM_WORDS_BIGENDIAN
00548 
00549    }
00550    else
00551    {
00552       // nothing was loaded, but we need to skip space on disc
00553       
00554       //  --> WARNING : nothing is written; 
00555       //  --> the initial data (on the the source image) is lost
00556       //  --> user is *not* informed !
00557       
00558       fp->seekp(l, std::ios::cur);
00559    }
00560    // to avoid gdcm to propagate oddities
00561    // (length was already modified)  
00562    if (l%2)
00563       fp->seekp(1, std::ios::cur);  
00564 }


Member Data Documentation

uint8_t* gdcm::DataEntry::BinArea [protected]
 

memory area to hold 'non std::string' representable values (ie : Lookup Tables, overlays, icons)

Definition at line 135 of file gdcmDataEntry.h.

Referenced by Copy(), CopyBinArea(), DataEntry(), DeleteBinArea(), GetString(), GetValue(), GetValueCount(), NewBinArea(), Print(), SetBinArea(), SetString(), SetValue(), and WriteContent().

DictEntry* gdcm::DocEntry::DicomDict [protected, inherited]
 

pointer to the underlying Dicom dictionary element

Definition at line 133 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::DocEntry(), and gdcm::DocEntry::~DocEntry().

TValueFlag gdcm::DataEntry::Flag [private]
 

0 for straight entries, FLAG_PIXELDATA for Pixel Data entries

Definition at line 144 of file gdcmDataEntry.h.

Referenced by Copy(), and DataEntry().

bool gdcm::DocEntry::ImplicitVR [protected, inherited]
 

Even when reading explicit vr files, some elements happen to be implicit. Flag them here since we can't use the entry->vr without breaking the underlying dictionary.

Definition at line 145 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::Copy(), gdcm::DocEntry::DocEntry(), and gdcm::SeqEntry::SeqEntry().

uint32_t gdcm::DocEntry::Length [protected, inherited]
 

Correspond to the real length of the data This length might always be even.

Definition at line 137 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::Copy(), gdcm::DocEntry::DocEntry(), and gdcm::SeqEntry::SeqEntry().

uint32_t gdcm::DataEntry::MaxSizePrintEntry = MAX_SIZE_PRINT_ELEMENT_VALUE [static, private]
 

Size threshold above which an element val By default, this upper bound is fixed to 64 bytes.

Definition at line 150 of file gdcmDataEntry.h.

size_t gdcm::DocEntry::Offset [protected, inherited]
 

Offset from the beginning of file for direct user access.

Definition at line 148 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::Copy(), gdcm::DocEntry::DocEntry(), and gdcm::SeqEntry::SeqEntry().

int gdcm::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::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), gdcm::DocEntry::Print(), gdcm::DictEntry::Print(), gdcm::DicomDirStudy::Print(), gdcm::DicomDirSerie::Print(), gdcm::DicomDirPatient::Print(), gdcm::DicomDirMeta::Print(), gdcm::DicomDir::Print(), and Print().

uint32_t gdcm::DocEntry::ReadLength [protected, inherited]
 

Length to read in the file to obtain data.

Definition at line 140 of file gdcmDocEntry.h.

Referenced by gdcm::DocEntry::Copy(), gdcm::DocEntry::DocEntry(), and gdcm::SeqEntry::SeqEntry().

bool gdcm::DataEntry::SelfArea [protected]
 

Whether DataEntry has its own BinArea or not.

Definition at line 137 of file gdcmDataEntry.h.

Referenced by DataEntry(), DeleteBinArea(), NewBinArea(), and SetBinArea().

TValueState gdcm::DataEntry::State [private]
 

Entry status:STATE_NOTLOADED,STATE_UNFOUND,STATE_UNREAD,STATE_LOADED.

Definition at line 146 of file gdcmDataEntry.h.

Referenced by Copy(), CopyBinArea(), DataEntry(), SetBinArea(), SetString(), and SetValue().

std::string gdcm::DataEntry::StrArea [mutable, protected]
 

std::string representable value of the Entry. Parts of a multivaluated data are separated by back-slash

Definition at line 140 of file gdcmDataEntry.h.

Referenced by GetString().


The documentation for this class was generated from the following files:
Generated on Fri Nov 18 15:58:05 2005 for gdcm by  doxygen 1.4.4