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>
70 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
71 vtkStandardNewMacro(vvSlicer);
72 static void copyExtent(int* in, int* to){
73 for(int i=0; i<6; ++i) to[i]=in[i];
75 //------------------------------------------------------------------------------
78 this->UnInstallPipeline();
80 mReducedExtent = new int[6];
82 mUseReducedExtent = false;
84 mCurrent[0] = -VTK_DOUBLE_MAX;
85 mCurrent[1] = -VTK_DOUBLE_MAX;
86 mCurrent[2] = -VTK_DOUBLE_MAX;
88 mCursor[0] = -VTK_DOUBLE_MAX;
89 mCursor[1] = -VTK_DOUBLE_MAX;
90 mCursor[2] = -VTK_DOUBLE_MAX;
91 mCursor[3] = -VTK_DOUBLE_MAX;
101 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
102 crossCursor->AllOff();
103 crossCursor->AxesOn();
104 crossCursor->SetTranslationMode(1);
105 crossCursor->SetRadius(2);
107 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
108 pdm->SetInput(crossCursor->GetOutput());
110 pdmA = vtkSmartPointer<vtkActor2D>::New();
111 pdmA->SetMapper(pdm);
112 pdmA->GetProperty()->SetColor(255,10,212);
113 pdmA->SetVisibility(0);
114 pdmA->SetPickable(0);
116 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
117 ca->GetTextProperty()->SetColor(255,10,212);
118 ca->SetVisibility(1);
126 legend = vtkSmartPointer<vtkScalarBarActor>::New();
127 //legend->SetTitle("test!");
128 legend->SetPosition(0.82,0.18);
129 legend->SetWidth(0.1);
130 legend->SetVisibility(0);
131 legend->SetLabelFormat("%.1f");
132 this->GetRenderer()->AddActor(legend);
134 this->WindowLevel->Delete();
135 this->WindowLevel = vvImageMapToWLColors::New();
137 this->InstallPipeline();
139 mLinkOverlayWindowLevel = true;
141 //------------------------------------------------------------------------------
144 //------------------------------------------------------------------------------
145 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
147 return mOverlayMapper.GetPointer();
149 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
153 vvBlendImageActor* vvSlicer::GetOverlayActor()
155 return mOverlayActor.GetPointer();
157 //------------------------------------------------------------------------------
160 //------------------------------------------------------------------------------
161 vtkImageMapToColors* vvSlicer::GetFusionMapper()
163 return mFusionMapper.GetPointer();
165 //------------------------------------------------------------------------------
168 //------------------------------------------------------------------------------
169 vtkImageActor* vvSlicer::GetFusionActor()
171 return mFusionActor.GetPointer();
173 //------------------------------------------------------------------------------
176 //------------------------------------------------------------------------------
177 vtkActor* vvSlicer::GetVFActor()
179 return mVFActor.GetPointer();
181 //------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------
185 vtkCornerAnnotation* vvSlicer::GetAnnotation()
187 return ca.GetPointer();
189 //------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------
193 void vvSlicer::EnableReducedExtent(bool b)
195 mUseReducedExtent = b;
197 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 void vvSlicer::SetReducedExtent(int * ext)
203 copyExtent(ext, mReducedExtent);
205 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
212 mSurfaceCutActors.push_back(new vvMeshActor());
214 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
216 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
217 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
218 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
222 //------------------------------------------------------------------------------
225 //------------------------------------------------------------------------------
226 void vvSlicer::ToggleContourSuperposition()
228 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
229 i!=mSurfaceCutActors.end(); i++)
230 (*i)->ToggleSuperposition();
232 //------------------------------------------------------------------------------
235 //------------------------------------------------------------------------------
236 void vvSlicer::SetCursorColor(int r,int g, int b)
238 pdmA->GetProperty()->SetColor(r,g,b);
240 //------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------
244 void vvSlicer::SetCursorVisibility(bool s)
246 pdmA->SetVisibility(s);
248 //------------------------------------------------------------------------------
251 //------------------------------------------------------------------------------
252 bool vvSlicer::GetCursorVisibility()
254 return pdmA->GetVisibility();
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 void vvSlicer::SetCornerAnnotationVisibility(bool s)
262 ca->SetVisibility(s);
264 //------------------------------------------------------------------------------
267 //------------------------------------------------------------------------------
268 bool vvSlicer::GetCornerAnnotationVisibility()
270 return ca->GetVisibility();
272 //------------------------------------------------------------------------------
275 //------------------------------------------------------------------------------
276 vvSlicer::~vvSlicer()
278 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
279 i!=mSurfaceCutActors.end(); i++)
281 delete [] mReducedExtent;
283 //------------------------------------------------------------------------------
286 //------------------------------------------------------------------------------
287 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
294 //------------------------------------------------------------------------------
297 //------------------------------------------------------------------------------
298 void vvSlicer::SetImage(vvImage::Pointer image)
300 if (image->GetVTKImages().size()) {
303 if (!mImageReslice) {
304 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
305 mImageReslice->SetInterpolationModeToLinear();
306 mImageReslice->AutoCropOutputOn();
307 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
309 mImageReslice->SetResliceTransform(mImage->GetTransform());
310 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
311 mImageReslice->UpdateInformation();
313 this->Superclass::SetInput(mImageReslice->GetOutput());
316 this->GetInput()->GetWholeExtent(extent);
318 // Prevent crash when reload -> change slice if outside extent
319 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
320 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
323 // Make sure that the required part image has been computed
324 extent[SliceOrientation*2] = Slice;
325 extent[SliceOrientation*2+1] = Slice;
326 mImageReslice->GetOutput()->SetUpdateExtent(extent);
327 mImageReslice->GetOutput()->Update();
329 this->UpdateDisplayExtent();
332 ca->SetText(0,mFileName.c_str());
335 //------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------
339 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
341 if (overlay->GetVTKImages().size()) {
344 if (!mOverlayReslice) {
345 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
346 mOverlayReslice->SetInterpolationModeToLinear();
347 mOverlayReslice->AutoCropOutputOn();
348 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
350 mOverlayReslice->SetResliceTransform(mOverlay->GetTransform());
351 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
354 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
355 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
357 if (!mOverlayActor) {
358 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
359 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
360 mOverlayActor->SetPickable(0);
361 mOverlayActor->SetVisibility(true);
362 mOverlayActor->SetOpacity(0.5);
365 //stupid but necessary : the Overlay need to be rendered before fusion
367 this->GetRenderer()->RemoveActor(mFusionActor);
368 this->GetRenderer()->AddActor(mOverlayActor);
369 this->GetRenderer()->AddActor(mFusionActor);
371 this->GetRenderer()->AddActor(mOverlayActor);
373 //Synchronize orientation and slice
374 AdjustResliceToSliceOrientation(mOverlayReslice);
375 this->UpdateDisplayExtent();
376 this->SetTSlice(mCurrentTSlice);
379 //------------------------------------------------------------------------------
382 //------------------------------------------------------------------------------
383 void vvSlicer::SetFusion(vvImage::Pointer fusion)
385 if (fusion->GetVTKImages().size()) {
388 if (!mFusionReslice) {
389 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
390 mFusionReslice->SetInterpolationModeToLinear();
391 mFusionReslice->AutoCropOutputOn();
392 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
394 mFusionReslice->SetResliceTransform(mFusion->GetTransform());
395 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
398 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
400 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
402 lut->SetValueRange(0, 1);
403 lut->SetSaturationRange(0, 0);
405 mFusionMapper->SetLookupTable(lut);
406 mFusionMapper->SetInput(mFusionReslice->GetOutput());
409 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
410 mFusionActor->SetInput(mFusionMapper->GetOutput());
411 mFusionActor->SetPickable(0);
412 mFusionActor->SetVisibility(true);
413 mFusionActor->SetOpacity(0.7);
414 this->GetRenderer()->AddActor(mFusionActor);
417 //Synchronize orientation and slice
418 AdjustResliceToSliceOrientation(mFusionReslice);
419 this->UpdateDisplayExtent();
420 this->SetTSlice(mCurrentTSlice);
423 //------------------------------------------------------------------------------
426 //------------------------------------------------------------------------------
427 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
430 if (actor_type == "image") {
431 vis = this->ImageActor->GetVisibility();
433 else if (actor_type == "vector") {
434 vis = this->mVFActor->GetVisibility();
436 else if (actor_type == "overlay") {
437 vis = this->mOverlayActor->GetVisibility();
439 else if (actor_type == "fusion") {
440 vis = this->mFusionActor->GetVisibility();
442 else if (actor_type == "contour")
443 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
447 //------------------------------------------------------------------------------
449 //------------------------------------------------------------------------------
450 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
452 if (actor_type == "image") {
453 this->ImageActor->SetVisibility(vis);
455 else if (actor_type == "vector") {
456 this->mVFActor->SetVisibility(vis);
458 else if (actor_type == "overlay") {
459 this->mOverlayActor->SetVisibility(vis);
461 else if (actor_type == "fusion") {
462 this->mFusionActor->SetVisibility(vis);
464 else if (actor_type == "contour")
465 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
466 UpdateDisplayExtent();
468 //------------------------------------------------------------------------------
470 //------------------------------------------------------------------------------
471 void vvSlicer::SetVF(vvImage::Pointer vf)
473 if (vf->GetVTKImages().size()) {
477 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
478 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
479 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
481 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
482 mAAFilter->SetInput(mVOIFilter->GetOutput());
483 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
484 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
487 mArrow = vtkSmartPointer<vvGlyphSource>::New();
488 mArrow->SetGlyphTypeToSpecificArrow();
489 mArrow->SetScale(mScale);
492 // Glyph the gradient vector (with arrows)
494 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
495 mGlyphFilter->SetInput(mAAFilter->GetOutput());
496 mGlyphFilter->SetSource(mArrow->GetOutput());
497 mGlyphFilter->ScalingOn();
498 mGlyphFilter->SetScaleModeToScaleByVector();
499 mGlyphFilter->OrientOn();
500 mGlyphFilter->SetVectorModeToUseVector();
501 mGlyphFilter->SetColorModeToColorByVector();
504 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
506 double mVFColorHSV[3];
507 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
508 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
509 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
510 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
513 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
514 mVFMapper->SetInput(mGlyphFilter->GetOutput());
515 mVFMapper->ImmediateModeRenderingOn();
516 mVFMapper->SetLookupTable(mVFColorLUT);
519 mVFActor = vtkSmartPointer<vtkActor>::New();
520 mVFActor->SetMapper(mVFMapper);
521 mVFActor->SetPickable(0);
522 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
523 this->UpdateDisplayExtent();
524 this->GetRenderer()->AddActor(mVFActor);
527 SetTSlice(mCurrentTSlice);
530 //------------------------------------------------------------------------------
533 //------------------------------------------------------------------------------
534 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
536 mLandmarks = landmarks;
540 mCross = vtkSmartPointer<vtkCursor3D>::New();
541 mCross->SetFocalPoint(0.0,0.0,0.0);
542 mCross->SetModelBounds(-10,10,-10,10,-10,10);
547 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
548 mLandGlyph->SetSource(mCross->GetOutput());
549 mLandGlyph->SetInput(landmarks->GetOutput());
550 //mLandGlyph->SetIndexModeToScalar();
551 mLandGlyph->SetRange(0,1);
552 mLandGlyph->ScalingOff();
554 mLandGlyph->SetColorModeToColorByScalar();
557 mClipBox = vtkSmartPointer<vtkBox>::New();
559 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
560 mLandClipper->InsideOutOn();
561 mLandClipper->SetInput(mLandGlyph->GetOutput());
562 mLandClipper->SetClipFunction(mClipBox);
565 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
566 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
567 //mLandMapper->ScalarVisibilityOff();
570 mLandActor = vtkSmartPointer<vtkActor>::New();
571 mLandActor->SetMapper(mLandMapper);
572 mLandActor->GetProperty()->SetColor(255,10,212);
573 mLandActor->SetPickable(0);
574 mLandActor->SetVisibility(true);
575 this->UpdateDisplayExtent();
576 this->GetRenderer()->AddActor(mLandActor);
579 //------------------------------------------------------------------------------
581 //------------------------------------------------------------------------------
582 //FIXME: this function leaks memory, we should fix it someday :)
583 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
585 if (actor_type == "vector") {
586 Renderer->RemoveActor(mVFActor);
595 if (actor_type == "overlay") {
596 Renderer->RemoveActor(mOverlayActor);
598 mOverlayActor = NULL;
599 mOverlayMapper = NULL;
601 if (actor_type == "fusion") {
602 Renderer->RemoveActor(mFusionActor);
605 mFusionMapper = NULL;
607 if (actor_type == "contour") {
608 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
609 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
612 //------------------------------------------------------------------------------
615 //------------------------------------------------------------------------------
616 void vvSlicer::SetVFSubSampling(int sub)
619 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
622 UpdateDisplayExtent();
625 //------------------------------------------------------------------------------
628 //------------------------------------------------------------------------------
629 void vvSlicer::SetVFScale(int scale)
633 mArrow->SetScale(mScale);
634 UpdateDisplayExtent();
637 //------------------------------------------------------------------------------
639 //------------------------------------------------------------------------------
640 void vvSlicer::SetVFWidth(int width)
644 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
645 UpdateDisplayExtent();
648 //------------------------------------------------------------------------------
651 //------------------------------------------------------------------------------
652 void vvSlicer::SetVFLog(int log)
656 mGlyphFilter->SetUseLog(mVFLog);
657 mGlyphFilter->Modified();
659 UpdateDisplayExtent();
662 //------------------------------------------------------------------------------
665 //------------------------------------------------------------------------------
666 void vvSlicer::SetTSlice(int t)
670 else if ((unsigned int)t >= mImage->GetVTKImages().size())
671 t = mImage->GetVTKImages().size() -1;
673 if (mCurrentTSlice == t) return;
676 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
677 if (mVF && mVFActor->GetVisibility()) {
678 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
679 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
681 if (mOverlay && mOverlayActor->GetVisibility()) {
682 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
683 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
685 if (mFusion && mFusionActor->GetVisibility()) {
686 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
687 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
689 if (mSurfaceCutActors.size() > 0)
690 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
691 i!=mSurfaceCutActors.end(); i++)
692 (*i)->SetTimeSlice(mCurrentTSlice);
693 UpdateDisplayExtent();
695 //------------------------------------------------------------------------------
698 //------------------------------------------------------------------------------
699 int vvSlicer::GetTSlice()
701 return mCurrentTSlice;
703 //------------------------------------------------------------------------------
705 //------------------------------------------------------------------------------
706 void vvSlicer::SetSliceOrientation(int orientation)
708 //if 2D image, force to watch in Axial View
710 this->GetInput()->GetWholeExtent(extent);
711 if (extent[5]-extent[4] <= 2)
712 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
714 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
715 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
716 vtkErrorMacro("Error - invalid slice orientation " << orientation);
720 this->SliceOrientation = orientation;
723 AdjustResliceToSliceOrientation(mFusionReslice);
726 AdjustResliceToSliceOrientation(mOverlayReslice);
729 int *range = this->GetSliceRange();
731 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
733 // Go to current cursor position
734 // double* cursorPos = GetCursorPosition();
735 // DDV(cursorPos, 3);
736 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
738 this->UpdateOrientation();
739 this->UpdateDisplayExtent();
741 if (this->Renderer && this->GetInput()) {
742 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
743 this->Renderer->ResetCamera();
744 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
749 //----------------------------------------------------------------------------
751 //------------------------------------------------------------------------------
752 // This function ensures that we sample the slices of a vtkImageReslice filter
753 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
754 // In other words, we change the grid of the reslice in the same way as the grid
755 // of the displayed image in the slicing direction.
756 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
758 // Reset autocrop and update output information
759 reslice->SetOutputOriginToDefault();
760 reslice->SetOutputSpacingToDefault();
761 reslice->GetOutput()->UpdateInformation();
763 // Ge new origin / spacing
766 reslice->GetOutput()->GetOrigin(origin);
767 reslice->GetOutput()->GetSpacing(spacing);
769 // Use similar spacing as the image in the direction SliceOrientation
770 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
772 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
773 // Step 1: from world coordinates to image coordinates
774 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
775 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
776 // Step 2: round to superior grid positionInc
777 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
778 // Step 3: back to world coordinates
779 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
780 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
782 // Set new spacing and origin
783 reslice->SetOutputOrigin(origin);
784 reslice->SetOutputSpacing(spacing);
785 reslice->UpdateInformation();
786 reslice->GetOutput()->UpdateInformation();
788 //------------------------------------------------------------------------------
790 //----------------------------------------------------------------------------
791 int * vvSlicer::GetExtent(){
793 if (mUseReducedExtent) {
794 w_ext = mReducedExtent;
795 } else w_ext = GetInput()->GetWholeExtent();
798 //----------------------------------------------------------------------------
801 //----------------------------------------------------------------------------
802 int vvSlicer::GetOrientation()
804 return this->SliceOrientation;
806 //----------------------------------------------------------------------------
809 //----------------------------------------------------------------------------
810 void vvSlicer::UpdateDisplayExtent()
812 vtkImageData *input = this->GetInput();
813 if (!input || !this->ImageActor) {
816 input->UpdateInformation();
818 // Local copy of extent
820 int* ext = GetExtent();
821 copyExtent(ext, w_ext);
823 int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice;
824 w_ext[ this->SliceOrientation*2 ] = s;
825 w_ext[ this->SliceOrientation*2+1 ] = s;
828 this->ImageActor->SetDisplayExtent(w_ext);
830 // Overlay image actor
831 if (mOverlay && mOverlayActor->GetVisibility()) {
832 AdjustResliceToSliceOrientation(mOverlayReslice);
834 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
835 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
836 mOverlayActor->SetDisplayExtent( overExtent );
839 // Fusion image actor
840 if (mFusion && mFusionActor->GetVisibility()) {
841 AdjustResliceToSliceOrientation(mFusionReslice);
843 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
844 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
845 mFusionActor->SetDisplayExtent(fusExtent);
848 // Vector field actor
849 double* camera = Renderer->GetActiveCamera()->GetPosition();
850 double* image_bounds = ImageActor->GetBounds();
851 double position[3] = {0, 0, 0};
852 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
854 //print_vector<double, 6>("camera", camera);
855 //print_vector<double, 6>("image_bounds", image_bounds);
856 //print_vector<double, 3>("position", position);
858 // find where to place the VF actor. to deal with
859 // z-buffer issues, the VF is placed right in front of the image,
860 // subject to a small offset. the position actually depends on the
861 // the location of the camera relative to the image.
863 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
866 if (mVF && mVFActor->GetVisibility()) {
868 mVF->GetVTKImages()[0]->UpdateInformation();
869 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
870 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
871 mVOIFilter->SetVOI(vfExtent);
872 int orientation[3] = {1,1,1};
873 orientation[this->SliceOrientation] = 0;
874 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
877 position[this->SliceOrientation] += offset;
878 mVFActor->SetPosition(position);
885 for(unsigned int i=0; i<6; i++)
886 bounds[i] = ImageActor->GetBounds()[i];
887 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
888 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
889 mClipBox->SetBounds(bounds);
893 position[this->SliceOrientation] = offset;
894 mLandActor->SetPosition(position);
897 // Figure out the correct clipping range
898 if (this->Renderer) {
899 if (this->InteractorStyle &&
900 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
901 this->Renderer->ResetCameraClippingRange();
903 vtkCamera *cam = this->Renderer->GetActiveCamera();
906 this->ImageActor->GetBounds(bounds);
907 double spos = (double)bounds[this->SliceOrientation * 2];
908 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
909 double range = fabs(spos - cpos);
910 double *spacing = input->GetSpacing();
912 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
913 cam->SetClippingRange(range - avg_spacing * 3.0, range + avg_spacing * 3.0);
919 //----------------------------------------------------------------------------
921 //----------------------------------------------------------------------------
922 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
923 vtkImageData *targetImage, int targetExtent[6])
926 for(unsigned int i=0; i<6; i++) {
927 // From source voxel coordinates to world coordinates
928 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
930 // From world coordinates to floating point target voxel coordinates
931 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
934 //targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
935 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
938 //----------------------------------------------------------------------------
940 //----------------------------------------------------------------------------
941 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
946 //2D overlay on 3D image specific case
947 if (refExtent[4] == refExtent[5]) {
949 extent[4] = refExtent[4];
950 extent[5] = refExtent[5];
953 for (int i = 0; i < maxBound; i = i+2) {
954 //if we are totally outside the image
955 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
959 //crop to the limit of the image
960 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
961 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
962 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
963 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
966 for (int i = 0; i < maxBound; i = i+2) {
967 extent[i] = refExtent[i];
968 extent[i+1] = refExtent[i];
971 //----------------------------------------------------------------------------
974 //----------------------------------------------------------------------------
975 void vvSlicer::UpdateOrientation()
977 // Set the camera position
978 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
980 switch (this->SliceOrientation) {
981 case vtkImageViewer2::SLICE_ORIENTATION_XY:
982 cam->SetFocalPoint(0,0,0);
983 cam->SetPosition(0,0,-1); // -1 if medical ?
984 cam->SetViewUp(0,-1,0);
987 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
988 cam->SetFocalPoint(0,0,0);
989 cam->SetPosition(0,-1,0); // 1 if medical ?
990 cam->SetViewUp(0,0,1);
993 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
994 cam->SetFocalPoint(0,0,0);
995 cam->SetPosition(-1,0,0); // -1 if medical ?
996 cam->SetViewUp(0,0,1);
1001 //----------------------------------------------------------------------------
1004 //----------------------------------------------------------------------------
1005 void vvSlicer::SetOpacity(double s)
1007 this->GetImageActor()->SetOpacity(s);
1009 //----------------------------------------------------------------------------
1012 //----------------------------------------------------------------------------
1013 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1015 this->Superclass::SetRenderWindow(rw);
1016 this->SetupInteractor(rw->GetInteractor());
1017 ca->SetImageActor(this->GetImageActor());
1018 ca->SetWindowLevel(this->GetWindowLevel());
1019 ca->SetText(2, "<slice>");
1020 ca->SetText(3, "<window>\n<level>");
1032 crossCursor->SetModelBounds(bounds);
1033 this->GetRenderer()->AddActor(pdmA);
1034 this->GetRenderer()->AddActor(ca);
1035 this->GetRenderer()->ResetCamera();
1037 //this is just a mapping between the labeling of the orientations presented to the user and
1038 //the one used by vtk
1039 SetSliceOrientation(2-(orientation%3));
1042 //----------------------------------------------------------------------------
1045 //----------------------------------------------------------------------------
1046 void vvSlicer::ResetCamera()
1048 this->GetRenderer()->ResetCamera();
1050 //----------------------------------------------------------------------------
1053 //----------------------------------------------------------------------------
1054 void vvSlicer::SetDisplayMode(bool i)
1056 this->GetRenderer()->SetDraw(i);
1058 UpdateDisplayExtent();
1060 //----------------------------------------------------------------------------
1063 //----------------------------------------------------------------------------
1064 void vvSlicer::FlipHorizontalView()
1066 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1068 double *position = cam->GetPosition();
1069 double factor[3] = {1, 1, 1};
1070 factor[this->SliceOrientation] = -1;
1071 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1073 /* switch (this->SliceOrientation) {
1074 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1075 cam->SetPosition(position[0],position[1],-position[2]);
1078 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1079 cam->SetPosition(position[0],-position[1],position[2]);
1082 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1083 cam->SetPosition(-position[0],position[1],position[2]);
1087 this->Renderer->ResetCameraClippingRange();
1088 this->UpdateDisplayExtent();
1091 //----------------------------------------------------------------------------
1094 //----------------------------------------------------------------------------
1095 void vvSlicer::FlipVerticalView()
1097 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1099 FlipHorizontalView();
1100 double *viewup = cam->GetViewUp();
1101 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1102 this->UpdateDisplayExtent();
1105 //----------------------------------------------------------------------------
1108 //----------------------------------------------------------------------------
1109 void vvSlicer::SetColorWindow(double window)
1111 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1113 double level = this->GetWindowLevel()->GetLevel();
1114 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1117 this->vtkImageViewer2::SetColorWindow(window);
1119 //----------------------------------------------------------------------------
1121 //----------------------------------------------------------------------------
1122 void vvSlicer::SetColorLevel(double level)
1124 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1126 double window = this->GetWindowLevel()->GetWindow();
1127 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1130 this->vtkImageViewer2::SetColorLevel(level);
1132 //----------------------------------------------------------------------------
1134 //----------------------------------------------------------------------------
1135 double vvSlicer::GetOverlayColorWindow()
1138 return mOverlayMapper->GetWindow();
1142 //----------------------------------------------------------------------------
1144 //----------------------------------------------------------------------------
1145 double vvSlicer::GetOverlayColorLevel()
1148 return mOverlayMapper->GetLevel();
1152 //----------------------------------------------------------------------------
1154 //----------------------------------------------------------------------------
1155 void vvSlicer::SetOverlayColorWindow(double window)
1157 mOverlayMapper->SetWindow(window);
1159 //----------------------------------------------------------------------------
1161 //----------------------------------------------------------------------------
1162 void vvSlicer::SetOverlayColorLevel(double level)
1164 mOverlayMapper->SetLevel(level);
1166 //----------------------------------------------------------------------------
1168 //----------------------------------------------------------------------------
1169 // Returns the min an the max value in a 41x41 region around the mouse pointer
1170 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image)
1172 //Get mouse pointer position in view coordinates
1173 double fLocalExtents[6];
1174 for(int i=0; i<3; i++) {
1175 fLocalExtents[i*2 ] = mCurrent[i];
1176 fLocalExtents[i*2+1] = mCurrent[i];
1178 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1179 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1180 for(int i=0; i<3; i++) {
1181 if (i!=SliceOrientation) { //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1182 fLocalExtents[i*2 ] -= 0.2;
1183 fLocalExtents[i*2+1] += 0.2;
1186 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1187 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1189 //Convert to image pixel coordinates (rounded)
1190 int iLocalExtents[6];
1191 for(int i=0; i<3; i++) {
1192 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - image->GetOrigin()[i])/image->GetSpacing()[i];
1193 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - image->GetOrigin()[i])/image->GetSpacing()[i];
1195 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1196 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1198 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1199 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1202 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1203 voiFilter->SetInput(image);
1204 voiFilter->SetVOI(iLocalExtents);
1205 voiFilter->Update();
1206 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1212 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1213 accFilter->SetInput(voiFilter->GetOutput());
1214 accFilter->Update();
1216 min = *(accFilter->GetMin());
1217 max = *(accFilter->GetMax());
1219 //----------------------------------------------------------------------------
1221 //----------------------------------------------------------------------------
1222 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1227 if (ix < image->GetWholeExtent()[0] ||
1228 ix > image->GetWholeExtent()[1] ||
1229 iy < image->GetWholeExtent()[2] ||
1230 iy > image->GetWholeExtent()[3] ||
1231 iz < image->GetWholeExtent()[4] ||
1232 iz > image->GetWholeExtent()[5] )
1233 return std::numeric_limits<double>::quiet_NaN();
1235 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1237 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1239 //----------------------------------------------------------------------------
1241 //----------------------------------------------------------------------------
1242 void vvSlicer::Render()
1244 if (this->mFusion) {
1245 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1246 legend->UseOpacityOn();
1247 legend->SetVisibility(1);
1249 else if (this->GetWindowLevel()->GetLookupTable()) {// && !this->mOverlay && !this->mFusion) {
1250 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1251 legend->UseOpacityOff();
1252 legend->SetVisibility(1);
1253 } else legend->SetVisibility(0);
1255 if (ca->GetVisibility()) {
1256 std::stringstream worldPos;
1257 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1258 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1259 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1261 // if (X < this->GetInput()->GetWholeExtent()[0]) X = this->GetInput()->GetWholeExtent()[0];
1262 // else if (X > this->GetInput()->GetWholeExtent()[1]) X = this->GetInput()->GetWholeExtent()[1];
1263 // if (Y < this->GetInput()->GetWholeExtent()[2]) Y = this->GetInput()->GetWholeExtent()[2];
1264 // else if (Y > this->GetInput()->GetWholeExtent()[3]) Y = this->GetInput()->GetWholeExtent()[3];
1265 // if (Z < this->GetInput()->GetWholeExtent()[4]) Z = this->GetInput()->GetWholeExtent()[4];
1266 // else if (Z > this->GetInput()->GetWholeExtent()[5]) Z = this->GetInput()->GetWholeExtent()[5];
1268 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1269 X <= this->GetInput()->GetWholeExtent()[1] &&
1270 Y >= this->GetInput()->GetWholeExtent()[2] &&
1271 Y <= this->GetInput()->GetWholeExtent()[3] &&
1272 Z >= this->GetInput()->GetWholeExtent()[4] &&
1273 Z <= this->GetInput()->GetWholeExtent()[5]) {
1277 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1279 if(ImageActor->GetVisibility())
1280 worldPos << "data value : " << value << std::endl;
1282 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1283 << lrint(mCurrent[1]) << ' '
1284 << lrint(mCurrent[2]) << ' '
1287 worldPos << "pixel : " << ix << ' '
1293 ca->SetText(1,worldPos.str().c_str());
1296 if (pdmA->GetVisibility()) {
1297 double x = mCursor[0];
1298 double y = mCursor[1];
1299 double z = mCursor[2];
1300 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1301 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1302 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1304 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1305 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1306 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1307 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1308 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1309 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1310 vtkRenderer * renderer = this->Renderer;
1312 renderer->WorldToView(x,y,z);
1313 renderer->ViewToNormalizedViewport(x,y,z);
1314 renderer->NormalizedViewportToViewport(x,y);
1315 renderer->ViewportToNormalizedDisplay(x,y);
1316 renderer->NormalizedDisplayToDisplay(x,y);
1317 crossCursor->SetFocalPoint(x,y,z);
1319 crossCursor->SetFocalPoint(-1,-1,z);
1323 if (mOverlay && mOverlayActor->GetVisibility()) {
1324 if(mLinkOverlayWindowLevel) {
1325 mOverlayMapper->SetWindow(this->GetColorWindow());
1326 mOverlayMapper->SetLevel(this->GetColorLevel());
1328 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1329 mOverlayMapper->GetOutput()->Update();
1330 mOverlayMapper->Update();
1335 this->GetRenderWindow()->Render();
1337 //----------------------------------------------------------------------------
1340 //----------------------------------------------------------------------------
1341 void vvSlicer::UpdateCursorPosition()
1343 pdmA->SetVisibility(true);
1344 mCursor[0] = mCurrent[0];
1345 mCursor[1] = mCurrent[1];
1346 mCursor[2] = mCurrent[2];
1347 mCursor[3] = mCurrentTSlice;
1349 //----------------------------------------------------------------------------
1352 //----------------------------------------------------------------------------
1353 void vvSlicer::UpdateLandmarks()
1355 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1356 if (pd->GetPoints()) {
1357 mLandGlyph->SetRange(0,1);
1358 mLandGlyph->Modified();
1359 mLandGlyph->Update();
1361 mClipBox->Modified();
1362 mLandClipper->Update();
1363 mLandMapper->Update();
1367 //----------------------------------------------------------------------------
1370 //----------------------------------------------------------------------------
1371 void vvSlicer::SetSlice(int slice)
1373 int *range = this->GetSliceRange();
1375 if (slice < range[0]) {
1377 } else if (slice > range[1]) {
1382 if (this->Slice == slice) {
1386 this->Slice = slice;
1389 this->UpdateDisplayExtent();
1391 // Seems to work without this line
1394 //----------------------------------------------------------------------------
1397 //----------------------------------------------------------------------------
1398 void vvSlicer::SetContourSlice()
1400 if (mSurfaceCutActors.size() > 0)
1401 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1402 i!=mSurfaceCutActors.end(); i++) {
1404 (*i)->SetSlicingOrientation(this->SliceOrientation);
1405 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1406 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1409 //----------------------------------------------------------------------------
1412 //----------------------------------------------------------------------------
1413 void vvSlicer::ForceUpdateDisplayExtent()
1415 this->UpdateDisplayExtent();
1417 //----------------------------------------------------------------------------
1420 //----------------------------------------------------------------------------
1421 int* vvSlicer::GetDisplayExtent()
1423 return this->GetImageActor()->GetDisplayExtent();
1425 //----------------------------------------------------------------------------
1428 //----------------------------------------------------------------------------
1429 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1431 this->Superclass::PrintSelf(os, indent);
1433 //----------------------------------------------------------------------------
1435 //----------------------------------------------------------------------------
1436 void vvSlicer::SetVFColor(double r, double g, double b)
1438 double mVFColorHSV[3];
1443 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1444 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1445 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1446 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);