1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
21 #include "vvSlicerManagerCommand.h"
22 #include "vvGlyphSource.h"
23 #include "vvGlyph2D.h"
24 #include "vvImageMapToWLColors.h"
26 #include <vtkTextProperty.h>
27 #include <vtkTextActor.h>
28 #include <vtkTextSource.h>
29 #include <vtkActor2D.h>
30 #include <vtkCursor2D.h>
31 #include <vtkPolyDataMapper2D.h>
32 #include <vtkProperty2D.h>
33 #include <vtkCornerAnnotation.h>
34 #include <vtkImageMapToWindowLevelColors.h>
35 #include <vtkImageData.h>
36 #include <vtkImageActor.h>
37 #include <vvBlendImageActor.h>
38 #include <vtkToolkits.h>
39 #include <vtkObjectFactory.h>
40 #include <vtkPointData.h>
41 #include <vtkDataArray.h>
42 #include <vtkFloatArray.h>
43 #include <vtkClipPolyData.h>
44 #include <vtkGlyph3D.h>
46 #include <vtkCursor3D.h>
47 #include <vtkProperty.h>
49 #include <vtkLightCollection.h>
50 #include <vtkScalarBarActor.h>
51 #include <vtkLookupTable.h>
53 #include <vtkRenderer.h>
54 #include <vtkRendererCollection.h>
55 #include <vtkRenderWindow.h>
56 #include <vtkRenderWindowInteractor.h>
57 #include <vtkCamera.h>
58 #include <vtkCallbackCommand.h>
59 #include <vtkCommand.h>
60 #include <vtkPolyDataMapper.h>
63 #include <vtkExtractVOI.h>
64 #include <vtkSphereSource.h>
65 #include <vtkCutter.h>
66 #include <vtkAssignAttribute.h>
67 #include <vtkImageAccumulate.h>
68 #include <vtkImageReslice.h>
69 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
70 # include <vtkImageMapper3D.h>
73 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
74 vtkStandardNewMacro(vvSlicer);
75 static void copyExtent(int* in, int* to){
76 for(int i=0; i<6; ++i) to[i]=in[i];
78 //------------------------------------------------------------------------------
81 this->UnInstallPipeline();
83 mReducedExtent = new int[6];
85 mUseReducedExtent = false;
87 mCurrent[0] = -VTK_DOUBLE_MAX;
88 mCurrent[1] = -VTK_DOUBLE_MAX;
89 mCurrent[2] = -VTK_DOUBLE_MAX;
91 mCursor[0] = -VTK_DOUBLE_MAX;
92 mCursor[1] = -VTK_DOUBLE_MAX;
93 mCursor[2] = -VTK_DOUBLE_MAX;
94 mCursor[3] = -VTK_DOUBLE_MAX;
104 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
105 crossCursor->AllOff();
106 crossCursor->AxesOn();
107 crossCursor->SetTranslationMode(1);
108 crossCursor->SetRadius(2);
110 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
111 pdm->SetInput(crossCursor->GetOutput());
113 pdmA = vtkSmartPointer<vtkActor2D>::New();
114 pdmA->SetMapper(pdm);
115 pdmA->GetProperty()->SetColor(255,10,212);
116 pdmA->SetVisibility(0);
117 pdmA->SetPickable(0);
119 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
120 ca->GetTextProperty()->SetColor(255,10,212);
121 ca->SetVisibility(1);
129 legend = vtkSmartPointer<vtkScalarBarActor>::New();
130 //legend->SetTitle("test!");
131 legend->SetPosition(0.82,0.18);
132 legend->SetWidth(0.1);
133 legend->SetVisibility(0);
134 legend->SetLabelFormat("%.1f");
135 this->GetRenderer()->AddActor(legend);
136 showFusionLegend = false;
138 this->WindowLevel->Delete();
139 this->WindowLevel = vvImageMapToWLColors::New();
141 this->InstallPipeline();
143 mLinkOverlayWindowLevel = true;
145 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
146 this->GetImageActor()->GetMapper()->BorderOn();
149 mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
150 mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
152 //------------------------------------------------------------------------------
155 //------------------------------------------------------------------------------
156 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
158 return mOverlayMapper.GetPointer();
160 //------------------------------------------------------------------------------
163 //------------------------------------------------------------------------------
164 vvBlendImageActor* vvSlicer::GetOverlayActor()
166 return mOverlayActor.GetPointer();
168 //------------------------------------------------------------------------------
171 //------------------------------------------------------------------------------
172 vtkImageMapToColors* vvSlicer::GetFusionMapper()
174 return mFusionMapper.GetPointer();
176 //------------------------------------------------------------------------------
179 //------------------------------------------------------------------------------
180 vtkImageActor* vvSlicer::GetFusionActor()
182 return mFusionActor.GetPointer();
184 //------------------------------------------------------------------------------
187 //------------------------------------------------------------------------------
188 vtkActor* vvSlicer::GetVFActor()
190 return mVFActor.GetPointer();
192 //------------------------------------------------------------------------------
195 //------------------------------------------------------------------------------
196 vtkCornerAnnotation* vvSlicer::GetAnnotation()
198 return ca.GetPointer();
200 //------------------------------------------------------------------------------
203 //------------------------------------------------------------------------------
204 void vvSlicer::EnableReducedExtent(bool b)
206 mUseReducedExtent = b;
208 //------------------------------------------------------------------------------
211 //------------------------------------------------------------------------------
212 void vvSlicer::SetReducedExtent(int * ext)
214 copyExtent(ext, mReducedExtent);
216 //------------------------------------------------------------------------------
219 //------------------------------------------------------------------------------
220 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
223 mSurfaceCutActors.push_back(new vvMeshActor());
225 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
227 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
228 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
229 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
233 //------------------------------------------------------------------------------
236 //------------------------------------------------------------------------------
237 void vvSlicer::ToggleContourSuperposition()
239 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
240 i!=mSurfaceCutActors.end(); i++)
241 (*i)->ToggleSuperposition();
243 //------------------------------------------------------------------------------
246 //------------------------------------------------------------------------------
247 void vvSlicer::SetCursorColor(int r,int g, int b)
249 pdmA->GetProperty()->SetColor(r,g,b);
251 //------------------------------------------------------------------------------
254 //------------------------------------------------------------------------------
255 void vvSlicer::SetCursorVisibility(bool s)
257 pdmA->SetVisibility(s);
259 //------------------------------------------------------------------------------
262 //------------------------------------------------------------------------------
263 bool vvSlicer::GetCursorVisibility()
265 return pdmA->GetVisibility();
267 //------------------------------------------------------------------------------
270 //------------------------------------------------------------------------------
271 void vvSlicer::SetCornerAnnotationVisibility(bool s)
273 ca->SetVisibility(s);
275 //------------------------------------------------------------------------------
278 //------------------------------------------------------------------------------
279 bool vvSlicer::GetCornerAnnotationVisibility()
281 return ca->GetVisibility();
283 //------------------------------------------------------------------------------
286 //------------------------------------------------------------------------------
287 vvSlicer::~vvSlicer()
289 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
290 i!=mSurfaceCutActors.end(); i++)
292 delete [] mReducedExtent;
294 //------------------------------------------------------------------------------
296 //------------------------------------------------------------------------------
297 double* vvSlicer::GetCurrentPosition()
299 return mCurrentBeforeSlicingTransform;
301 //------------------------------------------------------------------------------
303 //------------------------------------------------------------------------------
304 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
306 mCurrentBeforeSlicingTransform[0]=x;
307 mCurrentBeforeSlicingTransform[1]=y;
308 mCurrentBeforeSlicingTransform[2]=z;
309 mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
312 //------------------------------------------------------------------------------
315 //------------------------------------------------------------------------------
316 void vvSlicer::SetImage(vvImage::Pointer image)
318 if (image->GetVTKImages().size()) {
321 if (!mImageReslice) {
322 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
323 mImageReslice->SetInterpolationModeToLinear();
324 mImageReslice->AutoCropOutputOn();
325 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
328 mConcatenatedTransform->Identity();
329 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
330 mConcatenatedTransform->Concatenate(mSlicingTransform);
331 mImageReslice->SetResliceTransform(mConcatenatedTransform);
332 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
333 mImageReslice->UpdateInformation();
335 this->Superclass::SetInput(mImageReslice->GetOutput());
338 this->GetInput()->GetWholeExtent(extent);
340 // Prevent crash when reload -> change slice if outside extent
341 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
342 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
345 // Make sure that the required part image has been computed
346 extent[SliceOrientation*2] = Slice;
347 extent[SliceOrientation*2+1] = Slice;
348 mImageReslice->GetOutput()->SetUpdateExtent(extent);
349 mImageReslice->GetOutput()->Update();
351 this->UpdateDisplayExtent();
354 ca->SetText(0,mFileName.c_str());
357 //------------------------------------------------------------------------------
360 //------------------------------------------------------------------------------
361 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
363 if (overlay->GetVTKImages().size()) {
366 if (!mOverlayReslice) {
367 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
368 mOverlayReslice->SetInterpolationModeToLinear();
369 mOverlayReslice->AutoCropOutputOn();
370 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
372 mOverlayReslice->SetResliceTransform(mOverlay->GetTransform()[0]);
373 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
376 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
377 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
379 if (!mOverlayActor) {
380 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
381 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
382 mOverlayActor->SetPickable(0);
383 mOverlayActor->SetVisibility(true);
384 mOverlayActor->SetOpacity(0.5);
385 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
386 mOverlayActor->GetMapper()->BorderOn();
390 //stupid but necessary : the Overlay need to be rendered before fusion
392 this->GetRenderer()->RemoveActor(mFusionActor);
393 this->GetRenderer()->AddActor(mOverlayActor);
394 this->GetRenderer()->AddActor(mFusionActor);
396 this->GetRenderer()->AddActor(mOverlayActor);
398 //Synchronize orientation and slice
399 AdjustResliceToSliceOrientation(mOverlayReslice);
400 this->UpdateDisplayExtent();
401 this->SetTSlice(mCurrentTSlice);
404 //------------------------------------------------------------------------------
407 //------------------------------------------------------------------------------
408 void vvSlicer::SetFusion(vvImage::Pointer fusion)
410 if (fusion->GetVTKImages().size()) {
413 if (!mFusionReslice) {
414 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
415 mFusionReslice->SetInterpolationModeToLinear();
416 mFusionReslice->AutoCropOutputOn();
417 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
419 mFusionReslice->SetResliceTransform(mFusion->GetTransform()[0]);
420 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
423 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
425 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
427 lut->SetValueRange(0, 1);
428 lut->SetSaturationRange(0, 0);
430 mFusionMapper->SetLookupTable(lut);
431 mFusionMapper->SetInput(mFusionReslice->GetOutput());
434 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
435 mFusionActor->SetInput(mFusionMapper->GetOutput());
436 mFusionActor->SetPickable(0);
437 mFusionActor->SetVisibility(true);
438 mFusionActor->SetOpacity(0.7);
439 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
440 mFusionActor->GetMapper()->BorderOn();
442 this->GetRenderer()->AddActor(mFusionActor);
445 //Synchronize orientation and slice
446 AdjustResliceToSliceOrientation(mFusionReslice);
447 this->UpdateDisplayExtent();
448 this->SetTSlice(mCurrentTSlice);
451 //------------------------------------------------------------------------------
454 //------------------------------------------------------------------------------
455 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
458 if (actor_type == "image") {
459 vis = this->ImageActor->GetVisibility();
461 else if (actor_type == "vector") {
462 vis = this->mVFActor->GetVisibility();
464 else if (actor_type == "overlay") {
465 vis = this->mOverlayActor->GetVisibility();
467 else if (actor_type == "fusion") {
468 vis = this->mFusionActor->GetVisibility();
470 else if (actor_type == "contour")
471 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
475 //------------------------------------------------------------------------------
477 //------------------------------------------------------------------------------
478 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
480 if (actor_type == "image") {
481 this->ImageActor->SetVisibility(vis);
483 else if (actor_type == "vector") {
484 this->mVFActor->SetVisibility(vis);
486 else if (actor_type == "overlay") {
487 this->mOverlayActor->SetVisibility(vis);
489 else if (actor_type == "fusion") {
490 this->mFusionActor->SetVisibility(vis);
492 else if (actor_type == "contour")
493 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
494 UpdateDisplayExtent();
496 //------------------------------------------------------------------------------
498 //------------------------------------------------------------------------------
499 void vvSlicer::SetVF(vvImage::Pointer vf)
501 if (vf->GetVTKImages().size()) {
505 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
506 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
507 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
509 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
510 mAAFilter->SetInput(mVOIFilter->GetOutput());
511 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
512 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
515 mArrow = vtkSmartPointer<vvGlyphSource>::New();
516 mArrow->SetGlyphTypeToSpecificArrow();
517 mArrow->SetScale(mScale);
520 // Glyph the gradient vector (with arrows)
522 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
523 mGlyphFilter->SetInput(mAAFilter->GetOutput());
524 mGlyphFilter->SetSource(mArrow->GetOutput());
525 mGlyphFilter->ScalingOn();
526 mGlyphFilter->SetScaleModeToScaleByVector();
527 mGlyphFilter->OrientOn();
528 mGlyphFilter->SetVectorModeToUseVector();
529 mGlyphFilter->SetColorModeToColorByVector();
532 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
534 double mVFColorHSV[3];
535 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
536 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
537 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
538 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
541 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
542 mVFMapper->SetInput(mGlyphFilter->GetOutput());
543 mVFMapper->ImmediateModeRenderingOn();
544 mVFMapper->SetLookupTable(mVFColorLUT);
547 mVFActor = vtkSmartPointer<vtkActor>::New();
548 mVFActor->SetMapper(mVFMapper);
549 mVFActor->SetPickable(0);
550 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
551 this->UpdateDisplayExtent();
552 this->GetRenderer()->AddActor(mVFActor);
555 SetTSlice(mCurrentTSlice);
558 //------------------------------------------------------------------------------
561 //------------------------------------------------------------------------------
562 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
564 mLandmarks = landmarks;
568 mCross = vtkSmartPointer<vtkCursor3D>::New();
569 mCross->SetFocalPoint(0.0,0.0,0.0);
570 mCross->SetModelBounds(-10,10,-10,10,-10,10);
575 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
576 mLandGlyph->SetSource(mCross->GetOutput());
577 mLandGlyph->SetInput(landmarks->GetOutput());
578 //mLandGlyph->SetIndexModeToScalar();
579 mLandGlyph->SetRange(0,1);
580 mLandGlyph->ScalingOff();
582 mLandGlyph->SetColorModeToColorByScalar();
585 mClipBox = vtkSmartPointer<vtkBox>::New();
587 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
588 mLandClipper->InsideOutOn();
589 mLandClipper->SetInput(mLandGlyph->GetOutput());
590 mLandClipper->SetClipFunction(mClipBox);
593 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
594 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
595 //mLandMapper->ScalarVisibilityOff();
598 mLandActor = vtkSmartPointer<vtkActor>::New();
599 mLandActor->SetMapper(mLandMapper);
600 mLandActor->GetProperty()->SetColor(255,10,212);
601 mLandActor->SetPickable(0);
602 mLandActor->SetVisibility(true);
603 this->UpdateDisplayExtent();
604 this->GetRenderer()->AddActor(mLandActor);
607 //------------------------------------------------------------------------------
609 //------------------------------------------------------------------------------
610 //FIXME: this function leaks memory, we should fix it someday :)
611 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
613 if (actor_type == "vector") {
614 Renderer->RemoveActor(mVFActor);
623 if (actor_type == "overlay") {
624 Renderer->RemoveActor(mOverlayActor);
626 mOverlayActor = NULL;
627 mOverlayMapper = NULL;
629 if (actor_type == "fusion") {
630 Renderer->RemoveActor(mFusionActor);
633 mFusionMapper = NULL;
635 if (actor_type == "contour") {
636 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
637 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
640 //------------------------------------------------------------------------------
643 //------------------------------------------------------------------------------
644 void vvSlicer::SetVFSubSampling(int sub)
647 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
650 UpdateDisplayExtent();
653 //------------------------------------------------------------------------------
656 //------------------------------------------------------------------------------
657 void vvSlicer::SetVFScale(int scale)
661 mArrow->SetScale(mScale);
662 UpdateDisplayExtent();
665 //------------------------------------------------------------------------------
667 //------------------------------------------------------------------------------
668 void vvSlicer::SetVFWidth(int width)
672 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
673 UpdateDisplayExtent();
676 //------------------------------------------------------------------------------
679 //------------------------------------------------------------------------------
680 void vvSlicer::SetVFLog(int log)
684 mGlyphFilter->SetUseLog(mVFLog);
685 mGlyphFilter->Modified();
687 UpdateDisplayExtent();
690 //------------------------------------------------------------------------------
693 //------------------------------------------------------------------------------
694 void vvSlicer::SetTSlice(int t)
698 else if ((unsigned int)t >= mImage->GetVTKImages().size())
699 t = mImage->GetVTKImages().size() -1;
702 mConcatenatedTransform->Identity();
703 mConcatenatedTransform->Concatenate(mImage->GetTransform()[t]);
704 mConcatenatedTransform->Concatenate(mSlicingTransform);
708 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
709 if (mVF && mVFActor->GetVisibility()) {
710 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
711 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
713 if (mOverlay && mOverlayActor->GetVisibility()) {
714 if (mOverlay->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
715 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentTSlice] );
717 if (mFusion && mFusionActor->GetVisibility()) {
718 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
719 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentTSlice]);
721 if (mSurfaceCutActors.size() > 0)
722 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
723 i!=mSurfaceCutActors.end(); i++)
724 (*i)->SetTimeSlice(mCurrentTSlice);
725 UpdateDisplayExtent();
727 //------------------------------------------------------------------------------
730 //------------------------------------------------------------------------------
731 int vvSlicer::GetTSlice()
733 return mCurrentTSlice;
735 //------------------------------------------------------------------------------
737 //------------------------------------------------------------------------------
738 void vvSlicer::SetSliceOrientation(int orientation)
740 //if 2D image, force to watch in Axial View
742 this->GetInput()->GetWholeExtent(extent);
743 if (extent[5]-extent[4] <= 2)
744 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
746 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
747 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
748 vtkErrorMacro("Error - invalid slice orientation " << orientation);
752 this->SliceOrientation = orientation;
755 AdjustResliceToSliceOrientation(mFusionReslice);
758 AdjustResliceToSliceOrientation(mOverlayReslice);
761 int *range = this->GetSliceRange();
763 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
765 // Go to current cursor position
766 // double* cursorPos = GetCursorPosition();
767 // DDV(cursorPos, 3);
768 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
770 this->UpdateOrientation();
771 this->UpdateDisplayExtent();
773 if (this->Renderer && this->GetInput()) {
774 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
775 this->Renderer->ResetCamera();
776 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
781 //----------------------------------------------------------------------------
783 //------------------------------------------------------------------------------
784 // This function ensures that we sample the slices of a vtkImageReslice filter
785 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
786 // In other words, we change the grid of the reslice in the same way as the grid
787 // of the displayed image in the slicing direction.
788 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
790 // Reset autocrop and update output information
791 reslice->SetOutputOriginToDefault();
792 reslice->SetOutputSpacingToDefault();
793 reslice->GetOutput()->UpdateInformation();
795 // Ge new origin / spacing
798 reslice->GetOutput()->GetOrigin(origin);
799 reslice->GetOutput()->GetSpacing(spacing);
801 // Use similar spacing as the image in the direction SliceOrientation
802 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
804 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
805 // Step 1: from world coordinates to image coordinates
806 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
807 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
808 // Step 2: round to superior grid positionInc
809 origin[this->SliceOrientation] = itk::Math::Ceil<double>(origin[this->SliceOrientation]);
810 // Step 3: back to world coordinates
811 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
812 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
814 // Set new spacing and origin
815 reslice->SetOutputOrigin(origin);
816 reslice->SetOutputSpacing(spacing);
817 reslice->UpdateInformation();
818 reslice->GetOutput()->UpdateInformation();
820 //------------------------------------------------------------------------------
822 //----------------------------------------------------------------------------
823 int * vvSlicer::GetExtent(){
825 if (mUseReducedExtent) {
826 w_ext = mReducedExtent;
827 } else w_ext = GetInput()->GetWholeExtent();
830 //----------------------------------------------------------------------------
833 //----------------------------------------------------------------------------
834 int vvSlicer::GetOrientation()
836 return this->SliceOrientation;
838 //----------------------------------------------------------------------------
841 //----------------------------------------------------------------------------
842 void vvSlicer::UpdateDisplayExtent()
844 vtkImageData *input = this->GetInput();
845 if (!input || !this->ImageActor) {
848 input->UpdateInformation();
850 // Local copy of extent
852 int* ext = GetExtent();
853 copyExtent(ext, w_ext);
855 int s = this->Slice > ext[this->SliceOrientation*2+1] ? ext[this->SliceOrientation*2 + 1] : this->Slice;
856 w_ext[ this->SliceOrientation*2 ] = s;
857 w_ext[ this->SliceOrientation*2+1 ] = s;
860 this->ImageActor->SetDisplayExtent(w_ext);
862 // Overlay image actor
863 if (mOverlay && mOverlayActor->GetVisibility()) {
864 AdjustResliceToSliceOrientation(mOverlayReslice);
866 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
867 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
868 mOverlayActor->SetDisplayExtent( overExtent );
871 // Fusion image actor
872 if (mFusion && mFusionActor->GetVisibility()) {
873 AdjustResliceToSliceOrientation(mFusionReslice);
875 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
876 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
877 mFusionActor->SetDisplayExtent(fusExtent);
880 // Vector field actor
881 double* camera = Renderer->GetActiveCamera()->GetPosition();
882 double* image_bounds = ImageActor->GetBounds();
883 double position[3] = {0, 0, 0};
884 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
886 //print_vector<double, 6>("camera", camera);
887 //print_vector<double, 6>("image_bounds", image_bounds);
888 //print_vector<double, 3>("position", position);
890 // find where to place the VF actor. to deal with
891 // z-buffer issues, the VF is placed right in front of the image,
892 // subject to a small offset. the position actually depends on the
893 // the location of the camera relative to the image.
895 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
898 if (mVF && mVFActor->GetVisibility()) {
900 mVF->GetVTKImages()[0]->UpdateInformation();
901 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
902 ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
903 mVOIFilter->SetVOI(vfExtent);
904 int orientation[3] = {1,1,1};
905 orientation[this->SliceOrientation] = 0;
906 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
909 position[this->SliceOrientation] += offset;
910 mVFActor->SetPosition(position);
917 for(unsigned int i=0; i<6; i++)
918 bounds[i] = ImageActor->GetBounds()[i];
919 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
920 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
921 mClipBox->SetBounds(bounds);
925 position[this->SliceOrientation] = offset;
926 mLandActor->SetPosition(position);
929 // Figure out the correct clipping range
930 if (this->Renderer) {
931 if (this->InteractorStyle &&
932 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
933 this->Renderer->ResetCameraClippingRange();
935 vtkCamera *cam = this->Renderer->GetActiveCamera();
938 this->ImageActor->GetBounds(bounds);
939 double spos = (double)bounds[this->SliceOrientation * 2];
940 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
941 double range = fabs(spos - cpos);
942 double *spacing = input->GetSpacing();
943 double sumSpacing = spacing[0] + spacing[1] + spacing[2];
944 cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
950 //----------------------------------------------------------------------------
952 //----------------------------------------------------------------------------
953 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
954 vtkImageData *targetImage, int targetExtent[6])
957 for(unsigned int i=0; i<6; i++) {
958 // From source voxel coordinates to world coordinates
959 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
961 // From world coordinates to floating point target voxel coordinates
962 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
965 //targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
966 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
969 //----------------------------------------------------------------------------
971 //----------------------------------------------------------------------------
972 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
977 //2D overlay on 3D image specific case
978 if (refExtent[4] == refExtent[5]) {
980 extent[4] = refExtent[4];
981 extent[5] = refExtent[5];
984 for (int i = 0; i < maxBound; i = i+2) {
985 //if we are totally outside the image
986 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
990 //crop to the limit of the image
991 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
992 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
993 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
994 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
997 for (int i = 0; i < maxBound; i = i+2) {
998 extent[i] = refExtent[i];
999 extent[i+1] = refExtent[i];
1002 //----------------------------------------------------------------------------
1005 //----------------------------------------------------------------------------
1006 void vvSlicer::UpdateOrientation()
1008 // Set the camera position
1009 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1011 switch (this->SliceOrientation) {
1012 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1013 cam->SetFocalPoint(0,0,0);
1014 cam->SetPosition(0,0,-1); // -1 if medical ?
1015 cam->SetViewUp(0,-1,0);
1018 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1019 cam->SetFocalPoint(0,0,0);
1020 cam->SetPosition(0,-1,0); // 1 if medical ?
1021 cam->SetViewUp(0,0,1);
1024 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1025 cam->SetFocalPoint(0,0,0);
1026 cam->SetPosition(-1,0,0); // -1 if medical ?
1027 cam->SetViewUp(0,0,1);
1032 //----------------------------------------------------------------------------
1035 //----------------------------------------------------------------------------
1036 void vvSlicer::SetOpacity(double s)
1038 this->GetImageActor()->SetOpacity(s);
1040 //----------------------------------------------------------------------------
1043 //----------------------------------------------------------------------------
1044 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1046 this->Superclass::SetRenderWindow(rw);
1047 this->SetupInteractor(rw->GetInteractor());
1048 ca->SetImageActor(this->GetImageActor());
1049 ca->SetWindowLevel(this->GetWindowLevel());
1050 ca->SetText(2, "<slice>");
1051 ca->SetText(3, "<window>\n<level>");
1063 crossCursor->SetModelBounds(bounds);
1064 this->GetRenderer()->AddActor(pdmA);
1065 this->GetRenderer()->AddActor(ca);
1066 this->GetRenderer()->ResetCamera();
1068 //this is just a mapping between the labeling of the orientations presented to the user and
1069 //the one used by vtk
1070 SetSliceOrientation(2-(orientation%3));
1073 //----------------------------------------------------------------------------
1076 //----------------------------------------------------------------------------
1077 void vvSlicer::ResetCamera()
1079 this->GetRenderer()->ResetCamera();
1081 //----------------------------------------------------------------------------
1084 //----------------------------------------------------------------------------
1085 void vvSlicer::SetDisplayMode(bool i)
1087 this->GetRenderer()->SetDraw(i);
1089 UpdateDisplayExtent();
1091 //----------------------------------------------------------------------------
1094 //----------------------------------------------------------------------------
1095 void vvSlicer::FlipHorizontalView()
1097 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1099 double *position = cam->GetPosition();
1100 double factor[3] = {1, 1, 1};
1101 factor[this->SliceOrientation] = -1;
1102 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1104 /* switch (this->SliceOrientation) {
1105 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1106 cam->SetPosition(position[0],position[1],-position[2]);
1109 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1110 cam->SetPosition(position[0],-position[1],position[2]);
1113 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1114 cam->SetPosition(-position[0],position[1],position[2]);
1118 this->Renderer->ResetCameraClippingRange();
1119 this->UpdateDisplayExtent();
1122 //----------------------------------------------------------------------------
1125 //----------------------------------------------------------------------------
1126 void vvSlicer::FlipVerticalView()
1128 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1130 FlipHorizontalView();
1131 double *viewup = cam->GetViewUp();
1132 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1133 this->UpdateDisplayExtent();
1136 //----------------------------------------------------------------------------
1139 //----------------------------------------------------------------------------
1140 void vvSlicer::SetColorWindow(double window)
1142 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1144 double level = this->GetWindowLevel()->GetLevel();
1145 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1148 this->vtkImageViewer2::SetColorWindow(window);
1150 //----------------------------------------------------------------------------
1152 //----------------------------------------------------------------------------
1153 void vvSlicer::SetColorLevel(double level)
1155 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1157 double window = this->GetWindowLevel()->GetWindow();
1158 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1161 this->vtkImageViewer2::SetColorLevel(level);
1163 //----------------------------------------------------------------------------
1165 //----------------------------------------------------------------------------
1166 double vvSlicer::GetOverlayColorWindow()
1169 return mOverlayMapper->GetWindow();
1173 //----------------------------------------------------------------------------
1175 //----------------------------------------------------------------------------
1176 double vvSlicer::GetOverlayColorLevel()
1179 return mOverlayMapper->GetLevel();
1183 //----------------------------------------------------------------------------
1185 //----------------------------------------------------------------------------
1186 void vvSlicer::SetOverlayColorWindow(double window)
1188 mOverlayMapper->SetWindow(window);
1190 //----------------------------------------------------------------------------
1192 //----------------------------------------------------------------------------
1193 void vvSlicer::SetOverlayColorLevel(double level)
1195 mOverlayMapper->SetLevel(level);
1197 //----------------------------------------------------------------------------
1199 //----------------------------------------------------------------------------
1200 // Returns the min an the max value in a 41x41 region around the mouse pointer
1201 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1203 //Get mouse pointer position in view coordinates
1206 for(int i=0; i<3; i++) {
1207 corner1[i] = mCurrent[i];
1208 corner2[i] = mCurrent[i];
1211 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1212 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1214 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1216 this->Renderer->GetTiledSize(&w, &h);
1217 corner1[0] -= 0.2*h/(double)w;
1218 corner2[0] += 0.2*h/(double)w;
1221 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1222 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1224 //Convert to image pixel coordinates (rounded)
1225 transform->TransformPoint(corner1, corner1);
1226 transform->TransformPoint(corner2, corner2);
1227 int iLocalExtents[6];
1228 for(int i=0; i<3; i++) {
1229 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1230 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1232 iLocalExtents[i*2 ] = lrint(corner1[i]);
1233 iLocalExtents[i*2+1] = lrint(corner2[i]);
1235 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1236 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1239 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1240 voiFilter->SetInput(image);
1241 voiFilter->SetVOI(iLocalExtents);
1242 voiFilter->Update();
1243 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1249 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1250 accFilter->SetInput(voiFilter->GetOutput());
1251 accFilter->Update();
1253 min = *(accFilter->GetMin());
1254 max = *(accFilter->GetMax());
1256 //----------------------------------------------------------------------------
1258 //----------------------------------------------------------------------------
1259 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1264 if (ix < image->GetWholeExtent()[0] ||
1265 ix > image->GetWholeExtent()[1] ||
1266 iy < image->GetWholeExtent()[2] ||
1267 iy > image->GetWholeExtent()[3] ||
1268 iz < image->GetWholeExtent()[4] ||
1269 iz > image->GetWholeExtent()[5] )
1270 return std::numeric_limits<double>::quiet_NaN();
1272 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1274 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1276 //----------------------------------------------------------------------------
1278 //----------------------------------------------------------------------------
1279 void vvSlicer::Render()
1281 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1282 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1283 legend->UseOpacityOn();
1284 legend->SetVisibility(1);
1286 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1287 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1288 legend->UseOpacityOff();
1289 legend->SetVisibility(1);
1290 } else legend->SetVisibility(0);
1292 if (ca->GetVisibility()) {
1293 std::stringstream worldPos;
1295 mConcatenatedTransform->TransformPoint(mCurrent, pt);
1296 double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
1297 double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
1298 double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
1300 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
1301 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
1302 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
1303 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
1304 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
1305 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
1309 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1311 if(ImageActor->GetVisibility())
1312 worldPos << "data value : " << value << std::endl;
1314 worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
1315 << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
1316 << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
1319 worldPos << "pixel : " << ix << ' '
1325 ca->SetText(1,worldPos.str().c_str());
1328 if (pdmA->GetVisibility()) {
1329 double x = mCursor[0];
1330 double y = mCursor[1];
1331 double z = mCursor[2];
1332 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1333 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1334 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1336 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1337 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1338 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1339 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1340 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1341 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1342 vtkRenderer * renderer = this->Renderer;
1344 renderer->WorldToView(x,y,z);
1345 renderer->ViewToNormalizedViewport(x,y,z);
1346 renderer->NormalizedViewportToViewport(x,y);
1347 renderer->ViewportToNormalizedDisplay(x,y);
1348 renderer->NormalizedDisplayToDisplay(x,y);
1349 crossCursor->SetFocalPoint(x,y,z);
1351 crossCursor->SetFocalPoint(-1,-1,z);
1355 if (mOverlay && mOverlayActor->GetVisibility()) {
1356 if(mLinkOverlayWindowLevel) {
1357 mOverlayMapper->SetWindow(this->GetColorWindow());
1358 mOverlayMapper->SetLevel(this->GetColorLevel());
1360 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1361 mOverlayMapper->GetOutput()->Update();
1362 mOverlayMapper->Update();
1367 this->GetRenderWindow()->Render();
1369 //----------------------------------------------------------------------------
1372 //----------------------------------------------------------------------------
1373 void vvSlicer::UpdateCursorPosition()
1375 pdmA->SetVisibility(true);
1376 mCursor[0] = mCurrent[0];
1377 mCursor[1] = mCurrent[1];
1378 mCursor[2] = mCurrent[2];
1379 mCursor[3] = mCurrentTSlice;
1381 //----------------------------------------------------------------------------
1384 //----------------------------------------------------------------------------
1385 void vvSlicer::UpdateLandmarks()
1387 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1388 if (pd->GetPoints()) {
1389 mLandGlyph->SetRange(0,1);
1390 mLandGlyph->Modified();
1391 mLandGlyph->Update();
1393 mClipBox->Modified();
1394 mLandClipper->Update();
1395 mLandMapper->Update();
1399 //----------------------------------------------------------------------------
1402 //----------------------------------------------------------------------------
1403 void vvSlicer::SetSlice(int slice)
1405 int *range = this->GetSliceRange();
1407 if (slice < range[0]) {
1409 } else if (slice > range[1]) {
1414 if (this->Slice == slice) {
1418 this->Slice = slice;
1421 this->UpdateDisplayExtent();
1423 // Seems to work without this line
1426 //----------------------------------------------------------------------------
1429 //----------------------------------------------------------------------------
1430 void vvSlicer::SetContourSlice()
1432 if (mSurfaceCutActors.size() > 0)
1433 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1434 i!=mSurfaceCutActors.end(); i++) {
1436 (*i)->SetSlicingOrientation(this->SliceOrientation);
1437 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1438 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1441 //----------------------------------------------------------------------------
1444 //----------------------------------------------------------------------------
1445 void vvSlicer::ForceUpdateDisplayExtent()
1447 this->UpdateDisplayExtent();
1449 //----------------------------------------------------------------------------
1452 //----------------------------------------------------------------------------
1453 int* vvSlicer::GetDisplayExtent()
1455 return this->GetImageActor()->GetDisplayExtent();
1457 //----------------------------------------------------------------------------
1460 //----------------------------------------------------------------------------
1461 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1463 this->Superclass::PrintSelf(os, indent);
1465 //----------------------------------------------------------------------------
1467 //----------------------------------------------------------------------------
1468 void vvSlicer::SetVFColor(double r, double g, double b)
1470 double mVFColorHSV[3];
1475 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1476 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1477 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1478 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);