From: srit Date: Thu, 22 Apr 2010 13:10:06 +0000 (+0000) Subject: Added reslicing via the transform set with SetTransform. Only enabled when CLITK_EXPE... X-Git-Tag: v1.2.0~700 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=d1ce705178f497e18fe7bc2c4115001a0755106d;p=clitk.git Added reslicing via the transform set with SetTransform. Only enabled when CLITK_EXPERIMENTAL is set. --- 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