#include "clitkCommon.h"
// itk include
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
// IMPLEMENTATION NOTE:
// The following has been done without the use of vtkGDCMImageReader which directly
// handle RTDOSE image. Another approach would have been to use gdcm::ImageReader
int rc;
#endif
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
m_GdcmImageReader.SetFileName(m_FileName.c_str());
m_GdcmImageReader.Read();
gdcm::File* m_GdcmFile = &m_GdcmImageReader.GetFile();
#endif
/* Modality -- better be RTSTRUCT */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::DataSet &ds = m_GdcmFile->GetDataSet();
gdcm::Attribute<0x8,0x60> at1;
}
/* ImagePositionPatient */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Attribute<0x20,0x32> at2;
at2.SetFromDataSet(ds);
ipp[0] = at2.GetValue(0);
#endif
/* Rows */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Attribute<0x28,0x10> at3;
at3.SetFromDataSet(ds);
dim[1] = at3.GetValue();
#endif
/* Columns */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Attribute<0x28,0x11> at4;
at4.SetFromDataSet(ds);
dim[0] = at4.GetValue();
#endif
/* PixelSpacing */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Attribute<0x28,0x30> at5;
at5.SetFromDataSet(ds);
spacing[0] = at5.GetValue(0);
#endif
/* GridFrameOffsetVector */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Attribute<0x3004,0x000C> at6;
const gdcm::DataElement& de6 = ds.GetDataElement( at6.GetTag() );
at6.SetFromDataElement(de6);
#endif
/* DoseGridScaling */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Attribute<0x3004,0x000E> at7 = { 1. } ;
at7.SetFromDataSet(ds);
m_DoseScaling = at7.GetValue();
// Read Image Information
bool clitk::DicomRTDoseIO::CanReadFile(const char* FileNameToRead)
{
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Reader creader;
creader.SetFileName(FileNameToRead);
if (!creader.Read())
npix *= GetDimensions(i);
/* PixelData */
-#if GDCM_MAJOR_VERSION == 2
+#if GDCM_MAJOR_VERSION >= 2
gdcm::Image &i = m_GdcmImageReader.GetImage();
- i.GetBuffer((char*)buffer);
- // WARNING: GetBuffer return the pixel values as stored on disk not the real pixel value
- // we still need to multiply by m_DoseScaling
- // An alternate solution would be to use vtkGDCMImageReader...
+
+ char* image_data = new char[i.GetBufferLength()];
+ i.GetBuffer(image_data);
+
+ gdcm::DataSet& ds = m_GdcmImageReader.GetFile().GetDataSet();
+ float *img = (float*) buffer;
+
+ gdcm::Attribute<0x28, 0x100> pixel_size;
+ pixel_size.SetFromDataSet(ds);
+ if (pixel_size.GetValue() == 16) {
+ unsigned short* image_data2 = (unsigned short*) image_data ;
+ dose_copy_raw (img, image_data2, npix, m_DoseScaling);
+ }
+ else if (pixel_size.GetValue() == 32) {
+ unsigned long* image_data2 = (unsigned long*) image_data;
+ dose_copy_raw (img, image_data2, npix, m_DoseScaling);
+ } else {
+ itkExceptionMacro(<< "Error RTDOSE not type 16U and 32U (type="
+ << pixel_size.GetValue() << ")");
+ }
+
+ delete [] image_data;
#else
float *img = (float*) buffer;