+ FATAL("Error : compile vv with itk4 + external gdcm");
+
+ // 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;
+
+std::map<int, clitk::DicomRT_ROI::Pointer> mROIs;
+ std::map<int, std::string> mMapOfROIName;
+#if GDCM_MAJOR_VERSION == 2
+ gdcm::Reader * mReader;
+ gdcm::SmartPointer<gdcm::SequenceOfItems> mROIInfoSequenceOfItems;
+ gdcm::SmartPointer<gdcm::SequenceOfItems> mROIContoursSequenceOfItems;
+#endif
+ gdcm::File * mFile;
+
+
+ //----------------------------------
+ // 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();
+
+ gdcm::Attribute<0x3006,0x26> roiname;
+ roiname.SetFromDataSet( nestedds );
+ std::string name = roiname.GetValue(); // 0x3006,0x0026 = [ROI Name]
+
+ // 0x3006,0x0022 = [ROI Number]
+ int nb = ReadROINumber(item);
+
+ // Store the item
+ mMapOfROIInfo[nb] = &item;
+
+ // Check if such a number already exist
+ if (mMapOfROIName.find(nb) != mMapOfROIName.end()) {
+ std::cerr << "WARNING. A Roi already exist with the number "
+ << nb << ". I replace." << std::endl;
+ }
+ // Add in map
+ mMapOfROIName[nb] = name;
+ }