X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkDicomRT_Contour.cxx;h=0cc62b0439c74dc7a756e050792f0a8e8a2d3dd9;hb=265fe0b1cf2d218f079ca8a5e85d2cbfcec42d9e;hp=5c12802cf31bac02917995319718bbb22723cd38;hpb=1e034c70105f0926939acaaa27ddb46e904ae8bf;p=clitk.git diff --git a/common/clitkDicomRT_Contour.cxx b/common/clitkDicomRT_Contour.cxx index 5c12802..0cc62b0 100644 --- a/common/clitkDicomRT_Contour.cxx +++ b/common/clitkDicomRT_Contour.cxx @@ -4,7 +4,7 @@ Authors belongs 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 @@ -20,11 +20,17 @@ #include "clitkDicomRT_Contour.h" #include +#if GDCM_MAJOR_VERSION == 2 +#include "gdcmAttribute.h" +#include "gdcmItem.h" +#endif + //-------------------------------------------------------------------- clitk::DicomRT_Contour::DicomRT_Contour() { mMeshIsUpToDate = false; mNbOfPoints = 0; + mZ = -1; } //-------------------------------------------------------------------- @@ -47,16 +53,76 @@ void clitk::DicomRT_Contour::Print(std::ostream & os) const //-------------------------------------------------------------------- +#if GDCM_MAJOR_VERSION == 2 +bool clitk::DicomRT_Contour::Read(gdcm::Item const & item) +{ + const gdcm::DataSet& nestedds2 = item.GetNestedDataSet(); + + // Contour type [Contour Geometric Type] + gdcm::Attribute<0x3006,0x0042> contgeotype; + contgeotype.SetFromDataSet( nestedds2 ); + + if (contgeotype.GetValue() != "CLOSED_PLANAR " && contgeotype.GetValue() != "POINT ") { ///WARNING to the space after the name ... + //std::cerr << "Skip this contour : type=" << mType << std::endl; + return false; + } + if (contgeotype.GetValue() == "POINT ") { + std::cerr << "Warning: POINT type not fully supported. (don't use GetMesh() with this!)" + << std::endl; + } + + gdcm::Attribute<0x3006,0x0046> numcontpoints; + numcontpoints.SetFromDataSet( nestedds2 ); + // Number of points [Number of Contour Points] + mNbOfPoints = numcontpoints.GetValue(); + // DD(mNbOfPoints); + + gdcm::Attribute<0x3006,0x0050> at; + gdcm::Tag tcontourdata(0x3006,0x0050); + const gdcm::DataElement & contourdata = nestedds2.GetDataElement( tcontourdata ); + at.SetFromDataElement( contourdata ); + const double* points = at.GetValues(); + + assert(at.GetNumberOfValues() == static_cast(mNbOfPoints)*3); + + // Organize values + mData = vtkSmartPointer::New(); + mData->SetDataTypeToDouble(); + mData->SetNumberOfPoints(mNbOfPoints); + for(unsigned int i=0; iSetPoint(i, p); + if (mZ == -1) mZ = p[2]; + if (p[2] != mZ) { + DD(i); + DD(p[2]); + DD(mZ); + std::cout << "ERROR ! contour not in the same slice" << std::endl; + assert(p[2] == mZ); + } + } + + return true; + +} +#else bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item) { // Contour type [Contour Geometric Type] mType = item->GetEntryValue(0x3006,0x0042); // DD(mType); - if (mType != "CLOSED_PLANAR ") { ///WARNING to the space after the name ... - std::cerr << "Skip this contour : type=" << mType << std::endl; + if (mType != "CLOSED_PLANAR " && mType != "POINT ") { ///WARNING to the space after the name ... + //std::cerr << "Skip this contour : type=" << mType << std::endl; return false; } + if (mType == "POINT ") { + std::cerr << "Warning: POINT type not fully supported. (don't use GetMesh() with this!)" + << std::endl; + } // Number of points [Number of Contour Points] mNbOfPoints = parse_value(item->GetEntryValue(0x3006,0x0046)); @@ -67,28 +133,28 @@ bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item) assert(points.size() == static_cast(mNbOfPoints)*3); // Organize values - mData = vtkPoints::New(); + mData = vtkSmartPointer::New(); mData->SetDataTypeToDouble(); mData->SetNumberOfPoints(mNbOfPoints); - double z = -1; for(unsigned int i=0; iSetPoint(i, p); - if (z == -1) z = p[2]; - if (p[2] != z) { + if (mZ == -1) mZ = p[2]; + if (p[2] != mZ) { DD(i); DD(p[2]); - DD(z); + DD(mZ); std::cout << "ERROR ! contour not in the same slice" << std::endl; - assert(p[2] == z); + assert(p[2] == mZ); } } return true; } +#endif //-------------------------------------------------------------------- @@ -107,9 +173,10 @@ vtkPolyData * clitk::DicomRT_Contour::GetMesh() void clitk::DicomRT_Contour::ComputeMesh() { // DD("ComputeMesh Contour"); - mMesh = vtkPolyData::New(); + mMesh = vtkSmartPointer::New(); mMesh->Allocate(); //for cell structures - mMesh->SetPoints(vtkPoints::New()); + mPoints = vtkSmartPointer::New(); + mMesh->SetPoints(mPoints); vtkIdType ids[2]; for (unsigned int idx=0 ; idxGetPoints()->InsertNextPoint(mData->GetPoint(idx)[0],