From ddd0fa980287258b869cf7c9835c4a559cd4cb72 Mon Sep 17 00:00:00 2001 From: srit Date: Fri, 9 Jul 2010 08:24:10 +0000 Subject: [PATCH] Modified transform in vvImage. Now a vtkGeneralTransform which composes a vtkGridTransform with the (already there) vtkTransform. Removed CLITK_EXPERIMENTAL condition. --- common/CMakeLists.txt | 2 +- common/vvImage.cxx | 58 ++++++++++++++++++++----------------------- common/vvImage.h | 7 ++++-- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 9ac871a..19e6671 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -31,7 +31,7 @@ SET(clitkCommon_SRC ) ADD_LIBRARY(clitkCommon STATIC ${clitkCommon_SRC}) -TARGET_LINK_LIBRARIES(clitkCommon vtkCommon vtkImaging ITKBasicFilters) +TARGET_LINK_LIBRARIES(clitkCommon vtkCommon vtkImaging vtkHybrid ITKBasicFilters) ADD_LIBRARY(clitkDicomRTStruct STATIC clitkDicomRT_Contour.cxx diff --git a/common/vvImage.cxx b/common/vvImage.cxx index 797fa3e..55a56ef 100644 --- a/common/vvImage.cxx +++ b/common/vvImage.cxx @@ -19,14 +19,21 @@ #define VVIMAGE_CXX #include "vvImage.h" #include "clitkCommon.h" -#include #include #include #include +#include +#include +#include + //-------------------------------------------------------------------- -vvImage::vvImage() +vvImage::vvImage():mGeneralTransform(vtkSmartPointer::New()), + mTransform (vtkSmartPointer::New()), + mGridTransform (vtkSmartPointer::New()) { + mGeneralTransform->Concatenate(mTransform); + mGeneralTransform->Concatenate(mGridTransform); Init(); } //-------------------------------------------------------------------- @@ -37,9 +44,6 @@ void vvImage::Init() { mTimeSpacing = 1; mTimeOrigin = 0; - - if (CLITK_EXPERIMENTAL) - mTransform = vtkSmartPointer::New(); } //-------------------------------------------------------------------- @@ -53,12 +57,8 @@ vvImage::~vvImage() //-------------------------------------------------------------------- void vvImage::Reset() { - if (CLITK_EXPERIMENTAL) - for (unsigned int i = 0; i < mVtkImages.size(); i++) - mVtkImageReslice[i]->GetInput(0)->Delete(); - else - for (unsigned int i = 0; i < mVtkImages.size(); i++) - mVtkImages[i]->Delete(); + for (unsigned int i = 0; i < mVtkImages.size(); i++) + mVtkImageReslice[i]->GetInput()->Delete(); mVtkImages.resize(0); mVtkImageReslice.resize(0); @@ -67,7 +67,6 @@ void vvImage::Reset() } //-------------------------------------------------------------------- - //-------------------------------------------------------------------- void vvImage::SetImage(std::vector< vtkImageData* > images) { @@ -81,19 +80,16 @@ void vvImage::SetImage(std::vector< vtkImageData* > images) //-------------------------------------------------------------------- void vvImage::AddImage(vtkImageData* image) { - if (CLITK_EXPERIMENTAL) { - mVtkImageReslice.push_back(vtkSmartPointer::New()); - - mVtkImageReslice.back()->SetInterpolationModeToLinear(); - mVtkImageReslice.back()->AutoCropOutputOn(); - mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1); - mVtkImageReslice.back()->SetResliceTransform(mTransform); - mVtkImageReslice.back()->SetInput(0, image); - mVtkImageReslice.back()->Update(); - - mVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) ); - } else - mVtkImages.push_back(image); + mVtkImageReslice.push_back(vtkSmartPointer::New()); + + mVtkImageReslice.back()->SetInterpolationModeToLinear(); + mVtkImageReslice.back()->AutoCropOutputOn(); + mVtkImageReslice.back()->SetBackgroundColor(-1000,-1000,-1000,1); + mVtkImageReslice.back()->SetResliceTransform(mGeneralTransform); + mVtkImageReslice.back()->SetInput(0, image); + mVtkImageReslice.back()->Update(); + + mVtkImages.push_back( mVtkImageReslice.back()->GetOutput(0) ); } //-------------------------------------------------------------------- @@ -107,7 +103,7 @@ int vvImage::GetNumberOfSpatialDimensions() return dim; } //-------------------------------------------------------------------- -// + //-------------------------------------------------------------------- int vvImage::GetNumberOfDimensions() const { @@ -123,6 +119,8 @@ int vvImage::GetNumberOfDimensions() const } return 0; } +//-------------------------------------------------------------------- + //-------------------------------------------------------------------- void vvImage::GetScalarRange(double* range) { @@ -136,6 +134,7 @@ void vvImage::GetScalarRange(double* range) if (temp[1] > range[1]) range[1]=temp[1]; } } +//-------------------------------------------------------------------- //-------------------------------------------------------------------- std::string vvImage::GetScalarTypeAsITKString() @@ -233,7 +232,6 @@ const std::vector& vvImage::GetVTKImages() } //-------------------------------------------------------------------- - //-------------------------------------------------------------------- vtkImageData* vvImage::GetFirstVTKImageData() { @@ -241,7 +239,6 @@ vtkImageData* vvImage::GetFirstVTKImageData() } //-------------------------------------------------------------------- - //-------------------------------------------------------------------- bool vvImage::IsScalarTypeInteger() { @@ -279,10 +276,9 @@ vtkSmartPointer vvImage::GetTransform() //-------------------------------------------------------------------- //-------------------------------------------------------------------- -void vvImage::SetTransform(vtkSmartPointer transform) +vtkSmartPointer vvImage::GetGridTransform() { - mTransform = transform; - this->UpdateReslice(); + return mGridTransform; } //-------------------------------------------------------------------- diff --git a/common/vvImage.h b/common/vvImage.h index 7dbba1f..07987c7 100644 --- a/common/vvImage.h +++ b/common/vvImage.h @@ -25,9 +25,9 @@ class vtkImageData; class vtkImageReslice; +class vtkGeneralTransform; class vtkTransform; -class vtkImageReslice; -class vtkAbstractTransform; +class vtkGridTransform; //------------------------------------------------------------------------------ class vvImage : public itk::LightObject @@ -57,6 +57,7 @@ public : bool IsScalarTypeInteger(); bool IsScalarTypeInteger(int t); vtkSmartPointer GetTransform(); + vtkSmartPointer GetGridTransform(); void SetTransform(vtkSmartPointer transform); void SetTimeSpacing(double s) { mTimeSpacing = s; } void SetTimeOrigin(double o) { mTimeOrigin = o; } @@ -68,7 +69,9 @@ private: std::vector mVtkImages; std::vector< vtkSmartPointer > mVtkImageReslice; + vtkSmartPointer mGeneralTransform; vtkSmartPointer mTransform; + vtkSmartPointer mGridTransform; double mTimeOrigin; double mTimeSpacing; }; -- 2.47.1