+#if GDCM_MAJOR_VERSION == 2
+ // Read gdcm file
+ mReader = new gdcm::Reader;
+ mReader->SetFileName(filename.c_str());
+ mReader->Read();
+ mFile = &(mReader->GetFile());
+ const gdcm::DataSet & ds = mFile->GetDataSet();
+
+ // Check file type
+ //Verify if the file is a RT-Structure-Set dicom file
+ gdcm::MediaStorage ms;
+ ms.SetFromFile(*mFile);
+ if( ms != gdcm::MediaStorage::RTStructureSetStorage )
+ {
+ std::cerr << "Error. the file " << filename
+ << " is not a Dicom Struct ? (must have a SOP Class UID [0008|0016] = 1.2.840.10008.5.1.4.1.1.481.3 ==> [RT Structure Set Storage])"
+ << std::endl;
+ exit(0);
+ }
+
+ gdcm::Attribute<0x8,0x60> modality;
+ modality.SetFromDataSet( ds );
+ if( modality.GetValue() != "RTSTRUCT" )
+ {
+ std::cerr << "Error. the file " << filename
+ << " is not a Dicom Struct ? (must have 0x0008,0x0060 = RTSTRUCT [RT Structure Set Storage])"
+ << std::endl;
+ exit(0);
+ }
+
+ // Read global info
+ gdcm::Attribute<0x20,0x10> studyid;
+ studyid.SetFromDataSet( ds );
+ gdcm::Attribute<0x8,0x20> studytime;
+ studytime.SetFromDataSet( ds );
+ gdcm::Attribute<0x8,0x30> studydate;
+ studydate.SetFromDataSet( ds );
+ gdcm::Attribute<0x3006,0x02> label;
+ label.SetFromDataSet( ds );
+ gdcm::Attribute<0x3006,0x04> atname;
+ atname.SetFromDataSet( ds );
+ gdcm::Attribute<0x3006,0x09> time;
+ time.SetFromDataSet( ds );
+
+ mStudyID = studyid.GetValue();
+ mStudyTime = studytime.GetValue();
+ mStudyDate = studydate.GetValue();
+ mLabel = label.GetValue();
+ mName = atname.GetValue();
+ mTime = time.GetValue();
+
+ // Temporary store the list of items
+ std::map<int, gdcm::Item*> mMapOfROIInfo;
+ std::map<int, gdcm::Item*> mMapOfROIContours;
+
+ //----------------------------------
+ // Read all ROI Names and number
+ // 0x3006,0x0020 = [ Structure Set ROI Sequence ]
+ gdcm::Tag tssroisq(0x3006,0x0020);
+ const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq );
+ mROIInfoSequenceOfItems = ssroisq.GetValueAsSQ();
+ gdcm::SmartPointer<gdcm::SequenceOfItems> & roi_seq = mROIInfoSequenceOfItems;
+ assert(roi_seq); // TODO error message
+ for(unsigned int ridx = 0; ridx < roi_seq->GetNumberOfItems(); ++ridx)
+ {
+ gdcm::Item & item = roi_seq->GetItem( ridx + 1); // Item starts at 1
+ const gdcm::DataSet& nestedds = item.GetNestedDataSet();