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

gdcm::ValEntry Class Reference

Any Dicom Document (File or DicomDir) contains a set of DocEntry - Dicom entries - ValEntry is an elementary DocEntry (i.e. a ContentEntry, as opposed to SeqEntry) whose content is 'std::string representable' : characters, or integers (loaded in memory as a std::string) ValEntry is a specialisation of ContentEntry. More...

#include <gdcmValEntry.h>

Inheritance diagram for gdcm::ValEntry:

gdcm::ContentEntry gdcm::DocEntry gdcm::Base List of all members.

Public Member Functions

 ValEntry (DictEntry *e)
 Constructor from a given DictEntry.

 ValEntry (DocEntry *d)
 Constructor from a given DocEntry.

 ~ValEntry ()
 Canonical destructor.

void Print (std::ostream &os=std::cout, std::string const &indent="")
 Prints the 'std::string representable' value of ValEntry.

void WriteContent (std::ofstream *fp, FileType filetype)
 Writes the std::string representable' value of a ValEntry.

void SetValue (std::string const &val)
 Sets the std::string representable' value of a ValEntry.

std::string const & GetValue () const
 Returns the 'Value' (e.g. "Dupond Marcel") converted into a 'string', event if it's physically stored on disk as an integer.

void Copy (DocEntry *doc)
 Copies all the attributes from an other DocEntry.

DictEntryGetDictEntry ()
 Gets the DicEntry of the current Dicom entry.

uint16_t GetGroup ()
 Returns the Dicom Group number of the current Dicom entry.

uint16_t GetElement ()
 Returns the Dicom Element number of the current Dicom entry.

void SetKey (TagKey const &key)
 Set the 'key' of the current Dicom entry.

std::string const & 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.

std::string 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", "1-n", "6"), 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.

size_t GetOffset ()
 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.

uint32_t GetReadLength ()
 Returns the 'read length' of the current Dicom entry.

void SetLength (uint32_t l)
 Sets both 'Read Length' and 'Usable Length' of the current Dicom entry.

uint32_t GetLength ()
 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 ()
 Tells us if the current Dicom entry was checked as ImplicitVr.

bool IsVRUnknown ()
 Tells us if the VR of the current Dicom entry is Unknown.

bool IsVMUnknown ()
 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 IsSequenceDelimitor ()
 tells us if entry is the last one of a 'no length' Sequence (fffe,e0dd)

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

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.

TagKey Key
 Generalized key of this DocEntry (for details on the generalized key refer to TagKey documentation).

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


Detailed Description

Any Dicom Document (File or DicomDir) contains a set of DocEntry - Dicom entries - ValEntry is an elementary DocEntry (i.e. a ContentEntry, as opposed to SeqEntry) whose content is 'std::string representable' : characters, or integers (loaded in memory as a std::string) ValEntry is a specialisation of ContentEntry.

Definition at line 39 of file gdcmValEntry.h.


Constructor & Destructor Documentation

gdcm::ValEntry::ValEntry DictEntry e  ) 
 

Constructor from a given DictEntry.

Parameters:
e Pointer to existing dictionary entry

Definition at line 39 of file gdcmValEntry.cxx.

00040         : ContentEntry(e)
00041 {
00042 }

gdcm::ValEntry::ValEntry DocEntry e  ) 
 

Constructor from a given DocEntry.

Parameters:
e Pointer to existing Doc entry

Definition at line 48 of file gdcmValEntry.cxx.

References gdcm::ContentEntry::Copy().

00049         : ContentEntry(e->GetDictEntry())
00050 {
00051    Copy(e);
00052 }

gdcm::ValEntry::~ValEntry  ) 
 

Canonical destructor.

Definition at line 57 of file gdcmValEntry.cxx.

00058 {
00059 }


Member Function Documentation

void gdcm::ContentEntry::Copy DocEntry doc  )  [virtual, inherited]
 

Copies all the attributes from an other DocEntry.

Parameters:
doc entry to copy from

Reimplemented from gdcm::DocEntry.

Definition at line 65 of file gdcmContentEntry.cxx.

References gdcm::ContentEntry::Value.

Referenced by gdcm::BinEntry::BinEntry(), gdcm::ContentEntry::ContentEntry(), gdcm::FileHelper::CopyBinEntry(), gdcm::FileHelper::CopyValEntry(), gdcm::File::File(), gdcm::FileHelper::SetWriteToLibido(), and ValEntry().

00066 {
00067    DocEntry::Copy(doc);
00068 
00069    ContentEntry *entry = dynamic_cast<ContentEntry *>(doc);
00070    if(entry)
00071       Value = entry->Value;
00072 }

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 52 of file gdcmDocEntry.h.

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

00052 { return DicomDict; }; 

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

Returns the Dicom Element number of the current Dicom entry.

Definition at line 58 of file gdcmDocEntry.h.

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

00058 { return DicomDict->GetElement();};

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 150 of file gdcmDocEntry.cxx.

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

00151 {
00152    uint32_t l = GetReadLength();
00153    if ( IsImplicitVR() )
00154    {
00155       l = l + 8;  // 2 (gr) + 2 (el) + 4 (lgth) 
00156    }
00157    else
00158    {
00159       if ( GetVR()=="OB" || GetVR()=="OW" || GetVR()=="SQ" )
00160       {
00161          l = l + 12; // 2 (gr) + 2 (el) + 2 (vr) + 2 (unused) + 4 (lgth)
00162       }
00163       else
00164       {
00165          l = l + 8;  // 2 (gr) + 2 (el) + 2 (vr) + 2 (lgth)
00166       }
00167    }
00168    return l;
00169 }

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

Returns the Dicom Group number of the current Dicom entry.

Definition at line 55 of file gdcmDocEntry.h.

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

00055 { return DicomDict->GetGroup();  };

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

Returns the 'key' of the current Dicom entry.

Definition at line 63 of file gdcmDocEntry.h.

Referenced by gdcm::ElementSet::AddEntry(), gdcm::Document::ParseDES(), gdcm::Document::ParseSQ(), gdcm::SQItem::RemoveEntry(), gdcm::ElementSet::RemoveEntry(), gdcm::SQItem::RemoveEntryNoDestroy(), and gdcm::ElementSet::RemoveEntryNoDestroy().

00063 { return Key; }

uint32_t gdcm::DocEntry::GetLength  )  [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 knowned bugs

Definition at line 102 of file gdcmDocEntry.h.

Referenced by gdcm::File::AnonymizeNoLoad(), gdcm::Document::ComputeGroup0002Length(), gdcm::Document::GetDocEntryValue(), gdcm::DocEntrySet::GetEntryLength(), gdcm::File::GetPixelAreaLength(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::LoadEntryBinArea(), Print(), gdcm::BinEntry::Print(), gdcm::Document::SkipDocEntry(), WriteContent(), gdcm::DocEntry::WriteContent(), and gdcm::BinEntry::WriteContent().

00102 { return Length; };

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 67 of file gdcmDocEntry.h.

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

00067 { return DicomDict->GetName(); };

size_t gdcm::DocEntry::GetOffset  )  [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 85 of file gdcmDocEntry.h.

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

00085 { return Offset; };

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

Gets the print level for the Dicom Entries.

Definition at line 48 of file gdcmBase.h.

00048 { return PrintLevel; };

uint32_t gdcm::DocEntry::GetReadLength  )  [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 94 of file gdcmDocEntry.h.

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

00094 { return ReadLength; };

std::string const& gdcm::ContentEntry::GetValue  )  const [inline, inherited]
 

Returns the 'Value' (e.g. "Dupond Marcel") converted into a 'string', event if it's physically stored on disk as an integer.

Definition at line 46 of file gdcmContentEntry.h.

Referenced by gdcm::DicomDir::CreateDicomDir(), gdcm::DocEntrySet::GetEntryValue(), gdcm::Document::GetTransferSyntax(), Print(), gdcm::BinEntry::Print(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), and WriteContent().

00046 { return Value; };

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

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

Definition at line 77 of file gdcmDocEntry.h.

00077 { return DicomDict->GetVM(); };

std::string 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 72 of file gdcmDocEntry.h.

Referenced by gdcm::Document::ComputeGroup0002Length(), gdcm::FileHelper::CopyBinEntry(), gdcm::File::File(), gdcm::Document::FixDocEntryFoundLength(), gdcm::Document::GetDocEntryUnvalue(), gdcm::Document::GetDocEntryValue(), gdcm::DocEntrySet::GetEntryVR(), gdcm::DocEntry::GetFullLength(), gdcm::DocEntrySet::InsertBinEntry(), gdcm::DocEntrySet::InsertValEntry(), gdcm::Document::IsDocEntryAnInteger(), gdcm::Document::LoadDocEntry(), gdcm::Document::ParseDES(), Print(), gdcm::DocEntry::Print(), SetValue(), WriteContent(), gdcm::DocEntry::WriteContent(), and gdcm::BinEntry::WriteContent().

00072 { return DicomDict->GetVR(); };

bool gdcm::DocEntry::IsImplicitVR  )  [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 117 of file gdcmDocEntry.h.

References gdcm::ImplicitVR.

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

00117 { 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 175 of file gdcmDocEntry.cxx.

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

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

00176 {
00177    return (GetGroup() == 0xfffe && GetElement() == 0xe00d);
00178 }

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

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

Definition at line 184 of file gdcmDocEntry.cxx.

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

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

00185 {
00186    return (GetGroup() == 0xfffe && GetElement() == 0xe0dd);
00187 }

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

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

Returns:
true if the VM is unknown

Definition at line 125 of file gdcmDocEntry.h.

00125 { return DicomDict->IsVMUnknown(); };

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

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

Returns:
true if the VR is unknown

Definition at line 121 of file gdcmDocEntry.h.

00121 { return DicomDict->IsVRUnknown(); };

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

Prints the 'std::string representable' value of ValEntry.

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

Reimplemented from gdcm::DocEntry.

Definition at line 174 of file gdcmValEntry.cxx.

References gdcm::GDCM_NOTLOADED, gdcm::DocEntry::GetElement(), gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ContentEntry::GetValue(), gdcm::DocEntry::GetVR(), MAX_SIZE_PRINT_ELEMENT_VALUE, and gdcm::VRKey.

00175 {
00176    uint16_t g = GetGroup();
00177    uint16_t e = GetElement();
00178    VRKey vr   = GetVR();
00179    std::ostringstream s; 
00180    std::string st;
00181    std::string d2;
00182      
00183    os << "V ";
00184    DocEntry::Print(os); 
00185 
00186    if (g == 0xfffe) // delimiters have NO value
00187    {
00188       // just to avoid identing all the remaining code     
00189       return;
00190    }
00191    
00192    TS *ts = Global::GetTS();
00193     
00194    TSAtr v  = GetValue();  // not applicable for SQ ...     
00195    d2 = Util::CreateCleanString(v);  // replace non printable characters by '.'            
00196    if( GetLength() <= MAX_SIZE_PRINT_ELEMENT_VALUE
00197     || PrintLevel >= 3
00198     || d2.find(GDCM_NOTLOADED) < d2.length() )
00199    {
00200       s << " [" << d2 << "]";
00201    }
00202    else
00203    {
00204       s << " [gdcm::too long for print (" << GetLength() << ") ]";
00205    }
00206    
00207    // Display the UID value (instead of displaying only the rough code)
00208    // First 'clean' trailing character (space or zero) 
00209    if (g == 0x0002)
00210    {
00211       // Any more to be displayed ?
00212       if ( e == 0x0010 || e == 0x0002 )
00213       {
00214          if ( v.length() != 0 )  // for brain damaged headers
00215          {
00216             if ( ! isdigit((unsigned char)v[v.length()-1]) )
00217             {
00218                v.erase(v.length()-1, 1);
00219             }
00220          }
00221          s << "  ==>\t[" << ts->GetValue(v) << "]";
00222       }
00223    }
00224    else
00225    {
00226       if (g == 0x0008)
00227       {
00228          if ( e == 0x0016 || e == 0x1150 )
00229          {
00230             if ( v.length() != 0 )  // for brain damaged headers
00231             {
00232                if ( ! isdigit((unsigned char)v[v.length()-1]) )
00233                {
00234                   v.erase(v.length()-1, 1);
00235                }
00236             }
00237             s << "  ==>\t[" << ts->GetValue(v) << "]";
00238          }
00239       }
00240       else
00241       {
00242          if (g == 0x0004)
00243          {
00244             if ( e == 0x1510 || e == 0x1512  )
00245             {
00246                if ( v.length() != 0 )  // for brain damaged headers  
00247                {
00248                   if ( ! isdigit((unsigned char)v[v.length()-1]) )
00249                   {
00250                      v.erase(v.length()-1, 1);  
00251                   }
00252                }
00253               s << "  ==>\t[" << ts->GetValue(v) << "]";
00254             }
00255          }     
00256       }
00257    }
00258    //if (e == 0x0000) {        // elem 0x0000 --> group length 
00259    if ( vr == "UL" || vr == "US" || vr == "SL" || vr == "SS" )
00260    {
00261       if (v == "4294967295") // to avoid troubles in convertion 
00262       {
00263          st = Util::Format(" x(ffffffff)");
00264       }
00265       else
00266       {
00267          if ( GetLength() != 0 )
00268          {
00269             st = Util::Format(" x(%x)", atoi(v.c_str()));//FIXME
00270          }
00271          else
00272          {
00273             st = Util::Format(" ");
00274          }
00275       }
00276       s << st;
00277    }
00278    os << s.str();
00279 }

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

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

Definition at line 113 of file gdcmDocEntry.h.

References gdcm::ImplicitVR.

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

00113 { ImplicitVR = true; };

void gdcm::DocEntry::SetKey TagKey const &  key  )  [inline, inherited]
 

Set the 'key' of the current Dicom entry.

Definition at line 61 of file gdcmDocEntry.h.

References gdcm::TagKey.

Referenced by gdcm::DocEntry::DocEntry(), and gdcm::Document::ParseDES().

00061 { Key = key; }

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

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

Definition at line 98 of file gdcmDocEntry.h.

Referenced by gdcm::Document::FixDocEntryFoundLength(), gdcm::DocEntrySet::SetBinEntry(), SetValue(), gdcm::FileHelper::SetWriteToRaw(), and gdcm::FileHelper::SetWriteToRGB().

00098 { Length = l; };

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 110 of file gdcmDocEntry.h.

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

00110 { 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

Definition at line 45 of file gdcmBase.h.

Referenced by gdcm::SQItem::Print(), gdcm::SeqEntry::Print(), gdcm::FileHelper::Print(), gdcm::ElementSet::Print(), and gdcm::DicomDir::Print().

00045 { 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 89 of file gdcmDocEntry.h.

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

00089 { ReadLength = l; };

void gdcm::ValEntry::SetValue std::string const &  val  )  [virtual]
 

Sets the std::string representable' value of a ValEntry.

Sets the value (string) of the current Dicom entry. The size is updated

Reimplemented from gdcm::ContentEntry.

Definition at line 121 of file gdcmValEntry.cxx.

References gdcmAssertMacro, gdcm::DocEntry::GetVR(), gdcm::DocEntry::SetLength(), and gdcm::VRKey.

Referenced by gdcm::DicomDirObject::FillObject(), gdcm::Document::LoadDocEntry(), gdcm::DicomDir::SetElement(), gdcm::DocEntrySet::SetValEntry(), gdcm::FileHelper::SetWriteFileTypeToExplicitVR(), gdcm::FileHelper::SetWriteFileTypeToImplicitVR(), gdcm::FileHelper::SetWriteToLibido(), gdcm::FileHelper::SetWriteToNoLibido(), gdcm::FileHelper::SetWriteToRaw(), gdcm::FileHelper::SetWriteToRGB(), and gdcm::File::Write().

00122 {
00123    // Integers have a special treatement for their length:
00124    int l = val.length();
00125    if ( l != 0) // To avoid to be cheated by 'zero length' integers
00126    {   
00127       const VRKey &vr = GetVR();
00128       if( vr == "US" || vr == "SS" )
00129       {
00130          // for multivaluated items
00131          l = (Util::CountSubstring(val, "\\") + 1) * 2;
00132          ContentEntry::SetValue(val);
00133       }
00134       else if( vr == "UL" || vr == "SL" )
00135       {
00136          // for multivaluated items
00137          l = (Util::CountSubstring(val, "\\") + 1) * 4;;
00138          ContentEntry::SetValue(val);
00139       }
00140       else
00141       {
00142          std::string finalVal = Util::DicomString( val.c_str() );
00143          gdcmAssertMacro( !(finalVal.size() % 2) );
00144 
00145          l = finalVal.length();
00146          ContentEntry::SetValue(finalVal);
00147       }
00148    }
00149    else
00150    {
00151       std::string finalVal = Util::DicomString( val.c_str() );
00152       gdcmAssertMacro( !(finalVal.size() % 2) );
00153 
00154       l = finalVal.length();
00155       ContentEntry::SetValue(finalVal);
00156    }
00157 
00158    SetLength(l);
00159 }

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

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

Definition at line 80 of file gdcmDocEntry.h.

References gdcm::TagName.

00080 { DicomDict->SetVM(v); }; 

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

Writes the std::string representable' value of a ValEntry.

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

Implements gdcm::ContentEntry.

Definition at line 68 of file gdcmValEntry.cxx.

References gdcm::binary_write(), gdcmAssertMacro, gdcm::DocEntry::GetGroup(), gdcm::DocEntry::GetLength(), gdcm::ContentEntry::GetValue(), gdcm::DocEntry::GetVR(), and gdcm::VRKey.

00069 {
00070    DocEntry::WriteContent(fp, filetype);
00071 
00072    if ( GetGroup() == 0xfffe )
00073    {
00074       return; //delimitors have NO value
00075    }
00076 
00077    const VRKey &vr = GetVR();
00078    unsigned int lgth = GetLength();
00079    if (vr == "US" || vr == "SS")
00080    {
00081       // some 'Short integer' fields may be multivaluated
00082       // each single value is separated from the next one by '\'
00083       // we split the string and write each value as a short int
00084       std::vector<std::string> tokens;
00085       tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
00086       Util::Tokenize (GetValue(), tokens, "\\");
00087       for (unsigned int i=0; i<tokens.size();i++)
00088       {
00089          uint16_t val_uint16 = atoi(tokens[i].c_str());
00090          binary_write( *fp, val_uint16);
00091       }
00092       tokens.clear();
00093       return;
00094    }
00095    if (vr == "UL" || vr == "SL")
00096    {
00097       // Some 'Integer' fields may be multivaluated (multiple instances 
00098       // of integer). But each single integer value is separated from the
00099       // next one by '\' (backslash character). Hence we split the string
00100       // along the '\' and write each value as an int:
00101       std::vector<std::string> tokens;
00102       tokens.erase(tokens.begin(),tokens.end()); // clean any previous value
00103       Util::Tokenize (GetValue(), tokens, "\\");
00104       for (unsigned int i=0; i<tokens.size();i++)
00105       {
00106          uint32_t val_uint32 = atoi(tokens[i].c_str());
00107          binary_write( *fp, val_uint32);
00108       }
00109       tokens.clear();
00110       return;
00111    } 
00112 
00113    gdcmAssertMacro( lgth == GetValue().length() );
00114    binary_write(*fp, GetValue());
00115 } 


Member Data Documentation

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

pointer to the underlying Dicom dictionary element

Definition at line 134 of file gdcmDocEntry.h.

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

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 146 of file gdcmDocEntry.h.

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

TagKey gdcm::DocEntry::Key [protected, inherited]
 

Generalized key of this DocEntry (for details on the generalized key refer to TagKey documentation).

Definition at line 153 of file gdcmDocEntry.h.

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

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

Definition at line 138 of file gdcmDocEntry.h.

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

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

Offset from the beginning of file for direct user access.

Definition at line 149 of file gdcmDocEntry.h.

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

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

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

Definition at line 53 of file gdcmBase.h.

Referenced by gdcm::Base::Base().

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

Length to read in the file to obtain data.

Definition at line 141 of file gdcmDocEntry.h.

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


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