-
- switch (i)
- {
- case 0:
- if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > mSlice)
- {
- mSquaresActor->SetPosition(1,0,0);
- }
- else
- {
- mSquaresActor->SetPosition(-1,0,0);
- }
- break;
- case 2:
- if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > mSlice)
- {
- mSquaresActor->SetPosition(0,1,0);
- }
- else
- {
- mSquaresActor->SetPosition(0,-1,0);
- }
- break;
- case 4:
- if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > mSlice)
- {
- mSquaresActor->SetPosition(0,0,1);
- }
- else
- {
- mSquaresActor->SetPosition(0,0,-1);
- }
- break;
+ orientation = orientation/2;
+ return orientation;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvImageContour::UpdateWithFastCacheMode() {
+clitkExceptionMacro("TODO : not implemented yet");
+
+ // Compute orientation
+ int orientation = ComputeCurrentOrientation();
+
+ if ((mPreviousSlice == mSlice) && (mPreviousOrientation == orientation)) return;
+
+ vtkActor * actor = mListOfCachedContourActors[orientation][mSlice];
+ if (actor != NULL) {
+ mListOfCachedContourActors[orientation][mSlice]->VisibilityOn();
+ } else {
+ 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)
+ mListOfCachedContourActors[mPreviousOrientation][mPreviousSlice]->VisibilityOff();
+ mPreviousSlice = mSlice;
+ mPreviousOrientation = orientation;
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+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)
+ clipper->SetInput(mHiddenImage->GetVTKImages()[0]);
+ else
+ 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);
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvImageContour::UpdateActor(vtkActor * actor,
+ vtkMarchingSquares * squares,
+ vtkImageClip * clipper,
+ double threshold, int orientation, int slice) {
+ // Set parameter for the MarchigSquare
+ squares->SetValue(0, threshold);
+
+ // Get image extent
+ int* extent = mSlicer->GetImageActor()->GetDisplayExtent();
+
+ // Change extent if needed
+ int* extent2;
+ if (mHiddenImageIsUsed) {
+ 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
+ s = s+mSlicer->GetImage()->GetOrigin()[orientation]; // from origin
+ 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];