]> Creatis software - clitk.git/commitdiff
Check extents before adding landmark
authorsrit <srit>
Mon, 7 Jun 2010 21:46:04 +0000 (21:46 +0000)
committersrit <srit>
Mon, 7 Jun 2010 21:46:04 +0000 (21:46 +0000)
vv/vvSlicerManager.cxx

index 2bc9810ae69a934dbabac40c21cb5203caf8e1b7..55efda3965169896acfe11ffa5bdbeea91efeb37 100644 (file)
@@ -1168,12 +1168,19 @@ void vvSlicerManager::AddLandmark(float x,float y,float z,float t)
   double x_index = (x - mSlicers[0]->GetInput()->GetOrigin()[0])/mSlicers[0]->GetInput()->GetSpacing()[0];
   double y_index = (y - mSlicers[0]->GetInput()->GetOrigin()[1])/mSlicers[0]->GetInput()->GetSpacing()[1];
   double z_index = (z - mSlicers[0]->GetInput()->GetOrigin()[2])/mSlicers[0]->GetInput()->GetSpacing()[2];
-  double value = mSlicers[0]->GetInput()->GetScalarComponentAsDouble(
-                   (int)x_index,
-                   (int)y_index,
-                   (int)z_index,0);
-  this->GetLandmarks()->AddLandmark(x,y,z,t,value);
-  emit LandmarkAdded();
+  if (x_index >= mSlicers[0]->GetInput()->GetWholeExtent()[0] &&
+      x_index <= mSlicers[0]->GetInput()->GetWholeExtent()[1] &&
+      y_index >= mSlicers[0]->GetInput()->GetWholeExtent()[2] &&
+      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);
+    this->GetLandmarks()->AddLandmark(x,y,z,t,value);
+    emit LandmarkAdded();
+  }
 }
 //----------------------------------------------------------------------------