From: delmon Date: Thu, 31 Mar 2011 15:24:50 +0000 (+0000) Subject: Mathieu Malaterre : X-Git-Tag: v1.2.0~77 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=c69e6ac8e16ac42d32f3a13d60396ddf65616188;p=clitk.git Mathieu Malaterre : - From gdcm 1.x to gdcm 2.0 clitk should compile with itk 3.20 and gdcm 2.0 --- diff --git a/common/clitkDicomRTDoseIO.cxx b/common/clitkDicomRTDoseIO.cxx index 02d953e..da35bb8 100644 --- a/common/clitkDicomRTDoseIO.cxx +++ b/common/clitkDicomRTDoseIO.cxx @@ -22,6 +22,10 @@ // itk include #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 +// which also properly recognize RTDOSE #include #include #else @@ -278,6 +282,9 @@ void clitk::DicomRTDoseIO::Read(void * buffer) #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... #else float *img = (float*) buffer; diff --git a/common/clitkDicomRT_Contour.cxx b/common/clitkDicomRT_Contour.cxx index 9a98045..9f63dac 100644 --- a/common/clitkDicomRT_Contour.cxx +++ b/common/clitkDicomRT_Contour.cxx @@ -48,6 +48,8 @@ void clitk::DicomRT_Contour::Print(std::ostream & os) const //-------------------------------------------------------------------- +#if GDCM_MAJOR_VERSION == 2 +#else bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item) { @@ -93,6 +95,7 @@ bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item) return true; } +#endif //-------------------------------------------------------------------- diff --git a/common/clitkDicomRT_Contour.h b/common/clitkDicomRT_Contour.h index 88100f4..53a1875 100644 --- a/common/clitkDicomRT_Contour.h +++ b/common/clitkDicomRT_Contour.h @@ -21,8 +21,12 @@ #define CLITKDICOMRT_CONTOUR_H #include "clitkCommon.h" +#include +#if GDCM_MAJOR_VERSION == 2 +#else #include #include +#endif #include #include #include @@ -38,7 +42,10 @@ public: itkNewMacro(Self); void Print(std::ostream & os = std::cout) const; +#if GDCM_MAJOR_VERSION == 2 +#else bool Read(gdcm::SQItem * item); +#endif vtkPolyData * GetMesh(); vtkPoints * GetPoints() {return mData;} double GetZ() const {return mZ;} diff --git a/common/clitkDicomRT_ROI.cxx b/common/clitkDicomRT_ROI.cxx index 0219b4a..67e5341 100644 --- a/common/clitkDicomRT_ROI.cxx +++ b/common/clitkDicomRT_ROI.cxx @@ -129,6 +129,8 @@ double clitk::DicomRT_ROI::GetForegroundValueLabelImage() const //-------------------------------------------------------------------- +#if GDCM_MAJOR_VERSION == 2 +#else void clitk::DicomRT_ROI::Read(std::map & rois, gdcm::SQItem * item) { @@ -167,6 +169,7 @@ void clitk::DicomRT_ROI::Read(std::map & rois, gdcm::SQItem * } } } +#endif //-------------------------------------------------------------------- diff --git a/common/clitkDicomRT_ROI.h b/common/clitkDicomRT_ROI.h index b05b9d6..8a24b47 100644 --- a/common/clitkDicomRT_ROI.h +++ b/common/clitkDicomRT_ROI.h @@ -35,7 +35,10 @@ public: itkNewMacro(Self); void Print(std::ostream & os = std::cout) const; +#if GDCM_MAJOR_VERSION == 2 +#else void Read(std::map & rois, gdcm::SQItem * item); +#endif void SetFromBinaryImage(vvImage * image, int n, std::string name, std::vector color, diff --git a/common/clitkDicomRT_StructureSet.cxx b/common/clitkDicomRT_StructureSet.cxx index 9d128b8..fb2d9a2 100644 --- a/common/clitkDicomRT_StructureSet.cxx +++ b/common/clitkDicomRT_StructureSet.cxx @@ -19,6 +19,10 @@ #include "clitkDicomRT_StructureSet.h" #include +#include "gdcmFile.h" +#if GDCM_MAJOR_VERSION == 2 +#include "vtkGDCMPolyDataReader.h" +#endif //-------------------------------------------------------------------- clitk::DicomRT_StructureSet::DicomRT_StructureSet() @@ -140,6 +144,10 @@ void clitk::DicomRT_StructureSet::Print(std::ostream & os) const void clitk::DicomRT_StructureSet::Read(const std::string & filename) { // Open DICOM +#if GDCM_MAJOR_VERSION == 2 + vtkGDCMPolyDataReader * reader = vtkGDCMPolyDataReader::New(); + reader->SetFileName( filename.c_str() ); +#else gdcm::File reader; reader.SetFileName(filename.c_str()); reader.SetMaxSizeLoadEntry(16384); // Needed ... @@ -205,6 +213,7 @@ void clitk::DicomRT_StructureSet::Read(const std::string & filename) n++; } +#endif } //-------------------------------------------------------------------- diff --git a/vv/vvMeshReader.cxx b/vv/vvMeshReader.cxx index 92939bd..fc420d4 100644 --- a/vv/vvMeshReader.cxx +++ b/vv/vvMeshReader.cxx @@ -19,8 +19,12 @@ #include +#include +#if GDCM_MAJOR_VERSION == 2 +#else #include #include +#endif #include #include @@ -80,6 +84,9 @@ void vvMeshReader::run() std::vector > vvMeshReader::GetROINames() { assert(filename!=""); + std::vector > roi_names; +#if GDCM_MAJOR_VERSION == 2 +#else gdcm::File reader; reader.SetFileName(filename.c_str()); reader.SetMaxSizeLoadEntry(16384); @@ -87,23 +94,25 @@ std::vector > vvMeshReader::GetROINames() gdcm::SeqEntry * roi_info=reader.GetSeqEntry(0x3006,0x0020); assert(roi_info); - std::vector > roi_names; // DD("ici"); //int n=0; for (gdcm::SQItem* i=roi_info->GetFirstSQItem(); i!=0; i=roi_info->GetNextSQItem()) if (i->GetEntryValue(0x3006,0x0022)!= gdcm::GDCM_UNFOUND) roi_names.push_back(make_pair(atoi(i->GetEntryValue(0x3006,0x0022).c_str()),i->GetEntryValue(0x3006,0x0026))); +#endif return roi_names; } std::vector vvMeshReader::readSelectedContours() { + std::vector result; +#if GDCM_MAJOR_VERSION == 2 +#else gdcm::File reader; reader.SetFileName(filename.c_str()); reader.SetMaxSizeLoadEntry(16384); reader.Load(); - std::vector result; gdcm::SeqEntry * rois=reader.GetSeqEntry(0x3006,0x0039); ///We need to iterate both on the contours themselves, and on the contour info gdcm::SeqEntry * roi_info=reader.GetSeqEntry(0x3006,0x0020); @@ -160,6 +169,7 @@ std::vector vvMeshReader::readSelectedContours() } k=roi_info->GetNextSQItem(); //increment the second loop variable } +#endif return result; } diff --git a/vv/vvQDicomSeriesSelector.cxx b/vv/vvQDicomSeriesSelector.cxx index 2102ddb..2740767 100644 --- a/vv/vvQDicomSeriesSelector.cxx +++ b/vv/vvQDicomSeriesSelector.cxx @@ -20,7 +20,13 @@ #include #include #include +#if GDCM_MAJOR_VERSION == 2 +#include +#include +#include +#else #include +#endif #include "vvQDicomSeriesSelector.h" //#include "vvUserConfig.h" @@ -129,6 +135,12 @@ void vvDicomSeriesSelector::SearchButtonRelease() mListOfSeriesFilenames[seriesUID[i]] = filenames; // store first header +#if GDCM_MAJOR_VERSION == 2 + gdcm::ImageReader reader; + reader.SetFileName( (*filenames)[0].c_str() ); + reader.Read(); + mDicomHeader[seriesUID[i]] = &reader.GetFile(); +#else gdcm::File *header = new gdcm::File(); header->SetFileName((*filenames)[0]); header->SetMaxSizeLoadEntry(16384); @@ -167,6 +179,7 @@ void vvDicomSeriesSelector::SearchButtonRelease() mDicomHeader[seriesUID[i]] = header; +#endif // new item QListWidgetItem *newItem = new QListWidgetItem; @@ -216,6 +229,32 @@ void vvDicomSeriesSelector::itemDetailsSelectionChanged() QString l; gdcm::File * header = mDicomHeader[mCurrentSerie]; +#if GDCM_MAJOR_VERSION == 2 + gdcm::StringFilter sf; + sf.SetFile( *header ); + gdcm::DataSet &ds = header->GetDataSet(); + gdcm::DataSet::ConstIterator it = ds.Begin(); + for (; it != ds.End(); ++it ) + { + const gdcm::DataElement & ref = *it; + const gdcm::Tag & tag = ref.GetTag(); + gdcm::VR vr = gdcm::DataSetHelper::ComputeVR(*header, ds, tag); + if ( vr & ( gdcm::VR::OB | gdcm::VR::OF | gdcm::VR::OW | gdcm::VR::SQ | gdcm::VR::UN ) ) + { + // What is the behavior for binary stuff ? + } + else /* if ( vr & gdcm::VR::VRASCII ) */ + { + if ( tag.IsPublic() ) + { + std::pair p = sf.ToStringPair(tag); + l += QString("%1 : %2\n") + .arg( p.first.c_str() ) + .arg( p.second.c_str() ); + } + } + } +#else gdcm::DocEntry * e = header->GetFirstEntry(); while (e) { if (e->GetName() != "gdcm::Unknown") { @@ -225,6 +264,7 @@ void vvDicomSeriesSelector::itemDetailsSelectionChanged() } e = header->GetNextEntry(); } +#endif mDicomDetails[(*mFilenames)[i]] = l.toStdString(); } @@ -237,6 +277,9 @@ void vvDicomSeriesSelector::itemDetailsSelectionChanged() QString vvDicomSeriesSelector::MakeDicomInfo(std::string & s, gdcm::File *header) { QString n = QString("%1").arg(mListOfSeriesFilenames[s]->size()); +#if GDCM_MAJOR_VERSION == 2 + QString ss; +#else QString size = QString("%1x%2x%3") .arg(header->GetXSize()) .arg(header->GetYSize()) @@ -262,6 +305,7 @@ QString vvDicomSeriesSelector::MakeDicomInfo(std::string & s, gdcm::File *header AddInfo( "Origin : ", origin.toStdString())+ AddInfo(header, "Pixel size : ", 0x0028,0x0100)+ AddInfo( "Pixel type : ", header->GetPixelType()); +#endif return ss; } //==================================================================== @@ -269,7 +313,15 @@ QString vvDicomSeriesSelector::MakeDicomInfo(std::string & s, gdcm::File *header //==================================================================== QString vvDicomSeriesSelector::AddInfo(gdcm::File *header, QString n, uint16_t group, uint16_t elem) { +#if GDCM_MAJOR_VERSION == 2 + gdcm::StringFilter sf; + sf.SetFile( *header ); + gdcm::Tag t( group, elem ); + std::string s = sf.ToString( t ); + return AddInfo(n.toStdString(), s); +#else return AddInfo(n.toStdString(), header->GetEntryValue(group, elem)); +#endif } //==================================================================== @@ -285,6 +337,8 @@ QString vvDicomSeriesSelector::AddInfo(std::string n, std::string m) //==================================================================== void vvDicomSeriesSelector::AddSerieToTheTable(int i, std::vector & filenames) { +#if GDCM_MAJOR_VERSION == 2 +#else gdcm::File *header = new gdcm::File(); header->SetFileName(filenames[0]); header->SetMaxSizeLoadEntry(16384); @@ -303,6 +357,7 @@ void vvDicomSeriesSelector::AddSerieToTheTable(int i, std::vector & DD(ui.mTableWidget->rowCount()); ui.mTableWidget->setItem(i, 0, newItem); */ +#endif } //====================================================================