X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=vv%2FvvImageContour.cxx;h=99bc6e495858a5156cc6951600e555edb7a31be7;hb=573d80d0f7a17607d2ee883c21c940c0ba020282;hp=56a91203b1a8609bf4e8465d34cd01e5996bcd1b;hpb=8d8c142b9adc1529993aaa856dc5ac725bf37679;p=clitk.git diff --git a/vv/vvImageContour.cxx b/vv/vvImageContour.cxx index 56a9120..99bc6e4 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" @@ -45,9 +45,6 @@ vvImageContour::~vvImageContour() for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) { mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]); } - mSquaresActorList.clear(); - mSquaresList.clear(); - mClipperList.clear(); } //------------------------------------------------------------------------------ @@ -57,20 +54,14 @@ void vvImageContour::SetSlicer(vvSlicer * slicer) { mSlicer = slicer; // Create an actor for each time slice for (unsigned int numImage = 0; numImage < mSlicer->GetImage()->GetVTKImages().size(); numImage++) { - vtkImageClip * mClipper = vtkImageClip::New(); - vtkMarchingSquares * mSquares = vtkMarchingSquares::New(); - vtkActor * mSquaresActor = vtkActor::New(); - CreateNewActor(&mSquaresActor, &mSquares, &mClipper, numImage); - mSquaresActorList.push_back(mSquaresActor); - mSquaresList.push_back(mSquares); - mClipperList.push_back(mClipper); + CreateNewActor(numImage); } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ -void vvImageContour::SetImage(vvImage::Pointer image) { +void vvImageContour::SetImage(vvImage * image) { for (unsigned int numImage = 0; numImage < image->GetVTKImages().size(); numImage++) { mClipperList[numImage]->SetInput(image->GetVTKImages()[numImage]); } @@ -186,7 +177,7 @@ void vvImageContour::UpdateWithPreserveMemoryMode() { int orientation = ComputeCurrentOrientation(); UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); - mSquaresActorList[mTSlice]->VisibilityOn(); + //mSquaresActorList[mTSlice]->VisibilityOn(); if (mPreviousTslice != mTSlice) { if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff(); @@ -197,6 +188,7 @@ void vvImageContour::UpdateWithPreserveMemoryMode() { //------------------------------------------------------------------------------ void vvImageContour::InitializeCacheMode() { +clitkExceptionMacro("TODO : not implemented yet"); mPreviousSlice = mPreviousOrientation = 0; int dim = mSlicer->GetImage()->GetNumberOfDimensions(); @@ -232,6 +224,8 @@ int vvImageContour::ComputeCurrentOrientation() { //------------------------------------------------------------------------------ void vvImageContour::UpdateWithFastCacheMode() { +clitkExceptionMacro("TODO : not implemented yet"); + // Compute orientation int orientation = ComputeCurrentOrientation(); @@ -241,13 +235,11 @@ void vvImageContour::UpdateWithFastCacheMode() { if (actor != NULL) { mListOfCachedContourActors[orientation][mSlice]->VisibilityOn(); } else { - vtkImageClip * mClipper; - vtkMarchingSquares * mSquares; - vtkActor * mSquaresActor; - CreateNewActor(&mSquaresActor, &mSquares, &mClipper, 0); - UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); - mListOfCachedContourActors[orientation][mSlice] = mSquaresActor; - mSquaresActor->VisibilityOn(); + CreateNewActor(0); + //SR: commented out, this code is never reached anyway + //UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice); + //mListOfCachedContourActors[orientation][mSlice] = mSquaresActor; + //mSquaresActor->VisibilityOn(); } if (mListOfCachedContourActors[mPreviousOrientation][mPreviousSlice] != NULL) @@ -259,27 +251,29 @@ void vvImageContour::UpdateWithFastCacheMode() { //------------------------------------------------------------------------------ -void vvImageContour::CreateNewActor(vtkActor ** actor, - vtkMarchingSquares ** squares, - vtkImageClip ** clipper, - int numImage) { - vtkActor * mSquaresActor = (*actor = vtkActor::New()); - vtkImageClip * mClipper = (*clipper = vtkImageClip::New()); - vtkMarchingSquares * mSquares = (*squares = vtkMarchingSquares::New()); - vtkPolyDataMapper * mSquaresMapper = vtkPolyDataMapper::New(); +void vvImageContour::CreateNewActor(int numImage) { + vtkSmartPointer squaresActor = vtkSmartPointer::New(); + vtkSmartPointer clipper = vtkSmartPointer::New(); + vtkSmartPointer squares = vtkSmartPointer::New(); + vtkSmartPointer squaresMapper = vtkSmartPointer::New(); if (mHiddenImageIsUsed) - mClipper->SetInput(mHiddenImage->GetVTKImages()[0]); + clipper->SetInput(mHiddenImage->GetVTKImages()[0]); else - mClipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]); - mSquares->SetInput(mClipper->GetOutput()); - mSquaresMapper->SetInput(mSquares->GetOutput()); - mSquaresMapper->ScalarVisibilityOff(); - mSquaresActor->SetMapper(mSquaresMapper); - mSquaresActor->GetProperty()->SetColor(1.0,0,0); - mSquaresActor->SetPickable(0); - mSquaresActor->VisibilityOff(); - mSlicer->GetRenderer()->AddActor(mSquaresActor); + clipper->SetInput(mSlicer->GetImage()->GetVTKImages()[numImage]); + squares->SetInput(clipper->GetOutput()); + squaresMapper->SetInput(squares->GetOutput()); + squaresMapper->ScalarVisibilityOff(); + squaresActor->SetMapper(squaresMapper); + squaresActor->GetProperty()->SetColor(1.0,0,0); + squaresActor->SetPickable(0); + squaresActor->VisibilityOff(); + mSlicer->GetRenderer()->AddActor(squaresActor); + + mSquaresActorList.push_back(squaresActor); + mClipperList.push_back(clipper); + mSquaresList.push_back(squares); + mSquaresMapperList.push_back(squaresMapper); } //------------------------------------------------------------------------------ @@ -330,7 +324,7 @@ void vvImageContour::UpdateActor(vtkActor * actor, clipper->SetOutputWholeExtent(extent2[0],extent2[1],extent2[2], extent2[3],extent2[4],extent2[5]); - if (mHiddenImage) delete extent2; + if (mHiddenImageIsUsed) delete extent2; // Move the actor to be visible switch (orientation) {