]> Creatis software - clitk.git/commitdiff
Return nan when quering scalar value outside whole extent
authorsrit <srit>
Tue, 15 Mar 2011 15:37:39 +0000 (15:37 +0000)
committersrit <srit>
Tue, 15 Mar 2011 15:37:39 +0000 (15:37 +0000)
vv/vvSlicer.cxx

index 24a552b251486faffaf677ebf989f9174686c883..86824a2c7a0932e656273410ea093c6d0eda75c8 100644 (file)
@@ -1214,6 +1214,14 @@ double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, int X, double Y
   ix = lrint(X);
   iy = lrint(Y);
   iz = lrint(Z);
+  if (ix < image->GetWholeExtent()[0] ||
+      ix > image->GetWholeExtent()[1] ||
+      iy < image->GetWholeExtent()[2] ||
+      iy > image->GetWholeExtent()[3] ||
+      iz < image->GetWholeExtent()[4] ||
+      iz > image->GetWholeExtent()[5] )
+    return sqrt(-1);
+
   image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
   image->Update();
   return image->GetScalarComponentAsDouble(ix, iy, iz, component);