From a5cd7f0f5418749e683bd3b50915ff9da09d35cb Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Thu, 12 Apr 2012 15:14:07 +0200 Subject: [PATCH] Crash with rigid transformation - when current slice was outside the image extent after the transformation --- vv/vvSlicer.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 92cb268..d2a6ba7 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -817,10 +817,12 @@ void vvSlicer::UpdateDisplayExtent() // Local copy of extent int w_ext[6]; - copyExtent(GetExtent(), w_ext); + int* ext = GetExtent(); + copyExtent(ext, w_ext); // Set slice value - w_ext[ this->SliceOrientation*2 ] = this->Slice; - w_ext[ this->SliceOrientation*2+1 ] = this->Slice; + int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice; + w_ext[ this->SliceOrientation*2 ] = s; + w_ext[ this->SliceOrientation*2+1 ] = s; // Image actor this->ImageActor->SetDisplayExtent(w_ext); @@ -929,7 +931,8 @@ void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2]; // Round to nearest - targetExtent[i] = itk::Math::Round(dExtents[i]); + //targetExtent[i] = itk::Math::Round(dExtents[i]); + targetExtent[i] = itk::Math::Floor(dExtents[i]); } } //---------------------------------------------------------------------------- -- 2.47.1