Program: gdcm
Module: $RCSfile: gdcmDocEntrySet.h,v $
Language: C++
- Date: $Date: 2005/07/11 14:40:40 $
- Version: $Revision: 1.53 $
+ Date: $Date: 2005/08/24 12:09:13 $
+ Version: $Revision: 1.54 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
public:
/// Canonical Constructor
- DocEntrySet() {};
+ DocEntrySet();
/// Canonical Destructor
virtual ~DocEntrySet() {};
DictEntry *GetDictEntry(uint16_t group, uint16_t elem);
DictEntry *GetDictEntry(uint16_t group, uint16_t elem,
TagName const &vr);
+ /// To be able to backtrack (Private Sequence, Implicit VR related pb)
+ DocEntry *PreviousDocEntry;
private:
};
Program: gdcm
Module: $RCSfile: gdcmDocument.cxx,v $
Language: C++
- Date: $Date: 2005/08/23 14:41:59 $
- Version: $Revision: 1.266 $
+ Date: $Date: 2005/08/24 12:09:13 $
+ Version: $Revision: 1.267 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
VRKey vr;
bool used;
bool delim_mode_intern = delim_mode;
-
+ bool first = true;
while (true)
{
if ( !delim_mode && ((long)(Fp->tellg())-offset) >= l_max)
newDocEntry = ReadNextDocEntry( );
+ // Uncoment this printf line to be able to 'follow' the DocEntries
+ // when something *very* strange happens
+
+ printf( "%04x|%04x %s\n",newDocEntry->GetGroup(),
+ newDocEntry->GetElement(),
+ newDocEntry->GetVR().c_str() );
+
if ( !newDocEntry )
{
break;
}
- // Uncoment this printf line to be able to 'follow' the DocEntries
- // when something *very* strange happens
-
- //printf( "%04x|%04x %s\n",newDocEntry->GetGroup(),
- // newDocEntry->GetElement(),
- // newDocEntry->GetVR().c_str() );
+ // an Item Starter found elsewhere but the first postition
+ // of a SeqEntry means previous entry was a Sequence
+ // but we didn't get it (private Sequence + Implicit VR)
+ // we have to backtrack.
+ if ( !first && newDocEntry->IsItemStarter() )
+ {
+ newDocEntry = Backtrack(newDocEntry);
+ }
+ else
+ {
+ PreviousDocEntry = newDocEntry;
+ }
+
used = true;
newValEntry = dynamic_cast<ValEntry*>(newDocEntry);
newBinEntry = dynamic_cast<BinEntry*>(newDocEntry);
bool delimitor=newValEntry->IsItemDelimitor();
- // FIXME : Brutal patch, waiting till we find a clever way to guess
- // if a doc entry is a Sequence,
- // - when it's odd number
- // - and the file is Implicit VR Transfert Syntax
- //
- // '&& offset!=132' is a very fierce way to guess
- // if we are at zero level (Probabely not enough ...).
- // We want to go on parsing.
- if ( (delimitor && offset!=132) ||
+ if ( (delimitor) ||
(!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
{
- if (delimitor && offset!=132)
- {
- gdcmWarningMacro( "in ParseDES : Item found out of a Sequence "
- << newValEntry->GetKey()
- << " (at offset : "
- << newValEntry->GetOffset() << " )" );
- }
if ( !used )
delete newDocEntry;
break;
{
delete newDocEntry;
}
+ first = false;
} // end While
}
}
}
+/**
+ * \brief When a private Sequence + Implicit VR is encountered
+ * we cannot guess it's a Sequence till we find the first
+ * Item Starter. We then backtrack to do the job.
+ * @param docEntry Item Starter that warned us
+ */
+DocEntry *Document::Backtrack(DocEntry *docEntry)
+{
+ // delete the Item Starter, built erroneously out of any Sequence
+ // it's not yet in the HTable/chained list
+ delete docEntry;
+
+ // Get all info we can from PreviousDocEntry
+ uint16_t group = PreviousDocEntry->GetGroup();
+ uint16_t elem = PreviousDocEntry->GetElement();
+ uint32_t lgt = PreviousDocEntry->GetLength();
+ long offset = PreviousDocEntry->GetOffset();
+
+ gdcmWarningMacro( "Backtrack :" << std::hex << group
+ << "|" << elem
+ << " at offset " << offset );
+ RemoveEntry( PreviousDocEntry );
+
+ // forge the Seq Entry
+ DocEntry *newEntry = NewSeqEntry(group, elem);
+ newEntry->SetLength(lgt);
+ newEntry->SetOffset(offset);
+
+ // Move back to the beginning of the Sequence
+ Fp->seekg( 0, std::ios::beg);
+ Fp->seekg(offset, std::ios::cur);
+
+return newEntry;
+}
+
/**
* \brief Loads the element content if its length doesn't exceed
* the value specified with Document::SetMaxSizeLoadEntry()
}
newEntry->SetOffset(Fp->tellg());
-
+
return newEntry;
}