From 89a8fa2bb1c1b40c20011729ee6dca940ce96496 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 3 Feb 2012 07:57:12 +0100 Subject: [PATCH] Use vtkGDCMPolyDataReader to read mesh --- vv/vvMeshReader.cxx | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/vv/vvMeshReader.cxx b/vv/vvMeshReader.cxx index 736dbcf..d740ea7 100644 --- a/vv/vvMeshReader.cxx +++ b/vv/vvMeshReader.cxx @@ -110,17 +110,16 @@ std::vector > vvMeshReader::GetROINames() DD(GDCM_MAJOR_VERSION); DD(CLITK_USE_SYSTEM_GDCM); -#if GDCM_MAJOR_VERSION == 2 - +#if CLITK_USE_SYSTEM_GDCM == 1 // Read RT-struct data DD("before read"); - vtkSmartPointer reader = vtkGDCMPolyDataReader::New(); - reader->SetFileName(filename.c_str()); - reader->Update(); + vtkSmartPointer areader = vtkGDCMPolyDataReader::New(); + areader->SetFileName(filename.c_str()); + areader->Update(); DD("after read"); // get info on roi names - vtkRTStructSetProperties * p = reader->GetRTStructSetProperties(); + vtkRTStructSetProperties * p = areader->GetRTStructSetProperties(); DD(p->GetNumberOfStructureSetROIs()); DD(p->GetStructureSetROIName(0)); DD(p->GetStructureSetROINumber(0)); @@ -133,20 +132,16 @@ std::vector > vvMeshReader::GetROINames() roi_names.push_back(make_pair(nb,name)); } - // ==================== +#else +#if GDCM_MAJOR_VERSION == 2 - if (false) { // duplicate code from clitk::DicomRT_StructureSet::Read gdcm::Reader * reader = new gdcm::Reader; reader->SetFileName( filename.c_str() ); reader->Read(); - DD("after gdcm read"); const gdcm::DataSet &ds = reader->GetFile().GetDataSet(); - DD("after ds"); - DD(ds.IsEmpty()); - // Check file type //Verify if the file is a RT-Structure-Set dicom file gdcm::File * mFile = &(reader->GetFile()); @@ -172,7 +167,6 @@ std::vector > vvMeshReader::GetROINames() gdcm::Attribute<0x20,0x10> studyid; studyid.SetFromDataSet( ds ); - DD(studyid.GetValue()); gdcm::Tag tssroisq(0x3006,0x0020); // 0x3006,0x0020 = [ Structure Set ROI Sequence ] @@ -182,38 +176,29 @@ std::vector > vvMeshReader::GetROINames() } const gdcm::DataElement &ssroisq = ds.GetDataElement( tssroisq ); - DD("after ssroisq"); gdcm::SmartPointer roi_seq = ssroisq.GetValueAsSQ(); assert(roi_seq); // FIXME error message - DD(roi_seq->GetNumberOfItems()); - for(unsigned int ridx = 0; ridx < roi_seq->GetNumberOfItems(); ++ridx) { - DD(ridx); - gdcm::Item & item = roi_seq->GetItem( ridx + 1); // Item starts at 1 + gdcm::Item & item = roi_seq->GetItem( ridx + 1); // Item starts at 1 const gdcm::Item & sitem = roi_seq->GetItem(ridx+1); // Item start at #1 const gdcm::DataSet& snestedds = sitem.GetNestedDataSet(); const gdcm::DataSet& nestedds = item.GetNestedDataSet(); - DD(nestedds.IsEmpty()); - if( snestedds.FindDataElement( gdcm::Tag(0x3006,0x22) ) ) { - DD("tag found"); // const gdcm::DataElement & a = nestedds.GetDataElement(gdcm::Tag(0x3006,0x26)); // DD(a.GetValue()); gdcm::Attribute<0x3006,0x26> roiname; roiname.SetFromDataSet( snestedds ); std::string name = roiname.GetValue(); // 0x3006,0x0026 = [ROI Name] - DD(name); gdcm::Attribute<0x3006,0x0022> roinumber; roinumber.SetFromDataSet( snestedds ); int nb = roinumber.GetValue(); // 0x3006,0x0022 = [ROI Number] - DD(nb); roi_names.push_back(make_pair(nb,name)); } @@ -221,8 +206,6 @@ std::vector > vvMeshReader::GetROINames() delete reader; - } - #else gdcm::File reader; reader.SetFileName(filename.c_str()); @@ -237,7 +220,10 @@ std::vector > vvMeshReader::GetROINames() 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 +#endif + return roi_names; + } //------------------------------------------------------------------------------ @@ -247,6 +233,13 @@ std::vector vvMeshReader::readSelectedContours() { std::vector result; #if GDCM_MAJOR_VERSION == 2 + +#if CLITK_USE_SYSTEM_GDCM == 0 + + clitkExceptionMacro("ERROR ! You need to compile vv with itk4 + system_gdcm to use this function"); + +#endif + gdcm::Reader reader; reader.SetFileName(filename.c_str()); reader.Read(); -- 2.47.1