-bool gdcmDocument::LoadDocEntrySet(bool exception_on_error) throw(gdcmFormatError) {
- (void)exception_on_error;
- rewind(fp);
- if (!CheckSwap())
- return false;
-
- guint16 g, n;
- gdcmValEntry *newValEntry = (gdcmValEntry *)0;
- gdcmBinEntry *newBinEntry = (gdcmBinEntry *)0;
- gdcmSeqEntry *newSeqEntry = (gdcmSeqEntry *)0;
- gdcmDictEntry *NewTag = (gdcmDictEntry *)0;
- char VR[3];
- long PositionOnEntry;
-
-// while ( (newHeaderEntry = ReadNextHeaderEntry()) ) {
- while (1) {
-
- // ----------------------- was ReadNextHeaderEntry -----------------
- g = ReadInt16();
- n = ReadInt16();
- if (errno == 1)
- // We reached the EOF (or an error occured) therefore
- // header parsing has to be considered as finished.
- break;
-
- // Find out if the tag we encountered is in the dictionaries:
- DictEntry = GetDictEntryByNumber(Group, Elem);
- if (!DictEntry)
- DictEntry = NewVirtualDictEntry(Group, Elem);
- if (!DictEntry) {
- dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
- "failed to allocate gdcmDictEntry");
- return false;
- }
-
- // Right now,
- vr = DictEntry->GetVR(); // Suppose we get it, suppose it's the same one
- // that's in the Explicit VR part of the Header
- // TODO
- // Resoudre pb quand inadequation entre Explicit VR et Dict
-
- if (filetype != ExplicitVR) {} // jamais de risque de conflit
- // pour les autres cas,
- // refaire l'equiv de gdcmParser::FindHeaderEntryVR
- // qui contient CheckHeaderEntryVR
- // le pb, c'est qu'on a besoin de la VR pour fabriquer l'Entry
-
- if (vr == "SQ" ) {
- // --- SeqEntry
- // TODO
- // SEQUENCE; appel 'récursif' de ??? pour charger la 'valeur'
- // (ensemble d' ITEMs, en fait,
- // chaque ITEM etant chargé avec LoadDocEntrySet)
-
-
- } else if (vr == "AE" || vr == "AS" || vr == "DA" || vr == "PN" ||
- vr == "UI" || vr == "TM" ) {
- // --- ValEntry
- NewValEntry = new gdcmValEntry(DictEntry);
- if (!NewValEntry) {
- dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
- "failed to allocate gdcmValEntry");
- return false;
- }
- FindHeaderEntryVR(NewEntry);
- FindHeaderEntryLength(NewEntry);
- }
-
-
- else {
- // --- BinEntry
- NewBinEntry = new gdcmBinEntry(DictEntry);
- if (!NewValEntry) {
- dbg.Verbose(1, "gdcmDocEntrySet::LoadDocEntrySet",
- "failed to allocate gdcmBinEntry");
- return false;
- }
- }
-
-
-
-// ------------- end of former ReadNextHeaderEntry -----------------
-
- SkipHeaderEntry(newHeaderEntry);
- if ( (ignoreShadow==0) || (newHeaderEntry->GetGroup()%2) == 0) {
- AddHeaderEntry(newHeaderEntry);
- }
- }
- rewind(fp);
- // Be carefull : merging this two loops may cause troubles ...
- for (ListTag::iterator i = GetListEntry().begin();
- i != GetListEntry().end();
- ++i)
- {
- LoadHeaderEntry(*i);
- }
- rewind(fp);
-
-
- // --------------------------------------------------------------
- // Special Patch to allow gdcm to read ACR-LibIDO formated images
- //
- // if recognition code tells us we deal with a LibIDO image
- // we switch lineNumber and columnNumber
- //
- std::string RecCode;
- RecCode = GetEntryByNumber(0x0008, 0x0010); // recognition code
- if (RecCode == "ACRNEMA_LIBIDO_1.1" ||
- RecCode == "CANRME_AILIBOD1_1." ) // for brain-damaged softwares
- // with "little-endian strings"