X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkDicomRT_Contour.cxx;h=6059f03b6644799d1bfff59410b17d499355e5b4;hb=f9ba8e0c066f58c8d9f2b10db4306f42470fe7a2;hp=ac6d441e3b82694f59a532d154759a319b7374f4;hpb=163fa80ef3873595f3e3cf75fb03e53536d1a6ee;p=clitk.git diff --git a/common/clitkDicomRT_Contour.cxx b/common/clitkDicomRT_Contour.cxx index ac6d441..6059f03 100644 --- a/common/clitkDicomRT_Contour.cxx +++ b/common/clitkDicomRT_Contour.cxx @@ -2,7 +2,7 @@ Program: vv http://www.creatis.insa-lyon.fr/rio/vv Main authors : XX XX XX - Authors belongs to: + Authors belongs to: - University of LYON http://www.universite-lyon.fr/ - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr @@ -17,69 +17,77 @@ =========================================================================*/ -#include "clitkDicomRT_Contour.h" +#include "clitkDicomRT_Contour.h" #include //-------------------------------------------------------------------- -clitk::DicomRT_Contour::DicomRT_Contour() { +clitk::DicomRT_Contour::DicomRT_Contour() +{ mMeshIsUpToDate = false; mNbOfPoints = 0; + mZ = -1; } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -clitk::DicomRT_Contour::~DicomRT_Contour() { - +clitk::DicomRT_Contour::~DicomRT_Contour() +{ + } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void clitk::DicomRT_Contour::Print(std::ostream & os) const { +void clitk::DicomRT_Contour::Print(std::ostream & os) const +{ DD("TODO : print Contours"); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item) { - +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)); // DD(mNbOfPoints); - + // Read values [Contour Data] std::vector points = parse_string(item->GetEntryValue(0x3006,0x0050),'\\'); assert(points.size() == static_cast(mNbOfPoints)*3); - + // Organize values mData = vtkPoints::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); } } @@ -89,7 +97,8 @@ bool clitk::DicomRT_Contour::Read(gdcm::SQItem * item) { //-------------------------------------------------------------------- -vtkPolyData * clitk::DicomRT_Contour::GetMesh() { +vtkPolyData * clitk::DicomRT_Contour::GetMesh() +{ if (!mMeshIsUpToDate) { ComputeMesh(); } @@ -99,17 +108,18 @@ vtkPolyData * clitk::DicomRT_Contour::GetMesh() { //-------------------------------------------------------------------- -void clitk::DicomRT_Contour::ComputeMesh() { - // DD("ComputeMesh Contour"); +void clitk::DicomRT_Contour::ComputeMesh() +{ +// DD("ComputeMesh Contour"); mMesh = vtkPolyData::New(); mMesh->Allocate(); //for cell structures mMesh->SetPoints(vtkPoints::New()); vtkIdType ids[2]; for (unsigned int idx=0 ; idxGetPoints()->InsertNextPoint(mData->GetPoint(idx)[0], - mData->GetPoint(idx)[1], + mMesh->GetPoints()->InsertNextPoint(mData->GetPoint(idx)[0], + mData->GetPoint(idx)[1], mData->GetPoint(idx)[2]); - ids[0]=idx; + ids[0]=idx; ids[1]=(ids[0]+1) % mNbOfPoints; //0-1,1-2,...,n-1-0 // DD(ids[0]); // DD(ids[1]);