+//------------------------------------------------------------------------------
+void vvImageContour::ShowActors() {
+ if (!mSlicer) return;
+ mSlice = mSlicer->GetSlice();
+ mTSlice = mSlicer->GetTSlice();
+ mSquaresActorList[mTSlice]->VisibilityOn();
+ Update(mValue);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvImageContour::Update(double value) {
+ if (!mSlicer) return;
+ if (mPreviousValue == value) {
+ if (mPreviousSlice == mSlicer->GetSlice()) {
+ if (mPreviousTSlice == mSlicer->GetTSlice()) {
+ if (mPreviousOrientation == ComputeCurrentOrientation()) {
+ return; // Nothing to do
+ }
+ }
+ }
+ }
+
+ // Get current threshold value
+ mValue = value;
+
+ // Get current slice
+ mSlice = mSlicer->GetSlice();
+
+ if (mDisplayModeIsPreserveMemory) {
+ UpdateWithPreserveMemoryMode();
+ }
+ else {
+ UpdateWithFastCacheMode();
+ }
+
+ //mSlicer->Render(); //DS ---> REMOVE ??
+
+ mPreviousTSlice = mSlicer->GetTSlice();
+ mPreviousSlice = mSlicer->GetSlice();
+ mPreviousValue = value;
+ mPreviousOrientation = ComputeCurrentOrientation();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvImageContour::UpdateWithPreserveMemoryMode() {
+ // Only change actor visibility if tslice change
+ 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, mapper, mSquares, mClipper, mValue, orientation, mSlice);
+
+ if (mPreviousTslice != mTSlice) {
+ if (mPreviousTslice != -1) mSquaresActorList[mPreviousTslice]->VisibilityOff();
+ }
+
+ mSlicer->Render();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+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];
+ mListOfCachedContourActors[d].resize(size);
+ for(int j=0; j<size; j++) {
+ mListOfCachedContourActors[d][j] = NULL;
+ }
+ }
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+int vvImageContour::ComputeCurrentOrientation() {
+ // Get extent of image in the slicer