From d1ce705178f497e18fe7bc2c4115001a0755106d Mon Sep 17 00:00:00 2001 From: srit Date: Thu, 22 Apr 2010 13:10:06 +0000 Subject: [PATCH] Added reslicing via the transform set with SetTransform. Only enabled when CLITK_EXPERIMENTAL is set. --- common/vvImage.cxx | 78 +++++++++++++++++++++++++++++++--------------- common/vvImage.h | 8 ++++- 2 files changed, 60 insertions(+), 26 deletions(-) diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 1d718bc..7772107 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -18,55 +18,76 @@ #ifndef VVIMAGE_CXX #define VVIMAGE_CXX #include "vvImage.h" -#include "vtkImageData.h" #include "clitkCommon.h" + +#include +#include + #include //-------------------------------------------------------------------- vvImage::vvImage() { - mVtkImages.resize(0); - mTimeSpacing = 1; - mTimeOrigin = 0; + Init(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void vvImage::Init() { + mTimeSpacing = 1; + mTimeOrigin = 0; + if (CLITK_EXPERIMENTAL) + { + mVtkImageReslice = vtkSmartPointer::New(); + mVtkImageReslice->SetInterpolationModeToLinear(); + mVtkImageReslice->AutoCropOutputOn(); + } } //-------------------------------------------------------------------- //-------------------------------------------------------------------- vvImage::~vvImage() { - for (unsigned int i = 0; i < mVtkImages.size(); i++) { - if (mVtkImages[i] != NULL) - mVtkImages[i]->Delete(); - } + Reset(); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void vvImage::SetImage(std::vector images) { - for (unsigned int i = 0; i < mVtkImages.size(); i++) { - if (mVtkImages[i] != NULL) - mVtkImages[i]->Delete(); - } - mVtkImages.resize(0); - for (unsigned int i = 0; i < images.size(); i++) { - mVtkImages.push_back(images[i]); - } +void vvImage::Reset() { + if (CLITK_EXPERIMENTAL) + { + for (unsigned int i = 0; i < mVtkImages.size(); i++) + mVtkImages[i] = (vtkImageData*)mVtkImageReslice->GetInput(i); + mVtkImageReslice->RemoveAllInputs(); + } + for (unsigned int i = 0; i < mVtkImages.size(); i++) + mVtkImages[i]->Delete(); + mVtkImages.resize(0); + Init(); } //-------------------------------------------------------------------- + //-------------------------------------------------------------------- -void vvImage::AddImage(vtkImageData* image) { - mVtkImages.push_back(image); +void vvImage::SetImage(std::vector< vtkImageData* > images) { + Reset(); + for (unsigned int i = 0; i < images.size(); i++) + AddImage(images[i]); } //-------------------------------------------------------------------- + //-------------------------------------------------------------------- -void vvImage::Init() { - for (unsigned int i = 0; i < mVtkImages.size(); i++) { - if (mVtkImages[i] != NULL) - mVtkImages[i]->Delete(); - } - mVtkImages.resize(0); +void vvImage::AddImage(vtkImageData* image) { + if (CLITK_EXPERIMENTAL) + { + mVtkImageReslice->SetInput(mVtkImages.size(), image); + mVtkImageReslice->Update(); + mVtkImages.push_back( mVtkImageReslice->GetOutput( mVtkImages.size() ) ); + } + else + mVtkImages.push_back(image); } //-------------------------------------------------------------------- @@ -251,4 +272,11 @@ bool vvImage::IsScalarTypeInteger(int t) { //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void vvImage::SetTransform(vtkAbstractTransform *transform) +{ + mVtkImageReslice->SetResliceTransform(transform); +} +//-------------------------------------------------------------------- + #endif // VVIMAGE_CXX diff --git a/common/vvImage.h b/common/vvImage.h index 7cb3e95..a0ab108 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -21,8 +21,11 @@ #include #include #include +#include class vtkImageData; +class vtkImageReslice; +class vtkAbstractTransform; class vvImage : public itk::LightObject { public : @@ -31,6 +34,8 @@ public : itkNewMacro(Self); void Init(); + void Reset(); + void SetImage(std::vector images); void AddImage(vtkImageData* image); const std::vector& GetVTKImages(); @@ -53,6 +58,7 @@ public : void SetTimeSpacing(double s) { mTimeSpacing = s; } void SetTimeOrigin(double o) { mTimeOrigin = o; } + void SetTransform(vtkAbstractTransform *transform); private: vvImage(); @@ -60,7 +66,7 @@ private: std::vector mVtkImages; double mTimeOrigin; double mTimeSpacing; - + vtkSmartPointer mVtkImageReslice; }; #endif -- 2.47.1