X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMeshReader.cxx;h=fb0baf47a10c0edd5cd9ef7edb01dbab36db1bf6;hb=431fea9a7c825943b07fc4b4f3423355a5fee501;hp=92939bdc0d5442ee5cc6eb27df8af9ae9bb9addd;hpb=42e71d936b3f3f8b261bc7668bc724fa4ea5be0b;p=clitk.git diff --git a/vv/vvMeshReader.cxx b/vv/vvMeshReader.cxx index 92939bd..fb0baf4 100644 --- a/vv/vvMeshReader.cxx +++ b/vv/vvMeshReader.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,13 +14,20 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #include #include -#include -#include +#include +#if GDCM_MAJOR_VERSION == 2 + #include + #include + #include +#else + #include + #include +#endif #include #include @@ -80,6 +87,36 @@ void vvMeshReader::run() std::vector > vvMeshReader::GetROINames() { assert(filename!=""); + std::vector > roi_names; +#if GDCM_MAJOR_VERSION == 2 + // duplicate code from clitk::DicomRT_StructureSet::Read + gdcm::Reader reader; + reader.SetFileName( filename.c_str() ); + reader.Read(); + + const gdcm::DataSet &ds = reader.GetFile().GetDataSet(); + + gdcm::Tag tssroisq(0x3006,0x0020); + const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq ); + gdcm::SmartPointer roi_seq = ssroisq.GetValueAsSQ(); + 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(); + if( nestedds.FindDataElement( gdcm::Tag(0x3006,0x22) ) ) + { + gdcm::Attribute<0x3006,0x26> roiname; + roiname.SetFromDataSet( nestedds ); + std::string name = roiname.GetValue(); // 0x3006,0x0026 = [ROI Name] + gdcm::Attribute<0x3006,0x0022> roinumber; + roinumber.SetFromDataSet( nestedds ); + int nb = roinumber.GetValue(); // 0x3006,0x0022 = [ROI Number] + + roi_names.push_back(make_pair(nb,name)); + } + } +#else gdcm::File reader; reader.SetFileName(filename.c_str()); reader.SetMaxSizeLoadEntry(16384); @@ -87,23 +124,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 +199,7 @@ std::vector vvMeshReader::readSelectedContours() } k=roi_info->GetNextSQItem(); //increment the second loop variable } +#endif return result; }