+ }
+
+ // 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() );
+ used = true;
+ newValEntry = dynamic_cast<ValEntry*>(newDocEntry);
+ newBinEntry = dynamic_cast<BinEntry*>(newDocEntry);
+
+ if ( newValEntry || newBinEntry )
+ {
+ //////////////////////////// ContentEntry
+ if ( newBinEntry )
+ {
+ vr = newDocEntry->GetVR();
+ if ( Filetype == ExplicitVR &&
+ !Global::GetVR()->IsVROfBinaryRepresentable(vr) )
+ {
+ ////// Neither ValEntry NOR BinEntry: should mean UNKOWN VR
+ gdcmWarningMacro( std::hex << newDocEntry->GetGroup()
+ << "|" << newDocEntry->GetElement()
+ << " : Neither Valentry, nor BinEntry."
+ "Probably unknown VR.");
+ }
+
+ //////////////////// BinEntry or UNKOWN VR:
+
+ // When "this" is a Document the Key is simply of the
+ // form ( group, elem )...
+ if ( dynamic_cast< Document* > ( set ) )
+ {
+ newBinEntry->SetKey( newBinEntry->GetKey() );
+ }
+ // but when "this" is a SQItem, we are inserting this new
+ // valEntry in a sequence item, and the key has the
+ // generalized form (refer to \ref BaseTagKey):
+
+ // time waste hunting
+ //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
+ //{
+ // newBinEntry->SetKey( parentSQItem->GetBaseTagKey()
+ // + newBinEntry->GetKey() );
+ //}
+
+ if ( !set->AddEntry( newBinEntry ) )
+ {
+ gdcmWarningMacro( "in ParseDES : cannot add a BinEntry "
+ << newBinEntry->GetKey()
+ << " (at offset : "
+ << newBinEntry->GetOffset() << " )" );
+ used=false;
+ }
+ else
+ {
+ // Load only if we can add (not a duplicate key)
+ LoadDocEntry( newBinEntry );
+ }
+ } // end BinEntry
+ else
+ {
+ /////////////////////// ValEntry
+
+ // When "set" is a Document, then we are at the top of the
+ // hierarchy and the Key is simply of the form ( group, elem )...
+ if ( dynamic_cast< Document* > ( set ) )
+ {
+ newValEntry->SetKey( newValEntry->GetKey() );
+ }
+ // ...but when "set" is a SQItem, we are inserting this new
+ // valEntry in a sequence item. Hence the key has the
+ // generalized form (refer to \ref BaseTagKey):
+
+ // time waste hunting
+ //if (SQItem *parentSQItem = dynamic_cast< SQItem* > ( set ) )
+ //{
+ // newValEntry->SetKey( parentSQItem->GetBaseTagKey()
+ // + newValEntry->GetKey() );
+ //}
+
+ if ( !set->AddEntry( newValEntry ) )
+ {
+ gdcmWarningMacro( "in ParseDES : cannot add a ValEntry "
+ << newValEntry->GetKey()
+ << " (at offset : "
+ << newValEntry->GetOffset() << " )" );
+ used=false;
+ }
+ else
+ {
+ // Load only if we can add (not a duplicate key)
+ LoadDocEntry( newValEntry );
+ }
+
+ if ( newValEntry->GetElement() == 0x0000 ) // if on group length
+ {
+ if ( newValEntry->GetGroup()%2 != 0 ) // if Shadow Group
+ {
+ if ( LoadMode & NO_SHADOW ) // if user asked to skip shad.gr
+ {
+ std::string strLgrGroup = newValEntry->GetValue();
+ int lgrGroup;
+ if ( strLgrGroup != GDCM_UNFOUND)
+ {
+ lgrGroup = atoi(strLgrGroup.c_str());
+ Fp->seekg(lgrGroup, std::ios::cur);
+ used = false;
+ RemoveEntry( newDocEntry );
+ newDocEntry = 0;
+ continue;
+ }
+ }
+ }
+ }
+
+ 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) ||
+ (!delim_mode && ((long)(Fp->tellg())-offset) >= l_max) )
+ {
+ if (offset!=132)
+ {
+ gdcmWarningMacro( "in ParseDES : Item found out of a Sequence "
+ << newValEntry->GetKey()
+ << " (at offset : "
+ << newValEntry->GetOffset() << " )" );
+ }
+ if ( !used )
+ delete newDocEntry;