From ba72deb1cf11f32261e565d3103afd84571a0cf2 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Tue, 4 Sep 2012 11:01:03 +0200 Subject: [PATCH] Account for reslicing transform in overlay and fusion (contours and vf have not been tested, TODO) --- vv/vvSlicer.cxx | 46 +++++++++++++++++++++++++++++++++++------- vv/vvSlicer.h | 14 ++++++++++--- vv/vvSlicerManager.cxx | 8 +++++--- 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index f84011c..abf6306 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -82,6 +82,8 @@ vvSlicer::vvSlicer() mImage = NULL; mReducedExtent = new int[6]; mCurrentTSlice = 0; + mCurrentFusionTSlice = 0; + mCurrentOverlayTSlice = 0; mUseReducedExtent = false; mCurrent[0] = -VTK_DOUBLE_MAX; @@ -148,6 +150,8 @@ vvSlicer::vvSlicer() mSlicingTransform = vtkSmartPointer::New(); mConcatenatedTransform = vtkSmartPointer::New(); + mConcatenatedFusionTransform = vtkSmartPointer::New(); + mConcatenatedOverlayTransform = vtkSmartPointer::New(); } //------------------------------------------------------------------------------ @@ -369,8 +373,13 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) mOverlayReslice->AutoCropOutputOn(); mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()[0]); + + mConcatenatedOverlayTransform->Identity(); + mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]); + mConcatenatedOverlayTransform->Concatenate(mSlicingTransform); + mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform); mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData()); + mImageReslice->UpdateInformation(); if (!mOverlayMapper) mOverlayMapper = vtkSmartPointer::New(); @@ -416,8 +425,13 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) mFusionReslice->AutoCropOutputOn(); mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mFusionReslice->SetResliceTransform(mFusion->GetTransform()[0]); + + mConcatenatedFusionTransform->Identity(); + mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]); + mConcatenatedFusionTransform->Concatenate(mSlicingTransform); + mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform); mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData()); + mFusionReslice->UpdateInformation(); if (!mFusionMapper) mFusionMapper = vtkSmartPointer::New(); @@ -711,12 +725,16 @@ void vvSlicer::SetTSlice(int t) mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]); } if (mOverlay && mOverlayActor->GetVisibility()) { - if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice) - mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] ); + if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice) { + mCurrentOverlayTSlice = mCurrentTSlice; + mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] ); + } } if (mFusion && mFusionActor->GetVisibility()) { - if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice) - mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]); + if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice) { + mCurrentFusionTSlice = mCurrentTSlice; + mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]); + } } if (mSurfaceCutActors.size() > 0) for (std::vector::iterator i=mSurfaceCutActors.begin(); @@ -734,6 +752,20 @@ int vvSlicer::GetTSlice() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +int vvSlicer::GetFusionTSlice() +{ + return mCurrentFusionTSlice; +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +int vvSlicer::GetOverlayTSlice() +{ + return mCurrentOverlayTSlice; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvSlicer::SetSliceOrientation(int orientation) { @@ -1197,7 +1229,7 @@ void vvSlicer::SetOverlayColorLevel(double level) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -// Returns the min an the max value in a 41x41 region around the mouse pointer +// Returns the min an the max value in a 20%x20% region around the mouse pointer void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform) { //Get mouse pointer position in view coordinates diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index 0a0bcca..71f7ece 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -99,6 +99,8 @@ public: void SetSliceOrientation(int orientation); void AdjustResliceToSliceOrientation(vtkImageReslice *reslice); int GetTSlice(); + int GetFusionTSlice(); + int GetOverlayTSlice(); ///Reimplemented from vtkImageViewer2 to add polydata support void SetSlice(int s); int GetTMax() { @@ -142,6 +144,8 @@ public: vtkTransform * GetSlicingTransform() { return mSlicingTransform; } vtkTransform * GetConcatenatedTransform() { return mConcatenatedTransform; } + vtkTransform * GetConcatenatedFusionTransform() { return mConcatenatedFusionTransform; } + vtkTransform * GetConcatenatedOverlayTransform() { return mConcatenatedOverlayTransform; } void SetCurrentPosition(double x, double y, double z, int t); double* GetCurrentPosition(); @@ -211,19 +215,21 @@ protected: // Λ Λ // | | vvImage.GetTransform() // | | - // GetConcatenatedTransform() | _|___ VV world coordinates (mm) (displayed in VV) + // GetConcatenatedTransform() | _|___ VV world coordinates (mm) (displayed in VV) mCurrentBeforeSlicingTransform // | Λ // | | GetSlicingTransform() // | | - // ___|__|___ VTK world coordinates (mm) (never displayed) + // ___|__|___ VTK world coordinates (mm) (never displayed) mCurrent - vtkSmartPointer mImageReslice; vtkSmartPointer mSlicingTransform; + vtkSmartPointer mImageReslice; vtkSmartPointer mConcatenatedTransform; vtkSmartPointer mOverlayReslice; + vtkSmartPointer mConcatenatedOverlayTransform; vtkSmartPointer mOverlayMapper; vtkSmartPointer mOverlayActor; vtkSmartPointer mFusionReslice; + vtkSmartPointer mConcatenatedFusionTransform; vtkSmartPointer mFusionMapper; vtkSmartPointer mFusionActor; vtkSmartPointer ca; @@ -247,6 +253,8 @@ protected: std::vector mSurfaceCutActors; int mCurrentTSlice; + int mCurrentFusionTSlice; + int mCurrentOverlayTSlice; double mCurrent[3]; double mCurrentBeforeSlicingTransform[3]; double mCursor[4]; diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 5affb4b..1c64221 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -1146,19 +1146,20 @@ void vvSlicerManager::SetPreset(int preset) void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlKey) { double min, max; - int t = this->GetTSlice(); if(bCtrlKey && this->mSlicers[slicer]->GetFusion()) { + int t = mSlicers[slicer]->GetFusionTSlice(); this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetFusion()->GetVTKImages()[t], - this->mSlicers[slicer]->GetFusion()->GetTransform()[t]); + this->mSlicers[slicer]->GetConcatenatedFusionTransform()); this->SetFusionWindow(max-min); this->SetFusionLevel(0.5*(min+max)); this->SetColorMap(mColorMap); } else if(bCtrlKey && this->mSlicers[slicer]->GetOverlay()) { + int t = mSlicers[slicer]->GetOverlayTSlice(); this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetOverlay()->GetVTKImages()[t], - this->mSlicers[slicer]->GetOverlay()->GetTransform()[t]); + this->mSlicers[slicer]->GetConcatenatedOverlayTransform()); if(this->mSlicers[slicer]->GetLinkOverlayWindowLevel()){ this->SetColorWindow(max-min); this->SetColorLevel(0.5*(min+max)); @@ -1168,6 +1169,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK } } else { + int t = this->GetTSlice(); this->mSlicers[slicer]->GetExtremasAroundMousePointer(min, max, this->mSlicers[slicer]->GetImage()->GetVTKImages()[t], this->mSlicers[slicer]->GetConcatenatedTransform()); -- 2.47.1