From: Romulo Pinho Date: Thu, 12 Apr 2012 13:14:07 +0000 (+0200) Subject: Crash with rigid transformation X-Git-Tag: v1.3.0~52^2~4^2 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a5cd7f0f5418749e683bd3b50915ff9da09d35cb;p=clitk.git Crash with rigid transformation - when current slice was outside the image extent after the transformation --- 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]); } } //----------------------------------------------------------------------------