X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvImageContour.cxx;h=173bde0e900e9f80b28cdf5c85bf87d906b8afb7;hb=ab206a7a4b46ce4289cf26690114e84b215e5a83;hp=f0c11b6c710a4afa6e88dd176f163615b78c2070;hpb=fad7d69a7df544d05deaa19b81bd770aa4c7dd47;p=clitk.git diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index f0c11b6..173bde0 100644 --- a/vv/vvImageContour.cxx +++ b/vv/vvImageContour.cxx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - Léon Bérard cancer center http://www.centreleonberard.fr - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr This software is distributed WITHOUT ANY WARRANTY; without even @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html - ======================================================================-====*/ + ===========================================================================**/ #include "vvImageContour.h" #include "vvImage.h" @@ -35,6 +35,8 @@ vvImageContour::vvImageContour() mHiddenImageIsUsed = false; mDisplayModeIsPreserveMemory = true; SetPreserveMemoryModeEnabled(true); + mPreviousOrientation = -1; + mDepth = 1.0; } //------------------------------------------------------------------------------ @@ -138,7 +140,9 @@ void vvImageContour::Update(double value) { if (mPreviousValue == value) { if (mPreviousSlice == mSlicer->GetSlice()) { if (mPreviousTSlice == mSlicer->GetTSlice()) { - return; // Nothing to do + if (mPreviousOrientation == ComputeCurrentOrientation()) { + return; // Nothing to do + } } } } @@ -156,11 +160,12 @@ void vvImageContour::Update(double value) { UpdateWithFastCacheMode(); } - // mSlicer->Render(); //DS ---> REMOVE ?? + //mSlicer->Render(); //DS ---> REMOVE ?? mPreviousTSlice = mSlicer->GetTSlice(); mPreviousSlice = mSlicer->GetSlice(); mPreviousValue = value; + mPreviousOrientation = ComputeCurrentOrientation(); } //------------------------------------------------------------------------------ @@ -168,20 +173,22 @@ void vvImageContour::Update(double value) { //------------------------------------------------------------------------------ void vvImageContour::UpdateWithPreserveMemoryMode() { // Only change actor visibility if tslice change - int mPreviousTslice = mTSlice; + mPreviousTslice = mTSlice; mTSlice = mSlicer->GetTSlice(); vtkMarchingSquares * mSquares = mSquaresList[mTSlice]; + vtkPolyDataMapper* mapper = mSquaresMapperList[mTSlice]; vtkImageClip * mClipper = mClipperList[mTSlice]; vtkActor * mSquaresActor = mSquaresActorList[mTSlice]; int orientation = ComputeCurrentOrientation(); - UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); - //mSquaresActorList[mTSlice]->VisibilityOn(); + UpdateActor(mSquaresActor, mapper, mSquares, mClipper, mValue, orientation, mSlice); if (mPreviousTslice != mTSlice) { if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff(); } + + mSlicer->Render(); } //------------------------------------------------------------------------------ @@ -261,6 +268,7 @@ void vvImageContour::CreateNewActor(int numImage) { clipper->SetInput(mHiddenImage->GetVTKImages()[0]); else clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]); + squares->SetInput(clipper->GetOutput()); squaresMapper->SetInput(squares->GetOutput()); squaresMapper->ScalarVisibilityOff(); @@ -280,10 +288,11 @@ void vvImageContour::CreateNewActor(int numImage) { //------------------------------------------------------------------------------ void vvImageContour::UpdateActor(vtkActor * actor, + vtkPolyDataMapper * mapper, vtkMarchingSquares * squares, vtkImageClip * clipper, double threshold, int orientation, int slice) { - // Set parameter for the MarchigSquare + // Set parameter for the MarchigSquare squares->SetValue(0, threshold); // Get image extent @@ -303,15 +312,16 @@ void vvImageContour::UpdateActor(vtkActor * actor, s = s-mHiddenImage->GetFirstVTKImageData()->GetOrigin()[orientation]; // from corner second image s = s/mHiddenImage->GetFirstVTKImageData()->GetSpacing()[orientation]; // in voxel - if (s == floor(s)) { - extent2[orientation*2] = extent2[orientation*2+1] = (int)floor(s); - } else { - extent2[orientation*2] = (int)floor(s); - extent2[orientation*2+1] = extent2[orientation*2]; - } + // Rint to the closest slice + extent2[orientation*2+1] = extent2[orientation*2] = (int)lrint(s); // Do not display a contour if there is no contour on this slice - if (extent2[orientation*2+1] > extent3[orientation*2+1]) { + // DD(extent2[orientation*2+1]); + // DD(extent3[orientation*2+1]); + // DD(extent2[orientation*2]); + // DD(extent3[orientation*2]); + if ((extent2[orientation*2+1] > extent3[orientation*2+1]) || + (extent2[orientation*2] < extent3[orientation*2])) { actor->VisibilityOff(); return; } @@ -319,6 +329,7 @@ void vvImageContour::UpdateActor(vtkActor * actor, } else { extent2 = extent; + actor->VisibilityOn(); } clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2], @@ -327,44 +338,11 @@ void vvImageContour::UpdateActor(vtkActor * actor, if (mHiddenImageIsUsed) delete extent2; // Move the actor to be visible - switch (orientation) { - case 0: - actor->SetPosition(-1,0,0); - /* - // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0]); - if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) { - actor->SetPosition(1,0,0); - } else { - actor->SetPosition(-1,0,0); - }*/ - break; - case 1: - actor->SetPosition(0,-1,0); - /* - // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1]); - if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) { - actor->SetPosition(0,1,0); - } else { - actor->SetPosition(0,-1,0); - } - */ - break; - case 2: - actor->SetPosition(0,0,-1); - /* - DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]); - if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) { - DD("1"); - actor->SetPosition(0,0,1); - } else { - DD("-1"); - actor->SetPosition(0,0,-1); - } - */ - break; - } - - squares->Update(); + double position[3] = {0, 0, 0}; + position[orientation] = -mDepth; + actor->SetPosition(position); + + mapper->Update(); } //------------------------------------------------------------------------------