- //Copy string only:
- if (tag->second->GetVR().find("SQ") == 0)
- {
- // skip DICOM SeQuence, otherwise following cast will crash
- continue;
- }
- const std::string &name = tag->second->GetName();
- const std::string &value = ((gdcm::ValEntry*)(tag->second))->GetValue();
- if( name != "unkn"
- && value.find( "gdcm::NotLoaded" ) != 0
- && value.find( "gdcm::Binary" ) != 0
- && value.find( "gdcm::Loaded" ) != 0 )
- {
- //std::cout << name << "," << value << std::endl;
- gdcm::DictEntry *dictEntry = h2->GetPubDict()->GetDictEntryByName(name);
- h2->ReplaceOrCreateByNumber( value, dictEntry->GetGroup(), dictEntry->GetElement());
+ if ( gdcm::ValEntry *v = dynamic_cast<gdcm::ValEntry*>(d) )
+ {
+ // Do not bother with field from private dict
+ if( v->GetName() != "gdcm::Unknown" )
+ {
+ h2->InsertValEntry( v->GetValue(),
+ v->GetGroup(),v->GetElement(),
+ v->GetVR() );
+ }