]> Creatis software - clitk.git/commitdiff
Crash with rigid transformation
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Thu, 12 Apr 2012 13:14:07 +0000 (15:14 +0200)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Thu, 12 Apr 2012 13:14:07 +0000 (15:14 +0200)
- when current slice was outside the image extent after the transformation

vv/vvSlicer.cxx

index 92cb2686d25cdb543f188a7112c101220c9712d2..d2a6ba71a24b842dae55db5ad2f6baaf09ee1dc7 100644 (file)
@@ -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<double>(dExtents[i]);
+    //targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
+    targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
   }
 }
 //----------------------------------------------------------------------------