]> Creatis software - clitk.git/commitdiff
Fixed bug in local windowing
authorsrit <srit>
Thu, 22 Apr 2010 15:36:28 +0000 (15:36 +0000)
committersrit <srit>
Thu, 22 Apr 2010 15:36:28 +0000 (15:36 +0000)
vv/vvSlicer.cxx

index 9552a387f061770d527c20bd4f1aefbec2753e1d..ec225e2066be3558524d2ffc6c421b29e55c7dd5 100644 (file)
@@ -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<vtkExtractVOI> voiFilter = vtkExtractVOI::New();
   voiFilter->SetInput(this->GetInput());
   voiFilter->SetVOI(iLocalExtents);
+  voiFilter->Update();
+  if (!voiFilter->GetOutput()->GetNumberOfPoints())
+    {
+      min = 0;
+      max = 0;
+      return;
+    }
 
   vtkSmartPointer<vtkImageAccumulate> accFilter = vtkImageAccumulate::New();
   accFilter->SetInput(voiFilter->GetOutput());
   accFilter->Update();
-   
+  
   min = *(accFilter->GetMin());
   max = *(accFilter->GetMax());
 }