From ef33edbce5ce9f897e3e6acbc5d36718407329c0 Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Fri, 3 Feb 2012 07:57:12 +0100 Subject: [PATCH] Read dicom-rt with vtkGDCMPolyDataReader --- common/clitkDicomRT_ROI.cxx | 75 ++++++++++++++++++++++++++++++++++--- common/clitkDicomRT_ROI.h | 10 +++++ 2 files changed, 80 insertions(+), 5 deletions(-) diff --git a/common/clitkDicomRT_ROI.cxx b/common/clitkDicomRT_ROI.cxx index 98f9f59..783b972 100644 --- a/common/clitkDicomRT_ROI.cxx +++ b/common/clitkDicomRT_ROI.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #if GDCM_MAJOR_VERSION == 2 #include "gdcmAttribute.h" @@ -394,24 +395,88 @@ void clitk::DicomRT_ROI::ComputeContoursFromImage() DDV(extent, 6); // std::vector extend; - // Prepare the marching squares - vtkSmartPointer squares = vtkSmartPointer::New(); - squares->SetInput(clipper->GetOutput()); // Loop on slice uint n = image->GetDimensions()[2]; DD(n); + DD(mListOfContours.size()); + mListOfContours.resize(n); /// ???FIXME + DD(mListOfContours.size()); + std::vector > contours; for(uint i=0; i squares = vtkSmartPointer::New(); + squares->SetInput(image); + squares->SetImageRange(extent[0], extent[1], extent[2], extent[3], i, i); + squares->SetValue(1, 1.0); + squares->Update(); + DD(squares->GetNumberOfContours()); + + //clitk::DicomRT_Contour * contour = new clitk::DicomRT_Contour(); + //mListOfContours[i]->SetMesh(squares->GetOutput()); + + + vtkSmartPointer m = squares->GetOutput(); + contours.push_back(m); + + /* // Clip to the current slice extent[4] = extent[5] = image->GetOrigin()[2]+i*image->GetSpacing()[2]; DDV(extent, 6); + // Prepare the marching squares + vtkSmartPointer squares = vtkSmartPointer::New(); clipper->SetOutputWholeExtent(extent[0],extent[1],extent[2], - extent[3],extent[4],extent[5]); - + extent[3],extent[4],extent[5]); + squares->SetInput(clipper->GetOutput()); squares->Update(); DD(squares->GetNumberOfContours()); mListOfContours[i]->SetMesh(squares->GetOutput()); + */ } + DD("done"); + + vtkSmartPointer append = vtkSmartPointer::New(); + for(unsigned int i=0; iAddInput(contours[i]); + } + append->Update(); + + mMesh = vtkSmartPointer::New(); + mMesh->DeepCopy(append->GetOutput()); + + // Write vtk + vtkPolyDataWriter * w = vtkPolyDataWriter::New(); + w->SetInput(mMesh); + w->SetFileName("toto.vtk"); + w->Write(); + + DD("done"); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +#if CLITK_USE_SYSTEM_GDCM == 1 +void clitk::DicomRT_ROI::Read(vtkSmartPointer & reader, int roiindex) +{ + vtkRTStructSetProperties * p = reader->GetRTStructSetProperties(); + + mName = p->GetStructureSetROIName(roiindex); + mNumber = p->GetStructureSetROINumber(roiindex); + //mColor = //FIXME !! + SetDicomUptodateFlag(true); + // Get the contour + mMesh = reader->GetOutput(roiindex); + DicomRT_Contour::Pointer c = DicomRT_Contour::New(); + c->SetMesh(mMesh); // FIXME no GetZ, not GetPoints + mMeshIsUpToDate = true; + mListOfContours.push_back(c); } +#endif //-------------------------------------------------------------------- + diff --git a/common/clitkDicomRT_ROI.h b/common/clitkDicomRT_ROI.h index 7be25a7..31d9db4 100644 --- a/common/clitkDicomRT_ROI.h +++ b/common/clitkDicomRT_ROI.h @@ -23,6 +23,12 @@ #include "clitkDicomRT_Contour.h" #include "vvImage.h" +#include "clitkConfiguration.h" +#if CLITK_USE_SYSTEM_GDCM == 1 +#include +#include +#endif + namespace clitk { //-------------------------------------------------------------------- @@ -76,6 +82,10 @@ public: void Read(std::map & rois, gdcm::SQItem * item); #endif +#if CLITK_USE_SYSTEM_GDCM == 1 + void Read(vtkSmartPointer & reader, int roiindex); +#endif + protected: std::string mName; std::string mFilename; -- 2.47.1