From: David Sarrut Date: Wed, 12 Jun 2013 09:35:59 +0000 (+0200) Subject: Check if it is really a rt-struct dicom before opening it X-Git-Tag: v1.4.0~210 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0077a466af401999b712a48458e19be29d5ec938;p=clitk.git Check if it is really a rt-struct dicom before opening it --- diff --git a/common/clitkImage2DicomRTStructFilter.txx b/common/clitkImage2DicomRTStructFilter.txx index 051211b..1b241a9 100644 --- a/common/clitkImage2DicomRTStructFilter.txx +++ b/common/clitkImage2DicomRTStructFilter.txx @@ -88,10 +88,22 @@ clitk::Image2DicomRTStructFilter::SetROIName(std::string name, std::s template void clitk::Image2DicomRTStructFilter::Update() { + // Check this is a RT-Struct + gdcm::Reader gdcm_reader; + gdcm_reader.SetFileName(m_StructureSetFilename.c_str()); + if (!gdcm_reader.Read()) { + clitkExceptionMacro("Error could not open the file '" << m_StructureSetFilename << std::endl); + } + gdcm::MediaStorage ms; + ms.SetFromFile(gdcm_reader.GetFile()); + if (ms != gdcm::MediaStorage::RTStructureSetStorage) { + clitkExceptionMacro("File '" << m_StructureSetFilename << "' is not a DICOM-RT-Struct file." << std::endl); + } + // Read rt struct vtkSmartPointer reader = vtkGDCMPolyDataReader::New(); reader->SetFileName(m_StructureSetFilename.c_str()); - reader->Update(); + reader->Update(); // Get properties vtkRTStructSetProperties * p = reader->GetRTStructSetProperties();