+#if GDCM_MAJOR_VERSION == 2
+//--------------------------------------------------------------------
+int clitk::DicomRT_StructureSet::ReadROINumber(const gdcm::Item & item)
+{
+ // 0x3006,0x0022 = [ROI Number]
+ const gdcm::DataSet & nestedds = item.GetNestedDataSet();
+ gdcm::Attribute<0x3006,0x0022> roinumber;
+ roinumber.SetFromDataSet( nestedds );
+ return roinumber.GetValue();
+}
+//--------------------------------------------------------------------
+#endif
+
+//--------------------------------------------------------------------
+void clitk::DicomRT_StructureSet::Write(const std::string & filename)
+{
+#if GDCM_MAJOR_VERSION == 2
+
+ // Assert that the gdcm file is still open (we can write only if it was readed)
+ if (mFile == NULL) {
+ //assert(mFile != NULL);
+ FATAL("Sorry, I can write DICOM only if it was read first from a file with 'Read' function");
+ }
+
+ // Loop and update each ROI
+ int i=0;
+ for(ROIIteratorType iter = mROIs.begin(); iter != mROIs.end(); iter++) {
+ iter->second->UpdateDicomItem();
+ i++;
+ }
+
+ // Write [ Structure Set ROI Sequence ] = 0x3006,0x0020
+ gdcm::DataSet & ds = mFile->GetDataSet();
+ gdcm::Tag tssroisq(0x3006,0x0020);
+ const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq );
+ gdcm::DataElement de(ssroisq);
+ de.SetValue(*mROIInfoSequenceOfItems);
+ ds.Replace(de);
+
+ // Write [ ROI Contour Sequence ] = 0x3006,0x0039
+ DD("ici");
+ gdcm::Tag troicsq(0x3006,0x0039);
+ const gdcm::DataElement &roicsq = ds.GetDataElement( troicsq );
+ gdcm::DataElement de2(roicsq);
+ de2.SetValue(*mROIContoursSequenceOfItems);
+ ds.Replace(de2);
+
+ //DEBUG
+ gdcm::DataSet & a = mROIContoursSequenceOfItems->GetItem(1).GetNestedDataSet();
+ gdcm::Tag tcsq(0x3006,0x0040);
+ const gdcm::DataElement& csq = a.GetDataElement( tcsq );
+ gdcm::SmartPointer<gdcm::SequenceOfItems> sqi2 = csq.GetValueAsSQ();
+ gdcm::Item & j = sqi2->GetItem(1);
+ gdcm::DataSet & b = j.GetNestedDataSet();
+ gdcm::Attribute<0x3006,0x0050> at;
+ gdcm::Tag tcontourdata(0x3006,0x0050);
+ gdcm::DataElement contourdata = b.GetDataElement( tcontourdata );
+ at.SetFromDataElement( contourdata );
+ const double* points = at.GetValues();
+ DD(points[0]);
+
+
+ // Write dicom
+ gdcm::Writer writer;
+ //writer.CheckFileMetaInformationOff();
+ writer.SetFileName(filename.c_str());
+ writer.SetFile(*mFile);
+ DD("before write");
+ writer.Write();
+ DD("End write");
+#else
+ FATAL("Sorry not compatible with GDCM1, use GDCM2");
+#endif
+}
+//--------------------------------------------------------------------
+
+