[Insight-developers] GDCM IO and metadata copying
Peter Cech
pcech at vision.ee.ethz.ch
Mon Nov 8 08:39:42 EST 2004
Hi,
when GDCM IO is copying metadata from image, it does not distinguish
between simple tags and sequence of tags. As a consequence, it segfaults
when reading DICOM file with sequence tag. You can grab such a file from
http://www.vision.ee.ethz.ch/~pcech/bugreports/ITK-20041108/
Attached patch contains a workaround. It will skip all tag sequences.
I suspect that the proper fix would require more than just copy all tags
from sequence, so I better leave it to someone with better knowledge of
DICOM format.
Regards,
Peter Cech
-------------- next part --------------
--- Insight/Code/IO/itkGDCMImageIO.cxx 2004-11-03 10:57:29.000000000 +0100
+++ Insight-modified/Code/IO/itkGDCMImageIO.cxx 2004-11-06 10:45:26.040344296 +0100
@@ -293,10 +293,14 @@
// Do not copy field from private (unknown) dictionary.
// In the longer term we might want to (but we need the Private dictionary
// from manufacturer)
+ if (tag->second->GetVR().find("SQ") == 0) {
+ // skip sequence, otherwise following cast will crash
+ continue;
+ }
#if GDCM_MAJOR_VERSION == 0 && GDCM_MINOR_VERSION <= 5
- std::string temp = ((gdcmValEntry*)(tag->second))->GetValue();
+ std::string temp = synamic_cast<gdcmValEntry*>(tag->second)->GetValue();
#else
- std::string temp = ((gdcm::ValEntry*)(tag->second))->GetValue();
+ std::string temp = dynamic_cast<gdcm::ValEntry*>(tag->second)->GetValue();
#endif
if( tag->second->GetName() != "unkn"
&& temp.find( "gdcm::NotLoaded" ) != 0
More information about the Insight-developers
mailing list