- }
- if ( !delim_mode && (ftell(Fp)-offset) >= l_max)
- {
- break;
- }
-
- gdcmSQItem *itemSQ = new gdcmSQItem(set->GetDepthLevel());
- itemSQ->AddEntry(newDocEntry);
- unsigned int l = newDocEntry->GetReadLength();
-
- if ( l == 0xffffffff )
- {
- dlm_mod = true;
- }
- else
- {
- dlm_mod = false;
- }
-
- int lgr = ParseDES(itemSQ, newDocEntry->GetOffset(), l, dlm_mod);
- (void)lgr; //FIXME not used
-
- set->AddEntry(itemSQ, SQItemNumber);
- SQItemNumber++;
- if ( !delim_mode && (ftell(Fp)-offset) >= l_max)
- {
- break;
- }
- }
-
- int lgth = ftell(Fp) - offset;
- return lgth;
-}
-
-/**
- * \brief Loads the element content if its length doesn't exceed
- * the value specified with gdcmDocument::SetMaxSizeLoadEntry()
- * @param Entry Header Entry (Dicom Element) to be dealt with
- */
-void gdcmDocument::LoadDocEntry(gdcmDocEntry* entry)
-{
- size_t item_read;
- uint16_t group = entry->GetGroup();
- std::string vr = entry->GetVR();
- uint32_t length = entry->GetLength();
-
- fseek(Fp, (long)entry->GetOffset(), SEEK_SET);
-
- // A SeQuence "contains" a set of Elements.
- // (fffe e000) tells us an Element is beginning
- // (fffe e00d) tells us an Element just ended
- // (fffe e0dd) tells us the current SeQuence just ended
- if( group == 0xfffe )
- {
- // NO more value field for SQ !
- return;
- }
-
- // When the length is zero things are easy:
- if ( length == 0 )
- {
- ((gdcmValEntry *)entry)->SetValue("");
- return;
- }
-
- // The elements whose length is bigger than the specified upper bound
- // are not loaded. Instead we leave a short notice of the offset of
- // the element content and it's length.
-
- std::ostringstream s;
- if (length > MaxSizeLoadEntry)
- {
- if (gdcmBinEntry* binEntryPtr = dynamic_cast< gdcmBinEntry* >(entry) )
- {
- s << "gdcm::NotLoaded (BinEntry)";
- s << " Address:" << (long)entry->GetOffset();
- s << " Length:" << entry->GetLength();
- s << " x(" << std::hex << entry->GetLength() << ")";
- binEntryPtr->SetValue(s.str());
- }
- // to be sure we are at the end of the value ...
- fseek(Fp, (long)entry->GetOffset()+(long)entry->GetLength(), SEEK_SET);
- // Following return introduced by JPR on version 1.25. Since the
- // treatement of a ValEntry is never executed (doh!) this means
- // we were lucky up to now because we NEVER encountered a ValEntry
- // whose length was bigger thant MaxSizeLoadEntry !? I can't believe
- // this could ever work...
- return; //FIXME FIXME FIXME FIXME JPR ????
-
- // Be carefull : a BinEntry IS_A ValEntry ...
- if (gdcmValEntry* valEntryPtr = dynamic_cast< gdcmValEntry* >(entry) )
- {
- s << "gdcm::NotLoaded. (ValEntry)";
- s << " Address:" << (long)entry->GetOffset();
- s << " Length:" << entry->GetLength();
- s << " x(" << std::hex << entry->GetLength() << ")";
- valEntryPtr->SetValue(s.str());
- }
- // to be sure we are at the end of the value ...
- fseek(Fp,(long)entry->GetOffset()+(long)entry->GetLength(),SEEK_SET);