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
- 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"
mSlice = 0;
mHiddenImageIsUsed = false;
mDisplayModeIsPreserveMemory = true;
+ SetPreserveMemoryModeEnabled(true);
}
//------------------------------------------------------------------------------
for (unsigned int i = 0; i < mSlicer->GetImage()->GetVTKImages().size(); i++) {
mSlicer->GetRenderer()->RemoveActor(mSquaresActorList[i]);
}
- mSquaresActorList.clear();
- mSquaresList.clear();
- mClipperList.clear();
}
//------------------------------------------------------------------------------
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]);
}
if (mDisplayModeIsPreserveMemory == b) return;
mDisplayModeIsPreserveMemory = b;
if (!b) {
+ clitkExceptionMacro("TODO : not implemented yet");
HideActors();
InitializeCacheMode();
}
if (!mSlicer) return;
mSlice = mSlicer->GetSlice();
mTSlice = mSlicer->GetTSlice();
- // for(unsigned int i=0; i<mSquaresActorList.size(); i++) {
mSquaresActorList[mTSlice]->VisibilityOn();
Update(mValue);
- //}
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void vvImageContour::Update(double value) {
- // DD(value);
if (!mSlicer) return;
if (mPreviousValue == value) {
if (mPreviousSlice == mSlicer->GetSlice()) {
if (mPreviousTSlice == mSlicer->GetTSlice()) {
- // DD("vvImageContour::update nothing");
return; // Nothing to do
}
}
// Get current slice
mSlice = mSlicer->GetSlice();
- // DD(mDisplayModeIsPreserveMemory);
+
if (mDisplayModeIsPreserveMemory) {
UpdateWithPreserveMemoryMode();
}
//------------------------------------------------------------------------------
void vvImageContour::UpdateWithPreserveMemoryMode() {
// Only change actor visibility if tslice change
- //DD(mTSlice);
- //DD(mSlice);
int mPreviousTslice = mTSlice;
- // ;
- // if (mTSlice != mSlicer->GetTSlice()) {
- // if (mTSlice != -1) mTsliceToSetOff = mTSlice;
- // mSquaresActorList[mTSlice]->VisibilityOff();
mTSlice = mSlicer->GetTSlice();
- // }
- // else return;
- // DD(mTSlice);
+
vtkMarchingSquares * mSquares = mSquaresList[mTSlice];
vtkImageClip * mClipper = mClipperList[mTSlice];
vtkActor * mSquaresActor = mSquaresActorList[mTSlice];
int orientation = ComputeCurrentOrientation();
- // DD(orientation);
- //DD(mValue);
- //DD(mSlice);
- //DD(mPreviousTslice);
+
UpdateActor(mSquaresActor, mSquares, mClipper, mValue, orientation, mSlice);
- mSquaresActorList[mTSlice]->VisibilityOn();
+ //mSquaresActorList[mTSlice]->VisibilityOn();
+
if (mPreviousTslice != mTSlice) {
if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff();
}
//------------------------------------------------------------------------------
void vvImageContour::InitializeCacheMode() {
+clitkExceptionMacro("TODO : not implemented yet");
mPreviousSlice = mPreviousOrientation = 0;
int dim = mSlicer->GetImage()->GetNumberOfDimensions();
mListOfCachedContourActors.resize(dim);
for(int d=0; d<dim; d++) {
int size = mSlicer->GetImage()->GetSize()[d];
- //DD(size);
mListOfCachedContourActors[d].resize(size);
for(int j=0; j<size; j++) {
mListOfCachedContourActors[d][j] = NULL;
//------------------------------------------------------------------------------
void vvImageContour::UpdateWithFastCacheMode() {
+clitkExceptionMacro("TODO : not implemented yet");
+
// Compute orientation
int orientation = ComputeCurrentOrientation();
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)
//------------------------------------------------------------------------------
-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<vtkActor> squaresActor = vtkSmartPointer<vtkActor>::New();
+ vtkSmartPointer<vtkImageClip> clipper = vtkSmartPointer<vtkImageClip>::New();
+ vtkSmartPointer<vtkMarchingSquares> squares = vtkSmartPointer<vtkMarchingSquares>::New();
+ vtkSmartPointer<vtkPolyDataMapper> squaresMapper = vtkSmartPointer<vtkPolyDataMapper>::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);
}
//------------------------------------------------------------------------------
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
extent2 = new int[6];
int * extent3;
extent3 = mHiddenImage->GetFirstVTKImageData()->GetExtent();
+
for(int i=0; i<6; i++) extent2[i] = extent3[i];
double s = (double)extent[orientation*2]*(double)mSlicer->GetImage()->GetSpacing()[orientation]; // in mm
extent2[orientation*2] = (int)floor(s);
extent2[orientation*2+1] = extent2[orientation*2];
}
+
+ // Do not display a contour if there is no contour on this slice
+ if (extent2[orientation*2+1] > extent3[orientation*2+1]) {
+ actor->VisibilityOff();
+ return;
+ }
+ else actor->VisibilityOn();
+
} else {
extent2 = extent;
}
+
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
- // DD(orientation);
- // DD(slice);
-
- //TO SIMPLiFY :!!!!!!!!! == ???????
- // actor->SetPosition(-1,-1,-1);
-
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);
+ 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:
- // DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
+ actor->SetPosition(0,0,-1);
+ /*
+ DD(mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2]);
if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
- // DD("1");
+ DD("1");
actor->SetPosition(0,0,1);
} else {
- // DD("-1");
+ DD("-1");
actor->SetPosition(0,0,-1);
}
+ */
break;
}