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://oncora1.lyon.fnclcc.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ======================================================================-====*/
21 #include "vvSlicerManagerCommand.h"
22 #include "vvGlyphSource.h"
23 #include "vvGlyph2D.h"
24 #include "vvImageMapToWLColors.h"
26 #include <vtkTextProperty.h>
27 #include <vtkTextActor.h>
28 #include <vtkTextSource.h>
29 #include <vtkActor2D.h>
30 #include <vtkCursor2D.h>
31 #include <vtkPolyDataMapper2D.h>
32 #include <vtkProperty2D.h>
33 #include <vtkCornerAnnotation.h>
34 #include <vtkImageMapToWindowLevelColors.h>
35 #include <vtkImageData.h>
36 #include <vtkImageActor.h>
37 #include <vvBlendImageActor.h>
38 #include <vtkToolkits.h>
39 #include <vtkObjectFactory.h>
40 #include <vtkPointData.h>
41 #include <vtkDataArray.h>
42 #include <vtkFloatArray.h>
43 #include <vtkClipPolyData.h>
44 #include <vtkGlyph3D.h>
46 #include <vtkCursor3D.h>
47 #include <vtkProperty.h>
49 #include <vtkLightCollection.h>
50 #include <vtkScalarBarActor.h>
51 #include <vtkLookupTable.h>
53 #include <vtkRenderer.h>
54 #include <vtkRendererCollection.h>
55 #include <vtkRenderWindow.h>
56 #include <vtkRenderWindowInteractor.h>
57 #include <vtkCamera.h>
58 #include <vtkCallbackCommand.h>
59 #include <vtkCommand.h>
60 #include <vtkPolyDataMapper.h>
63 #include <vtkExtractVOI.h>
64 #include <vtkSphereSource.h>
65 #include <vtkCutter.h>
66 #include <vtkAssignAttribute.h>
67 #include <vtkImageAccumulate.h>
68 #include <vtkImageReslice.h>
70 vtkCxxRevisionMacro(vvSlicer, "DummyRevision");
71 vtkStandardNewMacro(vvSlicer);
73 //------------------------------------------------------------------------------
76 this->UnInstallPipeline();
79 mUseReducedExtent = false;
81 mCurrent[0] = -VTK_DOUBLE_MAX;
82 mCurrent[1] = -VTK_DOUBLE_MAX;
83 mCurrent[2] = -VTK_DOUBLE_MAX;
85 mCursor[0] = -VTK_DOUBLE_MAX;
86 mCursor[1] = -VTK_DOUBLE_MAX;
87 mCursor[2] = -VTK_DOUBLE_MAX;
88 mCursor[3] = -VTK_DOUBLE_MAX;
95 std::string text = "F1 = sagital; F2 = coronal; F3 = axial\n";
96 text += "F5 = horizontal flip; F6 = vertical flip\n\n";
97 text += "0,1,2,3,4,5 : preset windowing\n";
98 text += "6,7,8,9 : preset colormap\n";
99 text += "z : local windowing\n";
100 text += "r : reset view\n";
101 text += "l : reload image\n";
102 text += "f : fly to mouse position\n";
103 text += "g : go to cross hair position\n\n";
104 text += "Up,down : change slice\n";
105 text += "Left,right : change tenporal slice\n\n";
106 text += "Scrollbar (or w/x) : zoom in/out\n";
107 text += "left button : synchronize all views\n";
108 text += "middle button : grab image\n";
109 text += "right button : change windowing\n";
111 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
112 crossCursor->AllOff();
113 crossCursor->AxesOn();
114 crossCursor->SetTranslationMode(1);
115 crossCursor->SetRadius(2);
117 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
118 pdm->SetInput(crossCursor->GetOutput());
120 pdmA = vtkSmartPointer<vtkActor2D>::New();
121 pdmA->SetMapper(pdm);
122 pdmA->GetProperty()->SetColor(255,10,212);
123 pdmA->SetVisibility(0);
124 pdmA->SetPickable(0);
126 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
127 ca->GetTextProperty()->SetColor(255,10,212);
128 ca->SetVisibility(1);
136 legend = vtkSmartPointer<vtkScalarBarActor>::New();
137 //legend->SetTitle("test!");
138 legend->SetPosition(0.82,0.18);
139 legend->SetWidth(0.1);
140 legend->SetVisibility(0);
141 legend->SetLabelFormat("%.1f");
142 this->GetRenderer()->AddActor(legend);
144 this->WindowLevel->Delete();
145 this->WindowLevel = vvImageMapToWLColors::New();
147 this->InstallPipeline();
149 //------------------------------------------------------------------------------
152 //------------------------------------------------------------------------------
153 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
155 return mOverlayMapper.GetPointer();
157 //------------------------------------------------------------------------------
160 //------------------------------------------------------------------------------
161 vvBlendImageActor* vvSlicer::GetOverlayActor()
163 return mOverlayActor.GetPointer();
165 //------------------------------------------------------------------------------
168 //------------------------------------------------------------------------------
169 vtkImageMapToWindowLevelColors* vvSlicer::GetFusionMapper()
171 return mFusionMapper.GetPointer();
173 //------------------------------------------------------------------------------
176 //------------------------------------------------------------------------------
177 vtkImageActor* vvSlicer::GetFusionActor()
179 return mFusionActor.GetPointer();
181 //------------------------------------------------------------------------------
184 //------------------------------------------------------------------------------
185 vtkActor* vvSlicer::GetVFActor()
187 return mVFActor.GetPointer();
189 //------------------------------------------------------------------------------
192 //------------------------------------------------------------------------------
193 vtkCornerAnnotation* vvSlicer::GetAnnotation()
195 return ca.GetPointer();
197 //------------------------------------------------------------------------------
200 //------------------------------------------------------------------------------
201 void vvSlicer::EnableReducedExtent(bool b)
203 mUseReducedExtent = b;
205 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 void vvSlicer::SetReducedExtent(int * ext)
211 mReducedExtent = ext;
213 //------------------------------------------------------------------------------
216 //------------------------------------------------------------------------------
217 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
220 mSurfaceCutActors.push_back(new vvMeshActor());
222 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
224 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
225 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
226 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
230 //------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------
234 void vvSlicer::ToggleContourSuperposition()
236 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
237 i!=mSurfaceCutActors.end(); i++)
238 (*i)->ToggleSuperposition();
240 //------------------------------------------------------------------------------
243 //------------------------------------------------------------------------------
244 void vvSlicer::SetCursorColor(int r,int g, int b)
246 pdmA->GetProperty()->SetColor(r,g,b);
248 //------------------------------------------------------------------------------
251 //------------------------------------------------------------------------------
252 void vvSlicer::SetCursorVisibility(bool s)
254 pdmA->SetVisibility(s);
256 //------------------------------------------------------------------------------
259 //------------------------------------------------------------------------------
260 bool vvSlicer::GetCursorVisibility()
262 return pdmA->GetVisibility();
264 //------------------------------------------------------------------------------
267 //------------------------------------------------------------------------------
268 vvSlicer::~vvSlicer()
270 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
271 i!=mSurfaceCutActors.end(); i++)
274 //------------------------------------------------------------------------------
277 //------------------------------------------------------------------------------
278 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
285 //------------------------------------------------------------------------------
288 //------------------------------------------------------------------------------
289 void vvSlicer::SetImage(vvImage::Pointer image)
291 if (image->GetVTKImages().size()) {
293 this->Superclass::SetInput(image->GetTransformedVTKImages()[0]);
296 this->GetInput()->GetWholeExtent(extent);
298 // Prevent crash when reload -> change slice if outside extent
299 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
300 Slice = (extent[SliceOrientation*2+1]-extent[SliceOrientation*2])/2.0;
303 // Make sure that the required part image has been computed
304 extent[SliceOrientation*2] = Slice;
305 extent[SliceOrientation*2+1] = Slice;
306 image->GetTransformedVTKImages()[0]->SetUpdateExtent(extent);
307 image->GetTransformedVTKImages()[0]->Update();
309 this->UpdateDisplayExtent();
312 ca->SetText(0,mFileName.c_str());
315 //------------------------------------------------------------------------------
318 //------------------------------------------------------------------------------
319 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
321 if (overlay->GetVTKImages().size()) {
325 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
326 mOverlayMapper->SetInput(overlay->GetTransformedVTKImages()[0]);
328 if (!mOverlayActor) {
329 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
330 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
331 mOverlayActor->SetPickable(0);
332 mOverlayActor->SetVisibility(false);
333 mOverlayActor->SetOpacity(0.5);
334 this->UpdateDisplayExtent();
337 //stupid but necessary : the Overlay need to be rendered before fusion
339 this->GetRenderer()->RemoveActor(mFusionActor);
340 this->GetRenderer()->AddActor(mOverlayActor);
341 this->GetRenderer()->AddActor(mFusionActor);
343 this->GetRenderer()->AddActor(mOverlayActor);
346 SetTSlice(mCurrentTSlice);
349 //------------------------------------------------------------------------------
352 //------------------------------------------------------------------------------
353 void vvSlicer::SetFusion(vvImage::Pointer fusion)
355 if (fusion->GetVTKImages().size()) {
359 mFusionMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
360 mFusionMapper->SetInput(fusion->GetTransformedVTKImages()[0]);
363 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
364 mFusionActor->SetInput(mFusionMapper->GetOutput());
365 mFusionActor->SetPickable(0);
366 mFusionActor->SetVisibility(false);
367 mFusionActor->SetOpacity(0.7);
368 this->UpdateDisplayExtent();
369 this->GetRenderer()->AddActor(mFusionActor);
373 SetTSlice(mCurrentTSlice);
376 //------------------------------------------------------------------------------
379 //------------------------------------------------------------------------------
380 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
382 if (actor_type == "vector") {
383 this->mVFActor->SetVisibility(vis);
385 if (actor_type == "overlay") {
386 this->mOverlayActor->SetVisibility(vis);
388 if (actor_type == "fusion") {
389 this->mFusionActor->SetVisibility(vis);
391 if (actor_type == "contour")
392 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
393 UpdateDisplayExtent();
395 //------------------------------------------------------------------------------
398 //------------------------------------------------------------------------------
399 void vvSlicer::SetVF(vvImage::Pointer vf)
401 if (vf->GetVTKImages().size()) {
405 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
406 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
407 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
409 mVOIFilter->SetInput(vf->GetTransformedVTKImages()[0]);
410 mAAFilter->SetInput(mVOIFilter->GetOutput());
411 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
412 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
415 mArrow = vtkSmartPointer<vvGlyphSource>::New();
416 mArrow->SetGlyphTypeToSpecificArrow();
417 mArrow->SetScale(mScale);
420 // Glyph the gradient vector (with arrows)
422 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
423 mGlyphFilter->SetInput(mAAFilter->GetOutput());
424 mGlyphFilter->SetSource(mArrow->GetOutput());
425 mGlyphFilter->ScalingOn();
426 mGlyphFilter->SetScaleModeToScaleByVector();
427 mGlyphFilter->OrientOn();
428 mGlyphFilter->SetVectorModeToUseVector();
429 mGlyphFilter->SetColorModeToColorByVector();
432 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
433 //mVFMapper->SetInputConnection(mGlyphFilter->GetOutputPort());
434 mVFMapper->SetInput(mGlyphFilter->GetOutput());
435 mVFMapper->ImmediateModeRenderingOn();
438 mVFActor = vtkSmartPointer<vtkActor>::New();
439 mVFActor->SetMapper(mVFMapper);
440 mVFActor->SetPickable(0);
441 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
442 this->UpdateDisplayExtent();
443 this->GetRenderer()->AddActor(mVFActor);
446 SetTSlice(mCurrentTSlice);
449 //------------------------------------------------------------------------------
452 //------------------------------------------------------------------------------
453 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
455 mLandmarks = landmarks;
459 mCross = vtkSmartPointer<vtkCursor3D>::New();
460 mCross->SetFocalPoint(0.0,0.0,0.0);
461 mCross->SetModelBounds(-10,10,-10,10,-10,10);
466 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
467 mLandGlyph->SetSource(mCross->GetOutput());
468 mLandGlyph->SetInput(landmarks->GetOutput());
469 //mLandGlyph->SetIndexModeToScalar();
470 mLandGlyph->SetRange(0,1);
471 mLandGlyph->ScalingOff();
473 mLandGlyph->SetColorModeToColorByScalar();
476 mClipBox = vtkSmartPointer<vtkBox>::New();
478 mLandClipper = vtkSmartPointer<vtkClipPolyData>::New();
479 mLandClipper->InsideOutOn();
480 mLandClipper->SetInput(mLandGlyph->GetOutput());
481 mLandClipper->SetClipFunction(mClipBox);
484 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
485 mLandMapper->SetInputConnection(mLandClipper->GetOutputPort());
486 //mLandMapper->ScalarVisibilityOff();
489 mLandActor = vtkSmartPointer<vtkActor>::New();
490 mLandActor->SetMapper(mLandMapper);
491 mLandActor->GetProperty()->SetColor(255,10,212);
492 mLandActor->SetPickable(0);
493 mLandActor->SetVisibility(true);
494 this->UpdateDisplayExtent();
495 this->GetRenderer()->AddActor(mLandActor);
498 //------------------------------------------------------------------------------
500 //------------------------------------------------------------------------------
501 //FIXME: this function leaks memory, we should fix it someday :)
502 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
504 if (actor_type == "vector") {
505 Renderer->RemoveActor(mVFActor);
514 if (actor_type == "overlay") {
515 Renderer->RemoveActor(mOverlayActor);
517 mOverlayActor = NULL;
518 mOverlayMapper = NULL;
520 if (actor_type == "fusion") {
521 Renderer->RemoveActor(mFusionActor);
524 mFusionMapper = NULL;
526 if (actor_type == "contour") {
527 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
528 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
531 //------------------------------------------------------------------------------
534 //------------------------------------------------------------------------------
535 void vvSlicer::SetVFSubSampling(int sub)
538 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
541 UpdateDisplayExtent();
544 //------------------------------------------------------------------------------
547 //------------------------------------------------------------------------------
548 void vvSlicer::SetVFScale(int scale)
552 mArrow->SetScale(mScale);
553 UpdateDisplayExtent();
556 //------------------------------------------------------------------------------
558 //------------------------------------------------------------------------------
559 void vvSlicer::SetVFWidth(int width)
563 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
564 UpdateDisplayExtent();
567 //------------------------------------------------------------------------------
570 //------------------------------------------------------------------------------
571 void vvSlicer::SetVFLog(int log)
575 mGlyphFilter->SetUseLog(mVFLog);
576 mGlyphFilter->Modified();
578 UpdateDisplayExtent();
581 //------------------------------------------------------------------------------
584 //------------------------------------------------------------------------------
585 void vvSlicer::SetTSlice(int t)
589 else if ((unsigned int)t >= mImage->GetVTKImages().size())
590 t = mImage->GetVTKImages().size() -1;
592 if (mCurrentTSlice == t) return;
595 this->SetInput(mImage->GetTransformedVTKImages()[t]);
596 if (mVF && mVFActor->GetVisibility()) {
597 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
598 mVOIFilter->SetInput(mVF->GetTransformedVTKImages()[mCurrentTSlice]);
600 if (mOverlay && mOverlayActor->GetVisibility()) {
601 if (mOverlay->GetTransformedVTKImages().size() > (unsigned int)mCurrentTSlice)
602 mOverlayMapper->SetInput(mOverlay->GetTransformedVTKImages()[mCurrentTSlice]);
604 if (mFusion && mFusionActor->GetVisibility()) {
605 if (mFusion->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
606 mFusionMapper->SetInput(mFusion->GetTransformedVTKImages()[mCurrentTSlice]);
608 if (mSurfaceCutActors.size() > 0)
609 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
610 i!=mSurfaceCutActors.end(); i++)
611 (*i)->SetTimeSlice(mCurrentTSlice);
612 UpdateDisplayExtent();
614 //------------------------------------------------------------------------------
617 //------------------------------------------------------------------------------
618 int vvSlicer::GetTSlice()
620 return mCurrentTSlice;
622 //------------------------------------------------------------------------------
625 //------------------------------------------------------------------------------
626 void vvSlicer::SetSliceOrientation(int orientation)
628 //if 2D image, force to watch in Axial View
630 this->GetInput()->GetWholeExtent(extent);
631 if (extent[5]-extent[4] <= 2)
634 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
635 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
636 vtkErrorMacro("Error - invalid slice orientation " << orientation);
640 this->SliceOrientation = orientation;
643 int *range = this->GetSliceRange();
645 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
647 // Go to current cursor position
648 // double* cursorPos = GetCursorPosition();
649 // DDV(cursorPos, 3);
650 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
652 this->UpdateOrientation();
653 this->UpdateDisplayExtent();
655 if (this->Renderer && this->GetInput()) {
656 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
657 this->Renderer->ResetCamera();
658 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
663 //----------------------------------------------------------------------------
666 //----------------------------------------------------------------------------
667 int * vvSlicer::GetExtent()
670 if (mUseReducedExtent) {
671 w_ext = mReducedExtent;
672 } else w_ext = GetInput()->GetWholeExtent();
675 //----------------------------------------------------------------------------
678 //----------------------------------------------------------------------------
679 int vvSlicer::GetOrientation()
681 return this->SliceOrientation;
683 //----------------------------------------------------------------------------
686 //----------------------------------------------------------------------------
687 void vvSlicer::UpdateDisplayExtent()
689 vtkImageData *input = this->GetInput();
690 if (!input || !this->ImageActor) {
693 input->UpdateInformation();
694 int *w_ext;// = input->GetWholeExtent();
696 if (mUseReducedExtent) {
697 w_ext = mReducedExtent;
698 } else w_ext = input->GetWholeExtent();
700 switch (this->SliceOrientation) {
701 case vtkImageViewer2::SLICE_ORIENTATION_XY:
702 this->ImageActor->SetDisplayExtent(
703 w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice);
704 if (mVF && mVFActor->GetVisibility()) {
706 ComputeVFDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,vfExtent);
707 mVOIFilter->SetVOI(vfExtent);
708 mGlyphFilter->SetOrientation(1,1,0);
710 // put the vector field between the image and the camera
711 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
712 mVFActor->SetPosition(0,0,ImageActor->GetBounds()[5]+2);
714 mVFActor->SetPosition(0,0,ImageActor->GetBounds()[4]-2);
716 if (mOverlay && mOverlayActor->GetVisibility()) {
718 ComputeOverlayDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,overExtent);
719 mOverlayActor->SetDisplayExtent(overExtent);
720 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
721 mOverlayActor->SetPosition(0,0,1);
723 mOverlayActor->SetPosition(0,0,-1);
725 if (mFusion && mFusionActor->GetVisibility()) {
727 ComputeFusionDisplayedExtent(w_ext[0], w_ext[1], w_ext[2], w_ext[3], this->Slice, this->Slice,fusExtent);
728 mFusionActor->SetDisplayExtent(fusExtent);
729 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
730 mFusionActor->SetPosition(0,0,1.5);
732 mFusionActor->SetPosition(0,0,-1.5);
737 bounds[0] = ImageActor->GetBounds()[0];
738 bounds[1] = ImageActor->GetBounds()[1];
739 bounds[2] = ImageActor->GetBounds()[2];
740 bounds[3] = ImageActor->GetBounds()[3];
741 bounds[4] = ImageActor->GetBounds()[4]-fabs(0.5/this->GetInput()->GetSpacing()[2]);
742 bounds[5] = ImageActor->GetBounds()[5]+fabs(0.5/this->GetInput()->GetSpacing()[2]);
743 mClipBox->SetBounds(bounds);
746 mLandActor->SetPosition(0,0,-1.5);
748 if (Renderer->GetActiveCamera()->GetPosition()[2] > this->Slice)
749 mLandActor->SetPosition(0,0,1.5);
751 mLandActor->SetPosition(0,0,-1.5);
756 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
757 this->ImageActor->SetDisplayExtent(
758 w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5]);
759 if (mVF && mVFActor->GetVisibility()) {
761 ComputeVFDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],vfExtent);
762 mVOIFilter->SetVOI(vfExtent);
763 mGlyphFilter->SetOrientation(1,0,1);
765 // put the vector field between the image aSpacingnd the camera
766 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
767 mVFActor->SetPosition(0,ImageActor->GetBounds()[3]+2,0);
769 mVFActor->SetPosition(0,ImageActor->GetBounds()[2]-2,0);
771 if (mOverlay && mOverlayActor->GetVisibility()) {
773 ComputeOverlayDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],overExtent);
774 mOverlayActor->SetDisplayExtent(overExtent);
775 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
776 mOverlayActor->SetPosition(0,1,0);
778 mOverlayActor->SetPosition(0,-1,0);
780 if (mFusion && mFusionActor->GetVisibility()) {
782 ComputeFusionDisplayedExtent(w_ext[0], w_ext[1], this->Slice, this->Slice, w_ext[4], w_ext[5],fusExtent);
783 mFusionActor->SetDisplayExtent(fusExtent);
784 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
785 mFusionActor->SetPosition(0,1.5,0);
787 mFusionActor->SetPosition(0,-1.5,0);
792 bounds[0] = ImageActor->GetBounds()[0];
793 bounds[1] = ImageActor->GetBounds()[1];
794 bounds[2] = ImageActor->GetBounds()[2]-fabs(0.5/this->GetInput()->GetSpacing()[1]);
795 bounds[3] = ImageActor->GetBounds()[3]+fabs(0.5/this->GetInput()->GetSpacing()[1]);
796 bounds[4] = ImageActor->GetBounds()[4];
797 bounds[5] = ImageActor->GetBounds()[5];
798 mClipBox->SetBounds(bounds);
801 if (Renderer->GetActiveCamera()->GetPosition()[1] > this->Slice)
802 mLandActor->SetPosition(0,1.5,0);
804 mLandActor->SetPosition(0,-1.5,0);
808 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
809 this->ImageActor->SetDisplayExtent(
810 this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5]);
811 if (mVF && mVFActor->GetVisibility()) {
813 ComputeVFDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],vfExtent);
814 mVOIFilter->SetVOI(vfExtent);
815 mGlyphFilter->SetOrientation(0,1,1);
817 // put the vector field between the image and the camera
818 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
819 mVFActor->SetPosition(ImageActor->GetBounds()[1]+2,0,0);
821 mVFActor->SetPosition(ImageActor->GetBounds()[0]-2,0,0);
823 if (mOverlay && mOverlayActor->GetVisibility()) {
825 ComputeOverlayDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],overExtent);
826 mOverlayActor->SetDisplayExtent(overExtent);
827 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
828 mOverlayActor->SetPosition(1,0,0);
830 mOverlayActor->SetPosition(-1,0,0);
832 if (mFusion && mFusionActor->GetVisibility()) {
834 ComputeFusionDisplayedExtent(this->Slice, this->Slice, w_ext[2], w_ext[3], w_ext[4], w_ext[5],fusExtent);
835 mFusionActor->SetDisplayExtent(fusExtent);
836 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
837 mFusionActor->SetPosition(1.5,0,0);
839 mFusionActor->SetPosition(-1.5,0,0);
844 bounds[0] = ImageActor->GetBounds()[0]-fabs(0.5/this->GetInput()->GetSpacing()[0]);
845 bounds[1] = ImageActor->GetBounds()[1]+fabs(0.5/this->GetInput()->GetSpacing()[0]);
846 bounds[2] = ImageActor->GetBounds()[2];
847 bounds[3] = ImageActor->GetBounds()[3];
848 bounds[4] = ImageActor->GetBounds()[4];
849 bounds[5] = ImageActor->GetBounds()[5];
850 mClipBox->SetBounds(bounds);
853 if (Renderer->GetActiveCamera()->GetPosition()[0] > this->Slice)
854 mLandActor->SetPosition(1.5,0,0);
856 mLandActor->SetPosition(-1.5,0,0);
861 // Figure out the correct clipping range
863 if (this->Renderer) {
864 if (this->InteractorStyle &&
865 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
866 this->Renderer->ResetCameraClippingRange();
868 vtkCamera *cam = this->Renderer->GetActiveCamera();
871 this->ImageActor->GetBounds(bounds);
872 double spos = (double)bounds[this->SliceOrientation * 2];
873 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
874 double range = fabs(spos - cpos);
875 double *spacing = input->GetSpacing();
877 ((double)spacing[0] + (double)spacing[1] + (double)spacing[2]) / 3.0;
878 cam->SetClippingRange(
879 range - avg_spacing * 3.0, range + avg_spacing * 3.0);
884 //----------------------------------------------------------------------------
887 //----------------------------------------------------------------------------
888 void vvSlicer::ComputeVFDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int vfExtent[6])
890 vtkImageData* image=this->GetInput();
891 vfExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mVF->GetOrigin()[0]) /
892 mVF->GetSpacing()[0];
893 vfExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mVF->GetOrigin()[0]) /
894 mVF->GetSpacing()[0];
895 vfExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mVF->GetOrigin()[1]) /
896 mVF->GetSpacing()[1];
897 vfExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mVF->GetOrigin()[1]) /
898 mVF->GetSpacing()[1];
899 vfExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mVF->GetOrigin()[2]) /
900 mVF->GetSpacing()[2];
901 vfExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mVF->GetOrigin()[2]) /
902 mVF->GetSpacing()[2];
904 ClipDisplayedExtent(vfExtent,mVOIFilter->GetInput()->GetWholeExtent());
906 //----------------------------------------------------------------------------
909 //----------------------------------------------------------------------------
910 void vvSlicer::ComputeOverlayDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int overExtent[6])
912 vtkImageData* image=this->GetInput();
913 overExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mOverlay->GetOrigin()[0]) /
914 mOverlay->GetSpacing()[0];
915 overExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mOverlay->GetOrigin()[0]) /
916 mOverlay->GetSpacing()[0];
917 overExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mOverlay->GetOrigin()[1]) /
918 mOverlay->GetSpacing()[1];
919 overExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mOverlay->GetOrigin()[1]) /
920 mOverlay->GetSpacing()[1];
921 overExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mOverlay->GetOrigin()[2]) /
922 mOverlay->GetSpacing()[2];
923 overExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mOverlay->GetOrigin()[2]) /
924 mOverlay->GetSpacing()[2];
925 ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
927 //----------------------------------------------------------------------------
930 //----------------------------------------------------------------------------
931 void vvSlicer::ComputeFusionDisplayedExtent(int x1,int x2,int y1,int y2,int z1,int z2,int fusExtent[6])
933 vtkImageData* image=this->GetInput();
934 fusExtent[0] = (( image->GetOrigin()[0] + x1*image->GetSpacing()[0] ) - mFusion->GetOrigin()[0]) /
935 mFusion->GetSpacing()[0];
936 fusExtent[1] = (( image->GetOrigin()[0] + x2*image->GetSpacing()[0] ) - mFusion->GetOrigin()[0]) /
937 mFusion->GetSpacing()[0];
938 fusExtent[2] = (( image->GetOrigin()[1] + y1*image->GetSpacing()[1] ) - mFusion->GetOrigin()[1]) /
939 mFusion->GetSpacing()[1];
940 fusExtent[3] = (( image->GetOrigin()[1] + y2*image->GetSpacing()[1] ) - mFusion->GetOrigin()[1]) /
941 mFusion->GetSpacing()[1];
942 fusExtent[4] = (( image->GetOrigin()[2] + z1*image->GetSpacing()[2] ) - mFusion->GetOrigin()[2]) /
943 mFusion->GetSpacing()[2];
944 fusExtent[5] = (( image->GetOrigin()[2] + z2*image->GetSpacing()[2] ) - mFusion->GetOrigin()[2]) /
945 mFusion->GetSpacing()[2];
946 ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
948 //----------------------------------------------------------------------------
951 //----------------------------------------------------------------------------
952 void vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
957 //2D overlay on 3D image specific case
958 if (refExtent[4] == refExtent[5]) {
960 extent[4] = refExtent[4];
961 extent[5] = refExtent[5];
964 for (int i = 0; i < maxBound; i = i+2) {
965 //if we are totally outside the image
966 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
970 //crop to the limit of the image
971 extent[i] = (extent[i] > refExtent[i]) ? extent[i] : refExtent[i];
972 extent[i] = (extent[i] < refExtent[i+1]) ? extent[i] : refExtent[i+1];
973 extent[i+1] = (extent[i+1] > refExtent[i]) ? extent[i+1] : refExtent[i];
974 extent[i+1] = (extent[i+1] < refExtent[i+1]) ? extent[i+1] : refExtent[i+1];
977 for (int i = 0; i < maxBound; i = i+2) {
978 extent[i] = refExtent[i];
979 extent[i+1] = refExtent[i];
982 //----------------------------------------------------------------------------
985 //----------------------------------------------------------------------------
986 void vvSlicer::UpdateOrientation()
988 // Set the camera position
989 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
991 switch (this->SliceOrientation) {
992 case vtkImageViewer2::SLICE_ORIENTATION_XY:
993 cam->SetFocalPoint(0,0,0);
994 cam->SetPosition(0,0,-1); // -1 if medical ?
995 cam->SetViewUp(0,-1,0);
998 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
999 cam->SetFocalPoint(0,0,0);
1000 cam->SetPosition(0,-1,0); // 1 if medical ?
1001 cam->SetViewUp(0,0,1);
1004 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1005 cam->SetFocalPoint(0,0,0);
1006 cam->SetPosition(-1,0,0); // -1 if medical ?
1007 cam->SetViewUp(0,0,1);
1012 //----------------------------------------------------------------------------
1015 //----------------------------------------------------------------------------
1016 void vvSlicer::SetOpacity(double s)
1018 this->GetImageActor()->SetOpacity(s);
1020 //----------------------------------------------------------------------------
1023 //----------------------------------------------------------------------------
1024 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1026 this->Superclass::SetRenderWindow(rw);
1027 this->SetupInteractor(rw->GetInteractor());
1028 ca->SetImageActor(this->GetImageActor());
1029 ca->SetWindowLevel(this->GetWindowLevel());
1030 ca->SetText(2, "<slice>");
1031 ca->SetText(3, "<window>\n<level>");
1043 crossCursor->SetModelBounds(bounds);
1044 this->GetRenderer()->AddActor(pdmA);
1045 this->GetRenderer()->AddActor(ca);
1046 this->GetRenderer()->ResetCamera();
1048 //this is just a mapping between the labeling of the orientations presented to the user and
1049 //the one used by vtk
1050 SetSliceOrientation(2-(orientation%3));
1053 //----------------------------------------------------------------------------
1056 //----------------------------------------------------------------------------
1057 void vvSlicer::ResetCamera()
1059 this->GetRenderer()->ResetCamera();
1061 //----------------------------------------------------------------------------
1064 //----------------------------------------------------------------------------
1065 void vvSlicer::SetDisplayMode(bool i)
1067 this->GetImageActor()->SetVisibility(i);
1068 this->GetAnnotation()->SetVisibility(i);
1069 this->GetRenderer()->SetDraw(i);
1071 mLandActor->SetVisibility(i);
1072 pdmA->SetVisibility(i);
1074 UpdateDisplayExtent();
1076 //----------------------------------------------------------------------------
1079 //----------------------------------------------------------------------------
1080 void vvSlicer::FlipHorizontalView()
1082 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1084 double *position = cam->GetPosition();
1085 switch (this->SliceOrientation) {
1086 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1087 cam->SetPosition(position[0],position[1],-position[2]);
1090 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1091 cam->SetPosition(position[0],-position[1],position[2]);
1094 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1095 cam->SetPosition(-position[0],position[1],position[2]);
1098 this->Renderer->ResetCameraClippingRange();
1099 this->UpdateDisplayExtent();
1102 //----------------------------------------------------------------------------
1105 //----------------------------------------------------------------------------
1106 void vvSlicer::FlipVerticalView()
1108 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1110 FlipHorizontalView();
1111 double *viewup = cam->GetViewUp();
1112 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1113 this->UpdateDisplayExtent();
1116 //----------------------------------------------------------------------------
1119 //----------------------------------------------------------------------------
1120 void vvSlicer::SetColorWindow(double window)
1122 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1124 double level = this->GetWindowLevel()->GetLevel();
1125 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1128 this->vtkImageViewer2::SetColorWindow(window);
1130 //----------------------------------------------------------------------------
1133 //----------------------------------------------------------------------------
1134 void vvSlicer::SetColorLevel(double level)
1136 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1138 double window = this->GetWindowLevel()->GetWindow();
1139 LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4);
1142 this->vtkImageViewer2::SetColorLevel(level);
1144 //----------------------------------------------------------------------------
1146 //----------------------------------------------------------------------------
1147 // Returns the min an the max value in a 41x41 region around the mouse pointer
1148 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max)
1150 //Get mouse pointer position in view coordinates
1151 double fLocalExtents[6];
1152 for(int i=0; i<3; i++) {
1153 fLocalExtents[i*2 ] = mCurrent[i];
1154 fLocalExtents[i*2+1] = mCurrent[i];
1156 this->Renderer->WorldToView(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1157 this->Renderer->WorldToView(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1158 for(int i=0; i<3; i++) {
1159 if (i!=SliceOrientation) { //SR: assumes that SliceOrientation is valid in ViewCoordinates (???)
1160 fLocalExtents[i*2 ] -= 0.2;
1161 fLocalExtents[i*2+1] += 0.2;
1164 this->Renderer->ViewToWorld(fLocalExtents[0], fLocalExtents[2], fLocalExtents[4]);
1165 this->Renderer->ViewToWorld(fLocalExtents[1], fLocalExtents[3], fLocalExtents[5]);
1167 //Convert to image pixel coordinates (rounded)
1168 int iLocalExtents[6];
1169 for(int i=0; i<3; i++) {
1170 fLocalExtents[i*2 ] = (fLocalExtents[i*2 ] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1171 fLocalExtents[i*2+1] = (fLocalExtents[i*2+1] - this->GetInput()->GetOrigin()[i])/this->GetInput()->GetSpacing()[i];
1173 iLocalExtents[i*2 ] = lrint(fLocalExtents[i*2 ]);
1174 iLocalExtents[i*2+1] = lrint(fLocalExtents[i*2+1]);
1176 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1177 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1180 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1181 voiFilter->SetInput(this->GetInput());
1182 voiFilter->SetVOI(iLocalExtents);
1183 voiFilter->Update();
1184 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1190 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1191 accFilter->SetInput(voiFilter->GetOutput());
1192 accFilter->Update();
1194 min = *(accFilter->GetMin());
1195 max = *(accFilter->GetMax());
1197 //----------------------------------------------------------------------------
1199 //----------------------------------------------------------------------------
1200 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, int X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1205 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1207 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1209 //----------------------------------------------------------------------------
1211 //----------------------------------------------------------------------------
1212 void vvSlicer::Render()
1214 if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) {
1215 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1216 legend->SetVisibility(1);
1217 } else legend->SetVisibility(0);
1219 if (ca->GetVisibility()) {
1220 std::string worldPos = "";
1221 std::stringstream world1;
1222 std::stringstream world2;
1223 std::stringstream world3;
1224 world1 << (int)mCurrent[0];
1225 world2 << (int)mCurrent[1];
1226 world3 << (int)mCurrent[2];
1227 double X = (mCurrent[0] - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1228 double Y = (mCurrent[1] - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1229 double Z = (mCurrent[2] - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1231 if (pdmA->GetVisibility()) {
1232 double x = mCursor[0];
1233 double y = mCursor[1];
1234 double z = mCursor[2];
1235 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1236 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1237 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1239 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0] &&
1240 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+1 &&
1241 yCursor >= this->GetImageActor()->GetDisplayExtent()[2] &&
1242 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+1 &&
1243 zCursor >= this->GetImageActor()->GetDisplayExtent()[4] &&
1244 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+1 ) {
1245 vtkRenderer * renderer = this->Renderer;
1247 renderer->WorldToView(x,y,z);
1248 renderer->ViewToNormalizedViewport(x,y,z);
1249 renderer->NormalizedViewportToViewport(x,y);
1250 renderer->ViewportToNormalizedDisplay(x,y);
1251 renderer->NormalizedDisplayToDisplay(x,y);
1252 crossCursor->SetFocalPoint(x,y,z);
1254 crossCursor->SetFocalPoint(-1,-1,z);
1257 if (X >= this->GetInput()->GetWholeExtent()[0] &&
1258 X <= this->GetInput()->GetWholeExtent()[1] &&
1259 Y >= this->GetInput()->GetWholeExtent()[2] &&
1260 Y <= this->GetInput()->GetWholeExtent()[3] &&
1261 Z >= this->GetInput()->GetWholeExtent()[4] &&
1262 Z <= this->GetInput()->GetWholeExtent()[5]) {
1264 double value = this->GetScalarComponentAsDouble(this->GetInput(), X, Y, Z, ix, iy, iz);
1266 std::stringstream pixel1;
1267 std::stringstream pixel2;
1268 std::stringstream pixel3;
1269 std::stringstream temps;
1273 temps << mCurrentTSlice;
1275 std::stringstream val;
1277 worldPos += "data value : " + val.str();
1278 worldPos += "\n mm : " + world1.str() + " " + world2.str() + " " +
1279 world3.str() + " " + temps.str();
1280 worldPos += "\n pixel : " + pixel1.str() + " " + pixel2.str() + " " +
1281 pixel3.str() + " " + temps.str();
1283 ca->SetText(1,worldPos.c_str());
1285 if (mOverlay && mOverlayActor->GetVisibility()) {
1286 mOverlayMapper->SetWindow(this->GetColorWindow());
1287 mOverlayMapper->SetLevel(this->GetColorLevel());
1288 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1289 mOverlayMapper->GetOutput()->Update();
1290 mOverlayMapper->Update();
1294 //this->Superclass::Render();
1295 this->GetRenderWindow()->Render();
1297 //----------------------------------------------------------------------------
1300 //----------------------------------------------------------------------------
1301 void vvSlicer::UpdateCursorPosition()
1303 if (this->GetImageActor()->GetVisibility()) {
1304 pdmA->SetVisibility(true);
1305 mCursor[0] = mCurrent[0];
1306 mCursor[1] = mCurrent[1];
1307 mCursor[2] = mCurrent[2];
1308 mCursor[3] = mCurrentTSlice;
1311 //----------------------------------------------------------------------------
1314 //----------------------------------------------------------------------------
1315 void vvSlicer::UpdateLandmarks()
1317 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1318 if (pd->GetPoints()) {
1319 mLandGlyph->SetRange(0,1);
1320 mLandGlyph->Modified();
1321 mLandGlyph->Update();
1323 mClipBox->Modified();
1324 mLandClipper->Update();
1325 mLandMapper->Update();
1329 //----------------------------------------------------------------------------
1332 //----------------------------------------------------------------------------
1333 void vvSlicer::SetSlice(int slice)
1335 int *range = this->GetSliceRange();
1337 if (slice < range[0]) {
1339 } else if (slice > range[1]) {
1344 if (this->Slice == slice) {
1348 this->Slice = slice;
1351 this->UpdateDisplayExtent();
1353 // Seems to work without this line
1356 //----------------------------------------------------------------------------
1359 //----------------------------------------------------------------------------
1360 void vvSlicer::SetContourSlice()
1362 if (mSurfaceCutActors.size() > 0)
1363 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1364 i!=mSurfaceCutActors.end(); i++)
1365 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1366 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1368 //----------------------------------------------------------------------------
1371 //----------------------------------------------------------------------------
1372 void vvSlicer::ForceUpdateDisplayExtent()
1374 this->UpdateDisplayExtent();
1376 //----------------------------------------------------------------------------
1379 //----------------------------------------------------------------------------
1380 int* vvSlicer::GetDisplayExtent()
1382 return this->GetImageActor()->GetDisplayExtent();
1384 //----------------------------------------------------------------------------
1387 //----------------------------------------------------------------------------
1388 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1390 this->Superclass::PrintSelf(os, indent);
1392 //----------------------------------------------------------------------------