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 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
70 # include <vtkImageMapper3D.h>
73 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
74 vtkStandardNewMacro(vvSlicer);
75 static void copyExtent(int* in, int* to){
76 for(int i=0; i<6; ++i) to[i]=in[i];
78 //------------------------------------------------------------------------------
81 this->UnInstallPipeline();
83 mReducedExtent = new int[6];
85 mUseReducedExtent = false;
87 mCurrent[0] = -VTK_DOUBLE_MAX;
88 mCurrent[1] = -VTK_DOUBLE_MAX;
89 mCurrent[2] = -VTK_DOUBLE_MAX;
91 mCursor[0] = -VTK_DOUBLE_MAX;
92 mCursor[1] = -VTK_DOUBLE_MAX;
93 mCursor[2] = -VTK_DOUBLE_MAX;
94 mCursor[3] = -VTK_DOUBLE_MAX;
104 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
105 crossCursor->AllOff();
106 crossCursor->AxesOn();
107 crossCursor->SetTranslationMode(1);
108 crossCursor->SetRadius(2);
110 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
111 pdm->SetInput(crossCursor->GetOutput());
113 pdmA = vtkSmartPointer<vtkActor2D>::New();
114 pdmA->SetMapper(pdm);
115 pdmA->GetProperty()->SetColor(255,10,212);
116 pdmA->SetVisibility(0);
117 pdmA->SetPickable(0);
119 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
120 ca->GetTextProperty()->SetColor(255,10,212);
121 ca->SetVisibility(1);
129 legend = vtkSmartPointer<vtkScalarBarActor>::New();
130 //legend->SetTitle("test!");
131 legend->SetPosition(0.82,0.18);
132 legend->SetWidth(0.1);
133 legend->SetVisibility(0);
134 legend->SetLabelFormat("%.1f");
135 this->GetRenderer()->AddActor(legend);
136 showFusionLegend = false;
138 this->WindowLevel->Delete();
139 this->WindowLevel = vvImageMapToWLColors::New();
141 this->InstallPipeline();
143 mLinkOverlayWindowLevel = true;
145 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
146 this->GetImageActor()->GetMapper()->BorderOn();
149 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
153 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
155 return mOverlayMapper.GetPointer();
157 //------------------------------------------------------------------------------
160 //------------------------------------------------------------------------------
161 vvBlendImageActor* vvSlicer::GetOverlayActor()
163 return mOverlayActor.GetPointer();
165 //------------------------------------------------------------------------------
168 //------------------------------------------------------------------------------
169 vtkImageMapToColors* vvSlicer::GetFusionMapper()
171 return mFusionMapper.GetPointer();
173 //------------------------------------------------------------------------------
176 //------------------------------------------------------------------------------
177 vtkImageActor* vvSlicer::GetFusionActor()
179 return mFusionActor.GetPointer();
181 //------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------
185 vtkActor* vvSlicer::GetVFActor()
187 return mVFActor.GetPointer();
189 //------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------
193 vtkCornerAnnotation* vvSlicer::GetAnnotation()
195 return ca.GetPointer();
197 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 void vvSlicer::EnableReducedExtent(bool b)
203 mUseReducedExtent = b;
205 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 void vvSlicer::SetReducedExtent(int * ext)
211 copyExtent(ext, mReducedExtent);
213 //------------------------------------------------------------------------------
216 //------------------------------------------------------------------------------
217 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
220 mSurfaceCutActors.push_back(new vvMeshActor());
222 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
224 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
225 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
226 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
230 //------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------
234 void vvSlicer::ToggleContourSuperposition()
236 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
237 i!=mSurfaceCutActors.end(); i++)
238 (*i)->ToggleSuperposition();
240 //------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------
244 void vvSlicer::SetCursorColor(int r,int g, int b)
246 pdmA->GetProperty()->SetColor(r,g,b);
248 //------------------------------------------------------------------------------
251 //------------------------------------------------------------------------------
252 void vvSlicer::SetCursorVisibility(bool s)
254 pdmA->SetVisibility(s);
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 bool vvSlicer::GetCursorVisibility()
262 return pdmA->GetVisibility();
264 //------------------------------------------------------------------------------
267 //------------------------------------------------------------------------------
268 void vvSlicer::SetCornerAnnotationVisibility(bool s)
270 ca->SetVisibility(s);
272 //------------------------------------------------------------------------------
275 //------------------------------------------------------------------------------
276 bool vvSlicer::GetCornerAnnotationVisibility()
278 return ca->GetVisibility();
280 //------------------------------------------------------------------------------
283 //------------------------------------------------------------------------------
284 vvSlicer::~vvSlicer()
286 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
287 i!=mSurfaceCutActors.end(); i++)
289 delete [] mReducedExtent;
291 //------------------------------------------------------------------------------
294 //------------------------------------------------------------------------------
295 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
302 //------------------------------------------------------------------------------
305 //------------------------------------------------------------------------------
306 void vvSlicer::SetImage(vvImage::Pointer image)
308 if (image->GetVTKImages().size()) {
311 if (!mImageReslice) {
312 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
313 mImageReslice->SetInterpolationModeToLinear();
314 mImageReslice->AutoCropOutputOn();
315 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
317 mImageReslice->SetResliceTransform(mImage->GetTransform());
318 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
319 mImageReslice->UpdateInformation();
321 this->Superclass::SetInput(mImageReslice->GetOutput());
324 this->GetInput()->GetWholeExtent(extent);
326 // Prevent crash when reload -> change slice if outside extent
327 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
328 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
331 // Make sure that the required part image has been computed
332 extent[SliceOrientation*2] = Slice;
333 extent[SliceOrientation*2+1] = Slice;
334 mImageReslice->GetOutput()->SetUpdateExtent(extent);
335 mImageReslice->GetOutput()->Update();
337 this->UpdateDisplayExtent();
340 ca->SetText(0,mFileName.c_str());
343 //------------------------------------------------------------------------------
346 //------------------------------------------------------------------------------
347 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
349 if (overlay->GetVTKImages().size()) {
352 if (!mOverlayReslice) {
353 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
354 mOverlayReslice->SetInterpolationModeToLinear();
355 mOverlayReslice->AutoCropOutputOn();
356 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
358 mOverlayReslice->SetResliceTransform(mOverlay->GetTransform());
359 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
362 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
363 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
365 if (!mOverlayActor) {
366 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
367 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
368 mOverlayActor->SetPickable(0);
369 mOverlayActor->SetVisibility(true);
370 mOverlayActor->SetOpacity(0.5);
371 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
372 mOverlayActor->GetMapper()->BorderOn();
376 //stupid but necessary : the Overlay need to be rendered before fusion
378 this->GetRenderer()->RemoveActor(mFusionActor);
379 this->GetRenderer()->AddActor(mOverlayActor);
380 this->GetRenderer()->AddActor(mFusionActor);
382 this->GetRenderer()->AddActor(mOverlayActor);
384 //Synchronize orientation and slice
385 AdjustResliceToSliceOrientation(mOverlayReslice);
386 this->UpdateDisplayExtent();
387 this->SetTSlice(mCurrentTSlice);
390 //------------------------------------------------------------------------------
393 //------------------------------------------------------------------------------
394 void vvSlicer::SetFusion(vvImage::Pointer fusion)
396 if (fusion->GetVTKImages().size()) {
399 if (!mFusionReslice) {
400 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
401 mFusionReslice->SetInterpolationModeToLinear();
402 mFusionReslice->AutoCropOutputOn();
403 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
405 mFusionReslice->SetResliceTransform(mFusion->GetTransform());
406 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
409 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
411 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
413 lut->SetValueRange(0, 1);
414 lut->SetSaturationRange(0, 0);
416 mFusionMapper->SetLookupTable(lut);
417 mFusionMapper->SetInput(mFusionReslice->GetOutput());
420 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
421 mFusionActor->SetInput(mFusionMapper->GetOutput());
422 mFusionActor->SetPickable(0);
423 mFusionActor->SetVisibility(true);
424 mFusionActor->SetOpacity(0.7);
425 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
426 mFusionActor->GetMapper()->BorderOn();
428 this->GetRenderer()->AddActor(mFusionActor);
431 //Synchronize orientation and slice
432 AdjustResliceToSliceOrientation(mFusionReslice);
433 this->UpdateDisplayExtent();
434 this->SetTSlice(mCurrentTSlice);
437 //------------------------------------------------------------------------------
440 //------------------------------------------------------------------------------
441 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
444 if (actor_type == "image") {
445 vis = this->ImageActor->GetVisibility();
447 else if (actor_type == "vector") {
448 vis = this->mVFActor->GetVisibility();
450 else if (actor_type == "overlay") {
451 vis = this->mOverlayActor->GetVisibility();
453 else if (actor_type == "fusion") {
454 vis = this->mFusionActor->GetVisibility();
456 else if (actor_type == "contour")
457 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
461 //------------------------------------------------------------------------------
463 //------------------------------------------------------------------------------
464 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
466 if (actor_type == "image") {
467 this->ImageActor->SetVisibility(vis);
469 else if (actor_type == "vector") {
470 this->mVFActor->SetVisibility(vis);
472 else if (actor_type == "overlay") {
473 this->mOverlayActor->SetVisibility(vis);
475 else if (actor_type == "fusion") {
476 this->mFusionActor->SetVisibility(vis);
478 else if (actor_type == "contour")
479 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
480 UpdateDisplayExtent();
482 //------------------------------------------------------------------------------
484 //------------------------------------------------------------------------------
485 void vvSlicer::SetVF(vvImage::Pointer vf)
487 if (vf->GetVTKImages().size()) {
491 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
492 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
493 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
495 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
496 mAAFilter->SetInput(mVOIFilter->GetOutput());
497 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
498 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
501 mArrow = vtkSmartPointer<vvGlyphSource>::New();
502 mArrow->SetGlyphTypeToSpecificArrow();
503 mArrow->SetScale(mScale);
506 // Glyph the gradient vector (with arrows)
508 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
509 mGlyphFilter->SetInput(mAAFilter->GetOutput());
510 mGlyphFilter->SetSource(mArrow->GetOutput());
511 mGlyphFilter->ScalingOn();
512 mGlyphFilter->SetScaleModeToScaleByVector();
513 mGlyphFilter->OrientOn();
514 mGlyphFilter->SetVectorModeToUseVector();
515 mGlyphFilter->SetColorModeToColorByVector();
518 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
520 double mVFColorHSV[3];
521 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
522 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
523 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
524 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
527 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
528 mVFMapper->SetInput(mGlyphFilter->GetOutput());
529 mVFMapper->ImmediateModeRenderingOn();
530 mVFMapper->SetLookupTable(mVFColorLUT);
533 mVFActor = vtkSmartPointer<vtkActor>::New();
534 mVFActor->SetMapper(mVFMapper);
535 mVFActor->SetPickable(0);
536 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
537 this->UpdateDisplayExtent();
538 this->GetRenderer()->AddActor(mVFActor);
541 SetTSlice(mCurrentTSlice);
544 //------------------------------------------------------------------------------
547 //------------------------------------------------------------------------------
548 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
550 mLandmarks = landmarks;
554 mCross = vtkSmartPointer<vtkCursor3D>::New();
555 mCross->SetFocalPoint(0.0,0.0,0.0);
556 mCross->SetModelBounds(-10,10,-10,10,-10,10);
561 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
562 mLandGlyph->SetSource(mCross->GetOutput());
563 mLandGlyph->SetInput(landmarks->GetOutput());
564 //mLandGlyph->SetIndexModeToScalar();
565 mLandGlyph->SetRange(0,1);
566 mLandGlyph->ScalingOff();
568 mLandGlyph->SetColorModeToColorByScalar();
571 mClipBox = vtkSmartPointer<vtkBox>::New();
573 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
574 mLandClipper->InsideOutOn();
575 mLandClipper->SetInput(mLandGlyph->GetOutput());
576 mLandClipper->SetClipFunction(mClipBox);
579 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
580 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
581 //mLandMapper->ScalarVisibilityOff();
584 mLandActor = vtkSmartPointer<vtkActor>::New();
585 mLandActor->SetMapper(mLandMapper);
586 mLandActor->GetProperty()->SetColor(255,10,212);
587 mLandActor->SetPickable(0);
588 mLandActor->SetVisibility(true);
589 this->UpdateDisplayExtent();
590 this->GetRenderer()->AddActor(mLandActor);
593 //------------------------------------------------------------------------------
595 //------------------------------------------------------------------------------
596 //FIXME: this function leaks memory, we should fix it someday :)
597 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
599 if (actor_type == "vector") {
600 Renderer->RemoveActor(mVFActor);
609 if (actor_type == "overlay") {
610 Renderer->RemoveActor(mOverlayActor);
612 mOverlayActor = NULL;
613 mOverlayMapper = NULL;
615 if (actor_type == "fusion") {
616 Renderer->RemoveActor(mFusionActor);
619 mFusionMapper = NULL;
621 if (actor_type == "contour") {
622 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
623 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
626 //------------------------------------------------------------------------------
629 //------------------------------------------------------------------------------
630 void vvSlicer::SetVFSubSampling(int sub)
633 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
636 UpdateDisplayExtent();
639 //------------------------------------------------------------------------------
642 //------------------------------------------------------------------------------
643 void vvSlicer::SetVFScale(int scale)
647 mArrow->SetScale(mScale);
648 UpdateDisplayExtent();
651 //------------------------------------------------------------------------------
653 //------------------------------------------------------------------------------
654 void vvSlicer::SetVFWidth(int width)
658 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
659 UpdateDisplayExtent();
662 //------------------------------------------------------------------------------
665 //------------------------------------------------------------------------------
666 void vvSlicer::SetVFLog(int log)
670 mGlyphFilter->SetUseLog(mVFLog);
671 mGlyphFilter->Modified();
673 UpdateDisplayExtent();
676 //------------------------------------------------------------------------------
679 //------------------------------------------------------------------------------
680 void vvSlicer::SetTSlice(int t)
684 else if ((unsigned int)t >= mImage->GetVTKImages().size())
685 t = mImage->GetVTKImages().size() -1;
688 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
689 if (mVF && mVFActor->GetVisibility()) {
690 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
691 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
693 if (mOverlay && mOverlayActor->GetVisibility()) {
694 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
695 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
697 if (mFusion && mFusionActor->GetVisibility()) {
698 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
699 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
701 if (mSurfaceCutActors.size() > 0)
702 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
703 i!=mSurfaceCutActors.end(); i++)
704 (*i)->SetTimeSlice(mCurrentTSlice);
705 UpdateDisplayExtent();
707 //------------------------------------------------------------------------------
710 //------------------------------------------------------------------------------
711 int vvSlicer::GetTSlice()
713 return mCurrentTSlice;
715 //------------------------------------------------------------------------------
717 //------------------------------------------------------------------------------
718 void vvSlicer::SetSliceOrientation(int orientation)
720 //if 2D image, force to watch in Axial View
722 this->GetInput()->GetWholeExtent(extent);
723 if (extent[5]-extent[4] <= 2)
724 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
726 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
727 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
728 vtkErrorMacro("Error - invalid slice orientation " << orientation);
732 this->SliceOrientation = orientation;
735 AdjustResliceToSliceOrientation(mFusionReslice);
738 AdjustResliceToSliceOrientation(mOverlayReslice);
741 int *range = this->GetSliceRange();
743 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
745 // Go to current cursor position
746 // double* cursorPos = GetCursorPosition();
747 // DDV(cursorPos, 3);
748 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
750 this->UpdateOrientation();
751 this->UpdateDisplayExtent();
753 if (this->Renderer && this->GetInput()) {
754 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
755 this->Renderer->ResetCamera();
756 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
761 //----------------------------------------------------------------------------
763 //------------------------------------------------------------------------------
764 // This function ensures that we sample the slices of a vtkImageReslice filter
765 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
766 // In other words, we change the grid of the reslice in the same way as the grid
767 // of the displayed image in the slicing direction.
768 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
770 // Reset autocrop and update output information
771 reslice->SetOutputOriginToDefault();
772 reslice->SetOutputSpacingToDefault();
773 reslice->GetOutput()->UpdateInformation();
775 // Ge new origin / spacing
778 reslice->GetOutput()->GetOrigin(origin);
779 reslice->GetOutput()->GetSpacing(spacing);
781 // Use similar spacing as the image in the direction SliceOrientation
782 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
784 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
785 // Step 1: from world coordinates to image coordinates
786 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
787 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
788 // Step 2: round to superior grid positionInc
789 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
790 // Step 3: back to world coordinates
791 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
792 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
794 // Set new spacing and origin
795 reslice->SetOutputOrigin(origin);
796 reslice->SetOutputSpacing(spacing);
797 reslice->UpdateInformation();
798 reslice->GetOutput()->UpdateInformation();
800 //------------------------------------------------------------------------------
802 //----------------------------------------------------------------------------
803 int * vvSlicer::GetExtent(){
805 if (mUseReducedExtent) {
806 w_ext = mReducedExtent;
807 } else w_ext = GetInput()->GetWholeExtent();
810 //----------------------------------------------------------------------------
813 //----------------------------------------------------------------------------
814 int vvSlicer::GetOrientation()
816 return this->SliceOrientation;
818 //----------------------------------------------------------------------------
821 //----------------------------------------------------------------------------
822 void vvSlicer::UpdateDisplayExtent()
824 vtkImageData *input = this->GetInput();
825 if (!input || !this->ImageActor) {
828 input->UpdateInformation();
830 // Local copy of extent
832 int* ext = GetExtent();
833 copyExtent(ext, w_ext);
835 int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice;
836 w_ext[ this->SliceOrientation*2 ] = s;
837 w_ext[ this->SliceOrientation*2+1 ] = s;
840 this->ImageActor->SetDisplayExtent(w_ext);
842 // Overlay image actor
843 if (mOverlay && mOverlayActor->GetVisibility()) {
844 AdjustResliceToSliceOrientation(mOverlayReslice);
846 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
847 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
848 mOverlayActor->SetDisplayExtent( overExtent );
851 // Fusion image actor
852 if (mFusion && mFusionActor->GetVisibility()) {
853 AdjustResliceToSliceOrientation(mFusionReslice);
855 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
856 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
857 mFusionActor->SetDisplayExtent(fusExtent);
860 // Vector field actor
861 double* camera = Renderer->GetActiveCamera()->GetPosition();
862 double* image_bounds = ImageActor->GetBounds();
863 double position[3] = {0, 0, 0};
864 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
866 //print_vector<double, 6>("camera", camera);
867 //print_vector<double, 6>("image_bounds", image_bounds);
868 //print_vector<double, 3>("position", position);
870 // find where to place the VF actor. to deal with
871 // z-buffer issues, the VF is placed right in front of the image,
872 // subject to a small offset. the position actually depends on the
873 // the location of the camera relative to the image.
875 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
878 if (mVF && mVFActor->GetVisibility()) {
880 mVF->GetVTKImages()[0]->UpdateInformation();
881 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
882 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
883 mVOIFilter->SetVOI(vfExtent);
884 int orientation[3] = {1,1,1};
885 orientation[this->SliceOrientation] = 0;
886 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
889 position[this->SliceOrientation] += offset;
890 mVFActor->SetPosition(position);
897 for(unsigned int i=0; i<6; i++)
898 bounds[i] = ImageActor->GetBounds()[i];
899 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
900 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
901 mClipBox->SetBounds(bounds);
905 position[this->SliceOrientation] = offset;
906 mLandActor->SetPosition(position);
909 // Figure out the correct clipping range
910 if (this->Renderer) {
911 if (this->InteractorStyle &&
912 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
913 this->Renderer->ResetCameraClippingRange();
915 vtkCamera *cam = this->Renderer->GetActiveCamera();
918 this->ImageActor->GetBounds(bounds);
919 double spos = (double)bounds[this->SliceOrientation * 2];
920 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
921 double range = fabs(spos - cpos);
922 double *spacing = input->GetSpacing();
924 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
925 cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
931 //----------------------------------------------------------------------------
933 //----------------------------------------------------------------------------
934 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
935 vtkImageData *targetImage, int targetExtent[6])
938 for(unsigned int i=0; i<6; i++) {
939 // From source voxel coordinates to world coordinates
940 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
942 // From world coordinates to floating point target voxel coordinates
943 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
946 //targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
947 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
950 //----------------------------------------------------------------------------
952 //----------------------------------------------------------------------------
953 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
958 //2D overlay on 3D image specific case
959 if (refExtent[4] == refExtent[5]) {
961 extent[4] = refExtent[4];
962 extent[5] = refExtent[5];
965 for (int i = 0; i < maxBound; i = i+2) {
966 //if we are totally outside the image
967 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
971 //crop to the limit of the image
972 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
973 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
974 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
975 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
978 for (int i = 0; i < maxBound; i = i+2) {
979 extent[i] = refExtent[i];
980 extent[i+1] = refExtent[i];
983 //----------------------------------------------------------------------------
986 //----------------------------------------------------------------------------
987 void vvSlicer::UpdateOrientation()
989 // Set the camera position
990 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
992 switch (this->SliceOrientation) {
993 case vtkImageViewer2::SLICE_ORIENTATION_XY:
994 cam->SetFocalPoint(0,0,0);
995 cam->SetPosition(0,0,-1); // -1 if medical ?
996 cam->SetViewUp(0,-1,0);
999 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1000 cam->SetFocalPoint(0,0,0);
1001 cam->SetPosition(0,-1,0); // 1 if medical ?
1002 cam->SetViewUp(0,0,1);
1005 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1006 cam->SetFocalPoint(0,0,0);
1007 cam->SetPosition(-1,0,0); // -1 if medical ?
1008 cam->SetViewUp(0,0,1);
1013 //----------------------------------------------------------------------------
1016 //----------------------------------------------------------------------------
1017 void vvSlicer::SetOpacity(double s)
1019 this->GetImageActor()->SetOpacity(s);
1021 //----------------------------------------------------------------------------
1024 //----------------------------------------------------------------------------
1025 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1027 this->Superclass::SetRenderWindow(rw);
1028 this->SetupInteractor(rw->GetInteractor());
1029 ca->SetImageActor(this->GetImageActor());
1030 ca->SetWindowLevel(this->GetWindowLevel());
1031 ca->SetText(2, "<slice>");
1032 ca->SetText(3, "<window>\n<level>");
1044 crossCursor->SetModelBounds(bounds);
1045 this->GetRenderer()->AddActor(pdmA);
1046 this->GetRenderer()->AddActor(ca);
1047 this->GetRenderer()->ResetCamera();
1049 //this is just a mapping between the labeling of the orientations presented to the user and
1050 //the one used by vtk
1051 SetSliceOrientation(2-(orientation%3));
1054 //----------------------------------------------------------------------------
1057 //----------------------------------------------------------------------------
1058 void vvSlicer::ResetCamera()
1060 this->GetRenderer()->ResetCamera();
1062 //----------------------------------------------------------------------------
1065 //----------------------------------------------------------------------------
1066 void vvSlicer::SetDisplayMode(bool i)
1068 this->GetRenderer()->SetDraw(i);
1070 UpdateDisplayExtent();
1072 //----------------------------------------------------------------------------
1075 //----------------------------------------------------------------------------
1076 void vvSlicer::FlipHorizontalView()
1078 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1080 double *position = cam->GetPosition();
1081 double factor[3] = {1, 1, 1};
1082 factor[this->SliceOrientation] = -1;
1083 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1085 /* switch (this->SliceOrientation) {
1086 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1087 cam->SetPosition(position[0],position[1],-position[2]);
1090 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1091 cam->SetPosition(position[0],-position[1],position[2]);
1094 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1095 cam->SetPosition(-position[0],position[1],position[2]);
1099 this->Renderer->ResetCameraClippingRange();
1100 this->UpdateDisplayExtent();
1103 //----------------------------------------------------------------------------
1106 //----------------------------------------------------------------------------
1107 void vvSlicer::FlipVerticalView()
1109 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1111 FlipHorizontalView();
1112 double *viewup = cam->GetViewUp();
1113 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1114 this->UpdateDisplayExtent();
1117 //----------------------------------------------------------------------------
1120 //----------------------------------------------------------------------------
1121 void vvSlicer::SetColorWindow(double window)
1123 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1125 double level = this->GetWindowLevel()->GetLevel();
1126 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1129 this->vtkImageViewer2::SetColorWindow(window);
1131 //----------------------------------------------------------------------------
1133 //----------------------------------------------------------------------------
1134 void vvSlicer::SetColorLevel(double level)
1136 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1138 double window = this->GetWindowLevel()->GetWindow();
1139 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1142 this->vtkImageViewer2::SetColorLevel(level);
1144 //----------------------------------------------------------------------------
1146 //----------------------------------------------------------------------------
1147 double vvSlicer::GetOverlayColorWindow()
1150 return mOverlayMapper->GetWindow();
1154 //----------------------------------------------------------------------------
1156 //----------------------------------------------------------------------------
1157 double vvSlicer::GetOverlayColorLevel()
1160 return mOverlayMapper->GetLevel();
1164 //----------------------------------------------------------------------------
1166 //----------------------------------------------------------------------------
1167 void vvSlicer::SetOverlayColorWindow(double window)
1169 mOverlayMapper->SetWindow(window);
1171 //----------------------------------------------------------------------------
1173 //----------------------------------------------------------------------------
1174 void vvSlicer::SetOverlayColorLevel(double level)
1176 mOverlayMapper->SetLevel(level);
1178 //----------------------------------------------------------------------------
1180 //----------------------------------------------------------------------------
1181 // Returns the min an the max value in a 41x41 region around the mouse pointer
1182 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1184 //Get mouse pointer position in view coordinates
1187 for(int i=0; i<3; i++) {
1188 corner1[i] = mCurrent[i];
1189 corner2[i] = mCurrent[i];
1192 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1193 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1195 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1197 this->Renderer->GetTiledSize(&w, &h);
1198 corner1[0] -= 0.2*h/(double)w;
1199 corner2[0] += 0.2*h/(double)w;
1202 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1203 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1205 //Convert to image pixel coordinates (rounded)
1206 transform->TransformPoint(corner1, corner1);
1207 transform->TransformPoint(corner2, corner2);
1208 int iLocalExtents[6];
1209 for(int i=0; i<3; i++) {
1210 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1211 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1213 iLocalExtents[i*2 ] = lrint(corner1[i]);
1214 iLocalExtents[i*2+1] = lrint(corner2[i]);
1216 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1217 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1220 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1221 voiFilter->SetInput(image);
1222 voiFilter->SetVOI(iLocalExtents);
1223 voiFilter->Update();
1224 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1230 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1231 accFilter->SetInput(voiFilter->GetOutput());
1232 accFilter->Update();
1234 min = *(accFilter->GetMin());
1235 max = *(accFilter->GetMax());
1237 //----------------------------------------------------------------------------
1239 //----------------------------------------------------------------------------
1240 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1245 if (ix < image->GetWholeExtent()[0] ||
1246 ix > image->GetWholeExtent()[1] ||
1247 iy < image->GetWholeExtent()[2] ||
1248 iy > image->GetWholeExtent()[3] ||
1249 iz < image->GetWholeExtent()[4] ||
1250 iz > image->GetWholeExtent()[5] )
1251 return std::numeric_limits<double>::quiet_NaN();
1253 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1255 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1257 //----------------------------------------------------------------------------
1259 //----------------------------------------------------------------------------
1260 void vvSlicer::Render()
1262 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1263 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1264 legend->UseOpacityOn();
1265 legend->SetVisibility(1);
1267 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1268 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1269 legend->UseOpacityOff();
1270 legend->SetVisibility(1);
1271 } else legend->SetVisibility(0);
1273 if (ca->GetVisibility()) {
1274 std::stringstream worldPos;
1275 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1276 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1277 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1279 // if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
1280 // else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
1281 // if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
1282 // else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
1283 // if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
1284 // else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
1286 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1287 X <= this->GetInput()->GetWholeExtent()[1] &&
1288 Y >= this->GetInput()->GetWholeExtent()[2] &&
1289 Y <= this->GetInput()->GetWholeExtent()[3] &&
1290 Z >= this->GetInput()->GetWholeExtent()[4] &&
1291 Z <= this->GetInput()->GetWholeExtent()[5]) {
1295 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1297 if(ImageActor->GetVisibility())
1298 worldPos << "data value : " << value << std::endl;
1300 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1301 << lrint(mCurrent[1]) << ' '
1302 << lrint(mCurrent[2]) << ' '
1305 worldPos << "pixel : " << ix << ' '
1311 ca->SetText(1,worldPos.str().c_str());
1314 if (pdmA->GetVisibility()) {
1315 double x = mCursor[0];
1316 double y = mCursor[1];
1317 double z = mCursor[2];
1318 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1319 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1320 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1322 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1323 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1324 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1325 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1326 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1327 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1328 vtkRenderer * renderer = this->Renderer;
1330 renderer->WorldToView(x,y,z);
1331 renderer->ViewToNormalizedViewport(x,y,z);
1332 renderer->NormalizedViewportToViewport(x,y);
1333 renderer->ViewportToNormalizedDisplay(x,y);
1334 renderer->NormalizedDisplayToDisplay(x,y);
1335 crossCursor->SetFocalPoint(x,y,z);
1337 crossCursor->SetFocalPoint(-1,-1,z);
1341 if (mOverlay && mOverlayActor->GetVisibility()) {
1342 if(mLinkOverlayWindowLevel) {
1343 mOverlayMapper->SetWindow(this->GetColorWindow());
1344 mOverlayMapper->SetLevel(this->GetColorLevel());
1346 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1347 mOverlayMapper->GetOutput()->Update();
1348 mOverlayMapper->Update();
1353 this->GetRenderWindow()->Render();
1355 //----------------------------------------------------------------------------
1358 //----------------------------------------------------------------------------
1359 void vvSlicer::UpdateCursorPosition()
1361 pdmA->SetVisibility(true);
1362 mCursor[0] = mCurrent[0];
1363 mCursor[1] = mCurrent[1];
1364 mCursor[2] = mCurrent[2];
1365 mCursor[3] = mCurrentTSlice;
1367 //----------------------------------------------------------------------------
1370 //----------------------------------------------------------------------------
1371 void vvSlicer::UpdateLandmarks()
1373 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1374 if (pd->GetPoints()) {
1375 mLandGlyph->SetRange(0,1);
1376 mLandGlyph->Modified();
1377 mLandGlyph->Update();
1379 mClipBox->Modified();
1380 mLandClipper->Update();
1381 mLandMapper->Update();
1385 //----------------------------------------------------------------------------
1388 //----------------------------------------------------------------------------
1389 void vvSlicer::SetSlice(int slice)
1391 int *range = this->GetSliceRange();
1393 if (slice < range[0]) {
1395 } else if (slice > range[1]) {
1400 if (this->Slice == slice) {
1404 this->Slice = slice;
1407 this->UpdateDisplayExtent();
1409 // Seems to work without this line
1412 //----------------------------------------------------------------------------
1415 //----------------------------------------------------------------------------
1416 void vvSlicer::SetContourSlice()
1418 if (mSurfaceCutActors.size() > 0)
1419 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1420 i!=mSurfaceCutActors.end(); i++) {
1422 (*i)->SetSlicingOrientation(this->SliceOrientation);
1423 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1424 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1427 //----------------------------------------------------------------------------
1430 //----------------------------------------------------------------------------
1431 void vvSlicer::ForceUpdateDisplayExtent()
1433 this->UpdateDisplayExtent();
1435 //----------------------------------------------------------------------------
1438 //----------------------------------------------------------------------------
1439 int* vvSlicer::GetDisplayExtent()
1441 return this->GetImageActor()->GetDisplayExtent();
1443 //----------------------------------------------------------------------------
1446 //----------------------------------------------------------------------------
1447 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1449 this->Superclass::PrintSelf(os, indent);
1451 //----------------------------------------------------------------------------
1453 //----------------------------------------------------------------------------
1454 void vvSlicer::SetVFColor(double r, double g, double b)
1456 double mVFColorHSV[3];
1461 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1462 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1463 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1464 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);