X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=1bf7f13a780fb6c466e48fbe86d0bb0fc0278b1c;hb=8dc75d1449323b08bf7378cded6f0bec24b2016f;hp=57500bb27e6fdb3c04b89e7913864d49463352fe;hpb=6d66b6a238133e2e237e792e46b27c6e71227d78;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 57500bb..1bf7f13 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -380,7 +380,6 @@ void vvSlicer::SetImage(vvImage::Pointer image) // Make sure that the required part image has been computed extent[SliceOrientation*2] = Slice; extent[SliceOrientation*2+1] = Slice; - #if VTK_MAJOR_VERSION <= 5 mImageReslice->GetOutput()->SetUpdateExtent(extent); mImageReslice->GetOutput()->Update(); @@ -1085,12 +1084,15 @@ void vvSlicer::UpdateDisplayExtent() // Local copy of extent int w_ext[6]; +#if VTK_MAJOR_VERSION <= 5 + int* ext = GetExtent(); +#else int* ext = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()); +#endif copyExtent(ext, w_ext); if (mUseReducedExtent) { copyExtent(mReducedExtent, w_ext); } - cout << mUseReducedExtent<< " " << w_ext[0] << " " << w_ext[1] << " " << w_ext[2] << " " << w_ext[3] << " " << w_ext[4] << " " << w_ext[5] << endl; // Set slice value w_ext[ this->SliceOrientation*2 ] = this->Slice; @@ -1109,10 +1111,11 @@ void vvSlicer::UpdateDisplayExtent() if (mOverlay && mOverlayVisibility) { AdjustResliceToSliceOrientation(mOverlayReslice); int overExtent[6]; - this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mOverlayReslice->GetOutput(), overExtent); #if VTK_MAJOR_VERSION <= 5 + this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent); bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent()); #else + this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mOverlayReslice->GetOutput(), overExtent); bool out = ClipDisplayedExtent(overExtent, mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); #endif mOverlayActor->SetVisibility(!out); @@ -1129,10 +1132,11 @@ void vvSlicer::UpdateDisplayExtent() if (mFusion && mFusionVisibility) { AdjustResliceToSliceOrientation(mFusionReslice); int fusExtent[6]; - this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mFusionReslice->GetOutput(), fusExtent); #if VTK_MAJOR_VERSION <= 5 + this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent); bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent()); #else + this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mFusionReslice->GetOutput(), fusExtent); bool out = ClipDisplayedExtent(fusExtent, mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); #endif mFusionActor->SetVisibility(!out); @@ -1166,13 +1170,11 @@ void vvSlicer::UpdateDisplayExtent() int vfExtent[6]; #if VTK_MAJOR_VERSION <= 5 mVF->GetVTKImages()[0]->UpdateInformation(); + this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent); + bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent()); #else //this->UpdateInformation(); -#endif this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVF->GetVTKImages()[0], vfExtent); -#if VTK_MAJOR_VERSION <= 5 - bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent()); -#else bool out = ClipDisplayedExtent(vfExtent, mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())); #endif mVFActor->SetVisibility(!out); @@ -1253,6 +1255,29 @@ void vvSlicer::ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, con } //---------------------------------------------------------------------------- +//---------------------------------------------------------------------------- +void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6], + vtkImageData *targetImage, int targetExtent[6]) +{ + double dExtents[6]; + for(unsigned int i=0; i<6; i++) { + // From source voxel coordinates to world coordinates + dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i]; + + // From world coordinates to floating point target voxel coordinates + dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2]; + + // Round to current slice or larger extent + if(i/2==this->GetOrientation()) + targetExtent[i] = itk::Math::Round(dExtents[i]); + else if(i%2==1) + targetExtent[i] = itk::Math::Ceil(dExtents[i]); + else + targetExtent[i] = itk::Math::Floor(dExtents[i]); + } +} +//---------------------------------------------------------------------------- + //---------------------------------------------------------------------------- bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6]) {