1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #include <QMessageBox>
24 #include "vvSlicerManagerCommand.h"
25 #include "vvGlyphSource.h"
26 #include "vvGlyph2D.h"
28 #include <vtkVersion.h>
29 #include <vtkExtentTranslator.h>
30 #include <vtkAlgorithm.h>
31 #include <vtkExecutive.h>
32 #include <vtkStreamingDemandDrivenPipeline.h>
33 #include <vtkInformation.h>
34 #include <vtkTextProperty.h>
35 #include <vtkTextActor.h>
36 #include <vtkTextSource.h>
37 #include <vtkActor2D.h>
38 #include <vtkCursor2D.h>
39 #include <vtkPolyDataMapper2D.h>
40 #include <vtkProperty2D.h>
41 #include <vtkCornerAnnotation.h>
42 #include <vtkImageMapToWindowLevelColors.h>
43 #include <vtkImageData.h>
44 #include <vtkImageActor.h>
45 #include <vvBlendImageActor.h>
46 #include <vtkToolkits.h>
47 #include <vtkObjectFactory.h>
48 #include <vtkPointData.h>
49 #include <vtkDataArray.h>
50 #include <vtkFloatArray.h>
51 #include <vtkClipPolyData.h>
52 #include <vtkActor2DCollection.h>
53 #include <vtkGlyph3D.h>
55 #include <vtkCursor3D.h>
56 #include <vtkProperty.h>
58 #include <vtkLightCollection.h>
59 #include <vtkScalarBarActor.h>
60 #include <vtkImageProperty.h>
61 #include <vtkLookupTable.h>
63 #include <vtkRenderer.h>
64 #include <vtkRendererCollection.h>
65 #include <vtkRenderWindow.h>
66 #include <vtkRenderWindowInteractor.h>
67 #include <vtkCamera.h>
68 #include <vtkCallbackCommand.h>
69 #include <vtkCommand.h>
70 #include <vtkPolyDataMapper.h>
73 #include <vtkExtractVOI.h>
74 #include <vtkSphereSource.h>
75 #include <vtkCutter.h>
76 #include <vtkAssignAttribute.h>
77 #include <vtkImageAccumulate.h>
78 #include <vtkImageReslice.h>
79 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
80 # include <vtkOpenGLImageSliceMapper.h>
81 # include <vtkImageMapper3D.h>
82 # include <vtkImageSliceMapper.h>
85 vtkStandardNewMacro(vvSlicer);
86 static void copyExtent(int* in, int* to){
87 for(int i=0; i<6; ++i)
92 //------------------------------------------------------------------------------
95 mFusionSequenceCode = -1;
96 this->UnInstallPipeline();
98 mReducedExtent = new int[6];
99 mRegisterExtent = NULL;
101 mCurrentFusionTSlice = 0;
102 mCurrentOverlayTSlice = 0;
103 mUseReducedExtent = false;
105 mCurrent[0] = -VTK_DOUBLE_MAX;
106 mCurrent[1] = -VTK_DOUBLE_MAX;
107 mCurrent[2] = -VTK_DOUBLE_MAX;
109 mCursor[0] = 0;//-VTK_DOUBLE_MAX;
110 mCursor[1] = 0;//-VTK_DOUBLE_MAX;
111 mCursor[2] = 0;//-VTK_DOUBLE_MAX;
112 mCursor[3] = 0;//-VTK_DOUBLE_MAX;
122 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
123 crossCursor->AllOff();
124 crossCursor->AxesOn();
125 crossCursor->SetTranslationMode(1);
126 crossCursor->SetRadius(2);
128 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
129 #if VTK_MAJOR_VERSION <= 5
130 pdm->SetInput(crossCursor->GetOutput());
132 pdm->SetInputConnection(crossCursor->GetOutputPort(0));
135 pdmA = vtkSmartPointer<vtkActor2D>::New();
136 pdmA->SetMapper(pdm);
137 pdmA->GetProperty()->SetColor(255,10,212);
138 pdmA->SetVisibility(0);
139 pdmA->SetPickable(0);
141 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
142 ca->GetTextProperty()->SetColor(255,10,212);
143 ca->SetVisibility(1);
151 legend = vtkSmartPointer<vtkScalarBarActor>::New();
152 //legend->SetTitle("test!");
153 legend->SetPosition(0.82,0.18);
154 legend->SetWidth(0.1);
155 legend->SetVisibility(0);
156 legend->SetLabelFormat("%.1f");
157 this->GetRenderer()->AddActor(legend);
158 showFusionLegend = false;
160 this->InstallPipeline();
162 mLinkOverlayWindowLevel = true;
163 mImageVisibility = true;
165 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
166 this->GetImageActor()->GetMapper()->BorderOn();
169 mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
170 mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
171 mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
172 mConcatenatedOverlayTransform = vtkSmartPointer<vtkTransform>::New();
173 mFirstSetSliceOrientation = true;
175 //------------------------------------------------------------------------------
178 //------------------------------------------------------------------------------
179 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
181 return mOverlayMapper.GetPointer();
183 //------------------------------------------------------------------------------
186 //------------------------------------------------------------------------------
187 vvBlendImageActor* vvSlicer::GetOverlayActor()
189 return mOverlayActor.GetPointer();
191 //------------------------------------------------------------------------------
194 //------------------------------------------------------------------------------
195 vtkImageMapToColors* vvSlicer::GetFusionMapper()
197 return mFusionMapper.GetPointer();
199 //------------------------------------------------------------------------------
202 //------------------------------------------------------------------------------
203 vtkImageActor* vvSlicer::GetFusionActor()
205 return mFusionActor.GetPointer();
207 //------------------------------------------------------------------------------
210 //------------------------------------------------------------------------------
211 vtkActor* vvSlicer::GetVFActor()
213 return mVFActor.GetPointer();
215 //------------------------------------------------------------------------------
218 //------------------------------------------------------------------------------
219 vtkCornerAnnotation* vvSlicer::GetAnnotation()
221 return ca.GetPointer();
223 //------------------------------------------------------------------------------
226 //------------------------------------------------------------------------------
227 void vvSlicer::EnableReducedExtent(bool b)
229 mUseReducedExtent = b;
231 //------------------------------------------------------------------------------
234 //------------------------------------------------------------------------------
235 void vvSlicer::SetReducedExtent(int * ext)
237 copyExtent(ext, mReducedExtent);
239 //------------------------------------------------------------------------------
242 //------------------------------------------------------------------------------
243 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
246 mSurfaceCutActors.push_back(new vvMeshActor());
248 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
250 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
251 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
252 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 void vvSlicer::ToggleContourSuperposition()
262 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
263 i!=mSurfaceCutActors.end(); i++)
264 (*i)->ToggleSuperposition();
266 //------------------------------------------------------------------------------
269 //------------------------------------------------------------------------------
270 void vvSlicer::SetCursorColor(int r,int g, int b)
272 pdmA->GetProperty()->SetColor(r,g,b);
274 //------------------------------------------------------------------------------
277 //------------------------------------------------------------------------------
278 void vvSlicer::SetCursorVisibility(bool s)
280 pdmA->SetVisibility(s);
282 //------------------------------------------------------------------------------
285 //------------------------------------------------------------------------------
286 bool vvSlicer::GetCursorVisibility()
288 return pdmA->GetVisibility();
290 //------------------------------------------------------------------------------
293 //------------------------------------------------------------------------------
294 void vvSlicer::SetCornerAnnotationVisibility(bool s)
296 ca->SetVisibility(s);
298 //------------------------------------------------------------------------------
301 //------------------------------------------------------------------------------
302 bool vvSlicer::GetCornerAnnotationVisibility()
304 return ca->GetVisibility();
306 //------------------------------------------------------------------------------
309 //------------------------------------------------------------------------------
310 vvSlicer::~vvSlicer()
312 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
313 i!=mSurfaceCutActors.end(); i++)
315 delete [] mReducedExtent;
317 //------------------------------------------------------------------------------
319 //------------------------------------------------------------------------------
320 double* vvSlicer::GetCurrentPosition()
322 return mCurrentBeforeSlicingTransform;
324 //------------------------------------------------------------------------------
326 //------------------------------------------------------------------------------
327 void vvSlicer::SetInterpolationImageReslice(int interpolation)
329 mImageReslice->SetInterpolationMode(interpolation);
331 //------------------------------------------------------------------------------
333 //------------------------------------------------------------------------------
334 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
336 mCurrentBeforeSlicingTransform[0]=x;
337 mCurrentBeforeSlicingTransform[1]=y;
338 mCurrentBeforeSlicingTransform[2]=z;
339 mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
340 if (t>=0) SetTSlice(t);
342 //------------------------------------------------------------------------------
345 //------------------------------------------------------------------------------
346 void vvSlicer::SetImage(vvImage::Pointer image)
348 if (image->GetVTKImages().size()) {
351 if (!mImageReslice) {
352 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
353 mImageReslice->SetInterpolationModeToLinear();
354 mImageReslice->AutoCropOutputOn();
355 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
358 mConcatenatedTransform->Identity();
359 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
360 mConcatenatedTransform->Concatenate(mSlicingTransform);
361 mImageReslice->SetResliceTransform(mConcatenatedTransform);
362 //mImageReslice->SetResliceAxes(mConcatenatedTransform->GetMatrix());
363 #if VTK_MAJOR_VERSION <= 5
364 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
366 mImageReslice->SetInputData(0, mImage->GetFirstVTKImageData());
368 mImageReslice->UpdateInformation();
370 #if VTK_MAJOR_VERSION <= 5
371 this->Superclass::SetInput(mImageReslice->GetOutput());
373 this->Superclass::SetInputConnection(mImageReslice->GetOutputPort());
377 #if VTK_MAJOR_VERSION <= 5
378 this->GetInput()->GetWholeExtent(extent);
380 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
381 copyExtent(ext, extent);
384 // Prevent crash when reload -> change slice if outside extent
385 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
386 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
389 // Make sure that the required part image has been computed
390 extent[SliceOrientation*2] = Slice;
391 extent[SliceOrientation*2+1] = Slice;
392 #if VTK_MAJOR_VERSION <= 5
393 mImageReslice->GetOutput()->SetUpdateExtent(extent);
394 mImageReslice->GetOutput()->Update();
396 //mImageReslice->SetUpdateExtent(extent);
397 mImageReslice->Update();
400 this->UpdateDisplayExtent();
403 ca->SetText(0,mFileName.c_str());
406 //------------------------------------------------------------------------------
409 //------------------------------------------------------------------------------
410 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
412 if (overlay->GetVTKImages().size()) {
414 mOverlayVisibility = true;
416 if (!mOverlayReslice) {
417 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
418 mOverlayReslice->SetInterpolationModeToLinear();
419 mOverlayReslice->AutoCropOutputOn();
420 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
423 mConcatenatedOverlayTransform->Identity();
424 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]);
425 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
426 mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform);
427 #if VTK_MAJOR_VERSION <= 5
428 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
429 mImageReslice->UpdateInformation();
431 mOverlayReslice->SetInputData(0, mOverlay->GetFirstVTKImageData());
433 mOverlayReslice->Update();
436 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
437 #if VTK_MAJOR_VERSION <= 5
438 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
440 mOverlayMapper->SetInputConnection(mOverlayReslice->GetOutputPort(0));
443 if (!mOverlayActor) {
444 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
445 #if VTK_MAJOR_VERSION <= 5
446 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
448 mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort());
450 mOverlayActor->SetPickable(0);
451 mOverlayActor->SetVisibility(true);
452 mOverlayActor->SetOpacity(0.5);
453 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
454 mOverlayActor->GetMapper()->BorderOn();
458 //stupid but necessary : the Overlay need to be rendered before fusion
460 this->GetRenderer()->RemoveActor(mFusionActor);
461 this->GetRenderer()->AddActor(mOverlayActor);
462 this->GetRenderer()->AddActor(mFusionActor);
464 this->GetRenderer()->AddActor(mOverlayActor);
466 //Synchronize orientation and slice
467 AdjustResliceToSliceOrientation(mOverlayReslice);
468 this->UpdateDisplayExtent();
469 this->SetTSlice(mCurrentTSlice);
472 //------------------------------------------------------------------------------
475 //------------------------------------------------------------------------------
476 void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
478 mFusionSequenceCode = fusionSequenceCode;
479 if (fusion->GetVTKImages().size()) {
481 mFusionVisibility = true;
483 if (!mFusionReslice) {
484 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
485 mFusionReslice->SetInterpolationModeToLinear();
486 mFusionReslice->AutoCropOutputOn();
487 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
490 mConcatenatedFusionTransform->Identity();
491 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]);
492 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
493 mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform);
494 #if VTK_MAJOR_VERSION <= 5
495 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
496 mFusionReslice->UpdateInformation();
498 mFusionReslice->SetInputData(0, mFusion->GetFirstVTKImageData());
500 mFusionReslice->Update();
503 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
505 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
507 lut->SetValueRange(0, 1);
508 lut->SetSaturationRange(0, 0);
510 mFusionMapper->SetLookupTable(lut);
511 #if VTK_MAJOR_VERSION <= 5
512 mFusionMapper->SetInput(mFusionReslice->GetOutput());
514 mFusionMapper->SetInputConnection(mFusionReslice->GetOutputPort(0));
518 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
519 #if VTK_MAJOR_VERSION <= 5
520 mFusionActor->SetInput(mFusionMapper->GetOutput());
522 mFusionActor->GetMapper()->SetInputConnection(mFusionMapper->GetOutputPort());
524 mFusionActor->SetPickable(0);
525 mFusionActor->SetVisibility(true);
526 mFusionActor->SetOpacity(0.7);
527 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
528 mFusionActor->GetMapper()->BorderOn();
531 this->GetRenderer()->AddActor(mFusionActor);
534 //Synchronize orientation and slice
535 AdjustResliceToSliceOrientation(mFusionReslice);
536 this->UpdateDisplayExtent();
537 this->SetTSlice(mCurrentTSlice);
540 //------------------------------------------------------------------------------
543 //------------------------------------------------------------------------------
544 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
547 if (actor_type == "image")
548 vis = mImageVisibility;
549 else if (actor_type == "vector")
551 else if (actor_type == "overlay")
552 vis = mOverlayVisibility;
553 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
554 vis = mFusionVisibility;
555 else if (actor_type == "contour")
556 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
559 //------------------------------------------------------------------------------
561 //------------------------------------------------------------------------------
562 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
564 if (actor_type == "image")
565 mImageVisibility = vis;
566 else if (actor_type == "vector")
568 else if (actor_type == "overlay")
569 mOverlayVisibility = vis;
570 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
571 mFusionVisibility = vis;
572 else if (actor_type == "contour")
573 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
574 UpdateDisplayExtent();
576 //------------------------------------------------------------------------------
578 //------------------------------------------------------------------------------
579 void vvSlicer::SetVF(vvImage::Pointer vf)
581 if (vf->GetVTKImages().size()) {
583 mVFVisibility = true;
586 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
587 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
588 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
590 #if VTK_MAJOR_VERSION <= 5
591 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
592 mAAFilter->SetInput(mVOIFilter->GetOutput());
594 mVOIFilter->SetInputData(vf->GetFirstVTKImageData());
595 mAAFilter->SetInputConnection(mVOIFilter->GetOutputPort());
597 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
598 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
601 mArrow = vtkSmartPointer<vvGlyphSource>::New();
602 mArrow->SetGlyphTypeToSpecificArrow();
603 mArrow->SetScale(mScale);
606 // Glyph the gradient vector (with arrows)
608 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
609 #if VTK_MAJOR_VERSION <= 5
610 mGlyphFilter->SetInput(mAAFilter->GetOutput());
611 mGlyphFilter->SetSource(mArrow->GetOutput());
613 mGlyphFilter->SetInputConnection(mAAFilter->GetOutputPort());
614 mGlyphFilter->SetSourceConnection(mArrow->GetOutputPort());
616 mGlyphFilter->ScalingOn();
617 mGlyphFilter->SetScaleModeToScaleByVector();
618 mGlyphFilter->OrientOn();
619 mGlyphFilter->SetVectorModeToUseVector();
620 mGlyphFilter->SetColorModeToColorByVector();
623 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
625 double mVFColorHSV[3];
626 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
627 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
628 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
629 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
632 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
633 #if VTK_MAJOR_VERSION <= 5
634 mVFMapper->SetInput(mGlyphFilter->GetOutput());
636 mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
638 mVFMapper->ImmediateModeRenderingOn();
639 mVFMapper->SetLookupTable(mVFColorLUT);
642 mVFActor = vtkSmartPointer<vtkActor>::New();
643 mVFActor->SetMapper(mVFMapper);
644 mVFActor->SetPickable(0);
645 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
646 this->UpdateDisplayExtent();
647 this->GetRenderer()->AddActor(mVFActor);
650 SetTSlice(mCurrentTSlice);
653 //------------------------------------------------------------------------------
656 //------------------------------------------------------------------------------
657 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
659 mLandmarks = landmarks;
663 mCross = vtkSmartPointer<vtkCursor3D>::New();
665 mClipBox = vtkSmartPointer<vtkBox>::New();
667 mLandClipper = vtkSmartPointer<vvClipPolyData>::New();
669 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
671 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
673 mLandActor = vtkSmartPointer<vtkActor>::New();
675 mCross->SetFocalPoint(0.0,0.0,0.0);
676 mCross->SetModelBounds(-10,10,-10,10,-10,10);
680 mLandClipper->SetClipFunction(mClipBox);
681 mLandClipper->InsideOutOn();
682 #if VTK_MAJOR_VERSION <= 5
683 mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
684 mLandmarkTransform->SetInput(mLandmarks->GetOutput());
685 mConcatenatedTransform->Identity();
686 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
687 mConcatenatedTransform->Concatenate(mSlicingTransform);
688 mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
689 mLandClipper->SetInput(mLandmarkTransform->GetOutput());
691 mLandGlyph->SetSource(mCross->GetOutput());
692 mLandGlyph->SetInput(mLandClipper->GetOutput());
694 mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
695 mLandmarkTransform->SetInputData(mLandmarks->GetOutput());
696 mConcatenatedTransform->Identity();
697 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
698 mConcatenatedTransform->Concatenate(mSlicingTransform);
699 mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
700 mLandClipper->SetInputConnection(mLandmarkTransform->GetOutputPort());
702 mLandGlyph->SetSourceConnection(mCross->GetOutputPort());
703 mLandGlyph->SetInputConnection(mLandClipper->GetOutputPort());
705 //mLandGlyph->SetIndexModeToScalar();
706 //mLandGlyph->SetRange(0,1);
707 //mLandGlyph->ScalingOff();
709 //mLandGlyph->SetColorModeToColorByScalar();
711 mLandGlyph->SetScaleModeToDataScalingOff();
712 mLandGlyph->SetIndexModeToOff();
714 mLandMapper->SetInputConnection(mLandGlyph->GetOutputPort());
715 //mLandMapper->ScalarVisibilityOff();
717 mLandActor->SetMapper(mLandMapper);
718 mLandActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
719 mLandActor->GetProperty()->SetColor(255,10,212);
720 mLandActor->SetPickable(0);
721 mLandActor->SetVisibility(true);
722 this->UpdateDisplayExtent();
725 //------------------------------------------------------------------------------
727 //------------------------------------------------------------------------------
728 //FIXME: this function leaks memory, we should fix it someday :)
729 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
731 if (actor_type == "vector") {
732 Renderer->RemoveActor(mVFActor);
741 if (actor_type == "overlay") {
742 Renderer->RemoveActor(mOverlayActor);
744 mOverlayActor = NULL;
745 mOverlayMapper = NULL;
747 if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ) {
748 Renderer->RemoveActor(mFusionActor);
751 mFusionMapper = NULL;
753 if (actor_type == "contour") {
754 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
755 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
758 //------------------------------------------------------------------------------
761 //------------------------------------------------------------------------------
762 void vvSlicer::SetVFSubSampling(int sub)
765 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
768 UpdateDisplayExtent();
771 //------------------------------------------------------------------------------
774 //------------------------------------------------------------------------------
775 void vvSlicer::SetVFScale(int scale)
779 mArrow->SetScale(mScale);
780 UpdateDisplayExtent();
783 //------------------------------------------------------------------------------
785 //------------------------------------------------------------------------------
786 void vvSlicer::SetVFWidth(int width)
790 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
791 UpdateDisplayExtent();
794 //------------------------------------------------------------------------------
797 //------------------------------------------------------------------------------
798 void vvSlicer::SetVFLog(int log)
802 mGlyphFilter->SetUseLog(mVFLog);
803 mGlyphFilter->Modified();
805 UpdateDisplayExtent();
808 //------------------------------------------------------------------------------
811 //------------------------------------------------------------------------------
812 void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
814 if (!updateLinkedImages) {
816 #if VTK_MAJOR_VERSION <= 5
817 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
819 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
822 mConcatenatedTransform->Identity();
823 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
824 mConcatenatedTransform->Concatenate(mSlicingTransform);
825 UpdateDisplayExtent();
830 else if ((unsigned int)t >= mImage->GetVTKImages().size())
831 mCurrentTSlice = mImage->GetVTKImages().size() -1;
836 mConcatenatedTransform->Identity();
837 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
838 mConcatenatedTransform->Concatenate(mSlicingTransform);
841 #if VTK_MAJOR_VERSION <= 5
842 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
844 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
846 if (mVF && mVFActor->GetVisibility()) {
847 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
848 #if VTK_MAJOR_VERSION <= 5
849 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
851 mVOIFilter->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]);
855 if (mOverlay && mOverlayActor->GetVisibility()) {
856 if (mOverlay->GetVTKImages().size() > (unsigned int)t) {
857 mCurrentOverlayTSlice = t;
858 #if VTK_MAJOR_VERSION <= 5
859 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
861 mOverlayReslice->SetInputData( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
863 // Update overlay transform
864 mConcatenatedOverlayTransform->Identity();
865 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[mCurrentOverlayTSlice]);
866 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
869 //update the fusion ; except in case this is a fusionSequence, in which case both 'times' should be independent.
870 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode<0)) {
871 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
872 mCurrentFusionTSlice = t;
873 #if VTK_MAJOR_VERSION <= 5
874 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
876 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
879 // Update fusion transform
880 mConcatenatedFusionTransform->Identity();
881 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]);
882 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
885 if (mSurfaceCutActors.size() > 0)
886 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
887 i!=mSurfaceCutActors.end(); i++)
888 (*i)->SetTimeSlice(mCurrentTSlice);
889 UpdateDisplayExtent();
891 //------------------------------------------------------------------------------
894 //------------------------------------------------------------------------------
895 void vvSlicer::SetFusionSequenceTSlice(int t)
897 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode>=0)) {
898 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
899 mCurrentFusionTSlice = t;
900 #if VTK_MAJOR_VERSION <= 5
901 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
903 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
905 // Update fusion transform
906 mConcatenatedFusionTransform->Identity();
907 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]); //not really useful...
908 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
912 UpdateDisplayExtent();
914 //------------------------------------------------------------------------------
917 //------------------------------------------------------------------------------
918 int vvSlicer::GetTSlice()
920 return mCurrentTSlice;
922 //------------------------------------------------------------------------------
924 //------------------------------------------------------------------------------
925 int vvSlicer::GetMaxCurrentTSlice()
927 int t = mCurrentTSlice;
928 if(mOverlay && mOverlayActor->GetVisibility())
929 t = std::max(t, mCurrentOverlayTSlice);
930 if(mFusion&& (mFusionSequenceCode<0) && mFusionActor->GetVisibility()) //ignore fusionSequence data: for these, the times are not to be related (this way)
931 t = std::max(t, mCurrentFusionTSlice);
934 //------------------------------------------------------------------------------
936 //------------------------------------------------------------------------------
937 int vvSlicer::GetFusionTSlice()
939 return mCurrentFusionTSlice;
941 //------------------------------------------------------------------------------
943 //------------------------------------------------------------------------------
944 int vvSlicer::GetOverlayTSlice()
946 return mCurrentOverlayTSlice;
948 //------------------------------------------------------------------------------
950 //------------------------------------------------------------------------------
951 void vvSlicer::SetSliceOrientation(int orientation)
953 //if 2D image, force to watch in Axial View
955 #if VTK_MAJOR_VERSION <= 5
956 this->GetInput()->GetWholeExtent(extent);
958 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
959 copyExtent(ext, extent);
962 if (extent[5]-extent[4] <= 2)
963 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
965 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
966 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
967 vtkErrorMacro("Error - invalid slice orientation " << orientation);
971 this->SliceOrientation = orientation;
974 AdjustResliceToSliceOrientation(mFusionReslice);
977 AdjustResliceToSliceOrientation(mOverlayReslice);
981 // Go to current cursor position
982 // double* cursorPos = GetCursorPosition();
983 // DDV(cursorPos, 3);
984 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
986 if (mFirstSetSliceOrientation) {
987 int *range = this->GetSliceRange();
989 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
990 #if VTK_MAJOR_VERSION <= 5
991 mFirstSetSliceOrientation = false;
994 else if (this->Renderer && this->GetInput()) {
995 double s = mCursor[orientation];
996 double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation];
997 this->Slice = static_cast<int>(sCursor);
1000 this->UpdateOrientation();
1002 this->UpdateDisplayExtent();
1004 if (mFirstSetSliceOrientation) {
1005 mFirstSetSliceOrientation = false;
1008 if (this->Renderer && this->GetInput()) {
1009 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
1010 this->Renderer->ResetCamera();
1011 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
1016 //----------------------------------------------------------------------------
1018 //------------------------------------------------------------------------------
1019 // This function ensures that we sample the slices of a vtkImageReslice filter
1020 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
1021 // In other words, we change the grid of the reslice in the same way as the grid
1022 // of the displayed image in the slicing direction.
1023 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
1025 // Reset autocrop and update output information
1026 reslice->SetOutputOriginToDefault();
1027 reslice->SetOutputSpacingToDefault();
1028 #if VTK_MAJOR_VERSION <= 5
1029 reslice->GetOutput()->UpdateInformation();
1031 reslice->UpdateInformation();
1034 // Ge new origin / spacing
1037 reslice->GetOutput()->GetOrigin(origin);
1038 reslice->GetOutput()->GetSpacing(spacing);
1040 // Use similar spacing as the image in the direction SliceOrientation
1041 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1043 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
1044 // Step 1: from world coordinates to image coordinates
1045 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1046 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1048 // Step 2: round to nearest grid positionInc. This has been validated as the only
1049 // way to have something consistent with the thickness of a 2D slice visible on the
1050 // other slices. The thickness is accounted for so if the 2D slice is to thin and
1051 // between two slices, one will never be able to see this 2D slice (bug #1883).
1052 origin[this->SliceOrientation] = itk::Math::Round<double>(origin[this->SliceOrientation]);
1054 // Step 3: back to world coordinates
1055 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1056 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1058 // Set new spacing and origin
1059 reslice->SetOutputOrigin(origin);
1060 reslice->SetOutputSpacing(spacing);
1061 reslice->UpdateInformation();
1062 #if VTK_MAJOR_VERSION <= 5
1063 reslice->GetOutput()->UpdateInformation();
1066 //------------------------------------------------------------------------------
1068 //----------------------------------------------------------------------------
1069 int * vvSlicer::GetExtent()
1072 if (mUseReducedExtent) {
1073 w_ext = mReducedExtent;
1076 #if VTK_MAJOR_VERSION <= 5
1077 w_ext = GetInput()->GetWholeExtent();
1079 w_ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1084 //----------------------------------------------------------------------------
1087 //----------------------------------------------------------------------------
1088 int vvSlicer::GetOrientation()
1090 return this->SliceOrientation;
1092 //----------------------------------------------------------------------------
1095 //----------------------------------------------------------------------------
1096 void vvSlicer::UpdateDisplayExtent()
1098 emit UpdateDisplayExtentBegin(mSlicerNumber);
1099 vtkImageData *input = this->GetInput();
1100 if (!input || !this->ImageActor) {
1104 #if VTK_MAJOR_VERSION <= 5
1105 input->UpdateInformation();
1107 mRegisterExtent = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1109 this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents
1111 // Local copy of extent
1113 #if VTK_MAJOR_VERSION <= 5
1114 int* ext = GetExtent();
1116 int* ext = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1118 copyExtent(ext, w_ext);
1119 if (mUseReducedExtent) {
1120 copyExtent(mReducedExtent, w_ext);
1124 w_ext[ this->SliceOrientation*2 ] = this->Slice;
1125 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
1128 this->ImageActor->SetVisibility(mImageVisibility);
1129 this->ImageActor->SetDisplayExtent(w_ext);
1131 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1132 // Fix for bug #1882
1133 dynamic_cast<vtkImageSliceMapper *>(this->ImageActor->GetMapper())->SetOrientation(this->GetOrientation());
1136 // Overlay image actor
1137 if (mOverlay && mOverlayVisibility) {
1138 AdjustResliceToSliceOrientation(mOverlayReslice);
1140 #if VTK_MAJOR_VERSION <= 5
1141 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
1142 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
1144 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mOverlayReslice->GetOutput(), overExtent);
1145 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1147 mOverlayActor->SetVisibility(!out);
1148 mOverlayActor->SetDisplayExtent( overExtent );
1149 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1150 // Fix for bug #1882
1151 dynamic_cast<vtkImageSliceMapper *>(mOverlayActor->GetMapper())->SetOrientation(this->GetOrientation());
1155 mOverlayActor->SetVisibility(false);
1157 // Fusion image actor
1158 if (mFusion && mFusionVisibility) {
1159 AdjustResliceToSliceOrientation(mFusionReslice);
1161 #if VTK_MAJOR_VERSION <= 5
1162 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
1163 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
1165 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mFusionReslice->GetOutput(), fusExtent);
1166 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1168 mFusionActor->SetVisibility(!out);
1169 mFusionActor->SetDisplayExtent( fusExtent );
1170 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1171 // Fix for bug #1882
1172 dynamic_cast<vtkImageSliceMapper *>(mFusionActor->GetMapper())->SetOrientation(this->GetOrientation());
1176 mFusionActor->SetVisibility(false);
1177 // Vector field actor
1178 double* camera = Renderer->GetActiveCamera()->GetPosition();
1179 double* image_bounds = ImageActor->GetBounds();
1180 double position[3] = {0, 0, 0};
1181 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
1183 //print_vector<double, 6>("camera", camera);
1184 //print_vector<double, 6>("image_bounds", image_bounds);
1185 //print_vector<double, 3>("position", position);
1187 // find where to place the VF actor. to deal with
1188 // z-buffer issues, the VF is placed right in front of the image,
1189 // subject to a small offset. the position actually depends on the
1190 // the location of the camera relative to the image.
1192 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
1195 if (mVF && mVFVisibility) {
1197 #if VTK_MAJOR_VERSION <= 5
1198 mVF->GetVTKImages()[0]->UpdateInformation();
1199 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
1200 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
1202 mVOIFilter->Update();
1203 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVF->GetVTKImages()[0], vfExtent);
1204 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1206 mVFActor->SetVisibility(!out);
1207 mVOIFilter->SetVOI(vfExtent);
1208 int orientation[3] = {1,1,1};
1209 orientation[this->SliceOrientation] = 0;
1210 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
1211 position[this->SliceOrientation] += offset;
1212 mVFActor->SetPosition(position);
1213 mVFActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
1214 mVFMapper->Update();
1218 mVFActor->SetVisibility(false);
1222 for(unsigned int i=0; i<6; i++)
1223 boundsT[i] = ImageActor->GetBounds()[i];
1224 boundsT[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1225 boundsT[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1234 position[this->SliceOrientation] = offset;
1235 mLandActor->SetPosition(position);
1238 // Figure out the correct clipping range
1239 if (this->Renderer) {
1240 if (this->InteractorStyle &&
1241 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
1242 this->Renderer->ResetCameraClippingRange();
1244 vtkCamera *cam = this->Renderer->GetActiveCamera();
1247 this->ImageActor->GetBounds(bounds);
1248 double spos = (double)bounds[this->SliceOrientation * 2];
1249 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
1250 double range = fabs(spos - cpos);
1251 double *spacing = input->GetSpacing();
1252 double sumSpacing = spacing[0] + spacing[1] + spacing[2];
1253 cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
1263 emit UpdateDisplayExtentEnd(mSlicerNumber);
1265 //----------------------------------------------------------------------------
1267 //----------------------------------------------------------------------------
1268 void vvSlicer::ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, const int sourceExtent[6],
1269 vtkImageData *targetImage, int targetExtent[6])
1272 double *origin, *spacing;
1273 origin = sourceImage->Get(vtkDataObject::ORIGIN());
1274 spacing = sourceImage->Get(vtkDataObject::SPACING());
1275 for(unsigned int i=0; i<6; i++) {
1276 // From source voxel coordinates to world coordinates
1277 dExtents[i] = origin[i/2] + spacing[i/2] * sourceExtent[i];
1279 // From world coordinates to floating point target voxel coordinates
1280 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1282 // Round to current slice or larger extent
1283 if(i/2==this->GetOrientation())
1284 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1286 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1288 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1291 //----------------------------------------------------------------------------
1293 //----------------------------------------------------------------------------
1294 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
1295 vtkImageData *targetImage, int targetExtent[6])
1298 for(unsigned int i=0; i<6; i++) {
1299 // From source voxel coordinates to world coordinates
1300 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
1302 // From world coordinates to floating point target voxel coordinates
1303 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1305 // Round to current slice or larger extent
1306 if(i/2==this->GetOrientation())
1307 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1309 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1311 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1314 //----------------------------------------------------------------------------
1316 //----------------------------------------------------------------------------
1317 bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
1322 for (int i = 0; i < maxBound; i = i+2) {
1323 //if we are totally outside the image
1324 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
1328 //crop to the limit of the image
1329 extent[i] = std::max(extent[i], refExtent[i]);
1330 extent[i] = std::min(extent[i], refExtent[i+1]);;
1331 extent[i+1] = std::max(extent[i+1], refExtent[i]);
1332 extent[i+1] = std::min(extent[i+1], refExtent[i+1]);;
1335 for (int i = 0; i < maxBound; i = i+2) {
1336 extent[i] = refExtent[i];
1337 extent[i+1] = refExtent[i];
1341 //----------------------------------------------------------------------------
1344 //----------------------------------------------------------------------------
1345 void vvSlicer::UpdateOrientation()
1347 // Set the camera position
1348 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1350 switch (this->SliceOrientation) {
1351 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1352 cam->SetFocalPoint(0,0,0);
1353 cam->SetPosition(0,0,-1); // -1 if medical ?
1354 cam->SetViewUp(0,-1,0);
1357 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1358 cam->SetFocalPoint(0,0,0);
1359 cam->SetPosition(0,-1,0); // 1 if medical ?
1360 cam->SetViewUp(0,0,1);
1363 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1364 cam->SetFocalPoint(0,0,0);
1365 cam->SetPosition(-1,0,0); // -1 if medical ?
1366 cam->SetViewUp(0,0,1);
1371 //----------------------------------------------------------------------------
1374 //----------------------------------------------------------------------------
1375 void vvSlicer::SetOpacity(double s)
1377 this->GetImageActor()->SetOpacity(s);
1379 //----------------------------------------------------------------------------
1382 //----------------------------------------------------------------------------
1383 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1385 this->Superclass::SetRenderWindow(rw);
1386 this->SetupInteractor(rw->GetInteractor());
1387 ca->SetImageActor(this->GetImageActor());
1388 ca->SetWindowLevel(this->GetWindowLevel());
1389 ca->SetText(3, "<window>\n<level>");
1400 crossCursor->SetModelBounds(bounds);
1402 this->GetRenderer()->AddActor(pdmA);
1403 this->GetRenderer()->AddActor(ca);
1404 this->GetRenderer()->ResetCamera();
1406 //this is just a mapping between the labeling of the orientations presented to the user and
1407 //the one used by vtk
1408 SetSliceOrientation(2-(orientation%3));
1411 //----------------------------------------------------------------------------
1414 //----------------------------------------------------------------------------
1415 void vvSlicer::ResetCamera()
1417 this->GetRenderer()->ResetCamera();
1419 //----------------------------------------------------------------------------
1422 //----------------------------------------------------------------------------
1423 void vvSlicer::SetDisplayMode(bool i)
1425 this->GetRenderer()->SetDraw(i);
1426 if (i) UpdateDisplayExtent();
1428 //----------------------------------------------------------------------------
1431 //----------------------------------------------------------------------------
1432 void vvSlicer::FlipHorizontalView()
1434 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1436 double *position = cam->GetPosition();
1437 double factor[3] = {1, 1, 1};
1438 factor[this->SliceOrientation] = -1;
1439 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1441 /* switch (this->SliceOrientation) {
1442 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1443 cam->SetPosition(position[0],position[1],-position[2]);
1446 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1447 cam->SetPosition(position[0],-position[1],position[2]);
1450 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1451 cam->SetPosition(-position[0],position[1],position[2]);
1455 this->Renderer->ResetCameraClippingRange();
1456 this->UpdateDisplayExtent();
1459 //----------------------------------------------------------------------------
1462 //----------------------------------------------------------------------------
1463 void vvSlicer::FlipVerticalView()
1465 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1467 FlipHorizontalView();
1468 double *viewup = cam->GetViewUp();
1469 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1470 this->UpdateDisplayExtent();
1473 //----------------------------------------------------------------------------
1476 //----------------------------------------------------------------------------
1477 void vvSlicer::SetColorWindow(double window)
1479 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1481 double level = this->GetWindowLevel()->GetLevel();
1482 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1485 this->vtkImageViewer2::SetColorWindow(window);
1487 //----------------------------------------------------------------------------
1489 //----------------------------------------------------------------------------
1490 void vvSlicer::SetColorLevel(double level)
1492 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1494 double window = this->GetWindowLevel()->GetWindow();
1495 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1498 this->vtkImageViewer2::SetColorLevel(level);
1500 //----------------------------------------------------------------------------
1502 //----------------------------------------------------------------------------
1503 double vvSlicer::GetOverlayColorWindow()
1506 return mOverlayMapper->GetWindow();
1510 //----------------------------------------------------------------------------
1512 //----------------------------------------------------------------------------
1513 double vvSlicer::GetOverlayColorLevel()
1516 return mOverlayMapper->GetLevel();
1520 //----------------------------------------------------------------------------
1522 //----------------------------------------------------------------------------
1523 void vvSlicer::SetOverlayColorWindow(double window)
1526 mOverlayMapper->SetWindow(window);
1528 //----------------------------------------------------------------------------
1530 //----------------------------------------------------------------------------
1531 void vvSlicer::SetOverlayColorLevel(double level)
1534 mOverlayMapper->SetLevel(level);
1536 //----------------------------------------------------------------------------
1538 //----------------------------------------------------------------------------
1539 // Returns the min an the max value in a 20%x20% region around the mouse pointer
1540 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1542 //Get mouse pointer position in view coordinates
1545 for(int i=0; i<3; i++) {
1546 corner1[i] = mCurrent[i];
1547 corner2[i] = mCurrent[i];
1550 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1551 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1553 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1555 this->Renderer->GetTiledSize(&w, &h);
1556 corner1[0] -= 0.2*h/(double)w;
1557 corner2[0] += 0.2*h/(double)w;
1560 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1561 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1563 //Convert to image pixel coordinates (rounded)
1564 transform->TransformPoint(corner1, corner1);
1565 transform->TransformPoint(corner2, corner2);
1566 int iLocalExtents[6];
1567 for(int i=0; i<3; i++) {
1568 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1569 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1571 iLocalExtents[i*2 ] = lrint(corner1[i]);
1572 iLocalExtents[i*2+1] = lrint(corner2[i]);
1574 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1575 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1577 #if VTK_MAJOR_VERSION > 5
1578 for(int j=0;j<2; j++) {
1579 if(iLocalExtents[i*2+j]< mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i])
1580 iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i];
1582 if(iLocalExtents[i*2+j]> mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1])
1583 iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1];
1588 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1589 #if VTK_MAJOR_VERSION <= 5
1590 voiFilter->SetInput(image);
1592 voiFilter->SetInputData(image);
1594 voiFilter->SetVOI(iLocalExtents);
1595 voiFilter->Update();
1596 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1602 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1603 #if VTK_MAJOR_VERSION <= 5
1604 accFilter->SetInput(voiFilter->GetOutput());
1606 accFilter->SetInputConnection(voiFilter->GetOutputPort(0));
1608 accFilter->Update();
1610 min = *(accFilter->GetMin());
1611 max = *(accFilter->GetMax());
1613 //----------------------------------------------------------------------------
1615 //----------------------------------------------------------------------------
1616 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1621 #if VTK_MAJOR_VERSION <= 5
1622 if (ix < image->GetWholeExtent()[0] ||
1623 ix > image->GetWholeExtent()[1] ||
1624 iy < image->GetWholeExtent()[2] ||
1625 iy > image->GetWholeExtent()[3] ||
1626 iz < image->GetWholeExtent()[4] ||
1627 iz > image->GetWholeExtent()[5] )
1628 return std::numeric_limits<double>::quiet_NaN();
1629 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1632 if (ix < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] ||
1633 ix > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] ||
1634 iy < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] ||
1635 iy > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] ||
1636 iz < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] ||
1637 iz > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5] )
1638 return std::numeric_limits<double>::quiet_NaN();
1639 //image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1642 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1644 //----------------------------------------------------------------------------
1646 //----------------------------------------------------------------------------
1647 void vvSlicer::Render()
1649 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1650 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1651 legend->UseOpacityOn();
1652 legend->SetVisibility(1);
1654 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1655 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1656 legend->UseOpacityOff();
1657 legend->SetVisibility(1);
1658 } else legend->SetVisibility(0);
1660 if (ca->GetVisibility()) {
1661 std::stringstream worldPos(" ");
1663 mConcatenatedTransform->TransformPoint(mCurrent, pt);
1664 double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
1665 double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
1666 double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
1667 #if VTK_MAJOR_VERSION <= 5
1668 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
1669 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
1670 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
1671 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
1672 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
1673 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
1675 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 &&
1676 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 &&
1677 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 &&
1678 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 &&
1679 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 &&
1680 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) {
1683 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1684 if(ImageActor->GetVisibility())
1685 worldPos << "data value : " << value << std::endl;
1686 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1687 << lrint(mCurrent[1]) << ' '
1688 << lrint(mCurrent[2]) << ' '
1691 worldPos << "pixel : " << ix << ' '
1698 ca->SetText(1,worldPos.str().c_str());
1700 std::stringstream slicePos;
1701 slicePos << "Slice: " << this->GetSlice();
1702 ca->SetText(2, slicePos.str().c_str());
1705 if (pdmA->GetVisibility()) {
1706 double x = mCursor[0];
1707 double y = mCursor[1];
1708 double z = mCursor[2];
1709 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1710 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1711 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1712 #if VTK_MAJOR_VERSION <= 5
1713 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
1714 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
1715 yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
1716 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+0.5 &&
1717 zCursor >= this->GetImageActor()->GetDisplayExtent()[4]-0.5 &&
1718 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+0.5 ) {
1719 vtkRenderer * renderer = this->Renderer;
1721 renderer->WorldToView(x,y,z);
1722 renderer->ViewToNormalizedViewport(x,y,z);
1723 renderer->NormalizedViewportToViewport(x,y);
1724 renderer->ViewportToNormalizedDisplay(x,y);
1725 renderer->NormalizedDisplayToDisplay(x,y);
1726 crossCursor->SetFocalPoint(x,y,z);
1728 crossCursor->SetFocalPoint(-1,-1,z);
1729 crossCursor->Update();
1732 vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
1734 mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
1735 } catch (const std::bad_cast& e) {
1736 std::cerr << e.what() << std::endl;
1737 std::cerr << "Conversion error" << std::endl;
1741 if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 &&
1742 xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 &&
1743 yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 &&
1744 yCursor < mapperOpenGL->GetCroppingRegion()[3]+0.5 &&
1745 zCursor >= mapperOpenGL->GetCroppingRegion()[4]-0.5 &&
1746 zCursor < mapperOpenGL->GetCroppingRegion()[5]+0.5 ) {
1747 vtkRenderer * renderer = this->Renderer;
1749 renderer->WorldToView(x,y,z);
1750 renderer->ViewToNormalizedViewport(x,y,z);
1751 renderer->NormalizedViewportToViewport(x,y);
1752 renderer->ViewportToNormalizedDisplay(x,y);
1753 renderer->NormalizedDisplayToDisplay(x,y);
1754 crossCursor->SetFocalPoint(x,y,z);
1756 crossCursor->SetFocalPoint(-1,-1,z);
1757 crossCursor->Update();
1761 if (mOverlay && mOverlayActor->GetVisibility()) {
1762 if(mLinkOverlayWindowLevel) {
1763 mOverlayMapper->SetWindow(this->GetColorWindow());
1764 mOverlayMapper->SetLevel(this->GetColorLevel());
1766 #if VTK_MAJOR_VERSION <= 5
1767 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1769 mOverlayMapper->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1771 mOverlayMapper->Update();
1773 if (mFusion && mFusionActor->GetVisibility()) {
1774 #if VTK_MAJOR_VERSION <= 5
1775 mFusionMapper->GetOutput()->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1777 mFusionMapper->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1779 mFusionMapper->Update();
1786 this->GetRenderWindow()->Render();
1788 //----------------------------------------------------------------------------
1791 //----------------------------------------------------------------------------
1792 void vvSlicer::UpdateCursorPosition()
1794 pdmA->SetVisibility(true);
1795 mCursor[0] = mCurrent[0];
1796 mCursor[1] = mCurrent[1];
1797 mCursor[2] = mCurrent[2];
1798 mCursor[3] = mCurrentTSlice;
1800 //----------------------------------------------------------------------------
1803 //----------------------------------------------------------------------------
1804 void vvSlicer::RemoveLandmarks()
1806 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
1807 if (pd->GetPoints()) {
1809 //First remove all captions:
1810 for(unsigned int i=0;i<mLandLabelActors.size();i++) {
1811 this->Renderer->RemoveActor2D(mLandLabelActors[i]);
1812 //allActors2D->Remove (mLandLabelActors[i]);
1814 mLandLabelActors.clear();
1817 //----------------------------------------------------------------------------
1820 //----------------------------------------------------------------------------
1821 void vvSlicer::DisplayLandmarks()
1825 for(unsigned int i=0; i<6; i++)
1826 bounds[i] = ImageActor->GetBounds()[i];
1827 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1828 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1829 mClipBox->SetBounds(bounds);
1832 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
1833 if (pd->GetPoints()) {
1834 this->GetRenderer()->AddActor(mLandActor);
1835 //mLandGlyph->SetRange(0,1);
1836 //mLandGlyph->Modified();
1837 //mLandGlyph->Update();
1838 mClipBox->Modified();
1839 mLandClipper->Update();
1840 mLandMapper->Update();
1841 //Next add the captions to the displayed points
1842 for (vtkIdType id=0; id<mLandClipper->GetOutput()->GetNumberOfPoints(); id++) {
1843 double *position = mLandClipper->GetOutput()->GetPoint(id);
1844 vtkStdString label = static_cast<vtkStringArray*>(mLandClipper->GetOutput()->GetPointData()->GetAbstractArray("labels"))->GetValue(id);
1845 vtkSmartPointer<vtkCaptionActor2D> label_actor = vtkSmartPointer<vtkCaptionActor2D>::New();
1846 label_actor->SetCaption(label);
1847 label_actor->SetAttachmentPoint(position);
1848 label_actor->GetCaptionTextProperty()->SetColor(1,0,0);
1849 label_actor->GetCaptionTextProperty()->SetOrientation(33.333333);
1850 label_actor->GetCaptionTextProperty()->SetFontFamilyToTimes();
1851 label_actor->GetCaptionTextProperty()->SetBold(0);
1852 label_actor->GetCaptionTextProperty()->SetFontSize(6);
1853 label_actor->BorderOff();
1854 label_actor->LeaderOff();
1855 label_actor->ThreeDimensionalLeaderOff();
1856 mLandLabelActors.push_back(label_actor);
1857 this->Renderer->AddActor2D(mLandLabelActors[id]);
1862 //----------------------------------------------------------------------------
1865 //----------------------------------------------------------------------------
1866 void vvSlicer::SetSlice(int slice)
1868 int *range = this->GetSliceRange();
1870 if (slice < range[0]) {
1872 } else if (slice > range[1]) {
1877 if (this->Slice == slice) {
1881 this->Slice = slice;
1884 this->UpdateDisplayExtent();
1886 // Seems to work without this line
1889 //----------------------------------------------------------------------------
1891 //----------------------------------------------------------------------------
1892 int vvSlicer::GetTMax()
1894 int tmax = (int)mImage->GetVTKImages().size() - 1;
1896 tmax = std::max(tmax, (int)mOverlay->GetVTKImages().size()-1);
1899 //----------------------------------------------------------------------------
1901 //----------------------------------------------------------------------------
1902 void vvSlicer::SetContourSlice()
1904 if (mSurfaceCutActors.size() > 0)
1905 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1906 i!=mSurfaceCutActors.end(); i++) {
1908 (*i)->SetSlicingOrientation(this->SliceOrientation);
1909 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1910 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1913 //----------------------------------------------------------------------------
1916 //----------------------------------------------------------------------------
1917 void vvSlicer::ForceUpdateDisplayExtent()
1919 this->UpdateDisplayExtent();
1921 //----------------------------------------------------------------------------
1924 //----------------------------------------------------------------------------
1925 int* vvSlicer::GetDisplayExtent()
1927 return this->GetImageActor()->GetDisplayExtent();
1929 //----------------------------------------------------------------------------
1932 //----------------------------------------------------------------------------
1933 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1935 this->Superclass::PrintSelf(os, indent);
1937 //----------------------------------------------------------------------------
1940 //----------------------------------------------------------------------------
1941 void vvSlicer::SetVFColor(double r, double g, double b)
1943 double mVFColorHSV[3];
1948 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1949 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1950 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1951 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
1955 //----------------------------------------------------------------------------
1958 //----------------------------------------------------------------------------
1959 void vvSlicer::SetRegisterExtent(int ext[6])
1961 copyExtent(ext, mRegisterExtent);
1963 //----------------------------------------------------------------------------
1966 //----------------------------------------------------------------------------
1967 void vvSlicer::GetRegisterExtent(int ext[6])
1969 copyExtent(mRegisterExtent, ext);
1971 //----------------------------------------------------------------------------