From f6bfd7ec2781c83bd818e93d3628a36d67bf5a63 Mon Sep 17 00:00:00 2001 From: srit Date: Thu, 22 Apr 2010 15:36:28 +0000 Subject: [PATCH] Fixed bug in local windowing --- vv/vvSlicer.cxx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 9552a38..ec225e2 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -1176,8 +1176,8 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) { if (i!=SliceOrientation) //SR: assumes that SliceOrientation is valid in ViewCoordinates (???) { - fLocalExtents[i*2 ] -= 0.2; - fLocalExtents[i*2+1] += 0.2; + fLocalExtents[i*2 ] -= 0.2; + fLocalExtents[i*2+1] += 0.2; } } this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]); @@ -1194,17 +1194,24 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max) iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]); if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1]) - std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]); + std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]); } - + vtkSmartPointer voiFilter = vtkExtractVOI::New(); voiFilter->SetInput(this->GetInput()); voiFilter->SetVOI(iLocalExtents); + voiFilter->Update(); + if (!voiFilter->GetOutput()->GetNumberOfPoints()) + { + min = 0; + max = 0; + return; + } vtkSmartPointer accFilter = vtkImageAccumulate::New(); accFilter->SetInput(voiFilter->GetOutput()); accFilter->Update(); - + min = *(accFilter->GetMin()); max = *(accFilter->GetMax()); } -- 2.47.1