From: srit Date: Thu, 22 Apr 2010 15:36:28 +0000 (+0000) Subject: Fixed bug in local windowing X-Git-Tag: v1.2.0~698 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f6bfd7ec2781c83bd818e93d3628a36d67bf5a63;p=clitk.git Fixed bug in local windowing --- 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()); }