- switch (orientation) {
- case 0: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) {
- actor->SetPosition(1,0,0);
- }
- else {
- actor->SetPosition(-1,0,0);
- }
- break;
- case 1: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) {
- actor->SetPosition(0,1,0);
- }
- else {
- actor->SetPosition(0,-1,0);
- }
- break;
- case 2: if (mSlicer->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) {
- actor->SetPosition(0,0,1);
- }
- else {
- actor->SetPosition(0,0,-1);
+ // 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
+
+ // 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
+ // 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;