1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #include <QMessageBox>
24 #include "vvSlicerManagerCommand.h"
25 #include "vvGlyphSource.h"
26 #include "vvGlyph2D.h"
28 #include <vtkVersion.h>
29 #include <vtkExtentTranslator.h>
30 #include <vtkAlgorithm.h>
31 #include <vtkExecutive.h>
32 #include <vtkStreamingDemandDrivenPipeline.h>
33 #include <vtkInformation.h>
34 #include <vtkTextProperty.h>
35 #include <vtkTextActor.h>
36 #include <vtkTextSource.h>
37 #include <vtkActor2D.h>
38 #include <vtkCursor2D.h>
39 #include <vtkPolyDataMapper2D.h>
40 #include <vtkProperty2D.h>
41 #include <vtkCornerAnnotation.h>
42 #include <vtkImageMapToWindowLevelColors.h>
43 #include <vtkImageData.h>
44 #include <vtkImageActor.h>
45 #include <vvBlendImageActor.h>
46 #include <vtkToolkits.h>
47 #include <vtkObjectFactory.h>
48 #include <vtkPointData.h>
49 #include <vtkDataArray.h>
50 #include <vtkFloatArray.h>
51 #include <vtkClipPolyData.h>
52 #include <vtkActor2DCollection.h>
53 #include <vtkGlyph3D.h>
55 #include <vtkCursor3D.h>
56 #include <vtkProperty.h>
58 #include <vtkLightCollection.h>
59 #include <vtkScalarBarActor.h>
60 #include <vtkImageProperty.h>
61 #include <vtkLookupTable.h>
63 #include <vtkRenderer.h>
64 #include <vtkRendererCollection.h>
65 #include <vtkRenderWindow.h>
66 #include <vtkRenderWindowInteractor.h>
67 #include <vtkCamera.h>
68 #include <vtkCallbackCommand.h>
69 #include <vtkCommand.h>
70 #include <vtkPolyDataMapper.h>
73 #include <vtkExtractVOI.h>
74 #include <vtkSphereSource.h>
75 #include <vtkCutter.h>
76 #include <vtkAssignAttribute.h>
77 #include <vtkImageAccumulate.h>
78 #include <vtkImageReslice.h>
79 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
80 # include <vtkOpenGLImageSliceMapper.h>
81 # include <vtkImageMapper3D.h>
82 # include <vtkImageSliceMapper.h>
85 vtkStandardNewMacro(vvSlicer);
86 static void copyExtent(int* in, int* to){
87 for(int i=0; i<6; ++i)
92 //------------------------------------------------------------------------------
95 mFusionSequenceCode = -1;
96 this->UnInstallPipeline();
98 mReducedExtent = new int[6];
99 mRegisterExtent = NULL;
101 mCurrentFusionTSlice = 0;
102 mCurrentOverlayTSlice = 0;
103 mUseReducedExtent = false;
105 mCurrent[0] = -VTK_DOUBLE_MAX;
106 mCurrent[1] = -VTK_DOUBLE_MAX;
107 mCurrent[2] = -VTK_DOUBLE_MAX;
109 mCursor[0] = 0;//-VTK_DOUBLE_MAX;
110 mCursor[1] = 0;//-VTK_DOUBLE_MAX;
111 mCursor[2] = 0;//-VTK_DOUBLE_MAX;
112 mCursor[3] = 0;//-VTK_DOUBLE_MAX;
122 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
123 crossCursor->AllOff();
124 crossCursor->AxesOn();
125 crossCursor->SetTranslationMode(1);
126 crossCursor->SetRadius(2);
128 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
129 #if VTK_MAJOR_VERSION <= 5
130 pdm->SetInput(crossCursor->GetOutput());
132 pdm->SetInputConnection(crossCursor->GetOutputPort(0));
135 pdmA = vtkSmartPointer<vtkActor2D>::New();
136 pdmA->SetMapper(pdm);
137 pdmA->GetProperty()->SetColor(255,10,212);
138 pdmA->SetVisibility(0);
139 pdmA->SetPickable(0);
141 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
142 ca->GetTextProperty()->SetColor(255,10,212);
143 ca->SetVisibility(1);
151 legend = vtkSmartPointer<vtkScalarBarActor>::New();
152 //legend->SetTitle("test!");
153 legend->SetPosition(0.82,0.18);
154 legend->SetWidth(0.1);
155 legend->SetVisibility(0);
156 legend->SetLabelFormat("%.1f");
157 this->GetRenderer()->AddActor(legend);
158 showFusionLegend = false;
160 this->InstallPipeline();
162 mLinkOverlayWindowLevel = true;
163 mImageVisibility = true;
165 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
166 this->GetImageActor()->GetMapper()->BorderOn();
169 mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
170 mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
171 mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
172 mConcatenatedOverlayTransform = vtkSmartPointer<vtkTransform>::New();
173 mFirstSetSliceOrientation = true;
175 //------------------------------------------------------------------------------
178 //------------------------------------------------------------------------------
179 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
181 return mOverlayMapper.GetPointer();
183 //------------------------------------------------------------------------------
186 //------------------------------------------------------------------------------
187 vvBlendImageActor* vvSlicer::GetOverlayActor()
189 return mOverlayActor.GetPointer();
191 //------------------------------------------------------------------------------
194 //------------------------------------------------------------------------------
195 vtkImageMapToColors* vvSlicer::GetFusionMapper()
197 return mFusionMapper.GetPointer();
199 //------------------------------------------------------------------------------
202 //------------------------------------------------------------------------------
203 vtkImageActor* vvSlicer::GetFusionActor()
205 return mFusionActor.GetPointer();
207 //------------------------------------------------------------------------------
210 //------------------------------------------------------------------------------
211 vtkActor* vvSlicer::GetVFActor()
213 return mVFActor.GetPointer();
215 //------------------------------------------------------------------------------
218 //------------------------------------------------------------------------------
219 vtkCornerAnnotation* vvSlicer::GetAnnotation()
221 return ca.GetPointer();
223 //------------------------------------------------------------------------------
226 //------------------------------------------------------------------------------
227 void vvSlicer::EnableReducedExtent(bool b)
229 mUseReducedExtent = b;
231 //------------------------------------------------------------------------------
234 //------------------------------------------------------------------------------
235 void vvSlicer::SetReducedExtent(int * ext)
237 copyExtent(ext, mReducedExtent);
239 //------------------------------------------------------------------------------
242 //------------------------------------------------------------------------------
243 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
246 mSurfaceCutActors.push_back(new vvMeshActor());
248 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
250 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
251 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
252 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 void vvSlicer::ToggleContourSuperposition()
262 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
263 i!=mSurfaceCutActors.end(); i++)
264 (*i)->ToggleSuperposition();
266 //------------------------------------------------------------------------------
269 //------------------------------------------------------------------------------
270 void vvSlicer::SetCursorColor(int r,int g, int b)
272 pdmA->GetProperty()->SetColor(r,g,b);
274 //------------------------------------------------------------------------------
277 //------------------------------------------------------------------------------
278 void vvSlicer::SetCursorVisibility(bool s)
280 pdmA->SetVisibility(s);
282 //------------------------------------------------------------------------------
285 //------------------------------------------------------------------------------
286 bool vvSlicer::GetCursorVisibility()
288 return pdmA->GetVisibility();
290 //------------------------------------------------------------------------------
293 //------------------------------------------------------------------------------
294 void vvSlicer::SetCornerAnnotationVisibility(bool s)
296 ca->SetVisibility(s);
298 //------------------------------------------------------------------------------
301 //------------------------------------------------------------------------------
302 bool vvSlicer::GetCornerAnnotationVisibility()
304 return ca->GetVisibility();
306 //------------------------------------------------------------------------------
309 //------------------------------------------------------------------------------
310 vvSlicer::~vvSlicer()
312 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
313 i!=mSurfaceCutActors.end(); i++)
315 delete [] mReducedExtent;
317 //------------------------------------------------------------------------------
319 //------------------------------------------------------------------------------
320 double* vvSlicer::GetCurrentPosition()
322 return mCurrentBeforeSlicingTransform;
324 //------------------------------------------------------------------------------
326 //------------------------------------------------------------------------------
327 void vvSlicer::SetInterpolationImageReslice(int interpolation)
329 mImageReslice->SetInterpolationMode(interpolation);
331 //------------------------------------------------------------------------------
333 //------------------------------------------------------------------------------
334 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
336 mCurrentBeforeSlicingTransform[0]=x;
337 mCurrentBeforeSlicingTransform[1]=y;
338 mCurrentBeforeSlicingTransform[2]=z;
339 mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
340 if (t>=0) SetTSlice(t);
342 //------------------------------------------------------------------------------
345 //------------------------------------------------------------------------------
346 void vvSlicer::SetImage(vvImage::Pointer image)
348 if (image->GetVTKImages().size()) {
351 if (!mImageReslice) {
352 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
353 mImageReslice->SetInterpolationModeToLinear();
354 mImageReslice->AutoCropOutputOn();
355 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
358 mConcatenatedTransform->Identity();
359 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
360 mConcatenatedTransform->Concatenate(mSlicingTransform);
361 mImageReslice->SetResliceTransform(mConcatenatedTransform);
362 #if VTK_MAJOR_VERSION <= 5
363 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
365 mImageReslice->SetInputData(0, mImage->GetFirstVTKImageData());
367 mImageReslice->UpdateInformation();
369 #if VTK_MAJOR_VERSION <= 5
370 this->Superclass::SetInput(mImageReslice->GetOutput());
372 this->Superclass::SetInputConnection(mImageReslice->GetOutputPort());
376 #if VTK_MAJOR_VERSION <= 5
377 this->GetInput()->GetWholeExtent(extent);
379 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
380 copyExtent(ext, extent);
383 // Prevent crash when reload -> change slice if outside extent
384 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
385 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
388 // Make sure that the required part image has been computed
389 extent[SliceOrientation*2] = Slice;
390 extent[SliceOrientation*2+1] = Slice;
391 #if VTK_MAJOR_VERSION <= 5
392 mImageReslice->GetOutput()->SetUpdateExtent(extent);
393 mImageReslice->GetOutput()->Update();
395 //mImageReslice->SetUpdateExtent(extent);
396 mImageReslice->Update();
399 this->UpdateDisplayExtent();
402 ca->SetText(0,mFileName.c_str());
405 //------------------------------------------------------------------------------
408 //------------------------------------------------------------------------------
409 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
411 if (overlay->GetVTKImages().size()) {
413 mOverlayVisibility = true;
415 if (!mOverlayReslice) {
416 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
417 mOverlayReslice->SetInterpolationModeToLinear();
418 mOverlayReslice->AutoCropOutputOn();
419 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
422 mConcatenatedOverlayTransform->Identity();
423 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]);
424 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
425 mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform);
426 #if VTK_MAJOR_VERSION <= 5
427 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
428 mImageReslice->UpdateInformation();
430 mOverlayReslice->SetInputData(0, mOverlay->GetFirstVTKImageData());
432 mOverlayReslice->Update();
435 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
436 #if VTK_MAJOR_VERSION <= 5
437 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
439 mOverlayMapper->SetInputConnection(mOverlayReslice->GetOutputPort(0));
442 if (!mOverlayActor) {
443 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
444 #if VTK_MAJOR_VERSION <= 5
445 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
447 mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort());
449 mOverlayActor->SetPickable(0);
450 mOverlayActor->SetVisibility(true);
451 mOverlayActor->SetOpacity(0.5);
452 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
453 mOverlayActor->GetMapper()->BorderOn();
457 //stupid but necessary : the Overlay need to be rendered before fusion
459 this->GetRenderer()->RemoveActor(mFusionActor);
460 this->GetRenderer()->AddActor(mOverlayActor);
461 this->GetRenderer()->AddActor(mFusionActor);
463 this->GetRenderer()->AddActor(mOverlayActor);
465 //Synchronize orientation and slice
466 AdjustResliceToSliceOrientation(mOverlayReslice);
467 this->UpdateDisplayExtent();
468 this->SetTSlice(mCurrentTSlice);
471 //------------------------------------------------------------------------------
474 //------------------------------------------------------------------------------
475 void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
477 mFusionSequenceCode = fusionSequenceCode;
478 if (fusion->GetVTKImages().size()) {
480 mFusionVisibility = true;
482 if (!mFusionReslice) {
483 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
484 mFusionReslice->SetInterpolationModeToLinear();
485 mFusionReslice->AutoCropOutputOn();
486 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
489 mConcatenatedFusionTransform->Identity();
490 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]);
491 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
492 mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform);
493 #if VTK_MAJOR_VERSION <= 5
494 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
495 mFusionReslice->UpdateInformation();
497 mFusionReslice->SetInputData(0, mFusion->GetFirstVTKImageData());
499 mFusionReslice->Update();
502 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
504 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
506 lut->SetValueRange(0, 1);
507 lut->SetSaturationRange(0, 0);
509 mFusionMapper->SetLookupTable(lut);
510 #if VTK_MAJOR_VERSION <= 5
511 mFusionMapper->SetInput(mFusionReslice->GetOutput());
513 mFusionMapper->SetInputConnection(mFusionReslice->GetOutputPort(0));
517 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
518 #if VTK_MAJOR_VERSION <= 5
519 mFusionActor->SetInput(mFusionMapper->GetOutput());
521 mFusionActor->GetMapper()->SetInputConnection(mFusionMapper->GetOutputPort());
523 mFusionActor->SetPickable(0);
524 mFusionActor->SetVisibility(true);
525 mFusionActor->SetOpacity(0.7);
526 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
527 mFusionActor->GetMapper()->BorderOn();
530 this->GetRenderer()->AddActor(mFusionActor);
533 //Synchronize orientation and slice
534 AdjustResliceToSliceOrientation(mFusionReslice);
535 this->UpdateDisplayExtent();
536 this->SetTSlice(mCurrentTSlice);
539 //------------------------------------------------------------------------------
542 //------------------------------------------------------------------------------
543 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
546 if (actor_type == "image")
547 vis = mImageVisibility;
548 else if (actor_type == "vector")
550 else if (actor_type == "overlay")
551 vis = mOverlayVisibility;
552 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
553 vis = mFusionVisibility;
554 else if (actor_type == "contour")
555 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
558 //------------------------------------------------------------------------------
560 //------------------------------------------------------------------------------
561 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
563 if (actor_type == "image")
564 mImageVisibility = vis;
565 else if (actor_type == "vector")
567 else if (actor_type == "overlay")
568 mOverlayVisibility = vis;
569 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
570 mFusionVisibility = vis;
571 else if (actor_type == "contour")
572 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
573 UpdateDisplayExtent();
575 //------------------------------------------------------------------------------
577 //------------------------------------------------------------------------------
578 void vvSlicer::SetVF(vvImage::Pointer vf)
580 if (vf->GetVTKImages().size()) {
582 mVFVisibility = true;
585 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
586 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
587 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
589 #if VTK_MAJOR_VERSION <= 5
590 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
591 mAAFilter->SetInput(mVOIFilter->GetOutput());
593 mVOIFilter->SetInputData(vf->GetFirstVTKImageData());
594 mAAFilter->SetInputConnection(mVOIFilter->GetOutputPort());
596 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
597 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
600 mArrow = vtkSmartPointer<vvGlyphSource>::New();
601 mArrow->SetGlyphTypeToSpecificArrow();
602 mArrow->SetScale(mScale);
605 // Glyph the gradient vector (with arrows)
607 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
608 #if VTK_MAJOR_VERSION <= 5
609 mGlyphFilter->SetInput(mAAFilter->GetOutput());
610 mGlyphFilter->SetSource(mArrow->GetOutput());
612 mGlyphFilter->SetInputConnection(mAAFilter->GetOutputPort());
613 mGlyphFilter->SetSourceConnection(mArrow->GetOutputPort());
615 mGlyphFilter->ScalingOn();
616 mGlyphFilter->SetScaleModeToScaleByVector();
617 mGlyphFilter->OrientOn();
618 mGlyphFilter->SetVectorModeToUseVector();
619 mGlyphFilter->SetColorModeToColorByVector();
622 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
624 double mVFColorHSV[3];
625 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
626 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
627 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
628 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
631 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
632 #if VTK_MAJOR_VERSION <= 5
633 mVFMapper->SetInput(mGlyphFilter->GetOutput());
635 mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
637 mVFMapper->ImmediateModeRenderingOn();
638 mVFMapper->SetLookupTable(mVFColorLUT);
641 mVFActor = vtkSmartPointer<vtkActor>::New();
642 mVFActor->SetMapper(mVFMapper);
643 mVFActor->SetPickable(0);
644 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
645 this->UpdateDisplayExtent();
646 this->GetRenderer()->AddActor(mVFActor);
649 SetTSlice(mCurrentTSlice);
652 //------------------------------------------------------------------------------
655 //------------------------------------------------------------------------------
656 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
658 mLandmarks = landmarks;
662 mCross = vtkSmartPointer<vtkCursor3D>::New();
664 mClipBox = vtkSmartPointer<vtkBox>::New();
666 mLandClipper = vtkSmartPointer<vvClipPolyData>::New();
668 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
670 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
672 mLandActor = vtkSmartPointer<vtkActor>::New();
674 mCross->SetFocalPoint(0.0,0.0,0.0);
675 mCross->SetModelBounds(-10,10,-10,10,-10,10);
679 mLandClipper->SetClipFunction(mClipBox);
680 mLandClipper->InsideOutOn();
681 #if VTK_MAJOR_VERSION <= 5
682 mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
683 mLandmarkTransform->SetInput(mLandmarks->GetOutput());
684 mConcatenatedTransform->Identity();
685 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
686 mConcatenatedTransform->Concatenate(mSlicingTransform);
687 mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
688 mLandClipper->SetInput(mLandmarkTransform->GetOutput());
690 mLandGlyph->SetSource(mCross->GetOutput());
691 mLandGlyph->SetInput(mLandClipper->GetOutput());
693 mLandmarkTransform = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
694 mLandmarkTransform->SetInputData(mLandmarks->GetOutput());
695 mConcatenatedTransform->Identity();
696 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
697 mConcatenatedTransform->Concatenate(mSlicingTransform);
698 mLandmarkTransform->SetTransform(mConcatenatedTransform->GetInverse());
699 mLandClipper->SetInputConnection(mLandmarkTransform->GetOutputPort());
701 mLandGlyph->SetSourceConnection(mCross->GetOutputPort());
702 mLandGlyph->SetInputConnection(mLandClipper->GetOutputPort());
704 //mLandGlyph->SetIndexModeToScalar();
705 //mLandGlyph->SetRange(0,1);
706 //mLandGlyph->ScalingOff();
708 //mLandGlyph->SetColorModeToColorByScalar();
710 mLandGlyph->SetScaleModeToDataScalingOff();
711 mLandGlyph->SetIndexModeToOff();
713 mLandMapper->SetInputConnection(mLandGlyph->GetOutputPort());
714 //mLandMapper->ScalarVisibilityOff();
716 mLandActor->SetMapper(mLandMapper);
717 mLandActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
718 mLandActor->GetProperty()->SetColor(255,10,212);
719 mLandActor->SetPickable(0);
720 mLandActor->SetVisibility(true);
721 this->UpdateDisplayExtent();
724 //------------------------------------------------------------------------------
726 //------------------------------------------------------------------------------
727 //FIXME: this function leaks memory, we should fix it someday :)
728 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
730 if (actor_type == "vector") {
731 Renderer->RemoveActor(mVFActor);
740 if (actor_type == "overlay") {
741 Renderer->RemoveActor(mOverlayActor);
743 mOverlayActor = NULL;
744 mOverlayMapper = NULL;
746 if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ) {
747 Renderer->RemoveActor(mFusionActor);
750 mFusionMapper = NULL;
752 if (actor_type == "contour") {
753 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
754 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
757 //------------------------------------------------------------------------------
760 //------------------------------------------------------------------------------
761 void vvSlicer::SetVFSubSampling(int sub)
764 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
767 UpdateDisplayExtent();
770 //------------------------------------------------------------------------------
773 //------------------------------------------------------------------------------
774 void vvSlicer::SetVFScale(int scale)
778 mArrow->SetScale(mScale);
779 UpdateDisplayExtent();
782 //------------------------------------------------------------------------------
784 //------------------------------------------------------------------------------
785 void vvSlicer::SetVFWidth(int width)
789 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
790 UpdateDisplayExtent();
793 //------------------------------------------------------------------------------
796 //------------------------------------------------------------------------------
797 void vvSlicer::SetVFLog(int log)
801 mGlyphFilter->SetUseLog(mVFLog);
802 mGlyphFilter->Modified();
804 UpdateDisplayExtent();
807 //------------------------------------------------------------------------------
810 //------------------------------------------------------------------------------
811 void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
813 if (!updateLinkedImages) {
815 #if VTK_MAJOR_VERSION <= 5
816 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
818 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
821 mConcatenatedTransform->Identity();
822 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
823 mConcatenatedTransform->Concatenate(mSlicingTransform);
824 UpdateDisplayExtent();
829 else if ((unsigned int)t >= mImage->GetVTKImages().size())
830 mCurrentTSlice = mImage->GetVTKImages().size() -1;
835 mConcatenatedTransform->Identity();
836 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
837 mConcatenatedTransform->Concatenate(mSlicingTransform);
840 #if VTK_MAJOR_VERSION <= 5
841 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
843 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
845 if (mVF && mVFActor->GetVisibility()) {
846 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
847 #if VTK_MAJOR_VERSION <= 5
848 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
850 mVOIFilter->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]);
854 if (mOverlay && mOverlayActor->GetVisibility()) {
855 if (mOverlay->GetVTKImages().size() > (unsigned int)t) {
856 mCurrentOverlayTSlice = t;
857 #if VTK_MAJOR_VERSION <= 5
858 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
860 mOverlayReslice->SetInputData( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
862 // Update overlay transform
863 mConcatenatedOverlayTransform->Identity();
864 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[mCurrentOverlayTSlice]);
865 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
868 //update the fusion ; except in case this is a fusionSequence, in which case both 'times' should be independent.
869 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode<0)) {
870 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
871 mCurrentFusionTSlice = t;
872 #if VTK_MAJOR_VERSION <= 5
873 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
875 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
878 // Update fusion transform
879 mConcatenatedFusionTransform->Identity();
880 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]);
881 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
884 if (mSurfaceCutActors.size() > 0)
885 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
886 i!=mSurfaceCutActors.end(); i++)
887 (*i)->SetTimeSlice(mCurrentTSlice);
888 UpdateDisplayExtent();
890 //------------------------------------------------------------------------------
893 //------------------------------------------------------------------------------
894 void vvSlicer::SetFusionSequenceTSlice(int t)
896 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode>=0)) {
897 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
898 mCurrentFusionTSlice = t;
899 #if VTK_MAJOR_VERSION <= 5
900 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
902 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
904 // Update fusion transform
905 mConcatenatedFusionTransform->Identity();
906 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]); //not really useful...
907 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
911 UpdateDisplayExtent();
913 //------------------------------------------------------------------------------
916 //------------------------------------------------------------------------------
917 int vvSlicer::GetTSlice()
919 return mCurrentTSlice;
921 //------------------------------------------------------------------------------
923 //------------------------------------------------------------------------------
924 int vvSlicer::GetMaxCurrentTSlice()
926 int t = mCurrentTSlice;
927 if(mOverlay && mOverlayActor->GetVisibility())
928 t = std::max(t, mCurrentOverlayTSlice);
929 if(mFusion&& (mFusionSequenceCode<0) && mFusionActor->GetVisibility()) //ignore fusionSequence data: for these, the times are not to be related (this way)
930 t = std::max(t, mCurrentFusionTSlice);
933 //------------------------------------------------------------------------------
935 //------------------------------------------------------------------------------
936 int vvSlicer::GetFusionTSlice()
938 return mCurrentFusionTSlice;
940 //------------------------------------------------------------------------------
942 //------------------------------------------------------------------------------
943 int vvSlicer::GetOverlayTSlice()
945 return mCurrentOverlayTSlice;
947 //------------------------------------------------------------------------------
949 //------------------------------------------------------------------------------
950 void vvSlicer::SetSliceOrientation(int orientation)
952 //if 2D image, force to watch in Axial View
954 #if VTK_MAJOR_VERSION <= 5
955 this->GetInput()->GetWholeExtent(extent);
957 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
958 copyExtent(ext, extent);
961 if (extent[5]-extent[4] <= 2)
962 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
964 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
965 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
966 vtkErrorMacro("Error - invalid slice orientation " << orientation);
970 this->SliceOrientation = orientation;
973 AdjustResliceToSliceOrientation(mFusionReslice);
976 AdjustResliceToSliceOrientation(mOverlayReslice);
980 // Go to current cursor position
981 // double* cursorPos = GetCursorPosition();
982 // DDV(cursorPos, 3);
983 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
985 if (mFirstSetSliceOrientation) {
986 int *range = this->GetSliceRange();
988 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
989 #if VTK_MAJOR_VERSION <= 5
990 mFirstSetSliceOrientation = false;
993 else if (this->Renderer && this->GetInput()) {
994 double s = mCursor[orientation];
995 double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation];
996 this->Slice = static_cast<int>(sCursor);
999 this->UpdateOrientation();
1001 this->UpdateDisplayExtent();
1003 if (mFirstSetSliceOrientation) {
1004 mFirstSetSliceOrientation = false;
1007 if (this->Renderer && this->GetInput()) {
1008 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
1009 this->Renderer->ResetCamera();
1010 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
1015 //----------------------------------------------------------------------------
1017 //------------------------------------------------------------------------------
1018 // This function ensures that we sample the slices of a vtkImageReslice filter
1019 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
1020 // In other words, we change the grid of the reslice in the same way as the grid
1021 // of the displayed image in the slicing direction.
1022 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
1024 // Reset autocrop and update output information
1025 reslice->SetOutputOriginToDefault();
1026 reslice->SetOutputSpacingToDefault();
1027 #if VTK_MAJOR_VERSION <= 5
1028 reslice->GetOutput()->UpdateInformation();
1030 reslice->UpdateInformation();
1033 // Ge new origin / spacing
1036 reslice->GetOutput()->GetOrigin(origin);
1037 reslice->GetOutput()->GetSpacing(spacing);
1039 // Use similar spacing as the image in the direction SliceOrientation
1040 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1042 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
1043 // Step 1: from world coordinates to image coordinates
1044 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1045 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1047 // Step 2: round to nearest grid positionInc. This has been validated as the only
1048 // way to have something consistent with the thickness of a 2D slice visible on the
1049 // other slices. The thickness is accounted for so if the 2D slice is to thin and
1050 // between two slices, one will never be able to see this 2D slice (bug #1883).
1051 origin[this->SliceOrientation] = itk::Math::Round<double>(origin[this->SliceOrientation]);
1053 // Step 3: back to world coordinates
1054 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1055 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1057 // Set new spacing and origin
1058 reslice->SetOutputOrigin(origin);
1059 reslice->SetOutputSpacing(spacing);
1060 reslice->UpdateInformation();
1061 #if VTK_MAJOR_VERSION <= 5
1062 reslice->GetOutput()->UpdateInformation();
1065 //------------------------------------------------------------------------------
1067 //----------------------------------------------------------------------------
1068 int * vvSlicer::GetExtent()
1071 if (mUseReducedExtent) {
1072 w_ext = mReducedExtent;
1075 #if VTK_MAJOR_VERSION <= 5
1076 w_ext = GetInput()->GetWholeExtent();
1078 w_ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1083 //----------------------------------------------------------------------------
1086 //----------------------------------------------------------------------------
1087 int vvSlicer::GetOrientation()
1089 return this->SliceOrientation;
1091 //----------------------------------------------------------------------------
1094 //----------------------------------------------------------------------------
1095 void vvSlicer::UpdateDisplayExtent()
1097 emit UpdateDisplayExtentBegin(mSlicerNumber);
1098 vtkImageData *input = this->GetInput();
1099 if (!input || !this->ImageActor) {
1103 #if VTK_MAJOR_VERSION <= 5
1104 input->UpdateInformation();
1106 mRegisterExtent = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1108 this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents
1110 // Local copy of extent
1112 #if VTK_MAJOR_VERSION <= 5
1113 int* ext = GetExtent();
1115 int* ext = mImageReslice->GetOutputInformation(0)->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1117 copyExtent(ext, w_ext);
1118 if (mUseReducedExtent) {
1119 copyExtent(mReducedExtent, w_ext);
1123 w_ext[ this->SliceOrientation*2 ] = this->Slice;
1124 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
1127 this->ImageActor->SetVisibility(mImageVisibility);
1128 this->ImageActor->SetDisplayExtent(w_ext);
1130 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1131 // Fix for bug #1882
1132 dynamic_cast<vtkImageSliceMapper *>(this->ImageActor->GetMapper())->SetOrientation(this->GetOrientation());
1135 // Overlay image actor
1136 if (mOverlay && mOverlayVisibility) {
1137 AdjustResliceToSliceOrientation(mOverlayReslice);
1139 #if VTK_MAJOR_VERSION <= 5
1140 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
1141 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
1143 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mOverlayReslice->GetOutput(), overExtent);
1144 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1146 mOverlayActor->SetVisibility(!out);
1147 mOverlayActor->SetDisplayExtent( overExtent );
1148 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1149 // Fix for bug #1882
1150 dynamic_cast<vtkImageSliceMapper *>(mOverlayActor->GetMapper())->SetOrientation(this->GetOrientation());
1154 mOverlayActor->SetVisibility(false);
1156 // Fusion image actor
1157 if (mFusion && mFusionVisibility) {
1158 AdjustResliceToSliceOrientation(mFusionReslice);
1160 #if VTK_MAJOR_VERSION <= 5
1161 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
1162 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
1164 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mFusionReslice->GetOutput(), fusExtent);
1165 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1167 mFusionActor->SetVisibility(!out);
1168 mFusionActor->SetDisplayExtent( fusExtent );
1169 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1170 // Fix for bug #1882
1171 dynamic_cast<vtkImageSliceMapper *>(mFusionActor->GetMapper())->SetOrientation(this->GetOrientation());
1175 mFusionActor->SetVisibility(false);
1176 // Vector field actor
1177 double* camera = Renderer->GetActiveCamera()->GetPosition();
1178 double* image_bounds = ImageActor->GetBounds();
1179 double position[3] = {0, 0, 0};
1180 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
1182 //print_vector<double, 6>("camera", camera);
1183 //print_vector<double, 6>("image_bounds", image_bounds);
1184 //print_vector<double, 3>("position", position);
1186 // find where to place the VF actor. to deal with
1187 // z-buffer issues, the VF is placed right in front of the image,
1188 // subject to a small offset. the position actually depends on the
1189 // the location of the camera relative to the image.
1191 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
1194 if (mVF && mVFVisibility) {
1196 #if VTK_MAJOR_VERSION <= 5
1197 mVF->GetVTKImages()[0]->UpdateInformation();
1198 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
1199 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
1201 mVOIFilter->Update();
1202 this->ConvertImageToImageDisplayExtent(mImageReslice->GetOutputInformation(0), w_ext, mVF->GetVTKImages()[0], vfExtent);
1203 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()));
1205 mVFActor->SetVisibility(!out);
1206 mVOIFilter->SetVOI(vfExtent);
1207 int orientation[3] = {1,1,1};
1208 orientation[this->SliceOrientation] = 0;
1209 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
1210 position[this->SliceOrientation] += offset;
1211 mVFActor->SetPosition(position);
1212 mVFActor->GetProperty()->SetOpacity(0.995); //in order to get VTK to turn on the alpha-blending in OpenGL
1213 mVFMapper->Update();
1217 mVFActor->SetVisibility(false);
1221 for(unsigned int i=0; i<6; i++)
1222 boundsT[i] = ImageActor->GetBounds()[i];
1223 boundsT[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1224 boundsT[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1233 position[this->SliceOrientation] = offset;
1234 mLandActor->SetPosition(position);
1237 // Figure out the correct clipping range
1238 if (this->Renderer) {
1239 if (this->InteractorStyle &&
1240 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
1241 this->Renderer->ResetCameraClippingRange();
1243 vtkCamera *cam = this->Renderer->GetActiveCamera();
1246 this->ImageActor->GetBounds(bounds);
1247 double spos = (double)bounds[this->SliceOrientation * 2];
1248 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
1249 double range = fabs(spos - cpos);
1250 double *spacing = input->GetSpacing();
1251 double sumSpacing = spacing[0] + spacing[1] + spacing[2];
1252 cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
1262 emit UpdateDisplayExtentEnd(mSlicerNumber);
1264 //----------------------------------------------------------------------------
1266 //----------------------------------------------------------------------------
1267 void vvSlicer::ConvertImageToImageDisplayExtent(vtkInformation *sourceImage, const int sourceExtent[6],
1268 vtkImageData *targetImage, int targetExtent[6])
1271 double *origin, *spacing;
1272 origin = sourceImage->Get(vtkDataObject::ORIGIN());
1273 spacing = sourceImage->Get(vtkDataObject::SPACING());
1274 for(unsigned int i=0; i<6; i++) {
1275 // From source voxel coordinates to world coordinates
1276 dExtents[i] = origin[i/2] + spacing[i/2] * sourceExtent[i];
1278 // From world coordinates to floating point target voxel coordinates
1279 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1281 // Round to current slice or larger extent
1282 if(i/2==this->GetOrientation())
1283 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1285 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1287 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1290 //----------------------------------------------------------------------------
1292 //----------------------------------------------------------------------------
1293 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
1294 vtkImageData *targetImage, int targetExtent[6])
1297 for(unsigned int i=0; i<6; i++) {
1298 // From source voxel coordinates to world coordinates
1299 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
1301 // From world coordinates to floating point target voxel coordinates
1302 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1304 // Round to current slice or larger extent
1305 if(i/2==this->GetOrientation())
1306 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1308 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1310 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1313 //----------------------------------------------------------------------------
1315 //----------------------------------------------------------------------------
1316 bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
1321 for (int i = 0; i < maxBound; i = i+2) {
1322 //if we are totally outside the image
1323 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
1327 //crop to the limit of the image
1328 extent[i] = std::max(extent[i], refExtent[i]);
1329 extent[i] = std::min(extent[i], refExtent[i+1]);;
1330 extent[i+1] = std::max(extent[i+1], refExtent[i]);
1331 extent[i+1] = std::min(extent[i+1], refExtent[i+1]);;
1334 for (int i = 0; i < maxBound; i = i+2) {
1335 extent[i] = refExtent[i];
1336 extent[i+1] = refExtent[i];
1340 //----------------------------------------------------------------------------
1343 //----------------------------------------------------------------------------
1344 void vvSlicer::UpdateOrientation()
1346 // Set the camera position
1347 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1349 switch (this->SliceOrientation) {
1350 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1351 cam->SetFocalPoint(0,0,0);
1352 cam->SetPosition(0,0,-1); // -1 if medical ?
1353 cam->SetViewUp(0,-1,0);
1356 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1357 cam->SetFocalPoint(0,0,0);
1358 cam->SetPosition(0,-1,0); // 1 if medical ?
1359 cam->SetViewUp(0,0,1);
1362 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1363 cam->SetFocalPoint(0,0,0);
1364 cam->SetPosition(-1,0,0); // -1 if medical ?
1365 cam->SetViewUp(0,0,1);
1370 //----------------------------------------------------------------------------
1373 //----------------------------------------------------------------------------
1374 void vvSlicer::SetOpacity(double s)
1376 this->GetImageActor()->SetOpacity(s);
1378 //----------------------------------------------------------------------------
1381 //----------------------------------------------------------------------------
1382 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1384 this->Superclass::SetRenderWindow(rw);
1385 this->SetupInteractor(rw->GetInteractor());
1386 ca->SetImageActor(this->GetImageActor());
1387 ca->SetWindowLevel(this->GetWindowLevel());
1388 ca->SetText(3, "<window>\n<level>");
1399 crossCursor->SetModelBounds(bounds);
1401 this->GetRenderer()->AddActor(pdmA);
1402 this->GetRenderer()->AddActor(ca);
1403 this->GetRenderer()->ResetCamera();
1405 //this is just a mapping between the labeling of the orientations presented to the user and
1406 //the one used by vtk
1407 SetSliceOrientation(2-(orientation%3));
1410 //----------------------------------------------------------------------------
1413 //----------------------------------------------------------------------------
1414 void vvSlicer::ResetCamera()
1416 this->GetRenderer()->ResetCamera();
1418 //----------------------------------------------------------------------------
1421 //----------------------------------------------------------------------------
1422 void vvSlicer::SetDisplayMode(bool i)
1424 this->GetRenderer()->SetDraw(i);
1425 if (i) UpdateDisplayExtent();
1427 //----------------------------------------------------------------------------
1430 //----------------------------------------------------------------------------
1431 void vvSlicer::FlipHorizontalView()
1433 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1435 double *position = cam->GetPosition();
1436 double factor[3] = {1, 1, 1};
1437 factor[this->SliceOrientation] = -1;
1438 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1440 /* switch (this->SliceOrientation) {
1441 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1442 cam->SetPosition(position[0],position[1],-position[2]);
1445 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1446 cam->SetPosition(position[0],-position[1],position[2]);
1449 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1450 cam->SetPosition(-position[0],position[1],position[2]);
1454 this->Renderer->ResetCameraClippingRange();
1455 this->UpdateDisplayExtent();
1458 //----------------------------------------------------------------------------
1461 //----------------------------------------------------------------------------
1462 void vvSlicer::FlipVerticalView()
1464 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1466 FlipHorizontalView();
1467 double *viewup = cam->GetViewUp();
1468 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1469 this->UpdateDisplayExtent();
1472 //----------------------------------------------------------------------------
1475 //----------------------------------------------------------------------------
1476 void vvSlicer::SetColorWindow(double window)
1478 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1480 double level = this->GetWindowLevel()->GetLevel();
1481 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1484 this->vtkImageViewer2::SetColorWindow(window);
1486 //----------------------------------------------------------------------------
1488 //----------------------------------------------------------------------------
1489 void vvSlicer::SetColorLevel(double level)
1491 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1493 double window = this->GetWindowLevel()->GetWindow();
1494 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1497 this->vtkImageViewer2::SetColorLevel(level);
1499 //----------------------------------------------------------------------------
1501 //----------------------------------------------------------------------------
1502 double vvSlicer::GetOverlayColorWindow()
1505 return mOverlayMapper->GetWindow();
1509 //----------------------------------------------------------------------------
1511 //----------------------------------------------------------------------------
1512 double vvSlicer::GetOverlayColorLevel()
1515 return mOverlayMapper->GetLevel();
1519 //----------------------------------------------------------------------------
1521 //----------------------------------------------------------------------------
1522 void vvSlicer::SetOverlayColorWindow(double window)
1525 mOverlayMapper->SetWindow(window);
1527 //----------------------------------------------------------------------------
1529 //----------------------------------------------------------------------------
1530 void vvSlicer::SetOverlayColorLevel(double level)
1533 mOverlayMapper->SetLevel(level);
1535 //----------------------------------------------------------------------------
1537 //----------------------------------------------------------------------------
1538 // Returns the min an the max value in a 20%x20% region around the mouse pointer
1539 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1541 //Get mouse pointer position in view coordinates
1544 for(int i=0; i<3; i++) {
1545 corner1[i] = mCurrent[i];
1546 corner2[i] = mCurrent[i];
1549 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1550 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1552 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1554 this->Renderer->GetTiledSize(&w, &h);
1555 corner1[0] -= 0.2*h/(double)w;
1556 corner2[0] += 0.2*h/(double)w;
1559 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1560 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1562 //Convert to image pixel coordinates (rounded)
1563 transform->TransformPoint(corner1, corner1);
1564 transform->TransformPoint(corner2, corner2);
1565 int iLocalExtents[6];
1566 for(int i=0; i<3; i++) {
1567 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1568 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1570 iLocalExtents[i*2 ] = lrint(corner1[i]);
1571 iLocalExtents[i*2+1] = lrint(corner2[i]);
1573 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1574 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1576 #if VTK_MAJOR_VERSION > 5
1577 for(int j=0;j<2; j++) {
1578 if(iLocalExtents[i*2+j]< mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i])
1579 iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i];
1581 if(iLocalExtents[i*2+j]> mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1])
1582 iLocalExtents[i*2+j] = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT())[2*i+1];
1587 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1588 #if VTK_MAJOR_VERSION <= 5
1589 voiFilter->SetInput(image);
1591 voiFilter->SetInputData(image);
1593 voiFilter->SetVOI(iLocalExtents);
1594 voiFilter->Update();
1595 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1601 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1602 #if VTK_MAJOR_VERSION <= 5
1603 accFilter->SetInput(voiFilter->GetOutput());
1605 accFilter->SetInputConnection(voiFilter->GetOutputPort(0));
1607 accFilter->Update();
1609 min = *(accFilter->GetMin());
1610 max = *(accFilter->GetMax());
1612 //----------------------------------------------------------------------------
1614 //----------------------------------------------------------------------------
1615 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1620 #if VTK_MAJOR_VERSION <= 5
1621 if (ix < image->GetWholeExtent()[0] ||
1622 ix > image->GetWholeExtent()[1] ||
1623 iy < image->GetWholeExtent()[2] ||
1624 iy > image->GetWholeExtent()[3] ||
1625 iz < image->GetWholeExtent()[4] ||
1626 iz > image->GetWholeExtent()[5] )
1627 return std::numeric_limits<double>::quiet_NaN();
1628 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1631 if (ix < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] ||
1632 ix > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] ||
1633 iy < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] ||
1634 iy > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] ||
1635 iz < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] ||
1636 iz > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5] )
1637 return std::numeric_limits<double>::quiet_NaN();
1638 //image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1641 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1643 //----------------------------------------------------------------------------
1645 //----------------------------------------------------------------------------
1646 void vvSlicer::Render()
1648 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1649 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1650 legend->UseOpacityOn();
1651 legend->SetVisibility(1);
1653 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1654 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1655 legend->UseOpacityOff();
1656 legend->SetVisibility(1);
1657 } else legend->SetVisibility(0);
1659 if (ca->GetVisibility()) {
1660 std::stringstream worldPos(" ");
1662 mConcatenatedTransform->TransformPoint(mCurrent, pt);
1663 double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
1664 double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
1665 double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
1666 #if VTK_MAJOR_VERSION <= 5
1667 if (X >= this->GetInput()->GetWholeExtent()[0]-0.5 &&
1668 X <= this->GetInput()->GetWholeExtent()[1]+0.5 &&
1669 Y >= this->GetInput()->GetWholeExtent()[2]-0.5 &&
1670 Y <= this->GetInput()->GetWholeExtent()[3]+0.5 &&
1671 Z >= this->GetInput()->GetWholeExtent()[4]-0.5 &&
1672 Z <= this->GetInput()->GetWholeExtent()[5]+0.5) {
1674 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 &&
1675 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 &&
1676 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 &&
1677 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 &&
1678 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 &&
1679 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) {
1682 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1683 if(ImageActor->GetVisibility())
1684 worldPos << "data value : " << value << std::endl;
1685 worldPos << "mm : " << lrint(mCurrent[0]) << ' '
1686 << lrint(mCurrent[1]) << ' '
1687 << lrint(mCurrent[2]) << ' '
1690 worldPos << "pixel : " << ix << ' '
1697 ca->SetText(1,worldPos.str().c_str());
1699 std::stringstream slicePos;
1700 slicePos << "Slice: " << this->GetSlice();
1701 ca->SetText(2, slicePos.str().c_str());
1704 if (pdmA->GetVisibility()) {
1705 double x = mCursor[0];
1706 double y = mCursor[1];
1707 double z = mCursor[2];
1708 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1709 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1710 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1711 #if VTK_MAJOR_VERSION <= 5
1712 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
1713 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
1714 yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
1715 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+0.5 &&
1716 zCursor >= this->GetImageActor()->GetDisplayExtent()[4]-0.5 &&
1717 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+0.5 ) {
1718 vtkRenderer * renderer = this->Renderer;
1720 renderer->WorldToView(x,y,z);
1721 renderer->ViewToNormalizedViewport(x,y,z);
1722 renderer->NormalizedViewportToViewport(x,y);
1723 renderer->ViewportToNormalizedDisplay(x,y);
1724 renderer->NormalizedDisplayToDisplay(x,y);
1725 crossCursor->SetFocalPoint(x,y,z);
1727 crossCursor->SetFocalPoint(-1,-1,z);
1728 crossCursor->Update();
1731 vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
1733 mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
1734 } catch (const std::bad_cast& e) {
1735 std::cerr << e.what() << std::endl;
1736 std::cerr << "Conversion error" << std::endl;
1740 if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 &&
1741 xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 &&
1742 yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 &&
1743 yCursor < mapperOpenGL->GetCroppingRegion()[3]+0.5 &&
1744 zCursor >= mapperOpenGL->GetCroppingRegion()[4]-0.5 &&
1745 zCursor < mapperOpenGL->GetCroppingRegion()[5]+0.5 ) {
1746 vtkRenderer * renderer = this->Renderer;
1748 renderer->WorldToView(x,y,z);
1749 renderer->ViewToNormalizedViewport(x,y,z);
1750 renderer->NormalizedViewportToViewport(x,y);
1751 renderer->ViewportToNormalizedDisplay(x,y);
1752 renderer->NormalizedDisplayToDisplay(x,y);
1753 crossCursor->SetFocalPoint(x,y,z);
1755 crossCursor->SetFocalPoint(-1,-1,z);
1756 crossCursor->Update();
1760 if (mOverlay && mOverlayActor->GetVisibility()) {
1761 if(mLinkOverlayWindowLevel) {
1762 mOverlayMapper->SetWindow(this->GetColorWindow());
1763 mOverlayMapper->SetLevel(this->GetColorLevel());
1765 #if VTK_MAJOR_VERSION <= 5
1766 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1768 mOverlayMapper->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1770 mOverlayMapper->Update();
1772 if (mFusion && mFusionActor->GetVisibility()) {
1773 #if VTK_MAJOR_VERSION <= 5
1774 mFusionMapper->GetOutput()->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1776 mFusionMapper->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1778 mFusionMapper->Update();
1785 this->GetRenderWindow()->Render();
1787 //----------------------------------------------------------------------------
1790 //----------------------------------------------------------------------------
1791 void vvSlicer::UpdateCursorPosition()
1793 pdmA->SetVisibility(true);
1794 mCursor[0] = mCurrent[0];
1795 mCursor[1] = mCurrent[1];
1796 mCursor[2] = mCurrent[2];
1797 mCursor[3] = mCurrentTSlice;
1799 //----------------------------------------------------------------------------
1802 //----------------------------------------------------------------------------
1803 void vvSlicer::RemoveLandmarks()
1805 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
1806 if (pd->GetPoints()) {
1808 //First remove all captions:
1809 for(unsigned int i=0;i<mLandLabelActors.size();i++) {
1810 this->Renderer->RemoveActor2D(mLandLabelActors[i]);
1811 //allActors2D->Remove (mLandLabelActors[i]);
1813 mLandLabelActors.clear();
1816 //----------------------------------------------------------------------------
1819 //----------------------------------------------------------------------------
1820 void vvSlicer::DisplayLandmarks()
1824 for(unsigned int i=0; i<6; i++)
1825 bounds[i] = ImageActor->GetBounds()[i];
1826 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1827 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1828 mClipBox->SetBounds(bounds);
1831 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandmarks->GetOutput());
1832 if (pd->GetPoints()) {
1833 this->GetRenderer()->AddActor(mLandActor);
1834 //mLandGlyph->SetRange(0,1);
1835 //mLandGlyph->Modified();
1836 //mLandGlyph->Update();
1837 mClipBox->Modified();
1838 mLandClipper->Update();
1839 mLandMapper->Update();
1840 //Next add the captions to the displayed points
1841 for (vtkIdType id=0; id<mLandClipper->GetOutput()->GetNumberOfPoints(); id++) {
1842 double *position = mLandClipper->GetOutput()->GetPoint(id);
1843 vtkStdString label = static_cast<vtkStringArray*>(mLandClipper->GetOutput()->GetPointData()->GetAbstractArray("labels"))->GetValue(id);
1844 vtkSmartPointer<vtkCaptionActor2D> label_actor = vtkSmartPointer<vtkCaptionActor2D>::New();
1845 label_actor->SetCaption(label);
1846 label_actor->SetAttachmentPoint(position);
1847 label_actor->GetCaptionTextProperty()->SetColor(1,0,0);
1848 label_actor->GetCaptionTextProperty()->SetOrientation(33.333333);
1849 label_actor->GetCaptionTextProperty()->SetFontFamilyToTimes();
1850 label_actor->GetCaptionTextProperty()->SetBold(0);
1851 label_actor->GetCaptionTextProperty()->SetFontSize(6);
1852 label_actor->BorderOff();
1853 label_actor->LeaderOff();
1854 label_actor->ThreeDimensionalLeaderOff();
1855 mLandLabelActors.push_back(label_actor);
1856 this->Renderer->AddActor2D(mLandLabelActors[id]);
1861 //----------------------------------------------------------------------------
1864 //----------------------------------------------------------------------------
1865 void vvSlicer::SetSlice(int slice)
1867 int *range = this->GetSliceRange();
1869 if (slice < range[0]) {
1871 } else if (slice > range[1]) {
1876 if (this->Slice == slice) {
1880 this->Slice = slice;
1883 this->UpdateDisplayExtent();
1885 // Seems to work without this line
1888 //----------------------------------------------------------------------------
1890 //----------------------------------------------------------------------------
1891 int vvSlicer::GetTMax()
1893 int tmax = (int)mImage->GetVTKImages().size() - 1;
1895 tmax = std::max(tmax, (int)mOverlay->GetVTKImages().size()-1);
1898 //----------------------------------------------------------------------------
1900 //----------------------------------------------------------------------------
1901 void vvSlicer::SetContourSlice()
1903 if (mSurfaceCutActors.size() > 0)
1904 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1905 i!=mSurfaceCutActors.end(); i++) {
1907 (*i)->SetSlicingOrientation(this->SliceOrientation);
1908 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1909 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1912 //----------------------------------------------------------------------------
1915 //----------------------------------------------------------------------------
1916 void vvSlicer::ForceUpdateDisplayExtent()
1918 this->UpdateDisplayExtent();
1920 //----------------------------------------------------------------------------
1923 //----------------------------------------------------------------------------
1924 int* vvSlicer::GetDisplayExtent()
1926 return this->GetImageActor()->GetDisplayExtent();
1928 //----------------------------------------------------------------------------
1931 //----------------------------------------------------------------------------
1932 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1934 this->Superclass::PrintSelf(os, indent);
1936 //----------------------------------------------------------------------------
1939 //----------------------------------------------------------------------------
1940 void vvSlicer::SetVFColor(double r, double g, double b)
1942 double mVFColorHSV[3];
1947 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1948 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1949 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1950 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
1954 //----------------------------------------------------------------------------
1957 //----------------------------------------------------------------------------
1958 void vvSlicer::SetRegisterExtent(int ext[6])
1960 copyExtent(ext, mRegisterExtent);
1962 //----------------------------------------------------------------------------
1965 //----------------------------------------------------------------------------
1966 void vvSlicer::GetRegisterExtent(int ext[6])
1968 copyExtent(mRegisterExtent, ext);
1970 //----------------------------------------------------------------------------