1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #include <QMessageBox>
24 #include "vvSlicerManagerCommand.h"
25 #include "vvGlyphSource.h"
26 #include "vvGlyph2D.h"
28 #include <vtkVersion.h>
29 #include <vtkExtentTranslator.h>
30 #include <vtkAlgorithm.h>
31 #include <vtkExecutive.h>
32 #include <vtkStreamingDemandDrivenPipeline.h>
33 #include <vtkInformation.h>
34 #include <vtkTextProperty.h>
35 #include <vtkTextActor.h>
36 #include <vtkTextSource.h>
37 #include <vtkActor2D.h>
38 #include <vtkCursor2D.h>
39 #include <vtkPolyDataMapper2D.h>
40 #include <vtkProperty2D.h>
41 #include <vtkCornerAnnotation.h>
42 #include <vtkImageMapToWindowLevelColors.h>
43 #include <vtkImageData.h>
44 #include <vtkImageActor.h>
45 #include <vvBlendImageActor.h>
46 #include <vtkToolkits.h>
47 #include <vtkObjectFactory.h>
48 #include <vtkPointData.h>
49 #include <vtkDataArray.h>
50 #include <vtkFloatArray.h>
51 #include <vtkClipPolyData.h>
52 #include <vtkActor2DCollection.h>
53 #include <vtkGlyph3D.h>
55 #include <vtkCursor3D.h>
56 #include <vtkProperty.h>
58 #include <vtkLightCollection.h>
59 #include <vtkScalarBarActor.h>
60 #include <vtkLookupTable.h>
62 #include <vtkRenderer.h>
63 #include <vtkRendererCollection.h>
64 #include <vtkRenderWindow.h>
65 #include <vtkRenderWindowInteractor.h>
66 #include <vtkCamera.h>
67 #include <vtkCallbackCommand.h>
68 #include <vtkCommand.h>
69 #include <vtkPolyDataMapper.h>
72 #include <vtkExtractVOI.h>
73 #include <vtkSphereSource.h>
74 #include <vtkCutter.h>
75 #include <vtkAssignAttribute.h>
76 #include <vtkImageAccumulate.h>
77 #include <vtkImageReslice.h>
78 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
79 # include <vtkOpenGLImageSliceMapper.h>
80 # include <vtkImageMapper3D.h>
81 # include <vtkImageSliceMapper.h>
84 vtkStandardNewMacro(vvSlicer);
85 static void copyExtent(int* in, int* to){
86 for(int i=0; i<6; ++i)
91 //------------------------------------------------------------------------------
94 mFusionSequenceCode = -1;
95 this->UnInstallPipeline();
97 mReducedExtent = new int[6];
98 mRegisterExtent = NULL;
100 mCurrentFusionTSlice = 0;
101 mCurrentOverlayTSlice = 0;
102 mUseReducedExtent = false;
104 mCurrent[0] = -VTK_DOUBLE_MAX;
105 mCurrent[1] = -VTK_DOUBLE_MAX;
106 mCurrent[2] = -VTK_DOUBLE_MAX;
108 mCursor[0] = 0;//-VTK_DOUBLE_MAX;
109 mCursor[1] = 0;//-VTK_DOUBLE_MAX;
110 mCursor[2] = 0;//-VTK_DOUBLE_MAX;
111 mCursor[3] = 0;//-VTK_DOUBLE_MAX;
121 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
122 crossCursor->AllOff();
123 crossCursor->AxesOn();
124 crossCursor->SetTranslationMode(1);
125 crossCursor->SetRadius(2);
127 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
128 #if VTK_MAJOR_VERSION <= 5
129 pdm->SetInput(crossCursor->GetOutput());
131 pdm->SetInputConnection(crossCursor->GetOutputPort(0));
134 pdmA = vtkSmartPointer<vtkActor2D>::New();
135 pdmA->SetMapper(pdm);
136 pdmA->GetProperty()->SetColor(255,10,212);
137 pdmA->SetVisibility(0);
138 pdmA->SetPickable(0);
140 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
141 ca->GetTextProperty()->SetColor(255,10,212);
142 ca->SetVisibility(1);
150 legend = vtkSmartPointer<vtkScalarBarActor>::New();
151 //legend->SetTitle("test!");
152 legend->SetPosition(0.82,0.18);
153 legend->SetWidth(0.1);
154 legend->SetVisibility(0);
155 legend->SetLabelFormat("%.1f");
156 this->GetRenderer()->AddActor(legend);
157 showFusionLegend = false;
159 this->InstallPipeline();
161 mLinkOverlayWindowLevel = true;
162 mImageVisibility = true;
164 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
165 this->GetImageActor()->GetMapper()->BorderOn();
168 mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
169 mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
170 mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
171 mConcatenatedOverlayTransform = vtkSmartPointer<vtkTransform>::New();
172 mFirstSetSliceOrientation = true;
174 //------------------------------------------------------------------------------
177 //------------------------------------------------------------------------------
178 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
180 return mOverlayMapper.GetPointer();
182 //------------------------------------------------------------------------------
185 //------------------------------------------------------------------------------
186 vvBlendImageActor* vvSlicer::GetOverlayActor()
188 return mOverlayActor.GetPointer();
190 //------------------------------------------------------------------------------
193 //------------------------------------------------------------------------------
194 vtkImageMapToColors* vvSlicer::GetFusionMapper()
196 return mFusionMapper.GetPointer();
198 //------------------------------------------------------------------------------
201 //------------------------------------------------------------------------------
202 vtkImageActor* vvSlicer::GetFusionActor()
204 return mFusionActor.GetPointer();
206 //------------------------------------------------------------------------------
209 //------------------------------------------------------------------------------
210 vtkActor* vvSlicer::GetVFActor()
212 return mVFActor.GetPointer();
214 //------------------------------------------------------------------------------
217 //------------------------------------------------------------------------------
218 vtkCornerAnnotation* vvSlicer::GetAnnotation()
220 return ca.GetPointer();
222 //------------------------------------------------------------------------------
225 //------------------------------------------------------------------------------
226 void vvSlicer::EnableReducedExtent(bool b)
228 mUseReducedExtent = b;
230 //------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------
234 void vvSlicer::SetReducedExtent(int * ext)
236 copyExtent(ext, mReducedExtent);
238 //------------------------------------------------------------------------------
241 //------------------------------------------------------------------------------
242 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
245 mSurfaceCutActors.push_back(new vvMeshActor());
247 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
249 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
250 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
251 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
255 //------------------------------------------------------------------------------
258 //------------------------------------------------------------------------------
259 void vvSlicer::ToggleContourSuperposition()
261 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
262 i!=mSurfaceCutActors.end(); i++)
263 (*i)->ToggleSuperposition();
265 //------------------------------------------------------------------------------
268 //------------------------------------------------------------------------------
269 void vvSlicer::SetCursorColor(int r,int g, int b)
271 pdmA->GetProperty()->SetColor(r,g,b);
273 //------------------------------------------------------------------------------
276 //------------------------------------------------------------------------------
277 void vvSlicer::SetCursorVisibility(bool s)
279 pdmA->SetVisibility(s);
281 //------------------------------------------------------------------------------
284 //------------------------------------------------------------------------------
285 bool vvSlicer::GetCursorVisibility()
287 return pdmA->GetVisibility();
289 //------------------------------------------------------------------------------
292 //------------------------------------------------------------------------------
293 void vvSlicer::SetCornerAnnotationVisibility(bool s)
295 ca->SetVisibility(s);
297 //------------------------------------------------------------------------------
300 //------------------------------------------------------------------------------
301 bool vvSlicer::GetCornerAnnotationVisibility()
303 return ca->GetVisibility();
305 //------------------------------------------------------------------------------
308 //------------------------------------------------------------------------------
309 vvSlicer::~vvSlicer()
311 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
312 i!=mSurfaceCutActors.end(); i++)
314 delete [] mReducedExtent;
316 //------------------------------------------------------------------------------
318 //------------------------------------------------------------------------------
319 double* vvSlicer::GetCurrentPosition()
321 return mCurrentBeforeSlicingTransform;
323 //------------------------------------------------------------------------------
325 //------------------------------------------------------------------------------
326 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
328 mCurrentBeforeSlicingTransform[0]=x;
329 mCurrentBeforeSlicingTransform[1]=y;
330 mCurrentBeforeSlicingTransform[2]=z;
331 mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
332 if (t>=0) SetTSlice(t);
334 //------------------------------------------------------------------------------
337 //------------------------------------------------------------------------------
338 void vvSlicer::SetImage(vvImage::Pointer image)
340 if (image->GetVTKImages().size()) {
343 if (!mImageReslice) {
344 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
345 mImageReslice->SetInterpolationModeToLinear();
346 mImageReslice->AutoCropOutputOn();
347 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
350 mConcatenatedTransform->Identity();
351 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
352 mConcatenatedTransform->Concatenate(mSlicingTransform);
353 mImageReslice->SetResliceTransform(mConcatenatedTransform);
354 #if VTK_MAJOR_VERSION <= 5
355 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
357 mImageReslice->SetInputData(0, mImage->GetFirstVTKImageData());
359 mImageReslice->UpdateInformation();
361 #if VTK_MAJOR_VERSION <= 5
362 this->Superclass::SetInput(mImageReslice->GetOutput());
364 this->Superclass::SetInputConnection(mImageReslice->GetOutputPort());
368 #if VTK_MAJOR_VERSION <= 5
369 this->GetInput()->GetWholeExtent(extent);
371 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
372 copyExtent(ext, extent);
375 // Prevent crash when reload -> change slice if outside extent
376 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
377 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
380 // Make sure that the required part image has been computed
381 extent[SliceOrientation*2] = Slice;
382 extent[SliceOrientation*2+1] = Slice;
383 #if VTK_MAJOR_VERSION <= 5
384 mImageReslice->GetOutput()->SetUpdateExtent(extent);
385 mImageReslice->GetOutput()->Update();
387 //mImageReslice->SetUpdateExtent(extent);
388 mImageReslice->Update();
391 this->UpdateDisplayExtent();
394 ca->SetText(0,mFileName.c_str());
397 //------------------------------------------------------------------------------
400 //------------------------------------------------------------------------------
401 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
403 if (overlay->GetVTKImages().size()) {
405 mOverlayVisibility = true;
407 if (!mOverlayReslice) {
408 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
409 mOverlayReslice->SetInterpolationModeToLinear();
410 mOverlayReslice->AutoCropOutputOn();
411 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
414 mConcatenatedOverlayTransform->Identity();
415 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]);
416 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
417 mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform);
418 #if VTK_MAJOR_VERSION <= 5
419 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
420 mImageReslice->UpdateInformation();
422 mOverlayReslice->SetInputData(0, mOverlay->GetFirstVTKImageData());
424 mOverlayReslice->Update();
427 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
428 #if VTK_MAJOR_VERSION <= 5
429 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
431 mOverlayMapper->SetInputConnection(mOverlayReslice->GetOutputPort(0));
434 if (!mOverlayActor) {
435 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
436 #if VTK_MAJOR_VERSION <= 5
437 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
439 mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort());
441 mOverlayActor->SetPickable(0);
442 mOverlayActor->SetVisibility(true);
443 mOverlayActor->SetOpacity(0.5);
444 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
445 mOverlayActor->GetMapper()->BorderOn();
449 //stupid but necessary : the Overlay need to be rendered before fusion
451 this->GetRenderer()->RemoveActor(mFusionActor);
452 this->GetRenderer()->AddActor(mOverlayActor);
453 this->GetRenderer()->AddActor(mFusionActor);
455 this->GetRenderer()->AddActor(mOverlayActor);
457 //Synchronize orientation and slice
458 AdjustResliceToSliceOrientation(mOverlayReslice);
459 this->UpdateDisplayExtent();
460 this->SetTSlice(mCurrentTSlice);
463 //------------------------------------------------------------------------------
466 //------------------------------------------------------------------------------
467 void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
469 mFusionSequenceCode = fusionSequenceCode;
470 if (fusion->GetVTKImages().size()) {
472 mFusionVisibility = true;
474 if (!mFusionReslice) {
475 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
476 mFusionReslice->SetInterpolationModeToLinear();
477 mFusionReslice->AutoCropOutputOn();
478 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
481 mConcatenatedFusionTransform->Identity();
482 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]);
483 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
484 mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform);
485 #if VTK_MAJOR_VERSION <= 5
486 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
487 mFusionReslice->UpdateInformation();
489 mFusionReslice->SetInputData(0, mFusion->GetFirstVTKImageData());
491 mFusionReslice->Update();
494 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
496 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
498 lut->SetValueRange(0, 1);
499 lut->SetSaturationRange(0, 0);
501 mFusionMapper->SetLookupTable(lut);
502 #if VTK_MAJOR_VERSION <= 5
503 mFusionMapper->SetInput(mFusionReslice->GetOutput());
505 mFusionMapper->SetInputConnection(mFusionReslice->GetOutputPort(0));
509 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
510 #if VTK_MAJOR_VERSION <= 5
511 mFusionActor->SetInput(mFusionMapper->GetOutput());
513 mFusionActor->GetMapper()->SetInputConnection(mFusionMapper->GetOutputPort());
515 mFusionActor->SetPickable(0);
516 mFusionActor->SetVisibility(true);
517 mFusionActor->SetOpacity(0.7);
518 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
519 mFusionActor->GetMapper()->BorderOn();
522 this->GetRenderer()->AddActor(mFusionActor);
525 //Synchronize orientation and slice
526 AdjustResliceToSliceOrientation(mFusionReslice);
527 this->UpdateDisplayExtent();
528 this->SetTSlice(mCurrentTSlice);
531 //------------------------------------------------------------------------------
534 //------------------------------------------------------------------------------
535 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
538 if (actor_type == "image")
539 vis = mImageVisibility;
540 else if (actor_type == "vector")
542 else if (actor_type == "overlay")
543 vis = mOverlayVisibility;
544 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
545 vis = mFusionVisibility;
546 else if (actor_type == "contour")
547 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
550 //------------------------------------------------------------------------------
552 //------------------------------------------------------------------------------
553 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
555 if (actor_type == "image")
556 mImageVisibility = vis;
557 else if (actor_type == "vector")
559 else if (actor_type == "overlay")
560 mOverlayVisibility = vis;
561 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
562 mFusionVisibility = vis;
563 else if (actor_type == "contour")
564 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
565 UpdateDisplayExtent();
567 //------------------------------------------------------------------------------
569 //------------------------------------------------------------------------------
570 void vvSlicer::SetVF(vvImage::Pointer vf)
572 if (vf->GetVTKImages().size()) {
574 mVFVisibility = true;
577 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
578 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
579 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
581 #if VTK_MAJOR_VERSION <= 5
582 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
583 mAAFilter->SetInput(mVOIFilter->GetOutput());
585 mVOIFilter->SetInputData(vf->GetFirstVTKImageData());
586 mAAFilter->SetInputConnection(mVOIFilter->GetOutputPort());
588 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
589 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
592 mArrow = vtkSmartPointer<vvGlyphSource>::New();
593 mArrow->SetGlyphTypeToSpecificArrow();
594 mArrow->SetScale(mScale);
597 // Glyph the gradient vector (with arrows)
599 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
600 #if VTK_MAJOR_VERSION <= 5
601 mGlyphFilter->SetInput(mAAFilter->GetOutput());
602 mGlyphFilter->SetSource(mArrow->GetOutput());
604 mGlyphFilter->SetInputConnection(mAAFilter->GetOutputPort());
605 mGlyphFilter->SetSourceConnection(mArrow->GetOutputPort());
607 mGlyphFilter->ScalingOn();
608 mGlyphFilter->SetScaleModeToScaleByVector();
609 mGlyphFilter->OrientOn();
610 mGlyphFilter->SetVectorModeToUseVector();
611 mGlyphFilter->SetColorModeToColorByVector();
614 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
616 double mVFColorHSV[3];
617 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
618 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
619 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
620 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
623 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
624 #if VTK_MAJOR_VERSION <= 5
625 mVFMapper->SetInput(mGlyphFilter->GetOutput());
627 mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
629 mVFMapper->ImmediateModeRenderingOn();
630 mVFMapper->SetLookupTable(mVFColorLUT);
633 mVFActor = vtkSmartPointer<vtkActor>::New();
634 mVFActor->SetMapper(mVFMapper);
635 mVFActor->SetPickable(0);
636 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
637 this->UpdateDisplayExtent();
638 this->GetRenderer()->AddActor(mVFActor);
641 SetTSlice(mCurrentTSlice);
644 //------------------------------------------------------------------------------
647 //------------------------------------------------------------------------------
648 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
650 mLandmarks = landmarks;
654 mCross = vtkSmartPointer<vtkCursor3D>::New();
656 mClipBox = vtkSmartPointer<vtkBox>::New();
658 mLandClipper = vtkSmartPointer<vvClipPolyData>::New();
660 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
662 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
664 mLandActor = vtkSmartPointer<vtkActor>::New();
666 mCross->SetFocalPoint(0.0,0.0,0.0);
667 mCross->SetModelBounds(-10,10,-10,10,-10,10);
671 mLandClipper->SetClipFunction(mClipBox);
672 mLandClipper->InsideOutOn();
673 #if VTK_MAJOR_VERSION <= 5
674 mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
675 mLandmarkTransform->SetInput(mLandmarks->GetOutput());
676 mConcatenatedTransform->Identity();
677 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
678 mConcatenatedTransform->Concatenate(mSlicingTransform);
679 mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
680 mLandClipper->SetInput(mLandmarkTransform->GetOutput());
682 mLandGlyph->SetSource(mCross->GetOutput());
683 mLandGlyph->SetInput(mLandClipper->GetOutput());
685 mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
686 mLandmarkTransform->SetInputData(mLandmarks->GetOutput());
687 mConcatenatedTransform->Identity();
688 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
689 mConcatenatedTransform->Concatenate(mSlicingTransform);
690 mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
691 mLandClipper->SetInputConnection(mLandmarkTransform->GetOutputPort());
693 mLandGlyph->SetSourceConnection(mCross->GetOutputPort());
694 mLandGlyph->SetInputConnection(mLandClipper->GetOutputPort());
696 //mLandGlyph->SetIndexModeToScalar();
697 //mLandGlyph->SetRange(0,1);
698 //mLandGlyph->ScalingOff();
700 //mLandGlyph->SetColorModeToColorByScalar();
702 mLandGlyph->SetScaleModeToDataScalingOff();
703 mLandGlyph->SetIndexModeToOff();
705 mLandMapper->SetInputConnection(mLandGlyph->GetOutputPort());
706 //mLandMapper->ScalarVisibilityOff();
708 mLandActor->SetMapper(mLandMapper);
709 mLandActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
710 mLandActor->GetProperty()->SetColor(255,10,212);
711 mLandActor->SetPickable(0);
712 mLandActor->SetVisibility(true);
713 this->UpdateDisplayExtent();
716 //------------------------------------------------------------------------------
718 //------------------------------------------------------------------------------
719 //FIXME: this function leaks memory, we should fix it someday :)
720 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
722 if (actor_type == "vector") {
723 Renderer->RemoveActor(mVFActor);
732 if (actor_type == "overlay") {
733 Renderer->RemoveActor(mOverlayActor);
735 mOverlayActor = NULL;
736 mOverlayMapper = NULL;
738 if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ) {
739 Renderer->RemoveActor(mFusionActor);
742 mFusionMapper = NULL;
744 if (actor_type == "contour") {
745 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
746 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
749 //------------------------------------------------------------------------------
752 //------------------------------------------------------------------------------
753 void vvSlicer::SetVFSubSampling(int sub)
756 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
759 UpdateDisplayExtent();
762 //------------------------------------------------------------------------------
765 //------------------------------------------------------------------------------
766 void vvSlicer::SetVFScale(int scale)
770 mArrow->SetScale(mScale);
771 UpdateDisplayExtent();
774 //------------------------------------------------------------------------------
776 //------------------------------------------------------------------------------
777 void vvSlicer::SetVFWidth(int width)
781 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
782 UpdateDisplayExtent();
785 //------------------------------------------------------------------------------
788 //------------------------------------------------------------------------------
789 void vvSlicer::SetVFLog(int log)
793 mGlyphFilter->SetUseLog(mVFLog);
794 mGlyphFilter->Modified();
796 UpdateDisplayExtent();
799 //------------------------------------------------------------------------------
802 //------------------------------------------------------------------------------
803 void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
805 if (!updateLinkedImages) {
807 #if VTK_MAJOR_VERSION <= 5
808 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
810 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
813 mConcatenatedTransform->Identity();
814 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
815 mConcatenatedTransform->Concatenate(mSlicingTransform);
816 UpdateDisplayExtent();
821 else if ((unsigned int)t >= mImage->GetVTKImages().size())
822 mCurrentTSlice = mImage->GetVTKImages().size() -1;
827 mConcatenatedTransform->Identity();
828 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
829 mConcatenatedTransform->Concatenate(mSlicingTransform);
832 #if VTK_MAJOR_VERSION <= 5
833 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
835 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
837 if (mVF && mVFActor->GetVisibility()) {
838 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
839 #if VTK_MAJOR_VERSION <= 5
840 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
842 mVOIFilter->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]);
846 if (mOverlay && mOverlayActor->GetVisibility()) {
847 if (mOverlay->GetVTKImages().size() > (unsigned int)t) {
848 mCurrentOverlayTSlice = t;
849 #if VTK_MAJOR_VERSION <= 5
850 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
852 mOverlayReslice->SetInputData( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
854 // Update overlay transform
855 mConcatenatedOverlayTransform->Identity();
856 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[mCurrentOverlayTSlice]);
857 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
860 //update the fusion ; except in case this is a fusionSequence, in which case both 'times' should be independent.
861 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode<0)) {
862 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
863 mCurrentFusionTSlice = t;
864 #if VTK_MAJOR_VERSION <= 5
865 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
867 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
870 // Update fusion transform
871 mConcatenatedFusionTransform->Identity();
872 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]);
873 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
876 if (mSurfaceCutActors.size() > 0)
877 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
878 i!=mSurfaceCutActors.end(); i++)
879 (*i)->SetTimeSlice(mCurrentTSlice);
880 UpdateDisplayExtent();
882 //------------------------------------------------------------------------------
885 //------------------------------------------------------------------------------
886 void vvSlicer::SetFusionSequenceTSlice(int t)
888 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode>=0)) {
889 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
890 mCurrentFusionTSlice = t;
891 #if VTK_MAJOR_VERSION <= 5
892 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
894 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
896 // Update fusion transform
897 mConcatenatedFusionTransform->Identity();
898 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]); //not really useful...
899 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
903 UpdateDisplayExtent();
905 //------------------------------------------------------------------------------
908 //------------------------------------------------------------------------------
909 int vvSlicer::GetTSlice()
911 return mCurrentTSlice;
913 //------------------------------------------------------------------------------
915 //------------------------------------------------------------------------------
916 int vvSlicer::GetMaxCurrentTSlice()
918 int t = mCurrentTSlice;
920 t = std::max(t, mCurrentOverlayTSlice);
921 if(mFusion&& (mFusionSequenceCode<0)) //ignore fusionSequence data: for these, the times are not to be related (this way)
922 t = std::max(t, mCurrentFusionTSlice);
925 //------------------------------------------------------------------------------
927 //------------------------------------------------------------------------------
928 int vvSlicer::GetFusionTSlice()
930 return mCurrentFusionTSlice;
932 //------------------------------------------------------------------------------
934 //------------------------------------------------------------------------------
935 int vvSlicer::GetOverlayTSlice()
937 return mCurrentOverlayTSlice;
939 //------------------------------------------------------------------------------
941 //------------------------------------------------------------------------------
942 void vvSlicer::SetSliceOrientation(int orientation)
944 //if 2D image, force to watch in Axial View
946 #if VTK_MAJOR_VERSION <= 5
947 this->GetInput()->GetWholeExtent(extent);
949 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
950 copyExtent(ext, extent);
953 if (extent[5]-extent[4] <= 2)
954 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
956 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
957 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
958 vtkErrorMacro("Error - invalid slice orientation " << orientation);
962 this->SliceOrientation = orientation;
965 AdjustResliceToSliceOrientation(mFusionReslice);
968 AdjustResliceToSliceOrientation(mOverlayReslice);
972 // Go to current cursor position
973 // double* cursorPos = GetCursorPosition();
974 // DDV(cursorPos, 3);
975 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
977 if (mFirstSetSliceOrientation) {
978 int *range = this->GetSliceRange();
980 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
981 #if VTK_MAJOR_VERSION <= 5
982 mFirstSetSliceOrientation = false;
985 else if (this->Renderer && this->GetInput()) {
986 double s = mCursor[orientation];
987 double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation];
988 this->Slice = static_cast<int>(sCursor);
991 this->UpdateOrientation();
993 this->UpdateDisplayExtent();
995 if (mFirstSetSliceOrientation) {
996 mFirstSetSliceOrientation = false;
999 if (this->Renderer && this->GetInput()) {
1000 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
1001 this->Renderer->ResetCamera();
1002 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
1007 //----------------------------------------------------------------------------
1009 //------------------------------------------------------------------------------
1010 // This function ensures that we sample the slices of a vtkImageReslice filter
1011 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
1012 // In other words, we change the grid of the reslice in the same way as the grid
1013 // of the displayed image in the slicing direction.
1014 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
1016 // Reset autocrop and update output information
1017 reslice->SetOutputOriginToDefault();
1018 reslice->SetOutputSpacingToDefault();
1019 #if VTK_MAJOR_VERSION <= 5
1020 reslice->GetOutput()->UpdateInformation();
1022 reslice->UpdateInformation();
1025 // Ge new origin / spacing
1028 reslice->GetOutput()->GetOrigin(origin);
1029 reslice->GetOutput()->GetSpacing(spacing);
1031 // Use similar spacing as the image in the direction SliceOrientation
1032 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1034 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
1035 // Step 1: from world coordinates to image coordinates
1036 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1037 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1039 // Step 2: round to nearest grid positionInc. This has been validated as the only
1040 // way to have something consistent with the thickness of a 2D slice visible on the
1041 // other slices. The thickness is accounted for so if the 2D slice is to thin and
1042 // between two slices, one will never be able to see this 2D slice (bug #1883).
1043 origin[this->SliceOrientation] = itk::Math::Round<double>(origin[this->SliceOrientation]);
1045 // Step 3: back to world coordinates
1046 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1047 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1049 // Set new spacing and origin
1050 reslice->SetOutputOrigin(origin);
1051 reslice->SetOutputSpacing(spacing);
1052 reslice->UpdateInformation();
1053 #if VTK_MAJOR_VERSION <= 5
1054 reslice->GetOutput()->UpdateInformation();
1057 //------------------------------------------------------------------------------
1059 //----------------------------------------------------------------------------
1060 int * vvSlicer::GetExtent()
1063 if (mUseReducedExtent) {
1064 w_ext = mReducedExtent;
1067 #if VTK_MAJOR_VERSION <= 5
1068 w_ext = GetInput()->GetWholeExtent();
1070 w_ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1075 //----------------------------------------------------------------------------
1078 //----------------------------------------------------------------------------
1079 int vvSlicer::GetOrientation()
1081 return this->SliceOrientation;
1083 //----------------------------------------------------------------------------
1086 //----------------------------------------------------------------------------
1087 void vvSlicer::UpdateDisplayExtent()
1089 emit UpdateDisplayExtentBegin(mSlicerNumber);
1090 vtkImageData *input = this->GetInput();
1091 if (!input || !this->ImageActor) {
1095 #if VTK_MAJOR_VERSION <= 5
1096 input->UpdateInformation();
1098 mRegisterExtent = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1100 this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents
1102 // Local copy of extent
1104 #if VTK_MAJOR_VERSION <= 5
1105 int* ext = GetExtent();
1107 int* ext = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1109 copyExtent(ext, w_ext);
1110 if (mUseReducedExtent) {
1111 copyExtent(mReducedExtent, w_ext);
1115 w_ext[ this->SliceOrientation*2 ] = this->Slice;
1116 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
1119 this->ImageActor->SetVisibility(mImageVisibility);
1120 this->ImageActor->SetDisplayExtent(w_ext);
1122 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1123 // Fix for bug #1882
1124 dynamic_cast<vtkImageSliceMapper *>(this->ImageActor->GetMapper())->SetOrientation(this->GetOrientation());
1127 // Overlay image actor
1128 if (mOverlay && mOverlayVisibility) {
1129 AdjustResliceToSliceOrientation(mOverlayReslice);
1131 #if VTK_MAJOR_VERSION <= 5
1132 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
1133 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
1135 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mOverlayReslice->GetOutput(), overExtent);
1136 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1138 mOverlayActor->SetVisibility(!out);
1139 mOverlayActor->SetDisplayExtent( overExtent );
1140 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1141 // Fix for bug #1882
1142 dynamic_cast<vtkImageSliceMapper *>(mOverlayActor->GetMapper())->SetOrientation(this->GetOrientation());
1146 mOverlayActor->SetVisibility(false);
1148 // Fusion image actor
1149 if (mFusion && mFusionVisibility) {
1150 AdjustResliceToSliceOrientation(mFusionReslice);
1152 #if VTK_MAJOR_VERSION <= 5
1153 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
1154 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
1156 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mFusionReslice->GetOutput(), fusExtent);
1157 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1159 mFusionActor->SetVisibility(!out);
1160 mFusionActor->SetDisplayExtent( fusExtent );
1161 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1162 // Fix for bug #1882
1163 dynamic_cast<vtkImageSliceMapper *>(mFusionActor->GetMapper())->SetOrientation(this->GetOrientation());
1167 mFusionActor->SetVisibility(false);
1168 // Vector field actor
1169 double* camera = Renderer->GetActiveCamera()->GetPosition();
1170 double* image_bounds = ImageActor->GetBounds();
1171 double position[3] = {0, 0, 0};
1172 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
1174 //print_vector<double, 6>("camera", camera);
1175 //print_vector<double, 6>("image_bounds", image_bounds);
1176 //print_vector<double, 3>("position", position);
1178 // find where to place the VF actor. to deal with
1179 // z-buffer issues, the VF is placed right in front of the image,
1180 // subject to a small offset. the position actually depends on the
1181 // the location of the camera relative to the image.
1183 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
1186 if (mVF && mVFVisibility) {
1188 #if VTK_MAJOR_VERSION <= 5
1189 mVF->GetVTKImages()[0]->UpdateInformation();
1190 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
1191 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
1193 mVOIFilter->Update();
1194 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVF->GetVTKImages()[0], vfExtent);
1195 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1197 mVFActor->SetVisibility(!out);
1198 mVOIFilter->SetVOI(vfExtent);
1199 int orientation[3] = {1,1,1};
1200 orientation[this->SliceOrientation] = 0;
1201 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
1202 position[this->SliceOrientation] += offset;
1203 mVFActor->SetPosition(position);
1204 mVFActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
1205 mVFMapper->Update();
1209 mVFActor->SetVisibility(false);
1213 for(unsigned int i=0; i<6; i++)
1214 boundsT[i] = ImageActor->GetBounds()[i];
1215 boundsT[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1216 boundsT[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1225 position[this->SliceOrientation] = offset;
1226 mLandActor->SetPosition(position);
1229 // Figure out the correct clipping range
1230 if (this->Renderer) {
1231 if (this->InteractorStyle &&
1232 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
1233 this->Renderer->ResetCameraClippingRange();
1235 vtkCamera *cam = this->Renderer->GetActiveCamera();
1238 this->ImageActor->GetBounds(bounds);
1239 double spos = (double)bounds[this->SliceOrientation * 2];
1240 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
1241 double range = fabs(spos - cpos);
1242 double *spacing = input->GetSpacing();
1243 double sumSpacing = spacing[0] + spacing[1] + spacing[2];
1244 cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
1254 emit UpdateDisplayExtentEnd(mSlicerNumber);
1256 //----------------------------------------------------------------------------
1258 //----------------------------------------------------------------------------
1259 void vvSlicer::ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, const int sourceExtent[6],
1260 vtkImageData *targetImage, int targetExtent[6])
1263 double *origin, *spacing;
1264 origin = sourceImage->Get(vtkDataObject::ORIGIN());
1265 spacing = sourceImage->Get(vtkDataObject::SPACING());
1266 for(unsigned int i=0; i<6; i++) {
1267 // From source voxel coordinates to world coordinates
1268 dExtents[i] = origin[i/2] + spacing[i/2] * sourceExtent[i];
1270 // From world coordinates to floating point target voxel coordinates
1271 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1273 // Round to current slice or larger extent
1274 if(i/2==this->GetOrientation())
1275 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1277 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1279 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1282 //----------------------------------------------------------------------------
1284 //----------------------------------------------------------------------------
1285 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
1286 vtkImageData *targetImage, int targetExtent[6])
1289 for(unsigned int i=0; i<6; i++) {
1290 // From source voxel coordinates to world coordinates
1291 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
1293 // From world coordinates to floating point target voxel coordinates
1294 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1296 // Round to current slice or larger extent
1297 if(i/2==this->GetOrientation())
1298 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1300 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1302 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1305 //----------------------------------------------------------------------------
1307 //----------------------------------------------------------------------------
1308 bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
1313 for (int i = 0; i < maxBound; i = i+2) {
1314 //if we are totally outside the image
1315 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
1319 //crop to the limit of the image
1320 extent[i] = std::max(extent[i], refExtent[i]);
1321 extent[i] = std::min(extent[i], refExtent[i+1]);;
1322 extent[i+1] = std::max(extent[i+1], refExtent[i]);
1323 extent[i+1] = std::min(extent[i+1], refExtent[i+1]);;
1326 for (int i = 0; i < maxBound; i = i+2) {
1327 extent[i] = refExtent[i];
1328 extent[i+1] = refExtent[i];
1332 //----------------------------------------------------------------------------
1335 //----------------------------------------------------------------------------
1336 void vvSlicer::UpdateOrientation()
1338 // Set the camera position
1339 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1341 switch (this->SliceOrientation) {
1342 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1343 cam->SetFocalPoint(0,0,0);
1344 cam->SetPosition(0,0,-1); // -1 if medical ?
1345 cam->SetViewUp(0,-1,0);
1348 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1349 cam->SetFocalPoint(0,0,0);
1350 cam->SetPosition(0,-1,0); // 1 if medical ?
1351 cam->SetViewUp(0,0,1);
1354 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1355 cam->SetFocalPoint(0,0,0);
1356 cam->SetPosition(-1,0,0); // -1 if medical ?
1357 cam->SetViewUp(0,0,1);
1362 //----------------------------------------------------------------------------
1365 //----------------------------------------------------------------------------
1366 void vvSlicer::SetOpacity(double s)
1368 this->GetImageActor()->SetOpacity(s);
1370 //----------------------------------------------------------------------------
1373 //----------------------------------------------------------------------------
1374 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1376 this->Superclass::SetRenderWindow(rw);
1377 this->SetupInteractor(rw->GetInteractor());
1378 ca->SetImageActor(this->GetImageActor());
1379 ca->SetWindowLevel(this->GetWindowLevel());
1380 ca->SetText(3, "<window>\n<level>");
1391 crossCursor->SetModelBounds(bounds);
1393 this->GetRenderer()->AddActor(pdmA);
1394 this->GetRenderer()->AddActor(ca);
1395 this->GetRenderer()->ResetCamera();
1397 //this is just a mapping between the labeling of the orientations presented to the user and
1398 //the one used by vtk
1399 SetSliceOrientation(2-(orientation%3));
1402 //----------------------------------------------------------------------------
1405 //----------------------------------------------------------------------------
1406 void vvSlicer::ResetCamera()
1408 this->GetRenderer()->ResetCamera();
1410 //----------------------------------------------------------------------------
1413 //----------------------------------------------------------------------------
1414 void vvSlicer::SetDisplayMode(bool i)
1416 this->GetRenderer()->SetDraw(i);
1417 if (i) UpdateDisplayExtent();
1419 //----------------------------------------------------------------------------
1422 //----------------------------------------------------------------------------
1423 void vvSlicer::FlipHorizontalView()
1425 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1427 double *position = cam->GetPosition();
1428 double factor[3] = {1, 1, 1};
1429 factor[this->SliceOrientation] = -1;
1430 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1432 /* switch (this->SliceOrientation) {
1433 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1434 cam->SetPosition(position[0],position[1],-position[2]);
1437 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1438 cam->SetPosition(position[0],-position[1],position[2]);
1441 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1442 cam->SetPosition(-position[0],position[1],position[2]);
1446 this->Renderer->ResetCameraClippingRange();
1447 this->UpdateDisplayExtent();
1450 //----------------------------------------------------------------------------
1453 //----------------------------------------------------------------------------
1454 void vvSlicer::FlipVerticalView()
1456 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1458 FlipHorizontalView();
1459 double *viewup = cam->GetViewUp();
1460 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1461 this->UpdateDisplayExtent();
1464 //----------------------------------------------------------------------------
1467 //----------------------------------------------------------------------------
1468 void vvSlicer::SetColorWindow(double window)
1470 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1472 double level = this->GetWindowLevel()->GetLevel();
1473 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1476 this->vtkImageViewer2::SetColorWindow(window);
1478 //----------------------------------------------------------------------------
1480 //----------------------------------------------------------------------------
1481 void vvSlicer::SetColorLevel(double level)
1483 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1485 double window = this->GetWindowLevel()->GetWindow();
1486 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1489 this->vtkImageViewer2::SetColorLevel(level);
1491 //----------------------------------------------------------------------------
1493 //----------------------------------------------------------------------------
1494 double vvSlicer::GetOverlayColorWindow()
1497 return mOverlayMapper->GetWindow();
1501 //----------------------------------------------------------------------------
1503 //----------------------------------------------------------------------------
1504 double vvSlicer::GetOverlayColorLevel()
1507 return mOverlayMapper->GetLevel();
1511 //----------------------------------------------------------------------------
1513 //----------------------------------------------------------------------------
1514 void vvSlicer::SetOverlayColorWindow(double window)
1517 mOverlayMapper->SetWindow(window);
1519 //----------------------------------------------------------------------------
1521 //----------------------------------------------------------------------------
1522 void vvSlicer::SetOverlayColorLevel(double level)
1525 mOverlayMapper->SetLevel(level);
1527 //----------------------------------------------------------------------------
1529 //----------------------------------------------------------------------------
1530 // Returns the min an the max value in a 20%x20% region around the mouse pointer
1531 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1533 //Get mouse pointer position in view coordinates
1536 for(int i=0; i<3; i++) {
1537 corner1[i] = mCurrent[i];
1538 corner2[i] = mCurrent[i];
1541 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1542 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1544 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1546 this->Renderer->GetTiledSize(&w, &h);
1547 corner1[0] -= 0.2*h/(double)w;
1548 corner2[0] += 0.2*h/(double)w;
1551 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1552 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1554 //Convert to image pixel coordinates (rounded)
1555 transform->TransformPoint(corner1, corner1);
1556 transform->TransformPoint(corner2, corner2);
1557 int iLocalExtents[6];
1558 for(int i=0; i<3; i++) {
1559 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1560 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1562 iLocalExtents[i*2 ] = lrint(corner1[i]);
1563 iLocalExtents[i*2+1] = lrint(corner2[i]);
1565 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1566 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1568 #if VTK_MAJOR_VERSION > 5
1569 for(int j=0;j<2; j++) {
1570 if(iLocalExtents[i*2+j]< mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i])
1571 iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i];
1573 if(iLocalExtents[i*2+j]> mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1])
1574 iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1];
1579 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1580 #if VTK_MAJOR_VERSION <= 5
1581 voiFilter->SetInput(image);
1583 voiFilter->SetInputData(image);
1585 voiFilter->SetVOI(iLocalExtents);
1586 voiFilter->Update();
1587 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1593 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1594 #if VTK_MAJOR_VERSION <= 5
1595 accFilter->SetInput(voiFilter->GetOutput());
1597 accFilter->SetInputConnection(voiFilter->GetOutputPort(0));
1599 accFilter->Update();
1601 min = *(accFilter->GetMin());
1602 max = *(accFilter->GetMax());
1604 //----------------------------------------------------------------------------
1606 //----------------------------------------------------------------------------
1607 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1612 #if VTK_MAJOR_VERSION <= 5
1613 if (ix < image->GetWholeExtent()[0] ||
1614 ix > image->GetWholeExtent()[1] ||
1615 iy < image->GetWholeExtent()[2] ||
1616 iy > image->GetWholeExtent()[3] ||
1617 iz < image->GetWholeExtent()[4] ||
1618 iz > image->GetWholeExtent()[5] )
1619 return std::numeric_limits<double>::quiet_NaN();
1620 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1623 if (ix < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] ||
1624 ix > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] ||
1625 iy < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] ||
1626 iy > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] ||
1627 iz < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] ||
1628 iz > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5] )
1629 return std::numeric_limits<double>::quiet_NaN();
1630 //image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1634 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1636 //----------------------------------------------------------------------------
1638 //----------------------------------------------------------------------------
1639 void vvSlicer::Render()
1641 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1642 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1643 legend->UseOpacityOn();
1644 legend->SetVisibility(1);
1646 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1647 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1648 legend->UseOpacityOff();
1649 legend->SetVisibility(1);
1650 } else legend->SetVisibility(0);
1652 if (ca->GetVisibility()) {
1654 std::stringstream worldPos(" ");
1656 mConcatenatedTransform->TransformPoint(mCurrent, pt);
1657 double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
1658 double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
1659 double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
1660 #if VTK_MAJOR_VERSION <= 5
1661 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
1662 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
1663 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
1664 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
1665 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
1666 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
1670 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1672 if(ImageActor->GetVisibility())
1673 worldPos << "data value : " << value << std::endl;
1675 worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
1676 << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
1677 << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
1680 worldPos << "pixel : " << ix << ' '
1687 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 &&
1688 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 &&
1689 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 &&
1690 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 &&
1691 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 &&
1692 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) {
1695 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1697 if(ImageActor->GetVisibility())
1698 worldPos << "data value : " << value << std::endl;
1700 worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
1701 << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
1702 << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
1705 worldPos << "pixel : " << ix << ' '
1713 ca->SetText(1,worldPos.str().c_str());
1715 std::stringstream slicePos;
1716 slicePos << "Slice: " << this->GetSlice();
1717 ca->SetText(2, slicePos.str().c_str());
1720 if (pdmA->GetVisibility()) {
1721 double x = mCursor[0];
1722 double y = mCursor[1];
1723 double z = mCursor[2];
1724 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1725 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1726 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1727 #if VTK_MAJOR_VERSION <= 5
1728 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
1729 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
1730 yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
1731 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+0.5 &&
1732 zCursor >= this->GetImageActor()->GetDisplayExtent()[4]-0.5 &&
1733 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+0.5 ) {
1734 vtkRenderer * renderer = this->Renderer;
1736 renderer->WorldToView(x,y,z);
1737 renderer->ViewToNormalizedViewport(x,y,z);
1738 renderer->NormalizedViewportToViewport(x,y);
1739 renderer->ViewportToNormalizedDisplay(x,y);
1740 renderer->NormalizedDisplayToDisplay(x,y);
1741 crossCursor->SetFocalPoint(x,y,z);
1743 crossCursor->SetFocalPoint(-1,-1,z);
1744 crossCursor->Update();
1747 vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
1749 mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
1750 } catch (const std::bad_cast& e) {
1751 std::cerr << e.what() << std::endl;
1752 std::cerr << "Conversion error" << std::endl;
1756 if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 &&
1757 xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 &&
1758 yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 &&
1759 yCursor < mapperOpenGL->GetCroppingRegion()[3]+0.5 &&
1760 zCursor >= mapperOpenGL->GetCroppingRegion()[4]-0.5 &&
1761 zCursor < mapperOpenGL->GetCroppingRegion()[5]+0.5 ) {
1762 vtkRenderer * renderer = this->Renderer;
1764 renderer->WorldToView(x,y,z);
1765 renderer->ViewToNormalizedViewport(x,y,z);
1766 renderer->NormalizedViewportToViewport(x,y);
1767 renderer->ViewportToNormalizedDisplay(x,y);
1768 renderer->NormalizedDisplayToDisplay(x,y);
1769 crossCursor->SetFocalPoint(x,y,z);
1771 crossCursor->SetFocalPoint(-1,-1,z);
1772 crossCursor->Update();
1776 if (mOverlay && mOverlayActor->GetVisibility()) {
1777 if(mLinkOverlayWindowLevel) {
1778 mOverlayMapper->SetWindow(this->GetColorWindow());
1779 mOverlayMapper->SetLevel(this->GetColorLevel());
1781 #if VTK_MAJOR_VERSION <= 5
1782 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1784 mOverlayMapper->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1786 mOverlayMapper->Update();
1788 if (mFusion && mFusionActor->GetVisibility()) {
1789 #if VTK_MAJOR_VERSION <= 5
1790 mFusionMapper->GetOutput()->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1792 mFusionMapper->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1794 mFusionMapper->Update();
1801 this->GetRenderWindow()->Render();
1803 //----------------------------------------------------------------------------
1806 //----------------------------------------------------------------------------
1807 void vvSlicer::UpdateCursorPosition()
1809 pdmA->SetVisibility(true);
1810 mCursor[0] = mCurrent[0];
1811 mCursor[1] = mCurrent[1];
1812 mCursor[2] = mCurrent[2];
1813 mCursor[3] = mCurrentTSlice;
1815 //----------------------------------------------------------------------------
1818 //----------------------------------------------------------------------------
1819 void vvSlicer::RemoveLandmarks()
1821 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
1822 if (pd->GetPoints()) {
1824 //First remove all captions:
1825 for(unsigned int i=0;i<mLandLabelActors.size();i++) {
1826 this->Renderer->RemoveActor2D(mLandLabelActors[i]);
1827 //allActors2D->Remove (mLandLabelActors[i]);
1829 mLandLabelActors.clear();
1832 //----------------------------------------------------------------------------
1835 //----------------------------------------------------------------------------
1836 void vvSlicer::DisplayLandmarks()
1840 for(unsigned int i=0; i<6; i++)
1841 bounds[i] = ImageActor->GetBounds()[i];
1842 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1843 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1844 mClipBox->SetBounds(bounds);
1847 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
1848 if (pd->GetPoints()) {
1849 this->GetRenderer()->AddActor(mLandActor);
1850 //mLandGlyph->SetRange(0,1);
1851 //mLandGlyph->Modified();
1852 //mLandGlyph->Update();
1853 mClipBox->Modified();
1854 mLandClipper->Update();
1855 mLandMapper->Update();
1856 //Next add the captions to the displayed points
1857 for (vtkIdType id=0; id<mLandClipper->GetOutput()->GetNumberOfPoints(); id++) {
1858 double *position = mLandClipper->GetOutput()->GetPoint(id);
1859 vtkStdString label = static_cast<vtkStringArray*>(mLandClipper->GetOutput()->GetPointData()->GetAbstractArray("labels"))->GetValue(id);
1860 vtkSmartPointer<vtkCaptionActor2D> label_actor = vtkSmartPointer<vtkCaptionActor2D>::New();
1861 label_actor->SetCaption(label);
1862 label_actor->SetAttachmentPoint(position);
1863 label_actor->GetCaptionTextProperty()->SetColor(1,0,0);
1864 label_actor->GetCaptionTextProperty()->SetOrientation(33.333333);
1865 label_actor->GetCaptionTextProperty()->SetFontFamilyToTimes();
1866 label_actor->GetCaptionTextProperty()->SetBold(0);
1867 label_actor->GetCaptionTextProperty()->SetFontSize(6);
1868 label_actor->BorderOff();
1869 label_actor->LeaderOff();
1870 label_actor->ThreeDimensionalLeaderOff();
1871 mLandLabelActors.push_back(label_actor);
1872 this->Renderer->AddActor2D(mLandLabelActors[id]);
1877 //----------------------------------------------------------------------------
1880 //----------------------------------------------------------------------------
1881 void vvSlicer::SetSlice(int slice)
1883 int *range = this->GetSliceRange();
1885 if (slice < range[0]) {
1887 } else if (slice > range[1]) {
1892 if (this->Slice == slice) {
1896 this->Slice = slice;
1899 this->UpdateDisplayExtent();
1901 // Seems to work without this line
1904 //----------------------------------------------------------------------------
1906 //----------------------------------------------------------------------------
1907 int vvSlicer::GetTMax()
1909 int tmax = (int)mImage->GetVTKImages().size() - 1;
1911 tmax = std::max(tmax, (int)mOverlay->GetVTKImages().size()-1);
1914 //----------------------------------------------------------------------------
1916 //----------------------------------------------------------------------------
1917 void vvSlicer::SetContourSlice()
1919 if (mSurfaceCutActors.size() > 0)
1920 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1921 i!=mSurfaceCutActors.end(); i++) {
1923 (*i)->SetSlicingOrientation(this->SliceOrientation);
1924 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1925 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1928 //----------------------------------------------------------------------------
1931 //----------------------------------------------------------------------------
1932 void vvSlicer::ForceUpdateDisplayExtent()
1934 this->UpdateDisplayExtent();
1936 //----------------------------------------------------------------------------
1939 //----------------------------------------------------------------------------
1940 int* vvSlicer::GetDisplayExtent()
1942 return this->GetImageActor()->GetDisplayExtent();
1944 //----------------------------------------------------------------------------
1947 //----------------------------------------------------------------------------
1948 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1950 this->Superclass::PrintSelf(os, indent);
1952 //----------------------------------------------------------------------------
1955 //----------------------------------------------------------------------------
1956 void vvSlicer::SetVFColor(double r, double g, double b)
1958 double mVFColorHSV[3];
1963 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1964 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1965 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1966 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
1970 //----------------------------------------------------------------------------
1973 //----------------------------------------------------------------------------
1974 void vvSlicer::SetRegisterExtent(int ext[6])
1976 copyExtent(ext, mRegisterExtent);
1978 //----------------------------------------------------------------------------
1981 //----------------------------------------------------------------------------
1982 void vvSlicer::GetRegisterExtent(int ext[6])
1984 copyExtent(mRegisterExtent, ext);
1986 //----------------------------------------------------------------------------