X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=ed53d2c83b138c600eeabf680da7edd775854cbc;hb=58f48784852ac6897f690a9ccbb2519ab8e5d9b6;hp=51ff1bc46df62d675d1bd376f89fec61187c8a02;hpb=8b7afc421b64df4f4b0dab56a36d6d4cf7335d87;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 51ff1bc..ed53d2c 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -155,6 +155,7 @@ vvSlicer::vvSlicer() mConcatenatedTransform = vtkSmartPointer::New(); mConcatenatedFusionTransform = vtkSmartPointer::New(); mConcatenatedOverlayTransform = vtkSmartPointer::New(); + mFirstSetSliceOrientation = true; } //------------------------------------------------------------------------------ @@ -853,15 +854,17 @@ void vvSlicer::SetSliceOrientation(int orientation) // DDV(cursorPos, 3); // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]); - if (this->Renderer && this->GetInput()) { + if (mFirstSetSliceOrientation) { + int *range = this->GetSliceRange(); + if (range) + this->Slice = static_cast((range[0] + range[1]) * 0.5); + mFirstSetSliceOrientation = false; + } + else if (this->Renderer && this->GetInput()) { double s = mCursor[orientation]; double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation]; this->Slice = static_cast(sCursor); } - -// int *range = this->GetSliceRange(); -// if (range) -// this->Slice = static_cast((range[0] + range[1]) * 0.5); this->UpdateOrientation(); this->UpdateDisplayExtent(); @@ -901,9 +904,13 @@ void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice) // Step 1: from world coordinates to image coordinates origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation]; origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation]; - // Step 2: round to inferior grid positionInc. This makes sense because a border is used to interpolate - // the original image (SR). - origin[this->SliceOrientation] = itk::Math::Floor(origin[this->SliceOrientation]); + + // Step 2: round to nearest grid positionInc. This has been validated as the only + // way to have something consistent with the thickness of a 2D slice visible on the + // other slices. The thickness is accounted for so if the 2D slice is to thin and + // between two slices, one will never be able to see this 2D slice (bug #1883). + origin[this->SliceOrientation] = itk::Math::Round(origin[this->SliceOrientation]); + // Step 3: back to world coordinates origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation]; origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];