From 261a091dbabc5df821d4220a5a4a55f35e4d8eb0 Mon Sep 17 00:00:00 2001 From: srit Date: Fri, 25 Mar 2011 12:52:10 +0000 Subject: [PATCH] Removed old files, now in common --- tools/clitkDicomRT_ROI.cxx | 117 ----------- tools/clitkDicomRT_ROI.h | 55 ----- .../clitkDicomRT_ROI_ConvertToImageFilter.cxx | 191 ------------------ tools/clitkDicomRT_ROI_ConvertToImageFilter.h | 58 ------ 4 files changed, 421 deletions(-) delete mode 100644 tools/clitkDicomRT_ROI.cxx delete mode 100644 tools/clitkDicomRT_ROI.h delete mode 100644 tools/clitkDicomRT_ROI_ConvertToImageFilter.cxx delete mode 100644 tools/clitkDicomRT_ROI_ConvertToImageFilter.h diff --git a/tools/clitkDicomRT_ROI.cxx b/tools/clitkDicomRT_ROI.cxx deleted file mode 100644 index d140398..0000000 --- a/tools/clitkDicomRT_ROI.cxx +++ /dev/null @@ -1,117 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Main authors : XX XX XX - - 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 - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - BSD http://www.opensource.org/licenses/bsd-license.php - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - - =========================================================================*/ - -#include "clitkDicomRT_ROI.h" -#include -#include - -//-------------------------------------------------------------------- -clitk::DicomRT_ROI::DicomRT_ROI() { - mName = "NoName"; - mNumber = -1; - mColor.resize(3); - mColor[0] = mColor[1] = mColor[2] = 0; - mMeshIsUpToDate = false; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -clitk::DicomRT_ROI::~DicomRT_ROI() { - -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -int clitk::DicomRT_ROI::GetROINumber() const { - return mNumber; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -const std::string & clitk::DicomRT_ROI::GetName() const { - return mName; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -const std::vector & clitk::DicomRT_ROI::GetDisplayColor() const { - return mColor; -} -//-------------------------------------------------------------------- - - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI::Print(std::ostream & os) const { - os << "ROI " << mNumber << "\t" << mName - << "\t(" << mColor[0] << " " << mColor[1] << " " << mColor[2] << ")" - << "\t Contours = " << mListOfContours.size() << std::endl; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI::Read(std::map & rois, gdcm::SQItem * item) { - - // ROI number [Referenced ROI Number] - mNumber = atoi(item->GetEntryValue(0x3006,0x0084).c_str()); - - // Retrieve ROI Name - mName = rois[mNumber]; - - // ROI Color [ROI Display Color] - mColor = clitk::parse_string(item->GetEntryValue(0x3006,0x002a),'\\'); - - // Read contours [Contour Sequence] - gdcm::SeqEntry * contours=item->GetSeqEntry(0x3006,0x0040); - for(gdcm::SQItem* j=contours->GetFirstSQItem();j!=0;j=contours->GetNextSQItem()) { - DicomRT_Contour * c = new DicomRT_Contour; - bool b = c->Read(j); - if (b) mListOfContours.push_back(c); - } -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -vtkPolyData * clitk::DicomRT_ROI::GetMesh() { - if (!mMeshIsUpToDate) { - ComputeMesh(); - } - return mMesh; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI::ComputeMesh() { - vtkAppendPolyData * append = vtkAppendPolyData::New(); - for(unsigned int i=0; iAddInput(mListOfContours[i]->GetMesh()); - } - append->Update(); - mMesh = append->GetOutput(); - mMeshIsUpToDate = true; -} -//-------------------------------------------------------------------- - diff --git a/tools/clitkDicomRT_ROI.h b/tools/clitkDicomRT_ROI.h deleted file mode 100644 index 0b8d6dc..0000000 --- a/tools/clitkDicomRT_ROI.h +++ /dev/null @@ -1,55 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Main authors : XX XX XX - - 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 - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - BSD http://www.opensource.org/licenses/bsd-license.php - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - - =========================================================================*/ - -#ifndef CLITKDICOMRT_ROI_H -#define CLITKDICOMRT_ROI_H - -#include "clitkDicomRT_Contour.h" - -namespace clitk { - - //-------------------------------------------------------------------- - class DicomRT_ROI { - - public: - DicomRT_ROI(); - ~DicomRT_ROI(); - - void Print(std::ostream & os = std::cout) const; - void Read(std::map & rois, gdcm::SQItem * item); - - int GetROINumber() const; - const std::string & GetName() const; - const std::vector & GetDisplayColor() const; - vtkPolyData * GetMesh(); - - protected: - void ComputeMesh(); - std::string mName; - int mNumber; - std::vector mColor; - std::vector mListOfContours; - vtkPolyData * mMesh; - bool mMeshIsUpToDate; - }; - //-------------------------------------------------------------------- - -} // end namespace clitk -#endif // CLITKDICOMRT_ROI_H - diff --git a/tools/clitkDicomRT_ROI_ConvertToImageFilter.cxx b/tools/clitkDicomRT_ROI_ConvertToImageFilter.cxx deleted file mode 100644 index cedef81..0000000 --- a/tools/clitkDicomRT_ROI_ConvertToImageFilter.cxx +++ /dev/null @@ -1,191 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Main authors : XX XX XX - - 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 - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - BSD http://www.opensource.org/licenses/bsd-license.php - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - - =========================================================================*/ - -#include "clitkDicomRT_ROI_ConvertToImageFilter.h" -#include -#include -#include -#include -#include -#include "clitkImageCommon.h" - -//-------------------------------------------------------------------- -clitk::DicomRT_ROI_ConvertToImageFilter::DicomRT_ROI_ConvertToImageFilter() { - mROI = NULL; - mImageInfoIsSet = false; - mWriteOutput = false; - mCropMask = true; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -clitk::DicomRT_ROI_ConvertToImageFilter::~DicomRT_ROI_ConvertToImageFilter() { - -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI_ConvertToImageFilter::SetROI(clitk::DicomRT_ROI * roi) { - mROI = roi; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI_ConvertToImageFilter::SetCropMaskEnabled(bool b) { - mCropMask = b; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI_ConvertToImageFilter::SetOutputImageFilename(std::string s) { - mOutputFilename = s; - mWriteOutput = true; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI_ConvertToImageFilter::SetImageFilename(std::string f) { - itk::ImageIOBase::Pointer header = clitk::readImageHeader(f); - if (header->GetNumberOfDimensions() < 3) { - std::cerr << "Error. Please provide a 3D image instead of " << f << std::endl; - exit(0); - } - if (header->GetNumberOfDimensions() > 3) { - std::cerr << "Warning dimension > 3 are ignored" << std::endl; - } - mSpacing.resize(3); - mOrigin.resize(3); - mSize.resize(3); - for(unsigned int i=0; i<3; i++) { - mSpacing[i] = header->GetSpacing(i); - mOrigin[i] = header->GetOrigin(i); - mSize[i] = header->GetDimensions(i); - } - mImageInfoIsSet = true; -} -//-------------------------------------------------------------------- - - -//-------------------------------------------------------------------- -void clitk::DicomRT_ROI_ConvertToImageFilter::Update() { - if (!mROI) { - std::cerr << "Error. No ROI set, please use SetROI." << std::endl; - exit(0); - } - if (!mImageInfoIsSet) { - std::cerr << "Error. Please provide image info (spacing/origin) with SetImageFilename" << std::endl; - exit(0); - } - // DD("Update"); - - // Get Mesh - vtkPolyData * mesh = mROI->GetMesh(); - // DD(mesh->GetNumberOfCells()); - - // Get bounds - double *bounds=mesh->GetBounds(); - // for(int i=0; i<6; i++){ -// DD(bounds[i]); -// } - - // Compute origin - std::vector origin; - origin.resize(3); - origin[0] = floor((bounds[0]-mOrigin[0])/mSpacing[0]-2)*mSpacing[0]+mOrigin[0]; - origin[1] = floor((bounds[2]-mOrigin[1])/mSpacing[1]-2)*mSpacing[1]+mOrigin[1]; - origin[2] = floor((bounds[4]-mOrigin[2])/mSpacing[2]-2)*mSpacing[2]+mOrigin[2]; - - // Compute extend - std::vector extend; - extend.resize(3); - extend[0] = ceil((bounds[1]-origin[0])/mSpacing[0]+4); - extend[1] = ceil((bounds[3]-origin[1])/mSpacing[1]+4); - extend[2] = ceil((bounds[5]-origin[2])/mSpacing[2]+4); - - // If no crop, set initial image size/origin - if (!mCropMask) { - for(int i=0; i<3; i++) { - origin[i] = mOrigin[i]; - extend[i] = mSize[i]-1; - } - } - - // Create new output image - mBinaryImage = vtkImageData::New(); - mBinaryImage->SetScalarTypeToUnsignedChar(); - mBinaryImage->SetOrigin(&origin[0]); - mBinaryImage->SetSpacing(&mSpacing[0]); - mBinaryImage->SetExtent(0, extend[0], - 0, extend[1], - 0, extend[2]); - mBinaryImage->AllocateScalars(); - - // for(int i=0; i<3; i++){ - // DD(origin[i]); - // DD(extend[i]); - // DD(mBinaryImage->GetDimensions()[i]); - // } - memset(mBinaryImage->GetScalarPointer(), 0, - mBinaryImage->GetDimensions()[0]*mBinaryImage->GetDimensions()[1]*mBinaryImage->GetDimensions()[2]*sizeof(unsigned char)); - - // Extrude - vtkSmartPointer extrude=vtkSmartPointer::New(); - extrude->SetInput(mesh); - ///We extrude in the -slice_spacing direction to respect the FOCAL convention // ????????????? - extrude->SetVector(0, 0, -mSpacing[2]); - - // Binarization - vtkSmartPointer sts=vtkSmartPointer::New(); - //The following line is extremely important - //http://www.nabble.com/Bug-in-vtkPolyDataToImageStencil--td23368312.html#a23370933 - sts->SetTolerance(0); - sts->SetInformationInput(mBinaryImage); - sts->SetInput(extrude->GetOutput()); - //sts->SetInput(mesh); - - vtkSmartPointer stencil=vtkSmartPointer::New(); - stencil->SetStencil(sts->GetOutput()); - stencil->SetInput(mBinaryImage); - stencil->ReverseStencilOn(); - stencil->Update(); - mBinaryImage->ShallowCopy(stencil->GetOutput()); - - if (mWriteOutput) { - typedef itk::Image ImageType; - typedef itk::VTKImageToImageFilter ConnectorType; - ConnectorType::Pointer connector = ConnectorType::New(); - connector->SetInput(GetOutput()); - connector->Update(); - clitk::writeImage(connector->GetOutput(), mOutputFilename); - } -} -//-------------------------------------------------------------------- - - - -//-------------------------------------------------------------------- -vtkImageData * clitk::DicomRT_ROI_ConvertToImageFilter::GetOutput() { - return mBinaryImage; -} -//-------------------------------------------------------------------- diff --git a/tools/clitkDicomRT_ROI_ConvertToImageFilter.h b/tools/clitkDicomRT_ROI_ConvertToImageFilter.h deleted file mode 100644 index d5d27b3..0000000 --- a/tools/clitkDicomRT_ROI_ConvertToImageFilter.h +++ /dev/null @@ -1,58 +0,0 @@ -/*========================================================================= - Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Main authors : XX XX XX - - 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 - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the copyright notices for more information. - - It is distributed under dual licence - - BSD http://www.opensource.org/licenses/bsd-license.php - - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - - =========================================================================*/ - -#ifndef CLITKDICOMRT_ROI_CONVERTTOIMAGEFILTER_H -#define CLITKDICOMRT_ROI_CONVERTTOIMAGEFILTER_H - -#include "clitkDicomRT_ROI.h" -#include "clitkImageCommon.h" -#include - -namespace clitk { - - //-------------------------------------------------------------------- - class DicomRT_ROI_ConvertToImageFilter { - - public: - DicomRT_ROI_ConvertToImageFilter(); - ~DicomRT_ROI_ConvertToImageFilter(); - - void SetROI(clitk::DicomRT_ROI * roi); - void SetImageFilename(std::string s); - void SetOutputImageFilename(std::string s); - void Update(); - vtkImageData * GetOutput(); - void SetCropMaskEnabled(bool b); - - protected: - bool mImageInfoIsSet; - bool mWriteOutput; - bool mCropMask; - std::string mOutputFilename; - std::vector mSpacing; - std::vector mOrigin; - std::vector mSize; - clitk::DicomRT_ROI * mROI; - vtkImageData * mBinaryImage; - }; - //-------------------------------------------------------------------- - -} // end namespace clitk -#endif // CLITKDICOMRT_ROI_CONVERTTOIMAGEFILTER_H - -- 2.47.1