X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvSlicer.cxx;h=abf6306f360164c63b7bbe5e492931c1a0e6c971;hb=ba72deb1cf11f32261e565d3103afd84571a0cf2;hp=247820561076c445f95e7943857878d62fd2f672;hpb=bc6406413211e543d16f2af0a94ac27ad75cbbb3;p=clitk.git diff --git a/vv/vvSlicer.cxx b/vv/vvSlicer.cxx index 2478205..abf6306 100644 --- a/vv/vvSlicer.cxx +++ b/vv/vvSlicer.cxx @@ -82,6 +82,8 @@ vvSlicer::vvSlicer() mImage = NULL; mReducedExtent = new int[6]; mCurrentTSlice = 0; + mCurrentFusionTSlice = 0; + mCurrentOverlayTSlice = 0; mUseReducedExtent = false; mCurrent[0] = -VTK_DOUBLE_MAX; @@ -145,6 +147,11 @@ vvSlicer::vvSlicer() #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10) this->GetImageActor()->GetMapper()->BorderOn(); #endif + + mSlicingTransform = vtkSmartPointer::New(); + mConcatenatedTransform = vtkSmartPointer::New(); + mConcatenatedFusionTransform = vtkSmartPointer::New(); + mConcatenatedOverlayTransform = vtkSmartPointer::New(); } //------------------------------------------------------------------------------ @@ -290,14 +297,21 @@ 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; - mCurrentTSlice = t; + mCurrentBeforeSlicingTransform[0]=x; + mCurrentBeforeSlicingTransform[1]=y; + mCurrentBeforeSlicingTransform[2]=z; + mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent); + SetTSlice(t); } //------------------------------------------------------------------------------ @@ -314,7 +328,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(); @@ -355,8 +373,13 @@ void vvSlicer::SetOverlay(vvImage::Pointer overlay) mOverlayReslice->AutoCropOutputOn(); mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()); + + mConcatenatedOverlayTransform->Identity(); + mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]); + mConcatenatedOverlayTransform->Concatenate(mSlicingTransform); + mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform); mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData()); + mImageReslice->UpdateInformation(); if (!mOverlayMapper) mOverlayMapper = vtkSmartPointer::New(); @@ -402,8 +425,13 @@ void vvSlicer::SetFusion(vvImage::Pointer fusion) mFusionReslice->AutoCropOutputOn(); mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1); } - mFusionReslice->SetResliceTransform(mFusion->GetTransform()); + + mConcatenatedFusionTransform->Identity(); + mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]); + mConcatenatedFusionTransform->Concatenate(mSlicingTransform); + mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform); mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData()); + mFusionReslice->UpdateInformation(); if (!mFusionMapper) mFusionMapper = vtkSmartPointer::New(); @@ -684,6 +712,12 @@ void vvSlicer::SetTSlice(int t) else if ((unsigned int)t >= mImage->GetVTKImages().size()) t = mImage->GetVTKImages().size() -1; + // 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()) { @@ -691,12 +725,16 @@ void vvSlicer::SetTSlice(int t) mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]); } if (mOverlay && mOverlayActor->GetVisibility()) { - if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice) - mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] ); + if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice) { + mCurrentOverlayTSlice = mCurrentTSlice; + mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] ); + } } if (mFusion && mFusionActor->GetVisibility()) { - if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice) - mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]); + if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice) { + mCurrentFusionTSlice = mCurrentTSlice; + mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]); + } } if (mSurfaceCutActors.size() > 0) for (std::vector::iterator i=mSurfaceCutActors.begin(); @@ -714,6 +752,20 @@ int vvSlicer::GetTSlice() } //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +int vvSlicer::GetFusionTSlice() +{ + return mCurrentFusionTSlice; +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +int vvSlicer::GetOverlayTSlice() +{ + return mCurrentOverlayTSlice; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvSlicer::SetSliceOrientation(int orientation) { @@ -1177,7 +1229,7 @@ void vvSlicer::SetOverlayColorLevel(double level) //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -// Returns the min an the max value in a 41x41 region around the mouse pointer +// Returns the min an the max value in a 20%x20% region around the mouse pointer void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform) { //Get mouse pointer position in view coordinates @@ -1271,34 +1323,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 << ' '