- if ( BinEntry *binEntry = dynamic_cast<BinEntry*>(currentEntry) )
- {
- binEntry->SetBinArea( area );
- return true;
- }
-
- return false;
-}*/
-
-/**
- * \brief retrieves a Dicom Element using (group, element)
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return
- */
-DocEntry *Document::GetDocEntry(uint16_t group, uint16_t elem)
-{
- TagKey key = DictEntry::TranslateToKey(group, elem);
- if ( !TagHT.count(key))
- {
- return NULL;
- }
- return TagHT.find(key)->second;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * ValEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding ValEntry.
- */
-ValEntry *Document::GetValEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( ValEntry *entry = dynamic_cast<ValEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound ValEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * BinEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding BinEntry.
- */
-BinEntry *Document::GetBinEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( BinEntry *entry = dynamic_cast<BinEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound BinEntry.");
-
- return 0;
-}
-
-/**
- * \brief Same as \ref Document::GetDocEntry except it only
- * returns a result when the corresponding entry is of type
- * SeqEntry.
- * @param group Group number of the searched Dicom Element
- * @param elem Element number of the searched Dicom Element
- * @return When present, the corresponding SeqEntry.
- */
-SeqEntry *Document::GetSeqEntry(uint16_t group, uint16_t elem)
-{
- DocEntry *currentEntry = GetDocEntry(group, elem);
- if ( !currentEntry )
- {
- return 0;
- }
- if ( SeqEntry *entry = dynamic_cast<SeqEntry*>(currentEntry) )
- {
- return entry;
- }
- gdcmVerboseMacro( "Unfound SeqEntry.");
-
- return 0;
-}
-
-
-/**
- * \brief Loads the element while preserving the current
- * underlying file position indicator as opposed to
- * LoadDocEntry that modifies it.
- * @param entry Header Entry whose value will be loaded.
- * @return
- */
-void Document::LoadDocEntrySafe(DocEntry *entry)
-{
- if(Fp)
- {
- long PositionOnEntry = Fp->tellg();
- LoadDocEntry(entry);
- Fp->seekg(PositionOnEntry, std::ios::beg);
- }
-}
-
-/**
- * \brief Swaps back the bytes of 4-byte long integer accordingly to
- * processor order.
- * @return The properly swaped 32 bits integer.
- */
-uint32_t Document::SwapLong(uint32_t a)
-{
- switch (SwapCode)
- {
- case 1234 :
- break;
- case 4321 :
- a=( ((a<<24) & 0xff000000) | ((a<<8) & 0x00ff0000) |
- ((a>>8) & 0x0000ff00) | ((a>>24) & 0x000000ff) );
- break;
- case 3412 :
- a=( ((a<<16) & 0xffff0000) | ((a>>16) & 0x0000ffff) );
- break;
- case 2143 :
- a=( ((a<< 8) & 0xff00ff00) | ((a>>8) & 0x00ff00ff) );
- break;
- default :
- gdcmErrorMacro( "Unset swap code:" << SwapCode );
- a = 0;
- }
- return a;
-}
-
-/**
- * \brief Unswaps back the bytes of 4-byte long integer accordingly to
- * processor order.
- * @return The properly unswaped 32 bits integer.
- */
-uint32_t Document::UnswapLong(uint32_t a)
-{
- return SwapLong(a);
-}
-
-/**
- * \brief Swaps the bytes so they agree with the processor order
- * @return The properly swaped 16 bits integer.
- */
-uint16_t Document::SwapShort(uint16_t a)
-{
- if ( SwapCode == 4321 || SwapCode == 2143 )
- {
- a = ((( a << 8 ) & 0x0ff00 ) | (( a >> 8 ) & 0x00ff ) );
- }
- return a;
-}
-
-/**
- * \brief Unswaps the bytes so they agree with the processor order
- * @return The properly unswaped 16 bits integer.
- */
-uint16_t Document::UnswapShort(uint16_t a)
-{
- return SwapShort(a);
-}
-
-//-----------------------------------------------------------------------------
-// Private
-
-/**
- * \brief Parses a DocEntrySet (Zero-level DocEntries or SQ Item DocEntries)
- * @return length of the parsed set.
- */
-void Document::ParseDES(DocEntrySet *set, long offset,
- long l_max, bool delim_mode)
-{
- DocEntry *newDocEntry = 0;
- ValEntry *newValEntry;
- BinEntry *newBinEntry;
- SeqEntry *newSeqEntry;
- VRKey vr;
- bool used = false;
-
- while (true)
- {
- if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)
- {
- break;
- }