X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=2a5c9247bbe3b0884d392521fa302a81c5e8c797;hb=dd6976090ab45c4ac8e483355851e4d35c828259;hp=2224a9ac9748dd6abb32b09a79185048f93137fc;hpb=2c80239b9508f34ec733115f2513522b887ca658;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 2224a9a..2a5c924 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -66,6 +66,9 @@ #include #include #include +#if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) +# include +#endif vtkCxxRevisionMacro(vvSlicer, "DummyRevision"); vtkStandardNewMacro(vvSlicer); @@ -138,6 +141,13 @@ vvSlicer::vvSlicer() this->InstallPipeline(); mLinkOverlayWindowLevel = true; + +#if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) + this->GetImageActor()->GetMapper()->BorderOn(); +#endif + + mSlicingTransform = vtkSmartPointer::New(); + mConcatenatedTransform = vtkSmartPointer::New(); } //------------------------------------------------------------------------------ @@ -283,13 +293,20 @@ vvSlicer::~vvSlicer() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +double* vvSlicer::GetCurrentPosition() +{ + return mCurrentBeforeSlicingTransform; +} +//------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvSlicer::SetCurrentPosition(double x, double y, double z, int t) { - mCurrent[0] = x; - mCurrent[1] = y; - mCurrent[2] = z; + mCurrentBeforeSlicingTransform[0]=x; + mCurrentBeforeSlicingTransform[1]=y; + mCurrentBeforeSlicingTransform[2]=z; + mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent); mCurrentTSlice = t; } //------------------------------------------------------------------------------ @@ -307,7 +324,11 @@ void vvSlicer::SetImage(vvImage::Pointer image) mImageReslice->AutoCropOutputOn(); mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mImageReslice->SetResliceTransform(mImage->GetTransform()); + + mConcatenatedTransform->Identity(); + mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]); + mConcatenatedTransform->Concatenate(mSlicingTransform); + mImageReslice->SetResliceTransform(mConcatenatedTransform); mImageReslice->SetInput(0, mImage->GetFirstVTKImageData()); mImageReslice->UpdateInformation(); @@ -348,7 +369,7 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) mOverlayReslice->AutoCropOutputOn(); mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()); + mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()[0]); mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData()); if (!mOverlayMapper) @@ -361,7 +382,10 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) mOverlayActor->SetPickable(0); mOverlayActor->SetVisibility(true); mOverlayActor->SetOpacity(0.5); - } +#if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) + mOverlayActor->GetMapper()->BorderOn(); +#endif + } //stupid but necessary : the Overlay need to be rendered before fusion if (mFusionActor) { @@ -392,12 +416,12 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) mFusionReslice->AutoCropOutputOn(); mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mFusionReslice->SetResliceTransform(mFusion->GetTransform()); + mFusionReslice->SetResliceTransform(mFusion->GetTransform()[0]); mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData()); if (!mFusionMapper) mFusionMapper = vtkSmartPointer::New(); - + vtkSmartPointer lut = vtkLookupTable::New(); lut->SetRange(0, 1); lut->SetValueRange(0, 1); @@ -412,6 +436,9 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) mFusionActor->SetPickable(0); mFusionActor->SetVisibility(true); mFusionActor->SetOpacity(0.7); +#if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) + mFusionActor->GetMapper()->BorderOn(); +#endif this->GetRenderer()->AddActor(mFusionActor); } @@ -671,8 +698,12 @@ void vvSlicer::SetTSlice(int t) else if ((unsigned int)t >= mImage->GetVTKImages().size()) t = mImage->GetVTKImages().size() -1; - if (mCurrentTSlice == t) return; + // Update transform + mConcatenatedTransform->Identity(); + mConcatenatedTransform->Concatenate(mImage->GetTransform()[t]); + mConcatenatedTransform->Concatenate(mSlicingTransform); + // Update image data mCurrentTSlice = t; mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] ); if (mVF && mVFActor->GetVisibility()) { @@ -909,9 +940,8 @@ void vvSlicer::UpdateDisplayExtent() double cpos = (double)cam->GetPosition()[this->SliceOrientation]; double range = fabs(spos - cpos); double *spacing = input->GetSpacing(); - double avg_spacing = - ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0; - cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0); + double sumSpacing = spacing[0] + spacing[1] + spacing[2]; + cam->SetClippingRange(range - sumSpacing, range + sumSpacing); } } } @@ -1177,6 +1207,7 @@ void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImag corner1[i] = mCurrent[i]; corner2[i] = mCurrent[i]; } + this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]); this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]); @@ -1260,34 +1291,29 @@ void vvSlicer::Render() if (ca->GetVisibility()) { std::stringstream worldPos; - double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0]; - double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1]; - double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2]; - -// if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0]; -// else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1]; -// if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2]; -// else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3]; -// if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4]; -// else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5]; - - if (X >= this->GetInput()->GetWholeExtent()[0] && - X <= this->GetInput()->GetWholeExtent()[1] && - Y >= this->GetInput()->GetWholeExtent()[2] && - Y <= this->GetInput()->GetWholeExtent()[3] && - Z >= this->GetInput()->GetWholeExtent()[4] && - Z <= this->GetInput()->GetWholeExtent()[5]) { + double pt[3]; + mConcatenatedTransform->TransformPoint(mCurrent, pt); + double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0]; + double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1]; + double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2]; + + if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 && + X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 && + Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 && + Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 && + Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 && + Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) { int ix, iy, iz; - double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz); + double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz); if(ImageActor->GetVisibility()) worldPos << "data value : " << value << std::endl; - worldPos << "mm : " << lrint(mCurrent[0]) << ' ' - << lrint(mCurrent[1]) << ' ' - << lrint(mCurrent[2]) << ' ' + worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' ' + << lrint(mCurrentBeforeSlicingTransform[1]) << ' ' + << lrint(mCurrentBeforeSlicingTransform[2]) << ' ' << mCurrentTSlice << std::endl; worldPos << "pixel : " << ix << ' '