+ {
+ if ( ! Global::GetVR()->IsVROfGdcmBinaryRepresentable(vr) )
+ {
+ ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR
+ dbg.Verbose(0, "Document::ParseDES: neither Valentry, "
+ "nor BinEntry. Probably unknown VR.");
+ }
+
+ //////////////////// BinEntry or UNKOWN VR:
+ BinEntry* newBinEntry =
+ new BinEntry( newDocEntry->GetDictEntry() );
+ newBinEntry->Copy( newDocEntry );
+
+ // When "this" is a Document the Key is simply of the
+ // form ( group, elem )...
+ if (Document* dummy = dynamic_cast< Document* > ( set ) )
+ {
+ (void)dummy;
+ newBinEntry->SetKey( newBinEntry->GetKey() );
+ }
+ // but when "this" is a SQItem, we are inserting this new
+ // valEntry in a sequence item, and the kay has the
+ // generalized form (refer to \ref BaseTagKey):
+ if (SQItem* parentSQItem = dynamic_cast< SQItem* > ( set ) )
+ {
+ newBinEntry->SetKey( parentSQItem->GetBaseTagKey()
+ + newBinEntry->GetKey() );
+ }
+
+ set->AddEntry( newBinEntry );
+ LoadDocEntry( newBinEntry );
+ }
+
+ if ( ( newDocEntry->GetGroup() == 0x7fe0 )
+ && ( newDocEntry->GetElement() == 0x0010 ) )
+ {
+ if ( IsRLELossLessTransferSyntax() )
+ {
+ long PositionOnEntry = ftell(Fp);
+ fseek( Fp, newDocEntry->GetOffset(), SEEK_SET );
+ ComputeRLEInfo();
+ fseek( Fp, PositionOnEntry, SEEK_SET );
+ }
+ else
+ if ( IsJPEGTransferSyntax() )
+ {
+ long PositionOnEntry = ftell(Fp);
+ fseek( Fp, newDocEntry->GetOffset(), SEEK_SET );
+ ComputeJPEGFragmentInfo();
+ fseek( Fp, PositionOnEntry, SEEK_SET );
+ }
+ }
+
+ // Just to make sure we are at the beginning of next entry.
+ SkipToNextDocEntry(newDocEntry);
+ }
+ else
+ {
+ // VR = "SQ"
+ unsigned long l = newDocEntry->GetReadLength();
+ if ( l != 0 ) // don't mess the delim_mode for zero-length sequence
+ {
+ if ( l == 0xffffffff )
+ {
+ delim_mode = true;
+ }
+ else
+ {
+ delim_mode = false;
+ }
+ }
+ // no other way to create it ...
+ SeqEntry* newSeqEntry =
+ new SeqEntry( newDocEntry->GetDictEntry() );
+ newSeqEntry->Copy( newDocEntry );
+ newSeqEntry->SetDelimitorMode( delim_mode );
+
+ // At the top of the hierarchy, stands a Document. When "set"
+ // is a Document, then we are building the first depth level.
+ // Hence the SeqEntry we are building simply has a depth
+ // level of one:
+ if (Document* dummy = dynamic_cast< Document* > ( set ) )
+ {
+ (void)dummy;
+ newSeqEntry->SetDepthLevel( 1 );
+ newSeqEntry->SetKey( newSeqEntry->GetKey() );
+ }
+ // But when "set" is allready a SQItem, we are building a nested
+ // sequence, and hence the depth level of the new SeqEntry
+ // we are building, is one level deeper:
+ if (SQItem* parentSQItem = dynamic_cast< SQItem* > ( set ) )
+ {
+ newSeqEntry->SetDepthLevel( parentSQItem->GetDepthLevel() + 1 );
+ newSeqEntry->SetKey( parentSQItem->GetBaseTagKey()
+ + newSeqEntry->GetKey() );
+ }
+
+ if ( l != 0 )
+ { // Don't try to parse zero-length sequences
+ ParseSQ( newSeqEntry,
+ newDocEntry->GetOffset(),
+ l, delim_mode);
+ }
+ set->AddEntry( newSeqEntry );
+ if ( !delim_mode && (ftell(Fp)-offset) >= l_max)
+ {