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

gdcm::DicomDirImage Class Reference

describes an IMAGE within a SERIE (DicomDirSerie) of a given DICOMDIR (DicomDir) More...

#include <gdcmDicomDirImage.h>

Inheritance diagram for gdcm::DicomDirImage:

gdcm::DicomDirObject gdcm::SQItem gdcm::DocEntrySet gdcm::Base List of all members.

Public Member Functions

 DicomDirImage (bool empty=false)
 Constructor.

 ~DicomDirImage ()
 Canonical destructor.

void Print (std::ostream &os=std::cout, std::string const &indent="")
 Prints the Object.

void WriteContent (std::ofstream *fp, FileType filetype)
 write any type of entry to the entry set

bool AddEntry (DocEntry *Entry)
 Inserts *in the right place* any Entry (Dicom Element) into the Sequence Item.

bool RemoveEntry (DocEntry *EntryToRemove)
 Clear the std::list from given entry AND delete the entry.

bool RemoveEntryNoDestroy (DocEntry *EntryToRemove)
 Clear the std::list from given entry BUT keep the entry.

void ClearEntry ()
 Remove all entry in the Sequence Item.

DocEntryGetFirstEntry ()
 Get the first Dicom entry while visiting the SQItem.

DocEntryGetNextEntry ()
 Get the next Dicom entry while visiting the SQItem.

DocEntryGetDocEntry (uint16_t group, uint16_t elem)
 Gets a Dicom Element inside a SQ Item Entry.

bool IsEmpty ()
 tells us if the set contains no entry

int GetSQItemNumber ()
 returns the ordinal position of a given SQItem

void SetSQItemNumber (int itemNumber)
 Sets the ordinal position of a given SQItem.

int GetDepthLevel ()
 Accessor on SQDepthLevel.

void SetDepthLevel (int depth)
 Accessor on SQDepthLevel.

void SetBaseTagKey (BaseTagKey const &key)
 Accessor on BaseTagKey.

BaseTagKey const & GetBaseTagKey () const
 Accessor on BaseTagKey.

virtual std::string GetEntryValue (uint16_t group, uint16_t elem)
 Get the "std::string representable" value of the Dicom entry.

virtual void * GetEntryBinArea (uint16_t group, uint16_t elem)
 Gets (from Header) a 'non string' element value.

virtual int GetEntryLength (uint16_t group, uint16_t elem)
 Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..

virtual std::string GetEntryVR (uint16_t group, uint16_t elem)
 Searches within Header Entries (Dicom Elements) parsed with the public [and private dictionaries] for the element value representation of a given tag.. Obtaining the VR (Value Representation) might be needed by caller to convert the string typed content to caller's native type (think of C++ vs Python). The VR is actually of a higher level of semantics than just the native C++ type.

ValEntryGetValEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type ValEntry.

BinEntryGetBinEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type BinEntry.

SeqEntryGetSeqEntry (uint16_t group, uint16_t elem)
 Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry.

bool SetValEntry (std::string const &content, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

bool SetValEntry (std::string const &content, ValEntry *entry)
 Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.

bool SetBinEntry (uint8_t *content, int lgth, uint16_t group, uint16_t elem)
 Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

bool SetBinEntry (uint8_t *content, int lgth, BinEntry *entry)
 Accesses an existing BinEntry (i.e. a Dicom Element) and modifies it's content with the given value.

ValEntryInsertValEntry (std::string const &value, uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN)
 Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.

BinEntryInsertBinEntry (uint8_t *binArea, int lgth, uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN)
 Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

SeqEntryInsertSeqEntry (uint16_t group, uint16_t elem)
 Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.

virtual bool CheckIfEntryExist (uint16_t group, uint16_t elem)
 Checks if a given Dicom Element exists within the H table.

ValEntryNewValEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN)
 Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

BinEntryNewBinEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN)
 Build a new Bin Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

SeqEntryNewSeqEntry (uint16_t group, uint16_t elem)
 Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

DictEntryNewVirtualDictEntry (uint16_t group, uint16_t elem, TagName const &vr=GDCM_UNKNOWN, TagName const &vm=GDCM_UNKNOWN, TagName const &name=GDCM_UNKNOWN)
 Request a new virtual dict entry to the dict set.

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

int GetPrintLevel ()
 Gets the print level for the Dicom Entries.


Protected Member Functions

void FillObject (ListDicomDirMetaElem const &elemList)
 add the 'Object' related Dicom Elements to the listEntries of a partially created DICOMDIR

DictEntryGetDictEntry (uint16_t group, uint16_t elem)
 Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one.

DictEntryGetDictEntry (uint16_t group, uint16_t elem, TagName const &vr)
 Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.


Protected Attributes

ListDocEntry DocEntries
 Chained list of Doc Entries.

ListDocEntry::iterator ItDocEntries
 Iterator, used to visit the entries.

ListDocEntry::iterator ItValEntries
 Iterator, used to visit the Val Entries (for Python users).

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


Detailed Description

describes an IMAGE within a SERIE (DicomDirSerie) of a given DICOMDIR (DicomDir)

Definition at line 31 of file gdcmDicomDirImage.h.


Constructor & Destructor Documentation

gdcm::DicomDirImage::DicomDirImage bool  empty = false  ) 
 

Constructor.

Note:
End user must use : DicomDirSerie::NewImage()

Definition at line 31 of file gdcmDicomDirImage.cxx.

References gdcm::DicomDirObject::FillObject(), and gdcm::ListDicomDirImageElem.

00031                                       :
00032    DicomDirObject()
00033 {
00034    if( !empty )
00035    {
00036       ListDicomDirImageElem const &elemList = 
00037          Global::GetDicomDirElements()->GetDicomDirImageElements();
00038       FillObject(elemList);
00039    }
00040 }

gdcm::DicomDirImage::~DicomDirImage  ) 
 

Canonical destructor.

Definition at line 45 of file gdcmDicomDirImage.cxx.

00046 {
00047 }


Member Function Documentation

bool gdcm::SQItem::AddEntry DocEntry entry  )  [virtual, inherited]
 

Inserts *in the right place* any Entry (Dicom Element) into the Sequence Item.

Parameters:
entry Entry to add

Implements gdcm::DocEntrySet.

Definition at line 107 of file gdcmSQItem.cxx.

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

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

00108 {   
00109    if (DocEntries.empty() )
00110    {
00111       DocEntries.push_back(entry);
00112       return true;
00113    }
00114  
00115    ListDocEntry::iterator insertSpot;
00116    ListDocEntry::iterator it = DocEntries.end();
00117    do
00118    {
00119       it--;
00120 
00121       if ( (*it)->IsItemDelimitor() )
00122       {
00123          continue;
00124       }
00125       if ( (*it)->GetGroup() < entry->GetGroup() )
00126          break;
00127       else
00128          if ( (*it)->GetGroup() == entry->GetGroup() &&
00129               (*it)->GetElement() < entry->GetElement() )
00130             break;
00131    } while (it != DocEntries.begin() );
00132   
00133    insertSpot = it++;
00134    insertSpot++; // ?!?
00135    DocEntries.insert(insertSpot, entry); 
00136    return true;
00137 }   

bool gdcm::DocEntrySet::CheckIfEntryExist uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Checks if a given Dicom Element exists within the H table.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
true is found

Definition at line 434 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

00435 {
00436    return GetDocEntry(group,elem)!=NULL;
00437 }

void gdcm::SQItem::ClearEntry  )  [virtual, inherited]
 

Remove all entry in the Sequence Item.

Implements gdcm::DocEntrySet.

Definition at line 189 of file gdcmSQItem.cxx.

References gdcm::SQItem::DocEntries.

Referenced by gdcm::SQItem::~SQItem().

00190 {
00191    for(ListDocEntry::iterator cc = DocEntries.begin();
00192                               cc != DocEntries.end();
00193                             ++cc)
00194    {
00195       delete *cc;
00196    }
00197    DocEntries.clear();
00198 }

void gdcm::DicomDirObject::FillObject ListDicomDirMetaElem const &  elemList  )  [protected, inherited]
 

add the 'Object' related Dicom Elements to the listEntries of a partially created DICOMDIR

Parameters:
elemList Element List to add at the right place

Definition at line 56 of file gdcmDicomDirObject.cxx.

References gdcm::SQItem::AddEntry(), gdcm::ListDicomDirMetaElem, gdcm::DocEntry::SetOffset(), and gdcm::ValEntry::SetValue().

Referenced by DicomDirImage(), gdcm::DicomDirMeta::DicomDirMeta(), gdcm::DicomDirPatient::DicomDirPatient(), gdcm::DicomDirSerie::DicomDirSerie(), and gdcm::DicomDirStudy::DicomDirStudy().

00057 {
00058   // FillObject fills up the SQItem that will be conneected to the right place
00059    ListDicomDirMetaElem::const_iterator it;
00060    uint16_t tmpGr,tmpEl;
00061    DictEntry *dictEntry;
00062    ValEntry *entry;
00063       
00064    // for all the Elements found in they own part of the DicomDir dict.     
00065    for(it = elemList.begin(); it != elemList.end(); ++it)
00066    {
00067       tmpGr = it->Group;
00068       tmpEl = it->Elem;
00069       dictEntry = Global::GetDicts()->GetDefaultPubDict()->GetEntry(tmpGr,tmpEl);
00070       entry = new ValEntry(dictEntry);
00071       entry->SetOffset(0); // just to avoid further missprinting
00072       entry->SetValue(it->Value);
00073 
00074       AddEntry(entry);
00075    }   
00076 }   

BaseTagKey const& gdcm::SQItem::GetBaseTagKey  )  const [inline, inherited]
 

Accessor on BaseTagKey.

Definition at line 77 of file gdcmSQItem.h.

References gdcm::BaseTagKey.

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

00077 { return BaseTagKeyNested; }

BinEntry * gdcm::DocEntrySet::GetBinEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type BinEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding BinEntry.

Definition at line 127 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetDocEntry().

Referenced by gdcm::DocEntrySet::GetEntryBinArea(), and gdcm::DocEntrySet::SetBinEntry().

00128 {
00129    DocEntry *currentEntry = GetDocEntry(group, elem);
00130    if ( !currentEntry )
00131    {
00132       gdcmWarningMacro( "No corresponding BinEntry " << std::hex << group <<
00133                          "," << elem);
00134       return NULL;
00135    }
00136 
00137    return dynamic_cast<BinEntry*>(currentEntry);
00138 }

int gdcm::SQItem::GetDepthLevel  )  [inline, inherited]
 

Accessor on SQDepthLevel.

Definition at line 68 of file gdcmSQItem.h.

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

00068 { return SQDepthLevel; }                                                                             

DictEntry * gdcm::DocEntrySet::GetDictEntry uint16_t  group,
uint16_t  elem,
TagName const &  vr
[protected, inherited]
 

Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element, and create a new virtual DictEntry if necessary.

Parameters:
group group number of the searched DictEntry
elem element number of the searched DictEntry
vr Value Representation to use, if necessary
Returns:
Corresponding DictEntry when it exists, NULL otherwise.

Definition at line 558 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_UNKNOWN, gdcm::DocEntrySet::GetDictEntry(), gdcm::DictEntry::GetName(), gdcm::DictEntry::GetVR(), gdcm::DocEntrySet::NewVirtualDictEntry(), and gdcm::TagName.

00560 {
00561    DictEntry *dictEntry = GetDictEntry(group,elem);
00562    DictEntry *goodEntry = dictEntry;
00563    std::string goodVR = vr;
00564 
00565    if (elem == 0x0000) goodVR="UL";
00566 
00567    if ( goodEntry )
00568    {
00569       if ( goodVR != goodEntry->GetVR()
00570         && goodVR != GDCM_UNKNOWN )
00571       {
00572          goodEntry = NULL;
00573       }
00574    }
00575 
00576    // Create a new virtual DictEntry if necessary
00577    if (!goodEntry)
00578    {
00579       if (dictEntry)
00580       {
00581          goodEntry = NewVirtualDictEntry(group, elem, goodVR, "FIXME", 
00582                                          dictEntry->GetName() );
00583       }
00584       else
00585       {
00586          goodEntry = NewVirtualDictEntry(group, elem, goodVR);
00587       }
00588    }
00589    return goodEntry;
00590 }

DictEntry * gdcm::DocEntrySet::GetDictEntry uint16_t  group,
uint16_t  elem
[protected, inherited]
 

Searches [both] the public [and the shadow dictionary (when they exist)] for the presence of the DictEntry with given group and element. The public dictionary has precedence on the shadow one.

Parameters:
group group number of the searched DictEntry
elem element number of the searched DictEntry
Returns:
Corresponding DictEntry when it exists, NULL otherwise.

Definition at line 534 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::Dict::GetEntry().

Referenced by gdcm::DocEntrySet::GetDictEntry(), gdcm::DocEntrySet::NewBinEntry(), gdcm::DocEntrySet::NewSeqEntry(), gdcm::DocEntrySet::NewValEntry(), and gdcm::Document::ReadNextDocEntry().

00535 {
00536    DictEntry *found = 0;
00537    Dict *pubDict = Global::GetDicts()->GetDefaultPubDict();
00538    if (!pubDict) 
00539    {
00540       gdcmWarningMacro( "We SHOULD have a default dictionary");
00541    }
00542    else
00543    {
00544       found = pubDict->GetEntry(group, elem);  
00545    }
00546    return found;
00547 }

DocEntry * gdcm::SQItem::GetDocEntry uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Gets a Dicom Element inside a SQ Item Entry.

Parameters:
group Group number of the Entry
elem Element number of the Entry
Returns:
Entry whose (group,elem) was passed. 0 if not found

Implements gdcm::DocEntrySet.

Definition at line 230 of file gdcmSQItem.cxx.

References gdcm::SQItem::DocEntries.

Referenced by gdcm::DicomDir::CreateDicomDir().

00231 {
00232    for(ListDocEntry::iterator i =  DocEntries.begin();
00233                               i != DocEntries.end(); 
00234                             ++i)
00235    {
00236       if ( (*i)->GetGroup() == group && (*i)->GetElement() == elem )
00237          return *i;
00238    }
00239    return NULL;
00240 }

void * gdcm::DocEntrySet::GetEntryBinArea uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Gets (from Header) a 'non string' element value.

Parameters:
group group number of the Entry
elem element number of the Entry
Returns:
Pointer to the 'non string' area

Definition at line 57 of file gdcmDocEntrySet.cxx.

References gdcm::BinEntry::GetBinArea(), and gdcm::DocEntrySet::GetBinEntry().

Referenced by gdcm::PixelReadConvert::GrabInformationsFromFile().

00058 {
00059    BinEntry *entry = GetBinEntry(group, elem);
00060    if( entry )
00061       return entry->GetBinArea();
00062    return 0;
00063 }

int gdcm::DocEntrySet::GetEntryLength uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Searches within Header Entries (Dicom Elements) parsed with the public and private dictionaries for the value length of a given tag..

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element length; -2 if not found

Definition at line 73 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetLength().

Referenced by gdcm::DicomDir::SetElement(), and gdcm::File::Write().

00074 {
00075    DocEntry *entry = GetDocEntry(group, elem);
00076    if( entry )
00077       return entry->GetLength();
00078    return -1;
00079 }

std::string gdcm::DocEntrySet::GetEntryValue uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Get the "std::string representable" value of the Dicom entry.

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element value when it exists, and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.

Definition at line 43 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetDocEntry(), and gdcm::ContentEntry::GetValue().

Referenced by gdcm::SerieHelper::AddFileName(), gdcm::File::AnonymizeFile(), gdcm::Document::Document(), gdcm::File::File(), gdcm::File::GetBitsAllocated(), gdcm::File::GetBitsStored(), gdcm::File::GetHighBitPosition(), gdcm::File::GetImageNumber(), gdcm::File::GetImageOrientationPatient(), gdcm::File::GetLUTNbits(), gdcm::File::GetModality(), gdcm::File::GetNumberOfScalarComponents(), gdcm::File::GetPixelType(), gdcm::File::GetPlanarConfiguration(), gdcm::File::GetRescaleIntercept(), gdcm::File::GetRescaleSlope(), gdcm::File::GetSamplesPerPixel(), gdcm::Document::GetTransferSyntaxName(), 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(), gdcm::PixelReadConvert::GrabInformationsFromFile(), gdcm::File::IsMonochrome(), gdcm::File::IsPaletteColor(), gdcm::File::IsReadable(), gdcm::File::IsSignedPixelData(), gdcm::File::IsYBRFull(), gdcm::Document::operator<(), gdcm::DicomDir::SetElement(), and gdcm::File::Write().

00044 {
00045    ContentEntry *entry = dynamic_cast<ContentEntry *>(GetDocEntry(group,elem));
00046    if( entry )
00047       return entry->GetValue();
00048    return GDCM_UNFOUND;
00049 }

std::string gdcm::DocEntrySet::GetEntryVR uint16_t  group,
uint16_t  elem
[virtual, inherited]
 

Searches within Header Entries (Dicom Elements) parsed with the public [and private dictionaries] for the element value representation of a given tag.. Obtaining the VR (Value Representation) might be needed by caller to convert the string typed content to caller's native type (think of C++ vs Python). The VR is actually of a higher level of semantics than just the native C++ type.

Parameters:
group Group number of the searched tag.
elem Element number of the searched tag.
Returns:
Corresponding element value representation when it exists, and the string GDCM_UNFOUND ("gdcm::Unfound") otherwise.

Definition at line 94 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_UNFOUND, gdcm::DocEntrySet::GetDocEntry(), and gdcm::DocEntry::GetVR().

00095 {
00096    DocEntry *entry = GetDocEntry(group, elem);
00097    if( entry )
00098       return entry->GetVR();
00099    return GDCM_UNFOUND;
00100 }

DocEntry * gdcm::SQItem::GetFirstEntry  )  [virtual, inherited]
 

Get the first Dicom entry while visiting the SQItem.

Returns:
The first DocEntry if found, otherwhise 0

Implements gdcm::DocEntrySet.

Definition at line 204 of file gdcmSQItem.cxx.

References gdcm::SQItem::DocEntries, and gdcm::SQItem::ItDocEntries.

00205 {
00206    ItDocEntries = DocEntries.begin();
00207    if( ItDocEntries != DocEntries.end() )
00208       return *ItDocEntries;
00209    return 0;   
00210 }

DocEntry * gdcm::SQItem::GetNextEntry  )  [virtual, inherited]
 

Get the next Dicom entry while visiting the SQItem.

Returns:
The next DocEntry if found, otherwhise NULL

Implements gdcm::DocEntrySet.

Definition at line 216 of file gdcmSQItem.cxx.

References gdcm::SQItem::DocEntries, and gdcm::SQItem::ItDocEntries.

00217 {
00218    ++ItDocEntries;
00219    if( ItDocEntries != DocEntries.end() )
00220       return  *ItDocEntries;
00221    return NULL;
00222 }

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; };

SeqEntry * gdcm::DocEntrySet::GetSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type SeqEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding SeqEntry.

Definition at line 148 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetDocEntry().

00149 {
00150    DocEntry *currentEntry = GetDocEntry(group, elem);
00151    if ( !currentEntry )
00152    {
00153       gdcmWarningMacro( "No corresponding SeqEntry " << std::hex << group <<
00154                         "," << elem);
00155       return NULL;
00156    }
00157 
00158    return dynamic_cast<SeqEntry*>(currentEntry);
00159 }

int gdcm::SQItem::GetSQItemNumber  )  [inline, inherited]
 

returns the ordinal position of a given SQItem

Definition at line 63 of file gdcmSQItem.h.

00063 { return SQItemNumber; };

ValEntry * gdcm::DocEntrySet::GetValEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Same as Document::GetDocEntry except it only returns a result when the corresponding entry is of type ValEntry.

Parameters:
group Group number of the searched Dicom Element
elem Element number of the searched Dicom Element
Returns:
When present, the corresponding ValEntry.

Definition at line 110 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::GetDocEntry().

Referenced by gdcm::DocEntrySet::SetValEntry(), and gdcm::File::Write().

00111 {
00112    DocEntry *currentEntry = GetDocEntry(group, elem);
00113    if ( !currentEntry )
00114       return NULL;
00115 
00116    return dynamic_cast<ValEntry*>(currentEntry);
00117 }

BinEntry * gdcm::DocEntrySet::InsertBinEntry uint8_t *  binArea,
int  lgth,
uint16_t  group,
uint16_t  elem,
TagName const &  vr = GDCM_UNKNOWN
[inherited]
 

Modifies the value of a given Header Entry (Dicom Element) when it exists. Create it with the given value when unexistant. A copy of the binArea is made to be kept in the Document.

Parameters:
binArea (binary) value to be set
lgth length of the Bin Area we want to set
group Group number of the Entry
elem Element number of the Entry
vr V(alue) R(epresentation) of the Entry -if private Entry-
Returns:
pointer to the modified/created Header Entry (NULL when creation failed).

Definition at line 309 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewBinEntry(), gdcm::DocEntrySet::RemoveEntry(), gdcm::DocEntrySet::SetBinEntry(), and gdcm::TagName.

Referenced by gdcm::File::InitializeDefaultFile(), and gdcm::FileHelper::InsertBinEntry().

00312 {
00313    BinEntry *binEntry = 0;
00314    DocEntry *currentEntry = GetDocEntry( group, elem );
00315 
00316    // Verify the currentEntry
00317    if (currentEntry)
00318    {
00319       binEntry = dynamic_cast<BinEntry *>(currentEntry);
00320 
00321       // Verify the VR
00322       if( binEntry )
00323          if( binEntry->GetVR()!=vr )
00324             binEntry = NULL;
00325 
00326       // if currentEntry doesn't correspond to the requested valEntry
00327       if( !binEntry)
00328       {
00329          if( !RemoveEntry(currentEntry) )
00330          {
00331             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00332 
00333             return NULL;
00334          }
00335       }
00336    }
00337 
00338    // Create a new binEntry if necessary
00339    if( !binEntry)
00340    {
00341       binEntry = NewBinEntry(group, elem, vr);
00342 
00343       if ( !AddEntry(binEntry) )
00344       {
00345          gdcmWarningMacro( "AddEntry failed allthough this is a creation.");
00346 
00347          delete binEntry;
00348          return NULL;
00349       }
00350    }
00351 
00352    // Set the binEntry value
00353    uint8_t *tmpArea;
00354    if( lgth>0 && binArea )
00355    {
00356       tmpArea = new uint8_t[lgth];
00357       memcpy(tmpArea,binArea,lgth);
00358    }
00359    else
00360    {
00361       tmpArea = 0;
00362    }
00363    if( !SetBinEntry(tmpArea,lgth,binEntry) )
00364    {
00365       if( tmpArea )
00366       {
00367          delete[] tmpArea;
00368       }
00369    }
00370 
00371    return binEntry;
00372 }  

SeqEntry * gdcm::DocEntrySet::InsertSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Modifies the value of a given Doc Entry (Dicom Element) when it exists. Creates it when unexistant.

Parameters:
group Group number of the Entry
elem Element number of the Entry
Returns:
pointer to the modified/created SeqEntry (NULL when creation failed).

Definition at line 382 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntrySet::NewSeqEntry(), and gdcm::DocEntrySet::RemoveEntry().

Referenced by gdcm::FileHelper::InsertSeqEntry().

00383 {
00384    SeqEntry *seqEntry = 0;
00385    DocEntry *currentEntry = GetDocEntry( group, elem );
00386 
00387    // Verify the currentEntry
00388    if( currentEntry )
00389    {
00390       seqEntry = dynamic_cast<SeqEntry *>(currentEntry);
00391 
00392       // Verify the VR
00393       if( seqEntry )
00394          seqEntry = NULL;
00395 
00396       // if currentEntry doesn't correspond to the requested seqEntry
00397       if( !seqEntry )
00398       {
00399          if (!RemoveEntry(currentEntry))
00400          {
00401             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00402 
00403             return NULL;
00404          }
00405       }
00406    }
00407    // Create a new seqEntry if necessary
00408    if( !seqEntry )
00409    {
00410       seqEntry = NewSeqEntry(group, elem);
00411 
00412       if( !AddEntry(seqEntry) )
00413       {
00414          gdcmWarningMacro( "AddEntry failed allthough this is a creation.");
00415 
00416          delete seqEntry;
00417          return NULL;
00418       }
00419    }
00420 
00421    // TODO : Find a trick to insert a SequenceDelimitationItem 
00422         //       in the SeqEntry, at the end.
00423    return seqEntry;
00424 } 

ValEntry * gdcm::DocEntrySet::InsertValEntry std::string const &  value,
uint16_t  group,
uint16_t  elem,
TagName const &  vr = GDCM_UNKNOWN
[inherited]
 

Modifies the value of a given Doc Entry (Dicom Element) when it exists. Create it with the given value when unexistant.

Parameters:
value (string) Value to be set
group Group number of the Entry
elem Element number of the Entry
vr V(alue) R(epresentation) of the Entry -if private Entry-
Returns:
pointer to the modified/created Header Entry (NULL when creation failed).

Definition at line 250 of file gdcmDocEntrySet.cxx.

References gdcm::DocEntrySet::AddEntry(), gdcmWarningMacro, gdcm::DocEntrySet::GetDocEntry(), gdcm::DocEntry::GetVR(), gdcm::DocEntrySet::NewValEntry(), gdcm::DocEntrySet::RemoveEntry(), gdcm::DocEntrySet::SetValEntry(), and gdcm::TagName.

Referenced by gdcm::File::InitializeDefaultFile(), gdcm::FileHelper::InsertValEntry(), and gdcm::File::Write().

00253 {
00254    ValEntry *valEntry = 0;
00255    DocEntry *currentEntry = GetDocEntry( group, elem );
00256    
00257    if (currentEntry)
00258    {
00259       valEntry = dynamic_cast<ValEntry *>(currentEntry);
00260 
00261       // Verify the VR
00262       if( valEntry )
00263          if( valEntry->GetVR()!=vr )
00264             valEntry = NULL;
00265 
00266       // if currentEntry doesn't correspond to the requested valEntry
00267       if( !valEntry)
00268       {
00269          if( !RemoveEntry(currentEntry) )
00270          {
00271             gdcmWarningMacro( "Removal of previous DocEntry failed.");
00272 
00273             return NULL;
00274          }
00275       }
00276    }
00277 
00278    // Create a new valEntry if necessary
00279    if( !valEntry )
00280    {
00281       valEntry = NewValEntry( group, elem, vr );
00282 
00283       if ( !AddEntry(valEntry) )
00284       {
00285          gdcmWarningMacro("AddEntry failed although this is a creation.");
00286 
00287          delete valEntry;
00288          return NULL;
00289       }
00290    }
00291 
00292    // Set the binEntry value
00293    SetValEntry(value, valEntry); // The std::string value
00294    return valEntry;
00295 }

bool gdcm::SQItem::IsEmpty  )  [inline, virtual, inherited]
 

tells us if the set contains no entry

Implements gdcm::DocEntrySet.

Definition at line 60 of file gdcmSQItem.h.

00060 { return DocEntries.empty(); };

BinEntry * gdcm::DocEntrySet::NewBinEntry uint16_t  group,
uint16_t  elem,
TagName const &  vr = GDCM_UNKNOWN
[inherited]
 

Build a new Bin Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group group number of the new Entry
elem element number of the new Entry
vr VR of the new Entry

Definition at line 471 of file gdcmDocEntrySet.cxx.

References gdcmAssertMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), and gdcm::TagName.

Referenced by gdcm::FileHelper::CopyBinEntry(), gdcm::DocEntrySet::InsertBinEntry(), and gdcm::Document::ReadNextDocEntry().

00473 {
00474    DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00475    gdcmAssertMacro(dictEntry);
00476 
00477    BinEntry *newEntry = new BinEntry(dictEntry);
00478    if (!newEntry) 
00479    {
00480       gdcmWarningMacro( "Failed to allocate BinEntry");
00481       return 0;
00482    }
00483    return newEntry;
00484 }

SeqEntry * gdcm::DocEntrySet::NewSeqEntry uint16_t  group,
uint16_t  elem
[inherited]
 

Build a new Seq Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group group number of the new Entry
elem element number of the new Entry

Definition at line 493 of file gdcmDocEntrySet.cxx.

References gdcmAssertMacro, gdcmWarningMacro, and gdcm::DocEntrySet::GetDictEntry().

Referenced by gdcm::DocEntrySet::InsertSeqEntry(), and gdcm::Document::ReadNextDocEntry().

00494 {
00495    DictEntry *dictEntry = GetDictEntry(group, elem, "SQ");
00496    gdcmAssertMacro(dictEntry);
00497 
00498    SeqEntry *newEntry = new SeqEntry( dictEntry );
00499    if (!newEntry)
00500    {
00501       gdcmWarningMacro( "Failed to allocate SeqEntry");
00502       return 0;
00503    }
00504    return newEntry;
00505 }

ValEntry * gdcm::DocEntrySet::NewValEntry uint16_t  group,
uint16_t  elem,
TagName const &  vr = GDCM_UNKNOWN
[inherited]
 

Build a new Val Entry from all the low level arguments. Check for existence of dictionary entry, and build a default one when absent.

Parameters:
group group number of the new Entry
elem element number of the new Entry
vr VR of the new Entry

Definition at line 447 of file gdcmDocEntrySet.cxx.

References gdcmAssertMacro, gdcmWarningMacro, gdcm::DocEntrySet::GetDictEntry(), and gdcm::TagName.

Referenced by gdcm::FileHelper::CopyValEntry(), gdcm::DocEntrySet::InsertValEntry(), and gdcm::Document::ReadNextDocEntry().

00449 {
00450    DictEntry *dictEntry = GetDictEntry(group, elem, vr);
00451    gdcmAssertMacro(dictEntry);
00452 
00453    ValEntry *newEntry = new ValEntry(dictEntry);
00454    if (!newEntry) 
00455    {
00456       gdcmWarningMacro( "Failed to allocate ValEntry");
00457       return 0;
00458    }
00459    return newEntry;
00460 }

DictEntry * gdcm::DocEntrySet::NewVirtualDictEntry uint16_t  group,
uint16_t  elem,
TagName const &  vr = GDCM_UNKNOWN,
TagName const &  vm = GDCM_UNKNOWN,
TagName const &  name = GDCM_UNKNOWN
[inherited]
 

Request a new virtual dict entry to the dict set.

Parameters:
group group number of the underlying DictEntry
elem element number of the underlying DictEntry
vr VR (Value Representation) of the underlying DictEntry
vm VM (Value Multiplicity) of the underlying DictEntry
name english name

Definition at line 515 of file gdcmDocEntrySet.cxx.

References gdcm::TagName.

Referenced by gdcm::File::File(), and gdcm::DocEntrySet::GetDictEntry().

00519 {
00520    return Global::GetDicts()->NewVirtualDictEntry(group,elem,vr,vm,name);
00521 }

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

Prints the Object.

Parameters:
os ostream to write to
indent Indentation string to be prepended during printing
Returns:

Reimplemented from gdcm::SQItem.

Definition at line 66 of file gdcmDicomDirImage.cxx.

00067 {
00068    os << "IMAGE : ";
00069    for(ListDocEntry::iterator i = DocEntries.begin();
00070                               i!= DocEntries.end();
00071                               ++i)
00072    {
00073       if( (*i)->GetGroup() == 0x0004 && (*i)->GetElement() == 0x1500 )
00074       {
00075          os << (dynamic_cast<ValEntry *>(*i))->GetValue(); //FIXME
00076       }
00077    }
00078    os << std::endl;
00079 
00080    DicomDirObject::Print(os);
00081 }

bool gdcm::SQItem::RemoveEntry DocEntry entryToRemove  )  [virtual, inherited]
 

Clear the std::list from given entry AND delete the entry.

Parameters:
entryToRemove Entry to remove AND delete.
Returns:
true if the entry was found and removed; false otherwise

Implements gdcm::DocEntrySet.

Definition at line 144 of file gdcmSQItem.cxx.

References gdcm::SQItem::DocEntries, gdcmWarningMacro, and gdcm::DocEntry::GetKey().

00145 {
00146    for(ListDocEntry::iterator it = DocEntries.begin();
00147                               it != DocEntries.end();
00148                             ++it)
00149    {
00150       if( *it == entryToRemove )
00151       {
00152          DocEntries.erase(it);
00153          gdcmWarningMacro( "One element erased: " << entryToRemove->GetKey() );
00154          delete entryToRemove;
00155          return true;
00156       }
00157    }
00158    gdcmWarningMacro( "Entry not found: " << entryToRemove->GetKey() );
00159    return false ;
00160 }

bool gdcm::SQItem::RemoveEntryNoDestroy DocEntry entryToRemove  )  [virtual, inherited]
 

Clear the std::list from given entry BUT keep the entry.

Parameters:
entryToRemove Entry to remove.
Returns:
true if the entry was found and removed; false otherwise

Implements gdcm::DocEntrySet.

Definition at line 167 of file gdcmSQItem.cxx.

References gdcm::SQItem::DocEntries, gdcmWarningMacro, and gdcm::DocEntry::GetKey().

00168 {
00169    for(ListDocEntry::iterator it =  DocEntries.begin();
00170                               it != DocEntries.end();
00171                             ++it)
00172    {
00173       if( *it == entryToRemove )
00174       {
00175          DocEntries.erase(it);
00176          gdcmWarningMacro( "One element erased, no destroyed: "
00177                             << entryToRemove->GetKey() );
00178          return true;
00179       }
00180    }
00181                                                                                 
00182    gdcmWarningMacro( "Entry not found:" << entryToRemove->GetKey() );
00183    return false ;
00184 }

void gdcm::SQItem::SetBaseTagKey BaseTagKey const &  key  )  [inline, inherited]
 

Accessor on BaseTagKey.

Definition at line 74 of file gdcmSQItem.h.

References gdcm::BaseTagKey.

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

00074 { BaseTagKeyNested = key; }

bool gdcm::DocEntrySet::SetBinEntry uint8_t *  content,
int  lgth,
BinEntry entry
[inherited]
 

Accesses an existing BinEntry (i.e. a Dicom Element) and modifies it's content with the given value.

Parameters:
content new value (void* -> uint8_t*) to substitute with
entry Entry to be modified
lgth new value length

Definition at line 228 of file gdcmDocEntrySet.cxx.

References gdcm::GDCM_BINLOADED, gdcm::BinEntry::SetBinArea(), gdcm::DocEntry::SetLength(), and gdcm::ContentEntry::SetValue().

00229 {
00230    if(entry)
00231    {
00232       entry->SetBinArea(content);  
00233       entry->SetLength(lgth);
00234       entry->SetValue(GDCM_BINLOADED);
00235       return true;
00236    }
00237    return false;
00238 }

bool gdcm::DocEntrySet::SetBinEntry uint8_t *  content,
int  lgth,
uint16_t  group,
uint16_t  elem
[inherited]
 

Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

Parameters:
content new value (void* -> uint8_t*) to substitute with
lgth new value length
group group number of the Dicom Element to modify
elem element number of the Dicom Element to modify

Definition at line 191 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetBinEntry().

Referenced by gdcm::DocEntrySet::InsertBinEntry(), and gdcm::FileHelper::SetBinEntry().

00193 {
00194    BinEntry *entry = GetBinEntry(group, elem);
00195    if (!entry )
00196    {
00197       gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
00198                         "," << elem << " element (try promotion first).");
00199       return false;
00200    }
00201 
00202    return SetBinEntry(content,lgth,entry);
00203 } 

void gdcm::SQItem::SetDepthLevel int  depth  )  [inline, inherited]
 

Accessor on SQDepthLevel.

Definition at line 71 of file gdcmSQItem.h.

00071 { SQDepthLevel = depth; }

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::SQItem::SetSQItemNumber int  itemNumber  )  [inline, inherited]
 

Sets the ordinal position of a given SQItem.

Definition at line 65 of file gdcmSQItem.h.

Referenced by gdcm::SeqEntry::AddSQItem(), and gdcm::DicomDir::NewMeta().

00065 { SQItemNumber = itemNumber; };

bool gdcm::DocEntrySet::SetValEntry std::string const &  content,
ValEntry entry
[inherited]
 

Accesses an existing DocEntry (i.e. a Dicom Element) and modifies it's content with the given value.

Parameters:
content new value (string) to substitute with
entry Entry to be modified

Definition at line 211 of file gdcmDocEntrySet.cxx.

References gdcm::ValEntry::SetValue().

00212 {
00213    if(entry)
00214    {
00215       entry->SetValue(content);
00216       return true;
00217    }
00218    return false;
00219 }

bool gdcm::DocEntrySet::SetValEntry std::string const &  content,
uint16_t  group,
uint16_t  elem
[inherited]
 

Accesses an existing DocEntry (i.e. a Dicom Element) through it's (group, element) and modifies it's content with the given value.

Parameters:
content new value (string) to substitute with
group group number of the Dicom Element to modify
elem element number of the Dicom Element to modify

Definition at line 169 of file gdcmDocEntrySet.cxx.

References gdcmWarningMacro, and gdcm::DocEntrySet::GetValEntry().

Referenced by gdcm::File::AnonymizeFile(), gdcm::Document::Document(), gdcm::DocEntrySet::InsertValEntry(), gdcm::FileHelper::SetValEntry(), and gdcm::File::Write().

00171 {
00172    ValEntry *entry = GetValEntry(group, elem);
00173    if (!entry )
00174    {
00175       gdcmWarningMacro( "No corresponding ValEntry " << std::hex << group <<
00176                          "," << elem << " element (try promotion first).");
00177       return false;
00178    }
00179    return SetValEntry(content,entry);
00180 }

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

write any type of entry to the entry set

Implements gdcm::DocEntrySet.

Reimplemented in gdcm::DicomDirMeta, gdcm::DicomDirPatient, gdcm::DicomDirSerie, and gdcm::DicomDirStudy.

Definition at line 59 of file gdcmSQItem.cxx.

References gdcm::binary_write(), and gdcm::SQItem::DocEntries.

00060 {
00061    int j;
00062    uint16_t item[4] = { 0xfffe, 0xe000, 0xffff, 0xffff };
00063    uint16_t itemt[4]= { 0xfffe, 0xe00d, 0xffff, 0xffff };
00064 
00065     //we force the writting of an 'Item' Start Element
00066     // because we want to write the Item as a 'no Length' item
00067    for(j=0;j<4;++j)
00068    {
00069       binary_write( *fp, item[j]);  // fffe e000 ffff ffff 
00070    }
00071      
00072    for (ListDocEntry::iterator it = DocEntries.begin();  
00073                                it != DocEntries.end();
00074                              ++it)
00075    {   
00076       // we skip delimitors (start and end one) because 
00077       // we force them as 'no length'
00078       if ( (*it)->GetGroup() == 0xfffe )
00079       {
00080          continue;
00081       }
00082 
00083       // Fix in order to make some MR PHILIPS images e-film readable
00084       // see gdcmData/gdcm-MR-PHILIPS-16-Multi-Seq.dcm:
00085       // we just *always* ignore spurious fffe|0000 tag ! 
00086       if ( (*it)->GetGroup() == 0xfffe && (*it)->GetElement() == 0x0000 )
00087       {
00088          break; // FIXME : continue; ?!?
00089       }
00090 
00091       (*it)->WriteContent(fp, filetype);
00092    }
00093       
00094     //we force the writting of an 'Item Delimitation' item
00095     // because we wrote the Item as a 'no Length' item
00096    for(j=0;j<4;++j)
00097    {
00098       binary_write( *fp, itemt[j]);  // fffe e000 ffff ffff 
00099    } 
00100 }


Member Data Documentation

ListDocEntry gdcm::SQItem::DocEntries [protected, inherited]
 

Chained list of Doc Entries.

Definition at line 82 of file gdcmSQItem.h.

Referenced by gdcm::SQItem::AddEntry(), gdcm::SQItem::ClearEntry(), gdcm::SQItem::GetDocEntry(), gdcm::SQItem::GetFirstEntry(), gdcm::SQItem::GetNextEntry(), gdcm::SQItem::Print(), gdcm::SQItem::RemoveEntry(), gdcm::SQItem::RemoveEntryNoDestroy(), and gdcm::SQItem::WriteContent().

ListDocEntry::iterator gdcm::SQItem::ItDocEntries [protected, inherited]
 

Iterator, used to visit the entries.

Definition at line 84 of file gdcmSQItem.h.

Referenced by gdcm::SQItem::GetFirstEntry(), and gdcm::SQItem::GetNextEntry().

ListDocEntry::iterator gdcm::SQItem::ItValEntries [protected, inherited]
 

Iterator, used to visit the Val Entries (for Python users).

Definition at line 86 of file gdcmSQItem.h.

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


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