From: David Sarrut Date: Fri, 3 Feb 2012 06:57:12 +0000 (+0100) Subject: Read with vtkGDCMPolyDataReader X-Git-Tag: v1.4.0~229^2~18 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9ad40998f59e733989f28f05bed0299979848638;p=clitk.git Read with vtkGDCMPolyDataReader --- diff --git a/common/clitkDicomRT_StructureSet.cxx b/common/clitkDicomRT_StructureSet.cxx index 761ea23..51c715e 100644 --- a/common/clitkDicomRT_StructureSet.cxx +++ b/common/clitkDicomRT_StructureSet.cxx @@ -110,6 +110,8 @@ const std::string & clitk::DicomRT_StructureSet::GetTime() const //-------------------------------------------------------------------- clitk::DicomRT_ROI* clitk::DicomRT_StructureSet::GetROIFromROINumber(int n) { + DD("GetROIFromROINumber"); + DD(n); if (mROIs.find(n) == mROIs.end()) { std::cerr << "No ROI number " << n << std::endl; return NULL; @@ -257,8 +259,10 @@ void clitk::DicomRT_StructureSet::Write(const std::string & filename) } // 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 @@ -310,8 +314,41 @@ void clitk::DicomRT_StructureSet::Write(const std::string & filename) //-------------------------------------------------------------------- void clitk::DicomRT_StructureSet::Read(const std::string & filename) { + DD(GDCM_MAJOR_VERSION); + DD(CLITK_USE_SYSTEM_GDCM); + +#if CLITK_USE_SYSTEM_GDCM == 1 + vtkSmartPointer reader = vtkGDCMPolyDataReader::New(); + reader->SetFileName(filename.c_str()); + reader->Update(); + + // FIXME : check + + // Get global information + // FIXME (could be remove with a single access to properties objet. + vtkRTStructSetProperties * p = reader->GetRTStructSetProperties(); + mStudyID = p->GetStudyInstanceUID(); + mStudyDate = p->GetStructureSetDate(); + mLabel = p->GetStructureSetLabel(); + mName = p->GetStructureSetName(); + mTime = p->GetStructureSetTime(); + + int n = p->GetNumberOfStructureSetROIs(); + for(unsigned int i=0; iGetStructureSetROINumber(i); + // Create the roi + DicomRT_ROI::Pointer roi = DicomRT_ROI::New(); + roi->Read(reader, i); + // Insert in the map + mROIs[roinumber] = roi; + } +#endif // END version with system gdcm (vtkGDCMPolyDataReader) + + // Open DICOM #if GDCM_MAJOR_VERSION == 2 + // Read gdcm file mReader = new gdcm::Reader; mReader->SetFileName(filename.c_str()); @@ -365,6 +402,16 @@ void clitk::DicomRT_StructureSet::Read(const std::string & filename) // Temporary store the list of items std::map mMapOfROIInfo; std::map mMapOfROIContours; + +std::map mROIs; + std::map mMapOfROIName; +#if GDCM_MAJOR_VERSION == 2 + gdcm::Reader * mReader; + gdcm::SmartPointer mROIInfoSequenceOfItems; + gdcm::SmartPointer mROIContoursSequenceOfItems; +#endif + gdcm::File * mFile; + //---------------------------------- // Read all ROI Names and number diff --git a/common/clitkDicomRT_StructureSet.h b/common/clitkDicomRT_StructureSet.h index 145e0a0..c26122e 100644 --- a/common/clitkDicomRT_StructureSet.h +++ b/common/clitkDicomRT_StructureSet.h @@ -36,6 +36,7 @@ // gdcm #if GDCM_MAJOR_VERSION == 2 +// This is not use if CLITK_USE_SYSTEM_GDCM==1 #include "gdcmReader.h" #include "gdcmWriter.h" #include "gdcmAttribute.h"