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 ===========================================================================**/
21 #include "vvSlicerManagerCommand.h"
22 #include "vvGlyphSource.h"
23 #include "vvGlyph2D.h"
24 #include "vvImageMapToWLColors.h"
26 #include <vtkTextProperty.h>
27 #include <vtkTextActor.h>
28 #include <vtkTextSource.h>
29 #include <vtkActor2D.h>
30 #include <vtkCursor2D.h>
31 #include <vtkPolyDataMapper2D.h>
32 #include <vtkProperty2D.h>
33 #include <vtkCornerAnnotation.h>
34 #include <vtkImageMapToWindowLevelColors.h>
35 #include <vtkImageData.h>
36 #include <vtkImageActor.h>
37 #include <vvBlendImageActor.h>
38 #include <vtkToolkits.h>
39 #include <vtkObjectFactory.h>
40 #include <vtkPointData.h>
41 #include <vtkDataArray.h>
42 #include <vtkFloatArray.h>
43 #include <vtkClipPolyData.h>
44 #include <vtkGlyph3D.h>
46 #include <vtkCursor3D.h>
47 #include <vtkProperty.h>
49 #include <vtkLightCollection.h>
50 #include <vtkScalarBarActor.h>
51 #include <vtkLookupTable.h>
53 #include <vtkRenderer.h>
54 #include <vtkRendererCollection.h>
55 #include <vtkRenderWindow.h>
56 #include <vtkRenderWindowInteractor.h>
57 #include <vtkCamera.h>
58 #include <vtkCallbackCommand.h>
59 #include <vtkCommand.h>
60 #include <vtkPolyDataMapper.h>
63 #include <vtkExtractVOI.h>
64 #include <vtkSphereSource.h>
65 #include <vtkCutter.h>
66 #include <vtkAssignAttribute.h>
67 #include <vtkImageAccumulate.h>
68 #include <vtkImageReslice.h>
69 #include <vtkImageMapper3D.h>
71 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
72 vtkStandardNewMacro(vvSlicer);
73 static void copyExtent(int* in, int* to){
74 for(int i=0; i<6; ++i) to[i]=in[i];
76 //------------------------------------------------------------------------------
79 this->UnInstallPipeline();
81 mReducedExtent = new int[6];
83 mUseReducedExtent = false;
85 mCurrent[0] = -VTK_DOUBLE_MAX;
86 mCurrent[1] = -VTK_DOUBLE_MAX;
87 mCurrent[2] = -VTK_DOUBLE_MAX;
89 mCursor[0] = -VTK_DOUBLE_MAX;
90 mCursor[1] = -VTK_DOUBLE_MAX;
91 mCursor[2] = -VTK_DOUBLE_MAX;
92 mCursor[3] = -VTK_DOUBLE_MAX;
102 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
103 crossCursor->AllOff();
104 crossCursor->AxesOn();
105 crossCursor->SetTranslationMode(1);
106 crossCursor->SetRadius(2);
108 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
109 pdm->SetInput(crossCursor->GetOutput());
111 pdmA = vtkSmartPointer<vtkActor2D>::New();
112 pdmA->SetMapper(pdm);
113 pdmA->GetProperty()->SetColor(255,10,212);
114 pdmA->SetVisibility(0);
115 pdmA->SetPickable(0);
117 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
118 ca->GetTextProperty()->SetColor(255,10,212);
119 ca->SetVisibility(1);
127 legend = vtkSmartPointer<vtkScalarBarActor>::New();
128 //legend->SetTitle("test!");
129 legend->SetPosition(0.82,0.18);
130 legend->SetWidth(0.1);
131 legend->SetVisibility(0);
132 legend->SetLabelFormat("%.1f");
133 this->GetRenderer()->AddActor(legend);
134 showFusionLegend = false;
136 this->WindowLevel->Delete();
137 this->WindowLevel = vvImageMapToWLColors::New();
139 this->InstallPipeline();
141 mLinkOverlayWindowLevel = true;
143 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
144 this->GetImageActor()->GetMapper()->BorderOn();
147 //------------------------------------------------------------------------------
150 //------------------------------------------------------------------------------
151 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
153 return mOverlayMapper.GetPointer();
155 //------------------------------------------------------------------------------
158 //------------------------------------------------------------------------------
159 vvBlendImageActor* vvSlicer::GetOverlayActor()
161 return mOverlayActor.GetPointer();
163 //------------------------------------------------------------------------------
166 //------------------------------------------------------------------------------
167 vtkImageMapToColors* vvSlicer::GetFusionMapper()
169 return mFusionMapper.GetPointer();
171 //------------------------------------------------------------------------------
174 //------------------------------------------------------------------------------
175 vtkImageActor* vvSlicer::GetFusionActor()
177 return mFusionActor.GetPointer();
179 //------------------------------------------------------------------------------
182 //------------------------------------------------------------------------------
183 vtkActor* vvSlicer::GetVFActor()
185 return mVFActor.GetPointer();
187 //------------------------------------------------------------------------------
190 //------------------------------------------------------------------------------
191 vtkCornerAnnotation* vvSlicer::GetAnnotation()
193 return ca.GetPointer();
195 //------------------------------------------------------------------------------
198 //------------------------------------------------------------------------------
199 void vvSlicer::EnableReducedExtent(bool b)
201 mUseReducedExtent = b;
203 //------------------------------------------------------------------------------
206 //------------------------------------------------------------------------------
207 void vvSlicer::SetReducedExtent(int * ext)
209 copyExtent(ext, mReducedExtent);
211 //------------------------------------------------------------------------------
214 //------------------------------------------------------------------------------
215 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
218 mSurfaceCutActors.push_back(new vvMeshActor());
220 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
222 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
223 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
224 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
228 //------------------------------------------------------------------------------
231 //------------------------------------------------------------------------------
232 void vvSlicer::ToggleContourSuperposition()
234 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
235 i!=mSurfaceCutActors.end(); i++)
236 (*i)->ToggleSuperposition();
238 //------------------------------------------------------------------------------
241 //------------------------------------------------------------------------------
242 void vvSlicer::SetCursorColor(int r,int g, int b)
244 pdmA->GetProperty()->SetColor(r,g,b);
246 //------------------------------------------------------------------------------
249 //------------------------------------------------------------------------------
250 void vvSlicer::SetCursorVisibility(bool s)
252 pdmA->SetVisibility(s);
254 //------------------------------------------------------------------------------
257 //------------------------------------------------------------------------------
258 bool vvSlicer::GetCursorVisibility()
260 return pdmA->GetVisibility();
262 //------------------------------------------------------------------------------
265 //------------------------------------------------------------------------------
266 void vvSlicer::SetCornerAnnotationVisibility(bool s)
268 ca->SetVisibility(s);
270 //------------------------------------------------------------------------------
273 //------------------------------------------------------------------------------
274 bool vvSlicer::GetCornerAnnotationVisibility()
276 return ca->GetVisibility();
278 //------------------------------------------------------------------------------
281 //------------------------------------------------------------------------------
282 vvSlicer::~vvSlicer()
284 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
285 i!=mSurfaceCutActors.end(); i++)
287 delete [] mReducedExtent;
289 //------------------------------------------------------------------------------
292 //------------------------------------------------------------------------------
293 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
300 //------------------------------------------------------------------------------
303 //------------------------------------------------------------------------------
304 void vvSlicer::SetImage(vvImage::Pointer image)
306 if (image->GetVTKImages().size()) {
309 if (!mImageReslice) {
310 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
311 mImageReslice->SetInterpolationModeToLinear();
312 mImageReslice->AutoCropOutputOn();
313 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
315 mImageReslice->SetResliceTransform(mImage->GetTransform());
316 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
317 mImageReslice->UpdateInformation();
319 this->Superclass::SetInput(mImageReslice->GetOutput());
322 this->GetInput()->GetWholeExtent(extent);
324 // Prevent crash when reload -> change slice if outside extent
325 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
326 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
329 // Make sure that the required part image has been computed
330 extent[SliceOrientation*2] = Slice;
331 extent[SliceOrientation*2+1] = Slice;
332 mImageReslice->GetOutput()->SetUpdateExtent(extent);
333 mImageReslice->GetOutput()->Update();
335 this->UpdateDisplayExtent();
338 ca->SetText(0,mFileName.c_str());
341 //------------------------------------------------------------------------------
344 //------------------------------------------------------------------------------
345 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
347 if (overlay->GetVTKImages().size()) {
350 if (!mOverlayReslice) {
351 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
352 mOverlayReslice->SetInterpolationModeToLinear();
353 mOverlayReslice->AutoCropOutputOn();
354 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
356 mOverlayReslice->SetResliceTransform(mOverlay->GetTransform());
357 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
360 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
361 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
363 if (!mOverlayActor) {
364 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
365 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
366 mOverlayActor->SetPickable(0);
367 mOverlayActor->SetVisibility(true);
368 mOverlayActor->SetOpacity(0.5);
369 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
370 mOverlayActor->GetMapper()->BorderOn();
374 //stupid but necessary : the Overlay need to be rendered before fusion
376 this->GetRenderer()->RemoveActor(mFusionActor);
377 this->GetRenderer()->AddActor(mOverlayActor);
378 this->GetRenderer()->AddActor(mFusionActor);
380 this->GetRenderer()->AddActor(mOverlayActor);
382 //Synchronize orientation and slice
383 AdjustResliceToSliceOrientation(mOverlayReslice);
384 this->UpdateDisplayExtent();
385 this->SetTSlice(mCurrentTSlice);
388 //------------------------------------------------------------------------------
391 //------------------------------------------------------------------------------
392 void vvSlicer::SetFusion(vvImage::Pointer fusion)
394 if (fusion->GetVTKImages().size()) {
397 if (!mFusionReslice) {
398 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
399 mFusionReslice->SetInterpolationModeToLinear();
400 mFusionReslice->AutoCropOutputOn();
401 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
403 mFusionReslice->SetResliceTransform(mFusion->GetTransform());
404 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
407 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
409 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
411 lut->SetValueRange(0, 1);
412 lut->SetSaturationRange(0, 0);
414 mFusionMapper->SetLookupTable(lut);
415 mFusionMapper->SetInput(mFusionReslice->GetOutput());
418 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
419 mFusionActor->SetInput(mFusionMapper->GetOutput());
420 mFusionActor->SetPickable(0);
421 mFusionActor->SetVisibility(true);
422 mFusionActor->SetOpacity(0.7);
423 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
424 mFusionActor->GetMapper()->BorderOn();
426 this->GetRenderer()->AddActor(mFusionActor);
429 //Synchronize orientation and slice
430 AdjustResliceToSliceOrientation(mFusionReslice);
431 this->UpdateDisplayExtent();
432 this->SetTSlice(mCurrentTSlice);
435 //------------------------------------------------------------------------------
438 //------------------------------------------------------------------------------
439 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
442 if (actor_type == "image") {
443 vis = this->ImageActor->GetVisibility();
445 else if (actor_type == "vector") {
446 vis = this->mVFActor->GetVisibility();
448 else if (actor_type == "overlay") {
449 vis = this->mOverlayActor->GetVisibility();
451 else if (actor_type == "fusion") {
452 vis = this->mFusionActor->GetVisibility();
454 else if (actor_type == "contour")
455 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
459 //------------------------------------------------------------------------------
461 //------------------------------------------------------------------------------
462 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
464 if (actor_type == "image") {
465 this->ImageActor->SetVisibility(vis);
467 else if (actor_type == "vector") {
468 this->mVFActor->SetVisibility(vis);
470 else if (actor_type == "overlay") {
471 this->mOverlayActor->SetVisibility(vis);
473 else if (actor_type == "fusion") {
474 this->mFusionActor->SetVisibility(vis);
476 else if (actor_type == "contour")
477 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
478 UpdateDisplayExtent();
480 //------------------------------------------------------------------------------
482 //------------------------------------------------------------------------------
483 void vvSlicer::SetVF(vvImage::Pointer vf)
485 if (vf->GetVTKImages().size()) {
489 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
490 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
491 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
493 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
494 mAAFilter->SetInput(mVOIFilter->GetOutput());
495 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
496 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
499 mArrow = vtkSmartPointer<vvGlyphSource>::New();
500 mArrow->SetGlyphTypeToSpecificArrow();
501 mArrow->SetScale(mScale);
504 // Glyph the gradient vector (with arrows)
506 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
507 mGlyphFilter->SetInput(mAAFilter->GetOutput());
508 mGlyphFilter->SetSource(mArrow->GetOutput());
509 mGlyphFilter->ScalingOn();
510 mGlyphFilter->SetScaleModeToScaleByVector();
511 mGlyphFilter->OrientOn();
512 mGlyphFilter->SetVectorModeToUseVector();
513 mGlyphFilter->SetColorModeToColorByVector();
516 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
518 double mVFColorHSV[3];
519 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
520 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
521 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
522 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
525 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
526 mVFMapper->SetInput(mGlyphFilter->GetOutput());
527 mVFMapper->ImmediateModeRenderingOn();
528 mVFMapper->SetLookupTable(mVFColorLUT);
531 mVFActor = vtkSmartPointer<vtkActor>::New();
532 mVFActor->SetMapper(mVFMapper);
533 mVFActor->SetPickable(0);
534 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
535 this->UpdateDisplayExtent();
536 this->GetRenderer()->AddActor(mVFActor);
539 SetTSlice(mCurrentTSlice);
542 //------------------------------------------------------------------------------
545 //------------------------------------------------------------------------------
546 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
548 mLandmarks = landmarks;
552 mCross = vtkSmartPointer<vtkCursor3D>::New();
553 mCross->SetFocalPoint(0.0,0.0,0.0);
554 mCross->SetModelBounds(-10,10,-10,10,-10,10);
559 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
560 mLandGlyph->SetSource(mCross->GetOutput());
561 mLandGlyph->SetInput(landmarks->GetOutput());
562 //mLandGlyph->SetIndexModeToScalar();
563 mLandGlyph->SetRange(0,1);
564 mLandGlyph->ScalingOff();
566 mLandGlyph->SetColorModeToColorByScalar();
569 mClipBox = vtkSmartPointer<vtkBox>::New();
571 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
572 mLandClipper->InsideOutOn();
573 mLandClipper->SetInput(mLandGlyph->GetOutput());
574 mLandClipper->SetClipFunction(mClipBox);
577 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
578 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
579 //mLandMapper->ScalarVisibilityOff();
582 mLandActor = vtkSmartPointer<vtkActor>::New();
583 mLandActor->SetMapper(mLandMapper);
584 mLandActor->GetProperty()->SetColor(255,10,212);
585 mLandActor->SetPickable(0);
586 mLandActor->SetVisibility(true);
587 this->UpdateDisplayExtent();
588 this->GetRenderer()->AddActor(mLandActor);
591 //------------------------------------------------------------------------------
593 //------------------------------------------------------------------------------
594 //FIXME: this function leaks memory, we should fix it someday :)
595 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
597 if (actor_type == "vector") {
598 Renderer->RemoveActor(mVFActor);
607 if (actor_type == "overlay") {
608 Renderer->RemoveActor(mOverlayActor);
610 mOverlayActor = NULL;
611 mOverlayMapper = NULL;
613 if (actor_type == "fusion") {
614 Renderer->RemoveActor(mFusionActor);
617 mFusionMapper = NULL;
619 if (actor_type == "contour") {
620 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
621 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
624 //------------------------------------------------------------------------------
627 //------------------------------------------------------------------------------
628 void vvSlicer::SetVFSubSampling(int sub)
631 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
634 UpdateDisplayExtent();
637 //------------------------------------------------------------------------------
640 //------------------------------------------------------------------------------
641 void vvSlicer::SetVFScale(int scale)
645 mArrow->SetScale(mScale);
646 UpdateDisplayExtent();
649 //------------------------------------------------------------------------------
651 //------------------------------------------------------------------------------
652 void vvSlicer::SetVFWidth(int width)
656 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
657 UpdateDisplayExtent();
660 //------------------------------------------------------------------------------
663 //------------------------------------------------------------------------------
664 void vvSlicer::SetVFLog(int log)
668 mGlyphFilter->SetUseLog(mVFLog);
669 mGlyphFilter->Modified();
671 UpdateDisplayExtent();
674 //------------------------------------------------------------------------------
677 //------------------------------------------------------------------------------
678 void vvSlicer::SetTSlice(int t)
682 else if ((unsigned int)t >= mImage->GetVTKImages().size())
683 t = mImage->GetVTKImages().size() -1;
686 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
687 if (mVF && mVFActor->GetVisibility()) {
688 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
689 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
691 if (mOverlay && mOverlayActor->GetVisibility()) {
692 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
693 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
695 if (mFusion && mFusionActor->GetVisibility()) {
696 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
697 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
699 if (mSurfaceCutActors.size() > 0)
700 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
701 i!=mSurfaceCutActors.end(); i++)
702 (*i)->SetTimeSlice(mCurrentTSlice);
703 UpdateDisplayExtent();
705 //------------------------------------------------------------------------------
708 //------------------------------------------------------------------------------
709 int vvSlicer::GetTSlice()
711 return mCurrentTSlice;
713 //------------------------------------------------------------------------------
715 //------------------------------------------------------------------------------
716 void vvSlicer::SetSliceOrientation(int orientation)
718 //if 2D image, force to watch in Axial View
720 this->GetInput()->GetWholeExtent(extent);
721 if (extent[5]-extent[4] <= 2)
722 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
724 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
725 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
726 vtkErrorMacro("Error - invalid slice orientation " << orientation);
730 this->SliceOrientation = orientation;
733 AdjustResliceToSliceOrientation(mFusionReslice);
736 AdjustResliceToSliceOrientation(mOverlayReslice);
739 int *range = this->GetSliceRange();
741 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
743 // Go to current cursor position
744 // double* cursorPos = GetCursorPosition();
745 // DDV(cursorPos, 3);
746 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
748 this->UpdateOrientation();
749 this->UpdateDisplayExtent();
751 if (this->Renderer && this->GetInput()) {
752 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
753 this->Renderer->ResetCamera();
754 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
759 //----------------------------------------------------------------------------
761 //------------------------------------------------------------------------------
762 // This function ensures that we sample the slices of a vtkImageReslice filter
763 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
764 // In other words, we change the grid of the reslice in the same way as the grid
765 // of the displayed image in the slicing direction.
766 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
768 // Reset autocrop and update output information
769 reslice->SetOutputOriginToDefault();
770 reslice->SetOutputSpacingToDefault();
771 reslice->GetOutput()->UpdateInformation();
773 // Ge new origin / spacing
776 reslice->GetOutput()->GetOrigin(origin);
777 reslice->GetOutput()->GetSpacing(spacing);
779 // Use similar spacing as the image in the direction SliceOrientation
780 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
782 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
783 // Step 1: from world coordinates to image coordinates
784 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
785 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
786 // Step 2: round to superior grid positionInc
787 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
788 // Step 3: back to world coordinates
789 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
790 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
792 // Set new spacing and origin
793 reslice->SetOutputOrigin(origin);
794 reslice->SetOutputSpacing(spacing);
795 reslice->UpdateInformation();
796 reslice->GetOutput()->UpdateInformation();
798 //------------------------------------------------------------------------------
800 //----------------------------------------------------------------------------
801 int * vvSlicer::GetExtent(){
803 if (mUseReducedExtent) {
804 w_ext = mReducedExtent;
805 } else w_ext = GetInput()->GetWholeExtent();
808 //----------------------------------------------------------------------------
811 //----------------------------------------------------------------------------
812 int vvSlicer::GetOrientation()
814 return this->SliceOrientation;
816 //----------------------------------------------------------------------------
819 //----------------------------------------------------------------------------
820 void vvSlicer::UpdateDisplayExtent()
822 vtkImageData *input = this->GetInput();
823 if (!input || !this->ImageActor) {
826 input->UpdateInformation();
828 // Local copy of extent
830 int* ext = GetExtent();
831 copyExtent(ext, w_ext);
833 int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice;
834 w_ext[ this->SliceOrientation*2 ] = s;
835 w_ext[ this->SliceOrientation*2+1 ] = s;
838 this->ImageActor->SetDisplayExtent(w_ext);
840 // Overlay image actor
841 if (mOverlay && mOverlayActor->GetVisibility()) {
842 AdjustResliceToSliceOrientation(mOverlayReslice);
844 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
845 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
846 mOverlayActor->SetDisplayExtent( overExtent );
849 // Fusion image actor
850 if (mFusion && mFusionActor->GetVisibility()) {
851 AdjustResliceToSliceOrientation(mFusionReslice);
853 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
854 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
855 mFusionActor->SetDisplayExtent(fusExtent);
858 // Vector field actor
859 double* camera = Renderer->GetActiveCamera()->GetPosition();
860 double* image_bounds = ImageActor->GetBounds();
861 double position[3] = {0, 0, 0};
862 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
864 //print_vector<double, 6>("camera", camera);
865 //print_vector<double, 6>("image_bounds", image_bounds);
866 //print_vector<double, 3>("position", position);
868 // find where to place the VF actor. to deal with
869 // z-buffer issues, the VF is placed right in front of the image,
870 // subject to a small offset. the position actually depends on the
871 // the location of the camera relative to the image.
873 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
876 if (mVF && mVFActor->GetVisibility()) {
878 mVF->GetVTKImages()[0]->UpdateInformation();
879 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
880 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
881 mVOIFilter->SetVOI(vfExtent);
882 int orientation[3] = {1,1,1};
883 orientation[this->SliceOrientation] = 0;
884 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
887 position[this->SliceOrientation] += offset;
888 mVFActor->SetPosition(position);
895 for(unsigned int i=0; i<6; i++)
896 bounds[i] = ImageActor->GetBounds()[i];
897 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
898 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
899 mClipBox->SetBounds(bounds);
903 position[this->SliceOrientation] = offset;
904 mLandActor->SetPosition(position);
907 // Figure out the correct clipping range
908 if (this->Renderer) {
909 if (this->InteractorStyle &&
910 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
911 this->Renderer->ResetCameraClippingRange();
913 vtkCamera *cam = this->Renderer->GetActiveCamera();
916 this->ImageActor->GetBounds(bounds);
917 double spos = (double)bounds[this->SliceOrientation * 2];
918 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
919 double range = fabs(spos - cpos);
920 double *spacing = input->GetSpacing();
922 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
923 cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
929 //----------------------------------------------------------------------------
931 //----------------------------------------------------------------------------
932 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
933 vtkImageData *targetImage, int targetExtent[6])
936 for(unsigned int i=0; i<6; i++) {
937 // From source voxel coordinates to world coordinates
938 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
940 // From world coordinates to floating point target voxel coordinates
941 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
944 //targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
945 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
948 //----------------------------------------------------------------------------
950 //----------------------------------------------------------------------------
951 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
956 //2D overlay on 3D image specific case
957 if (refExtent[4] == refExtent[5]) {
959 extent[4] = refExtent[4];
960 extent[5] = refExtent[5];
963 for (int i = 0; i < maxBound; i = i+2) {
964 //if we are totally outside the image
965 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
969 //crop to the limit of the image
970 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
971 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
972 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
973 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
976 for (int i = 0; i < maxBound; i = i+2) {
977 extent[i] = refExtent[i];
978 extent[i+1] = refExtent[i];
981 //----------------------------------------------------------------------------
984 //----------------------------------------------------------------------------
985 void vvSlicer::UpdateOrientation()
987 // Set the camera position
988 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
990 switch (this->SliceOrientation) {
991 case vtkImageViewer2::SLICE_ORIENTATION_XY:
992 cam->SetFocalPoint(0,0,0);
993 cam->SetPosition(0,0,-1); // -1 if medical ?
994 cam->SetViewUp(0,-1,0);
997 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
998 cam->SetFocalPoint(0,0,0);
999 cam->SetPosition(0,-1,0); // 1 if medical ?
1000 cam->SetViewUp(0,0,1);
1003 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1004 cam->SetFocalPoint(0,0,0);
1005 cam->SetPosition(-1,0,0); // -1 if medical ?
1006 cam->SetViewUp(0,0,1);
1011 //----------------------------------------------------------------------------
1014 //----------------------------------------------------------------------------
1015 void vvSlicer::SetOpacity(double s)
1017 this->GetImageActor()->SetOpacity(s);
1019 //----------------------------------------------------------------------------
1022 //----------------------------------------------------------------------------
1023 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1025 this->Superclass::SetRenderWindow(rw);
1026 this->SetupInteractor(rw->GetInteractor());
1027 ca->SetImageActor(this->GetImageActor());
1028 ca->SetWindowLevel(this->GetWindowLevel());
1029 ca->SetText(2, "<slice>");
1030 ca->SetText(3, "<window>\n<level>");
1042 crossCursor->SetModelBounds(bounds);
1043 this->GetRenderer()->AddActor(pdmA);
1044 this->GetRenderer()->AddActor(ca);
1045 this->GetRenderer()->ResetCamera();
1047 //this is just a mapping between the labeling of the orientations presented to the user and
1048 //the one used by vtk
1049 SetSliceOrientation(2-(orientation%3));
1052 //----------------------------------------------------------------------------
1055 //----------------------------------------------------------------------------
1056 void vvSlicer::ResetCamera()
1058 this->GetRenderer()->ResetCamera();
1060 //----------------------------------------------------------------------------
1063 //----------------------------------------------------------------------------
1064 void vvSlicer::SetDisplayMode(bool i)
1066 this->GetRenderer()->SetDraw(i);
1068 UpdateDisplayExtent();
1070 //----------------------------------------------------------------------------
1073 //----------------------------------------------------------------------------
1074 void vvSlicer::FlipHorizontalView()
1076 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1078 double *position = cam->GetPosition();
1079 double factor[3] = {1, 1, 1};
1080 factor[this->SliceOrientation] = -1;
1081 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1083 /* switch (this->SliceOrientation) {
1084 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1085 cam->SetPosition(position[0],position[1],-position[2]);
1088 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1089 cam->SetPosition(position[0],-position[1],position[2]);
1092 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1093 cam->SetPosition(-position[0],position[1],position[2]);
1097 this->Renderer->ResetCameraClippingRange();
1098 this->UpdateDisplayExtent();
1101 //----------------------------------------------------------------------------
1104 //----------------------------------------------------------------------------
1105 void vvSlicer::FlipVerticalView()
1107 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1109 FlipHorizontalView();
1110 double *viewup = cam->GetViewUp();
1111 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1112 this->UpdateDisplayExtent();
1115 //----------------------------------------------------------------------------
1118 //----------------------------------------------------------------------------
1119 void vvSlicer::SetColorWindow(double window)
1121 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1123 double level = this->GetWindowLevel()->GetLevel();
1124 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1127 this->vtkImageViewer2::SetColorWindow(window);
1129 //----------------------------------------------------------------------------
1131 //----------------------------------------------------------------------------
1132 void vvSlicer::SetColorLevel(double level)
1134 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1136 double window = this->GetWindowLevel()->GetWindow();
1137 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1140 this->vtkImageViewer2::SetColorLevel(level);
1142 //----------------------------------------------------------------------------
1144 //----------------------------------------------------------------------------
1145 double vvSlicer::GetOverlayColorWindow()
1148 return mOverlayMapper->GetWindow();
1152 //----------------------------------------------------------------------------
1154 //----------------------------------------------------------------------------
1155 double vvSlicer::GetOverlayColorLevel()
1158 return mOverlayMapper->GetLevel();
1162 //----------------------------------------------------------------------------
1164 //----------------------------------------------------------------------------
1165 void vvSlicer::SetOverlayColorWindow(double window)
1167 mOverlayMapper->SetWindow(window);
1169 //----------------------------------------------------------------------------
1171 //----------------------------------------------------------------------------
1172 void vvSlicer::SetOverlayColorLevel(double level)
1174 mOverlayMapper->SetLevel(level);
1176 //----------------------------------------------------------------------------
1178 //----------------------------------------------------------------------------
1179 // Returns the min an the max value in a 41x41 region around the mouse pointer
1180 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1182 //Get mouse pointer position in view coordinates
1185 for(int i=0; i<3; i++) {
1186 corner1[i] = mCurrent[i];
1187 corner2[i] = mCurrent[i];
1190 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1191 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1193 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1195 this->Renderer->GetTiledSize(&w, &h);
1196 corner1[0] -= 0.2*h/(double)w;
1197 corner2[0] += 0.2*h/(double)w;
1200 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1201 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1203 //Convert to image pixel coordinates (rounded)
1204 transform->TransformPoint(corner1, corner1);
1205 transform->TransformPoint(corner2, corner2);
1206 int iLocalExtents[6];
1207 for(int i=0; i<3; i++) {
1208 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1209 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1211 iLocalExtents[i*2 ] = lrint(corner1[i]);
1212 iLocalExtents[i*2+1] = lrint(corner2[i]);
1214 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1215 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1218 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1219 voiFilter->SetInput(image);
1220 voiFilter->SetVOI(iLocalExtents);
1221 voiFilter->Update();
1222 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1228 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1229 accFilter->SetInput(voiFilter->GetOutput());
1230 accFilter->Update();
1232 min = *(accFilter->GetMin());
1233 max = *(accFilter->GetMax());
1235 //----------------------------------------------------------------------------
1237 //----------------------------------------------------------------------------
1238 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1243 if (ix < image->GetWholeExtent()[0] ||
1244 ix > image->GetWholeExtent()[1] ||
1245 iy < image->GetWholeExtent()[2] ||
1246 iy > image->GetWholeExtent()[3] ||
1247 iz < image->GetWholeExtent()[4] ||
1248 iz > image->GetWholeExtent()[5] )
1249 return std::numeric_limits<double>::quiet_NaN();
1251 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1253 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1255 //----------------------------------------------------------------------------
1257 //----------------------------------------------------------------------------
1258 void vvSlicer::Render()
1260 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1261 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1262 legend->UseOpacityOn();
1263 legend->SetVisibility(1);
1265 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1266 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1267 legend->UseOpacityOff();
1268 legend->SetVisibility(1);
1269 } else legend->SetVisibility(0);
1271 if (ca->GetVisibility()) {
1272 std::stringstream worldPos;
1273 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1274 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1275 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1277 // if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
1278 // else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
1279 // if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
1280 // else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
1281 // if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
1282 // else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
1284 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1285 X <= this->GetInput()->GetWholeExtent()[1] &&
1286 Y >= this->GetInput()->GetWholeExtent()[2] &&
1287 Y <= this->GetInput()->GetWholeExtent()[3] &&
1288 Z >= this->GetInput()->GetWholeExtent()[4] &&
1289 Z <= this->GetInput()->GetWholeExtent()[5]) {
1293 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1295 if(ImageActor->GetVisibility())
1296 worldPos << "data value : " << value << std::endl;
1298 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1299 << lrint(mCurrent[1]) << ' '
1300 << lrint(mCurrent[2]) << ' '
1303 worldPos << "pixel : " << ix << ' '
1309 ca->SetText(1,worldPos.str().c_str());
1312 if (pdmA->GetVisibility()) {
1313 double x = mCursor[0];
1314 double y = mCursor[1];
1315 double z = mCursor[2];
1316 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1317 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1318 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1320 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1321 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1322 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1323 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1324 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1325 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1326 vtkRenderer * renderer = this->Renderer;
1328 renderer->WorldToView(x,y,z);
1329 renderer->ViewToNormalizedViewport(x,y,z);
1330 renderer->NormalizedViewportToViewport(x,y);
1331 renderer->ViewportToNormalizedDisplay(x,y);
1332 renderer->NormalizedDisplayToDisplay(x,y);
1333 crossCursor->SetFocalPoint(x,y,z);
1335 crossCursor->SetFocalPoint(-1,-1,z);
1339 if (mOverlay && mOverlayActor->GetVisibility()) {
1340 if(mLinkOverlayWindowLevel) {
1341 mOverlayMapper->SetWindow(this->GetColorWindow());
1342 mOverlayMapper->SetLevel(this->GetColorLevel());
1344 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1345 mOverlayMapper->GetOutput()->Update();
1346 mOverlayMapper->Update();
1351 this->GetRenderWindow()->Render();
1353 //----------------------------------------------------------------------------
1356 //----------------------------------------------------------------------------
1357 void vvSlicer::UpdateCursorPosition()
1359 pdmA->SetVisibility(true);
1360 mCursor[0] = mCurrent[0];
1361 mCursor[1] = mCurrent[1];
1362 mCursor[2] = mCurrent[2];
1363 mCursor[3] = mCurrentTSlice;
1365 //----------------------------------------------------------------------------
1368 //----------------------------------------------------------------------------
1369 void vvSlicer::UpdateLandmarks()
1371 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1372 if (pd->GetPoints()) {
1373 mLandGlyph->SetRange(0,1);
1374 mLandGlyph->Modified();
1375 mLandGlyph->Update();
1377 mClipBox->Modified();
1378 mLandClipper->Update();
1379 mLandMapper->Update();
1383 //----------------------------------------------------------------------------
1386 //----------------------------------------------------------------------------
1387 void vvSlicer::SetSlice(int slice)
1389 int *range = this->GetSliceRange();
1391 if (slice < range[0]) {
1393 } else if (slice > range[1]) {
1398 if (this->Slice == slice) {
1402 this->Slice = slice;
1405 this->UpdateDisplayExtent();
1407 // Seems to work without this line
1410 //----------------------------------------------------------------------------
1413 //----------------------------------------------------------------------------
1414 void vvSlicer::SetContourSlice()
1416 if (mSurfaceCutActors.size() > 0)
1417 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1418 i!=mSurfaceCutActors.end(); i++) {
1420 (*i)->SetSlicingOrientation(this->SliceOrientation);
1421 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1422 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1425 //----------------------------------------------------------------------------
1428 //----------------------------------------------------------------------------
1429 void vvSlicer::ForceUpdateDisplayExtent()
1431 this->UpdateDisplayExtent();
1433 //----------------------------------------------------------------------------
1436 //----------------------------------------------------------------------------
1437 int* vvSlicer::GetDisplayExtent()
1439 return this->GetImageActor()->GetDisplayExtent();
1441 //----------------------------------------------------------------------------
1444 //----------------------------------------------------------------------------
1445 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1447 this->Superclass::PrintSelf(os, indent);
1449 //----------------------------------------------------------------------------
1451 //----------------------------------------------------------------------------
1452 void vvSlicer::SetVFColor(double r, double g, double b)
1454 double mVFColorHSV[3];
1459 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1460 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1461 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1462 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);