File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -427,6 +427,19 @@ void CImageMapTool::OnCreate()
427427 int voxelIndexY = locPos.y /spacing.y ;
428428 int voxelIndexZ = locPos.z /spacing.z ;
429429
430+ // Ensure we're in the bounds of the image before we sample
431+ if (voxelIndexX < 0 ) voxelIndexX = 0 ;
432+ else if (voxelIndexX >= imageModel->Get3DImage ()->Width ())
433+ voxelIndexX = imageModel->Get3DImage ()->Width () - 1 ;
434+
435+ if (voxelIndexY < 0 ) voxelIndexY = 0 ;
436+ else if (voxelIndexY >= imageModel->Get3DImage ()->Height ())
437+ voxelIndexY = imageModel->Get3DImage ()->Height () - 1 ;
438+
439+ if (voxelIndexZ < 0 ) voxelIndexZ = 0 ;
440+ else if (voxelIndexZ >= imageModel->Get3DImage ()->Depth ())
441+ voxelIndexZ = imageModel->Get3DImage ()->Depth () - 1 ;
442+
430443 double discreteVal = imageModel->Get3DImage ()->Value (voxelIndexX, voxelIndexY, voxelIndexZ);
431444 if (discreteVal >= threshold)
432445 {
You can’t perform that action at this time.
0 commit comments