From a30d8dd30db9b6f4b67101e712f28c0b2a0227bf Mon Sep 17 00:00:00 2001 From: srit Date: Thu, 3 Mar 2011 16:26:13 +0000 Subject: [PATCH] Consistent GetScalarComponentAsDouble with the one in vvSlicer --- vv/vvSlicerManager.cxx | 39 ++++++++++++++++----------------------- vv/vvSlicerManager.h | 1 + 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 42982b7..7bc8d58 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -856,10 +856,8 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) Y <= mSlicers[slicer]->GetInput()->GetWholeExtent()[3] && Z >= mSlicers[slicer]->GetInput()->GetWholeExtent()[4] && Z <= mSlicers[slicer]->GetInput()->GetWholeExtent()[5]) { - value = mSlicers[slicer]->GetInput()->GetScalarComponentAsDouble( - (int)floor(X), - (int)floor(Y), - (int)floor(Z),0); + value = this->GetScalarComponentAsDouble(mSlicers[slicer]->GetInput(), X, Y, Z); + if (mSlicers[slicer]->GetVFActor() && mSlicers[slicer]->GetVFActor()->GetVisibility()) { displayVec = 1; unsigned int currentTime = mSlicers[slicer]->GetTSlice(); @@ -874,9 +872,9 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) double Xvf = (x - vf->GetOrigin()[0])/ vf->GetSpacing()[0]; double Yvf = (y - vf->GetOrigin()[1])/ vf->GetSpacing()[1]; double Zvf = (z - vf->GetOrigin()[2])/ vf->GetSpacing()[2]; - xVec = vf->GetScalarComponentAsDouble( (int)floor(Xvf), (int)floor(Yvf), (int)floor(Zvf),0); - yVec = vf->GetScalarComponentAsDouble( (int)floor(Xvf), (int)floor(Yvf), (int)floor(Zvf),1); - zVec = vf->GetScalarComponentAsDouble( (int)floor(Xvf), (int)floor(Yvf), (int)floor(Zvf),2); + xVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 0); + yVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 1); + zVec = this->GetScalarComponentAsDouble( vf, Xvf, Yvf, Zvf, 2); valueVec = sqrt(xVec*xVec + yVec*yVec + zVec*zVec); } } @@ -894,11 +892,7 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) Yover <= mSlicers[slicer]->GetOverlayMapper()->GetInput()->GetWholeExtent()[3] && Zover >= mSlicers[slicer]->GetOverlayMapper()->GetInput()->GetWholeExtent()[4] && Zover <= mSlicers[slicer]->GetOverlayMapper()->GetInput()->GetWholeExtent()[5]) { - valueOver = static_cast(mSlicers[slicer]->GetOverlayMapper()->GetInput())-> - GetScalarComponentAsDouble( - (int)floor(Xover), - (int)floor(Yover), - (int)floor(Zover),0); + valueOver = this->GetScalarComponentAsDouble(static_cast(mSlicers[slicer]->GetOverlayMapper()->GetInput()), Xover, Yover, Zover); } } if (mSlicers[slicer]->GetFusionActor() && mSlicers[slicer]->GetFusionActor()->GetVisibility()) { @@ -915,11 +909,7 @@ void vvSlicerManager::UpdateInfoOnCursorPosition(int slicer) Yfus <= mSlicers[slicer]->GetFusionMapper()->GetInput()->GetWholeExtent()[3] && Zfus >= mSlicers[slicer]->GetFusionMapper()->GetInput()->GetWholeExtent()[4] && Zfus <= mSlicers[slicer]->GetFusionMapper()->GetInput()->GetWholeExtent()[5]) { - valueFus = static_cast(mSlicers[slicer]->GetFusionMapper()->GetInput())-> - GetScalarComponentAsDouble( - (int)floor(Xfus), - (int)floor(Yfus), - (int)floor(Zfus),0); + valueFus = this->GetScalarComponentAsDouble(static_cast(mSlicers[slicer]->GetFusionMapper()->GetInput()), Xfus, Yfus, Zfus); } } emit UpdatePosition(mSlicers[slicer]->GetCursorVisibility(), @@ -1206,10 +1196,7 @@ void vvSlicerManager::AddLandmark(float x,float y,float z,float t) y_index <= mSlicers[0]->GetInput()->GetWholeExtent()[3] && z_index >= mSlicers[0]->GetInput()->GetWholeExtent()[4] && z_index <= mSlicers[0]->GetInput()->GetWholeExtent()[5]) { - double value = mSlicers[0]->GetInput()->GetScalarComponentAsDouble( - (int)x_index, - (int)y_index, - (int)z_index,0); + double value = this->GetScalarComponentAsDouble(mSlicers[0]->GetInput(), x_index, y_index, z_index); this->GetLandmarks()->AddLandmark(x,y,z,t,value); emit LandmarkAdded(); } @@ -1223,7 +1210,6 @@ void vvSlicerManager::PrevImage(int slicer) } //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- void vvSlicerManager::NextImage(int slicer) { @@ -1231,7 +1217,6 @@ void vvSlicerManager::NextImage(int slicer) } //---------------------------------------------------------------------------- - //---------------------------------------------------------------------------- void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice) { @@ -1239,3 +1224,11 @@ void vvSlicerManager::VerticalSliderHasChanged(int slicer, int slice) } //---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- +double vvSlicerManager::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component) +{ + int ix, iy, iz; + return mSlicers[0]->GetScalarComponentAsDouble(image, X, Y, Z, ix, iy, iz, component); +} +//---------------------------------------------------------------------------- diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 4272891..5cca97c 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -189,6 +189,7 @@ class vvSlicerManager : public QObject { void PrevImage(int slicer); void LeftButtonReleaseEvent(int slicer); void VerticalSliderHasChanged(int slicer, int slice); + double GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int component=0); signals : void currentImageChanged(std::string id); -- 2.47.1