1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
5 - University of LYON http://www.universite-lyon.fr/
6 - Léon Bérard cancer center http://www.centreleonberard.fr
7 - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the copyright notices for more information.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #include <QMessageBox>
24 #include "vvSlicerManagerCommand.h"
25 #include "vvGlyphSource.h"
26 #include "vvGlyph2D.h"
28 #include <vtkVersion.h>
29 #include <vtkExtentTranslator.h>
30 #include <vtkAlgorithm.h>
31 #include <vtkExecutive.h>
32 #include <vtkStreamingDemandDrivenPipeline.h>
33 #include <vtkInformation.h>
34 #include <vtkTextProperty.h>
35 #include <vtkTextActor.h>
36 #include <vtkTextSource.h>
37 #include <vtkActor2D.h>
38 #include <vtkCursor2D.h>
39 #include <vtkPolyDataMapper2D.h>
40 #include <vtkProperty2D.h>
41 #include <vtkCornerAnnotation.h>
42 #include <vtkImageMapToWindowLevelColors.h>
43 #include <vtkImageData.h>
44 #include <vtkImageActor.h>
45 #include <vvBlendImageActor.h>
46 #include <vtkToolkits.h>
47 #include <vtkObjectFactory.h>
48 #include <vtkPointData.h>
49 #include <vtkDataArray.h>
50 #include <vtkFloatArray.h>
51 #include <vtkClipPolyData.h>
52 #include <vtkActor2DCollection.h>
53 #include <vtkGlyph3D.h>
55 #include <vtkCursor3D.h>
56 #include <vtkProperty.h>
58 #include <vtkLightCollection.h>
59 #include <vtkScalarBarActor.h>
60 #include <vtkLookupTable.h>
62 #include <vtkRenderer.h>
63 #include <vtkRendererCollection.h>
64 #include <vtkRenderWindow.h>
65 #include <vtkRenderWindowInteractor.h>
66 #include <vtkCamera.h>
67 #include <vtkCallbackCommand.h>
68 #include <vtkCommand.h>
69 #include <vtkPolyDataMapper.h>
72 #include <vtkExtractVOI.h>
73 #include <vtkSphereSource.h>
74 #include <vtkCutter.h>
75 #include <vtkAssignAttribute.h>
76 #include <vtkImageAccumulate.h>
77 #include <vtkImageReslice.h>
78 #include <vtkOpenGLImageSliceMapper.h>
79 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
80 # include <vtkImageMapper3D.h>
81 # include <vtkImageSliceMapper.h>
84 vtkStandardNewMacro(vvSlicer);
85 static void copyExtent(int* in, int* to){
86 for(int i=0; i<6; ++i)
91 //------------------------------------------------------------------------------
93 { //out << __func__ << endl;
94 mFusionSequenceCode = -1;
95 this->UnInstallPipeline();
97 mReducedExtent = new int[6];
98 mRegisterExtent = new int[6];
100 mCurrentFusionTSlice = 0;
101 mCurrentOverlayTSlice = 0;
102 mUseReducedExtent = false;
104 mCurrent[0] = -VTK_DOUBLE_MAX;
105 mCurrent[1] = -VTK_DOUBLE_MAX;
106 mCurrent[2] = -VTK_DOUBLE_MAX;
108 mCursor[0] = 0;//-VTK_DOUBLE_MAX;
109 mCursor[1] = 0;//-VTK_DOUBLE_MAX;
110 mCursor[2] = 0;//-VTK_DOUBLE_MAX;
111 mCursor[3] = 0;//-VTK_DOUBLE_MAX;
121 crossCursor = vtkSmartPointer<vtkCursor2D>::New();
122 crossCursor->AllOff();
123 crossCursor->AxesOn();
124 crossCursor->SetTranslationMode(1);
125 crossCursor->SetRadius(2);
127 pdm = vtkSmartPointer<vtkPolyDataMapper2D>::New();
128 #if VTK_MAJOR_VERSION <= 5
129 pdm->SetInput(crossCursor->GetOutput());
131 pdm->SetInputData(crossCursor->GetOutput());
134 pdmA = vtkSmartPointer<vtkActor2D>::New();
135 pdmA->SetMapper(pdm);
136 pdmA->GetProperty()->SetColor(255,10,212);
137 pdmA->SetVisibility(0);
138 pdmA->SetPickable(0);
140 ca = vtkSmartPointer<vtkCornerAnnotation>::New();
141 ca->GetTextProperty()->SetColor(255,10,212);
142 ca->SetVisibility(1);
150 legend = vtkSmartPointer<vtkScalarBarActor>::New();
151 //legend->SetTitle("test!");
152 legend->SetPosition(0.82,0.18);
153 legend->SetWidth(0.1);
154 legend->SetVisibility(0);
155 legend->SetLabelFormat("%.1f");
156 this->GetRenderer()->AddActor(legend);
157 showFusionLegend = false;
159 this->InstallPipeline();
161 mLinkOverlayWindowLevel = true;
162 mImageVisibility = true;
164 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
165 this->GetImageActor()->GetMapper()->BorderOn();
168 mSlicingTransform = vtkSmartPointer<vtkTransform>::New();
169 mConcatenatedTransform = vtkSmartPointer<vtkTransform>::New();
170 mConcatenatedFusionTransform = vtkSmartPointer<vtkTransform>::New();
171 mConcatenatedOverlayTransform = vtkSmartPointer<vtkTransform>::New();
172 mFirstSetSliceOrientation = true;
174 //------------------------------------------------------------------------------
177 //------------------------------------------------------------------------------
178 vtkImageMapToWindowLevelColors* vvSlicer::GetOverlayMapper()
179 { //out << __func__ << endl;
180 return mOverlayMapper.GetPointer();
182 //------------------------------------------------------------------------------
185 //------------------------------------------------------------------------------
186 vvBlendImageActor* vvSlicer::GetOverlayActor()
187 { //out << __func__ << endl;
188 return mOverlayActor.GetPointer();
190 //------------------------------------------------------------------------------
193 //------------------------------------------------------------------------------
194 vtkImageMapToColors* vvSlicer::GetFusionMapper()
195 { //out << __func__ << endl;
196 return mFusionMapper.GetPointer();
198 //------------------------------------------------------------------------------
201 //------------------------------------------------------------------------------
202 vtkImageActor* vvSlicer::GetFusionActor()
203 { //out << __func__ << endl;
204 return mFusionActor.GetPointer();
206 //------------------------------------------------------------------------------
209 //------------------------------------------------------------------------------
210 vtkActor* vvSlicer::GetVFActor()
211 { //out << __func__ << endl;
212 return mVFActor.GetPointer();
214 //------------------------------------------------------------------------------
217 //------------------------------------------------------------------------------
218 vtkCornerAnnotation* vvSlicer::GetAnnotation()
219 { //out << __func__ << endl;
220 return ca.GetPointer();
222 //------------------------------------------------------------------------------
225 //------------------------------------------------------------------------------
226 void vvSlicer::EnableReducedExtent(bool b)
227 { //out << __func__ << endl;
228 mUseReducedExtent = b;
230 //------------------------------------------------------------------------------
233 //------------------------------------------------------------------------------
234 void vvSlicer::SetReducedExtent(int * ext)
235 { //out << __func__ << endl;
236 copyExtent(ext, mReducedExtent);
238 //------------------------------------------------------------------------------
241 //------------------------------------------------------------------------------
242 void vvSlicer::AddContour(vvMesh::Pointer contour,bool propagate)
243 { //out << __func__ << endl;
245 mSurfaceCutActors.push_back(new vvMeshActor());
247 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice,mVF);
249 mSurfaceCutActors.back()->Init(contour,mCurrentTSlice);
250 mSurfaceCutActors.back()->SetSlicingOrientation(SliceOrientation);
251 this->GetRenderer()->AddActor(mSurfaceCutActors.back()->GetActor());
255 //------------------------------------------------------------------------------
258 //------------------------------------------------------------------------------
259 void vvSlicer::ToggleContourSuperposition()
260 { //out << __func__ << endl;
261 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
262 i!=mSurfaceCutActors.end(); i++)
263 (*i)->ToggleSuperposition();
265 //------------------------------------------------------------------------------
268 //------------------------------------------------------------------------------
269 void vvSlicer::SetCursorColor(int r,int g, int b)
270 { //out << __func__ << endl;
271 pdmA->GetProperty()->SetColor(r,g,b);
273 //------------------------------------------------------------------------------
276 //------------------------------------------------------------------------------
277 void vvSlicer::SetCursorVisibility(bool s)
278 { //out << __func__ << endl;
279 pdmA->SetVisibility(s);
281 //------------------------------------------------------------------------------
284 //------------------------------------------------------------------------------
285 bool vvSlicer::GetCursorVisibility()
286 { //out << __func__ << endl;
287 return pdmA->GetVisibility();
289 //------------------------------------------------------------------------------
292 //------------------------------------------------------------------------------
293 void vvSlicer::SetCornerAnnotationVisibility(bool s)
294 { //out << __func__ << endl;
295 ca->SetVisibility(s);
297 //------------------------------------------------------------------------------
300 //------------------------------------------------------------------------------
301 bool vvSlicer::GetCornerAnnotationVisibility()
302 { //out << __func__ << endl;
303 return ca->GetVisibility();
305 //------------------------------------------------------------------------------
308 //------------------------------------------------------------------------------
309 vvSlicer::~vvSlicer()
310 { //out << __func__ << endl;
311 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
312 i!=mSurfaceCutActors.end(); i++)
314 delete [] mReducedExtent;
315 delete [] mRegisterExtent;
317 //------------------------------------------------------------------------------
319 //------------------------------------------------------------------------------
320 double* vvSlicer::GetCurrentPosition()
321 { //out << __func__ << endl;
322 return mCurrentBeforeSlicingTransform;
324 //------------------------------------------------------------------------------
326 //------------------------------------------------------------------------------
327 void vvSlicer::SetCurrentPosition(double x, double y, double z, int t)
328 { //out << __func__ << endl;
329 mCurrentBeforeSlicingTransform[0]=x;
330 mCurrentBeforeSlicingTransform[1]=y;
331 mCurrentBeforeSlicingTransform[2]=z;
332 mSlicingTransform->GetInverse()->TransformPoint(mCurrentBeforeSlicingTransform,mCurrent);
333 if (t>=0) SetTSlice(t);
335 //------------------------------------------------------------------------------
338 //------------------------------------------------------------------------------
339 void vvSlicer::SetImage(vvImage::Pointer image)
340 { //out << __func__ << endl;
341 if (image->GetVTKImages().size()) {
344 if (!mImageReslice) {
345 mImageReslice = vtkSmartPointer<vtkImageReslice>::New();
346 mImageReslice->SetInterpolationModeToLinear();
347 mImageReslice->AutoCropOutputOn();
348 mImageReslice->SetBackgroundColor(-1000,-1000,-1000,1);
351 mConcatenatedTransform->Identity();
352 mConcatenatedTransform->Concatenate(mImage->GetTransform()[0]);
353 mConcatenatedTransform->Concatenate(mSlicingTransform);
354 mImageReslice->SetResliceTransform(mConcatenatedTransform);
355 #if VTK_MAJOR_VERSION <= 5
356 mImageReslice->SetInput(0, mImage->GetFirstVTKImageData());
358 mImageReslice->SetInputData(0, mImage->GetFirstVTKImageData());
360 mImageReslice->UpdateInformation();
362 #if VTK_MAJOR_VERSION <= 5
363 this->Superclass::SetInput(mImageReslice->GetOutput());
365 this->Superclass::SetInputConnection(mImageReslice->GetOutputPort());
369 #if VTK_MAJOR_VERSION <= 5
370 this->GetInput()->GetWholeExtent(extent);
372 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
373 copyExtent(ext, extent);
376 // Prevent crash when reload -> change slice if outside extent
377 if (Slice < extent[SliceOrientation*2] || Slice>=extent[SliceOrientation*2+1]) {
378 Slice = (extent[SliceOrientation*2+1]+extent[SliceOrientation*2])/2.0;
381 // Make sure that the required part image has been computed
382 extent[SliceOrientation*2] = Slice;
383 extent[SliceOrientation*2+1] = Slice;
385 #if VTK_MAJOR_VERSION <= 5
386 mImageReslice->GetOutput()->SetUpdateExtent(extent);
387 mImageReslice->GetOutput()->Update();
389 mImageReslice->SetUpdateExtent(extent);
390 mImageReslice->Update();
393 this->UpdateDisplayExtent();
396 ca->SetText(0,mFileName.c_str());
399 //------------------------------------------------------------------------------
402 //------------------------------------------------------------------------------
403 void vvSlicer::SetOverlay(vvImage::Pointer overlay)
404 { //out << __func__ << endl;
405 if (overlay->GetVTKImages().size()) {
407 mOverlayVisibility = true;
409 if (!mOverlayReslice) {
410 mOverlayReslice = vtkSmartPointer<vtkImageReslice>::New();
411 mOverlayReslice->SetInterpolationModeToLinear();
412 mOverlayReslice->AutoCropOutputOn();
413 mOverlayReslice->SetBackgroundColor(-1000,-1000,-1000,1);
416 mConcatenatedOverlayTransform->Identity();
417 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[0]);
418 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
419 mOverlayReslice->SetResliceTransform(mConcatenatedOverlayTransform);
420 #if VTK_MAJOR_VERSION <= 5
421 mOverlayReslice->SetInput(0, mOverlay->GetFirstVTKImageData());
423 mOverlayReslice->SetInputData(0, mOverlay->GetFirstVTKImageData());
425 mImageReslice->UpdateInformation();
426 mOverlayReslice->Update();
429 mOverlayMapper = vtkSmartPointer<vtkImageMapToWindowLevelColors>::New();
430 #if VTK_MAJOR_VERSION <= 5
431 mOverlayMapper->SetInput(mOverlayReslice->GetOutput());
433 mOverlayMapper->SetInputData(mOverlayReslice->GetOutput());
436 if (!mOverlayActor) {
437 mOverlayActor = vtkSmartPointer<vvBlendImageActor>::New();
438 #if VTK_MAJOR_VERSION <= 5
439 mOverlayActor->SetInput(mOverlayMapper->GetOutput());
441 mOverlayActor->GetMapper()->SetInputConnection(mOverlayMapper->GetOutputPort());
443 mOverlayActor->SetPickable(0);
444 mOverlayActor->SetVisibility(true);
445 mOverlayActor->SetOpacity(0.5);
446 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
447 mOverlayActor->GetMapper()->BorderOn();
451 //stupid but necessary : the Overlay need to be rendered before fusion
453 this->GetRenderer()->RemoveActor(mFusionActor);
454 this->GetRenderer()->AddActor(mOverlayActor);
455 this->GetRenderer()->AddActor(mFusionActor);
457 this->GetRenderer()->AddActor(mOverlayActor);
459 //Synchronize orientation and slice
460 AdjustResliceToSliceOrientation(mOverlayReslice);
461 this->UpdateDisplayExtent();
462 this->SetTSlice(mCurrentTSlice);
465 //------------------------------------------------------------------------------
468 //------------------------------------------------------------------------------
469 void vvSlicer::SetFusion(vvImage::Pointer fusion, int fusionSequenceCode)
470 { //out << __func__ << endl;
471 mFusionSequenceCode = fusionSequenceCode;
472 if (fusion->GetVTKImages().size()) {
474 mFusionVisibility = true;
476 if (!mFusionReslice) {
477 mFusionReslice = vtkSmartPointer<vtkImageReslice>::New();
478 mFusionReslice->SetInterpolationModeToLinear();
479 mFusionReslice->AutoCropOutputOn();
480 mFusionReslice->SetBackgroundColor(-1000,-1000,-1000,1);
483 mConcatenatedFusionTransform->Identity();
484 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[0]);
485 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
486 mFusionReslice->SetResliceTransform(mConcatenatedFusionTransform);
487 #if VTK_MAJOR_VERSION <= 5
488 mFusionReslice->SetInput(0, mFusion->GetFirstVTKImageData());
490 mFusionReslice->SetInputData(0, mFusion->GetFirstVTKImageData());
492 mFusionReslice->Update();
495 mFusionMapper = vtkSmartPointer<vtkImageMapToColors>::New();
497 vtkSmartPointer<vtkLookupTable> lut = vtkLookupTable::New();
499 lut->SetValueRange(0, 1);
500 lut->SetSaturationRange(0, 0);
502 mFusionMapper->SetLookupTable(lut);
503 #if VTK_MAJOR_VERSION <= 5
504 mFusionMapper->SetInput(mFusionReslice->GetOutput());
506 mFusionMapper->SetInputData(mFusionReslice->GetOutput());
510 mFusionActor = vtkSmartPointer<vtkImageActor>::New();
511 #if VTK_MAJOR_VERSION <= 5
512 mFusionActor->SetInput(mFusionMapper->GetOutput());
514 mFusionActor->GetMapper()->SetInputConnection(mFusionMapper->GetOutputPort());
516 mFusionActor->SetPickable(0);
517 mFusionActor->SetVisibility(true);
518 mFusionActor->SetOpacity(0.7);
519 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
520 mFusionActor->GetMapper()->BorderOn();
523 this->GetRenderer()->AddActor(mFusionActor);
526 //Synchronize orientation and slice
527 AdjustResliceToSliceOrientation(mFusionReslice);
528 this->UpdateDisplayExtent();
529 this->SetTSlice(mCurrentTSlice);
532 //------------------------------------------------------------------------------
535 //------------------------------------------------------------------------------
536 bool vvSlicer::GetActorVisibility(const std::string& actor_type, int overlay_index)
537 { //out << __func__ << endl;
539 if (actor_type == "image")
540 vis = mImageVisibility;
541 else if (actor_type == "vector")
543 else if (actor_type == "overlay")
544 vis = mOverlayVisibility;
545 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
546 vis = mFusionVisibility;
547 else if (actor_type == "contour")
548 vis = this->mSurfaceCutActors[overlay_index]->GetActor()->GetVisibility();
551 //------------------------------------------------------------------------------
553 //------------------------------------------------------------------------------
554 void vvSlicer::SetActorVisibility(const std::string& actor_type, int overlay_index ,bool vis)
555 { //out << __func__ << endl;
556 if (actor_type == "image")
557 mImageVisibility = vis;
558 else if (actor_type == "vector")
560 else if (actor_type == "overlay")
561 mOverlayVisibility = vis;
562 else if ( (actor_type == "fusion") || (actor_type == "fusionSequence") )
563 mFusionVisibility = vis;
564 else if (actor_type == "contour")
565 this->mSurfaceCutActors[overlay_index]->GetActor()->SetVisibility(vis);
566 UpdateDisplayExtent();
568 //------------------------------------------------------------------------------
570 //------------------------------------------------------------------------------
571 void vvSlicer::SetVF(vvImage::Pointer vf)
572 { //out << __func__ << endl;
573 if (vf->GetVTKImages().size()) {
575 mVFVisibility = true;
578 mAAFilter= vtkSmartPointer<vtkAssignAttribute>::New();
579 mVOIFilter = vtkSmartPointer<vtkExtractVOI>::New();
580 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
582 #if VTK_MAJOR_VERSION <= 5
583 mVOIFilter->SetInput(vf->GetFirstVTKImageData());
584 mAAFilter->SetInput(mVOIFilter->GetOutput());
586 mVOIFilter->SetInputData(vf->GetFirstVTKImageData());
587 mAAFilter->SetInputData(mVOIFilter->GetOutput());
589 ///This tells VTK to use the scalar (pixel) data of the image to draw the little arrows
590 mAAFilter->Assign(vtkDataSetAttributes::SCALARS, vtkDataSetAttributes::VECTORS, vtkAssignAttribute::POINT_DATA);
593 mArrow = vtkSmartPointer<vvGlyphSource>::New();
594 mArrow->SetGlyphTypeToSpecificArrow();
595 mArrow->SetScale(mScale);
598 // Glyph the gradient vector (with arrows)
600 mGlyphFilter = vtkSmartPointer<vvGlyph2D>::New();
601 #if VTK_MAJOR_VERSION <= 5
602 mGlyphFilter->SetInput(mAAFilter->GetOutput());
603 mGlyphFilter->SetSource(mArrow->GetOutput());
605 mGlyphFilter->SetInputData(mAAFilter->GetOutput());
606 mGlyphFilter->SetSourceData(mArrow->GetOutput());
608 mGlyphFilter->ScalingOn();
609 mGlyphFilter->SetScaleModeToScaleByVector();
610 mGlyphFilter->OrientOn();
611 mGlyphFilter->SetVectorModeToUseVector();
612 mGlyphFilter->SetColorModeToColorByVector();
615 mVFColorLUT = vtkSmartPointer<vtkLookupTable>::New();
617 double mVFColorHSV[3];
618 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
619 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
620 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
621 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
624 mVFMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
625 #if VTK_MAJOR_VERSION <= 5
626 mVFMapper->SetInput(mGlyphFilter->GetOutput());
628 mVFMapper->SetInputData(mGlyphFilter->GetOutput());
630 mVFMapper->ImmediateModeRenderingOn();
631 mVFMapper->SetLookupTable(mVFColorLUT);
634 mVFActor = vtkSmartPointer<vtkActor>::New();
635 mVFActor->SetMapper(mVFMapper);
636 mVFActor->SetPickable(0);
637 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
638 this->UpdateDisplayExtent();
639 this->GetRenderer()->AddActor(mVFActor);
642 SetTSlice(mCurrentTSlice);
645 //------------------------------------------------------------------------------
648 //------------------------------------------------------------------------------
649 void vvSlicer::SetLandmarks(vvLandmarks* landmarks)
650 { //out << __func__ << endl;
651 mLandmarks = landmarks;
655 mCross = vtkSmartPointer<vtkCursor3D>::New();
657 mClipBox = vtkSmartPointer<vtkBox>::New();
659 mLandClipper = vtkSmartPointer<vvClipPolyData>::New();
661 mLandGlyph = vtkSmartPointer<vtkGlyph3D>::New();
663 mLandMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
665 mLandActor = vtkSmartPointer<vtkActor>::New();
667 mCross->SetFocalPoint(0.0,0.0,0.0);
668 mCross->SetModelBounds(-10,10,-10,10,-10,10);
672 mLandClipper->SetClipFunction(mClipBox);
673 mLandClipper->InsideOutOn();
674 #if VTK_MAJOR_VERSION <= 5
675 mLandClipper->SetInput(mLandmarks->GetOutput());
677 mLandGlyph->SetSource(mCross->GetOutput());
678 mLandGlyph->SetInput(mLandClipper->GetOutput());
680 mLandClipper->SetInputData(mLandmarks->GetOutput());
682 mLandGlyph->SetSourceData(mCross->GetOutput());
683 mLandGlyph->SetInputData(mLandClipper->GetOutput());
685 //mLandGlyph->SetIndexModeToScalar();
686 //mLandGlyph->SetRange(0,1);
687 //mLandGlyph->ScalingOff();
689 //mLandGlyph->SetColorModeToColorByScalar();
691 mLandGlyph->SetScaleModeToDataScalingOff();
692 mLandGlyph->SetIndexModeToOff();
694 mLandMapper->SetInputConnection(mLandGlyph->GetOutputPort());
695 //mLandMapper->ScalarVisibilityOff();
697 mLandActor->SetMapper(mLandMapper);
698 mLandActor->GetProperty()->SetColor(255,10,212);
699 mLandActor->SetPickable(0);
700 mLandActor->SetVisibility(true);
701 this->UpdateDisplayExtent();
702 this->GetRenderer()->AddActor(mLandActor);
705 //------------------------------------------------------------------------------
707 //------------------------------------------------------------------------------
708 //FIXME: this function leaks memory, we should fix it someday :)
709 void vvSlicer::RemoveActor(const std::string& actor_type, int overlay_index)
710 { //out << __func__ << endl;
711 if (actor_type == "vector") {
712 Renderer->RemoveActor(mVFActor);
721 if (actor_type == "overlay") {
722 Renderer->RemoveActor(mOverlayActor);
724 mOverlayActor = NULL;
725 mOverlayMapper = NULL;
727 if ( (actor_type == "fusion") || (actor_type == "fusionSequence") ) {
728 Renderer->RemoveActor(mFusionActor);
731 mFusionMapper = NULL;
733 if (actor_type == "contour") {
734 Renderer->RemoveActor(this->mSurfaceCutActors[overlay_index]->GetActor());
735 mSurfaceCutActors.erase(mSurfaceCutActors.begin()+overlay_index);
738 //------------------------------------------------------------------------------
741 //------------------------------------------------------------------------------
742 void vvSlicer::SetVFSubSampling(int sub)
743 { //out << __func__ << endl;
745 mVOIFilter->SetSampleRate(mSubSampling,mSubSampling,mSubSampling);
748 UpdateDisplayExtent();
751 //------------------------------------------------------------------------------
754 //------------------------------------------------------------------------------
755 void vvSlicer::SetVFScale(int scale)
756 { //out << __func__ << endl;
759 mArrow->SetScale(mScale);
760 UpdateDisplayExtent();
763 //------------------------------------------------------------------------------
765 //------------------------------------------------------------------------------
766 void vvSlicer::SetVFWidth(int width)
767 { //out << __func__ << endl;
770 mVFActor->GetProperty()->SetLineWidth(mVFWidth);
771 UpdateDisplayExtent();
774 //------------------------------------------------------------------------------
777 //------------------------------------------------------------------------------
778 void vvSlicer::SetVFLog(int log)
779 { //out << __func__ << endl;
782 mGlyphFilter->SetUseLog(mVFLog);
783 mGlyphFilter->Modified();
785 UpdateDisplayExtent();
788 //------------------------------------------------------------------------------
791 //------------------------------------------------------------------------------
792 void vvSlicer::SetTSlice(int t, bool updateLinkedImages)
793 { //out << __func__ << endl;
794 if (!updateLinkedImages) {
796 #if VTK_MAJOR_VERSION <= 5
797 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
799 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
802 mConcatenatedTransform->Identity();
803 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
804 mConcatenatedTransform->Concatenate(mSlicingTransform);
805 UpdateDisplayExtent();
810 else if ((unsigned int)t >= mImage->GetVTKImages().size())
811 mCurrentTSlice = mImage->GetVTKImages().size() -1;
816 mConcatenatedTransform->Identity();
817 mConcatenatedTransform->Concatenate(mImage->GetTransform()[mCurrentTSlice]);
818 mConcatenatedTransform->Concatenate(mSlicingTransform);
821 #if VTK_MAJOR_VERSION <= 5
822 mImageReslice->SetInput( mImage->GetVTKImages()[mCurrentTSlice] );
824 mImageReslice->SetInputData( mImage->GetVTKImages()[mCurrentTSlice] );
826 if (mVF && mVFActor->GetVisibility()) {
827 if (mVF->GetVTKImages().size() > (unsigned int)mCurrentTSlice)
828 #if VTK_MAJOR_VERSION <= 5
829 mVOIFilter->SetInput(mVF->GetVTKImages()[mCurrentTSlice]);
831 mVOIFilter->SetInputData(mVF->GetVTKImages()[mCurrentTSlice]);
835 if (mOverlay && mOverlayActor->GetVisibility()) {
836 if (mOverlay->GetVTKImages().size() > (unsigned int)t) {
837 mCurrentOverlayTSlice = t;
838 #if VTK_MAJOR_VERSION <= 5
839 mOverlayReslice->SetInput( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
841 mOverlayReslice->SetInputData( mOverlay->GetVTKImages()[mCurrentOverlayTSlice] );
844 // Update overlay transform
845 mConcatenatedOverlayTransform->Identity();
846 mConcatenatedOverlayTransform->Concatenate(mOverlay->GetTransform()[mCurrentOverlayTSlice]);
847 mConcatenatedOverlayTransform->Concatenate(mSlicingTransform);
850 //update the fusion ; except in case this is a fusionSequence, in which case both 'times' should be independent.
851 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode<0)) {
852 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
853 mCurrentFusionTSlice = t;
854 #if VTK_MAJOR_VERSION <= 5
855 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
857 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice]);
860 // Update fusion transform
861 mConcatenatedFusionTransform->Identity();
862 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]);
863 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
866 if (mSurfaceCutActors.size() > 0)
867 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
868 i!=mSurfaceCutActors.end(); i++)
869 (*i)->SetTimeSlice(mCurrentTSlice);
870 UpdateDisplayExtent();
872 //------------------------------------------------------------------------------
875 //------------------------------------------------------------------------------
876 void vvSlicer::SetFusionSequenceTSlice(int t)
877 { //out << __func__ << endl;
878 if (mFusion && mFusionActor->GetVisibility() && (mFusionSequenceCode>=0)) {
879 if (mFusion->GetVTKImages().size() > (unsigned int)t) {
880 mCurrentFusionTSlice = t;
881 #if VTK_MAJOR_VERSION <= 5
882 mFusionReslice->SetInput( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
884 mFusionReslice->SetInputData( mFusion->GetVTKImages()[mCurrentFusionTSlice] );
886 // Update fusion transform
887 mConcatenatedFusionTransform->Identity();
888 mConcatenatedFusionTransform->Concatenate(mFusion->GetTransform()[mCurrentFusionTSlice]); //not really useful...
889 mConcatenatedFusionTransform->Concatenate(mSlicingTransform);
893 UpdateDisplayExtent();
895 //------------------------------------------------------------------------------
898 //------------------------------------------------------------------------------
899 int vvSlicer::GetTSlice()
900 { //out << __func__ << endl;
901 return mCurrentTSlice;
903 //------------------------------------------------------------------------------
905 //------------------------------------------------------------------------------
906 int vvSlicer::GetMaxCurrentTSlice()
907 { //out << __func__ << endl;
908 int t = mCurrentTSlice;
910 t = std::max(t, mCurrentOverlayTSlice);
911 if(mFusion&& (mFusionSequenceCode<0)) //ignore fusionSequence data: for these, the times are not to be related (this way)
912 t = std::max(t, mCurrentFusionTSlice);
915 //------------------------------------------------------------------------------
917 //------------------------------------------------------------------------------
918 int vvSlicer::GetFusionTSlice()
919 { //out << __func__ << endl;
920 return mCurrentFusionTSlice;
922 //------------------------------------------------------------------------------
924 //------------------------------------------------------------------------------
925 int vvSlicer::GetOverlayTSlice()
926 { //out << __func__ << endl;
927 return mCurrentOverlayTSlice;
929 //------------------------------------------------------------------------------
931 //------------------------------------------------------------------------------
932 void vvSlicer::SetSliceOrientation(int orientation)
933 { //out << __func__ << endl;
934 //if 2D image, force to watch in Axial View
936 #if VTK_MAJOR_VERSION <= 5
937 this->GetInput()->GetWholeExtent(extent);
939 int* ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
940 copyExtent(ext, extent);
943 if (extent[5]-extent[4] <= 2)
944 orientation = vtkImageViewer2::SLICE_ORIENTATION_XY;
946 if (orientation < vtkImageViewer2::SLICE_ORIENTATION_YZ ||
947 orientation > vtkImageViewer2::SLICE_ORIENTATION_XY) {
948 vtkErrorMacro("Error - invalid slice orientation " << orientation);
952 this->SliceOrientation = orientation;
955 AdjustResliceToSliceOrientation(mFusionReslice);
958 AdjustResliceToSliceOrientation(mOverlayReslice);
962 // Go to current cursor position
963 // double* cursorPos = GetCursorPosition();
964 // DDV(cursorPos, 3);
965 // SetCurrentPosition(cursorPos[0],cursorPos[1],cursorPos[2],cursorPos[3]);
967 if (mFirstSetSliceOrientation) {
968 int *range = this->GetSliceRange();
970 this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
971 #if VTK_MAJOR_VERSION <= 5
972 mFirstSetSliceOrientation = false;
975 else if (this->Renderer && this->GetInput()) {
976 double s = mCursor[orientation];
977 double sCursor = (s - this->GetInput()->GetOrigin()[orientation])/this->GetInput()->GetSpacing()[orientation];
978 this->Slice = static_cast<int>(sCursor);
981 this->UpdateOrientation();
983 this->UpdateDisplayExtent();
985 if (mFirstSetSliceOrientation) {
986 mFirstSetSliceOrientation = false;
989 if (this->Renderer && this->GetInput()) {
990 double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
991 this->Renderer->ResetCamera();
992 this->Renderer->GetActiveCamera()->SetParallelScale(scale);
997 //----------------------------------------------------------------------------
999 //------------------------------------------------------------------------------
1000 // This function ensures that we sample the slices of a vtkImageReslice filter
1001 // in the direction of the slicer (SliceOrientation) similarly as mImageReslice.
1002 // In other words, we change the grid of the reslice in the same way as the grid
1003 // of the displayed image in the slicing direction.
1004 void vvSlicer::AdjustResliceToSliceOrientation(vtkImageReslice *reslice)
1005 { //out << __func__ << endl;
1006 // Reset autocrop and update output information
1007 reslice->SetOutputOriginToDefault();
1008 reslice->SetOutputSpacingToDefault();
1009 #if VTK_MAJOR_VERSION <= 5
1010 reslice->GetOutput()->UpdateInformation();
1012 reslice->UpdateInformation();
1015 // Ge new origin / spacing
1018 reslice->GetOutput()->GetOrigin(origin);
1019 reslice->GetOutput()->GetSpacing(spacing);
1021 // Use similar spacing as the image in the direction SliceOrientation
1022 spacing[this->SliceOrientation] = mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1024 // Modify origin to be on the image grid in the direction SliceOrientation in 3 steps
1025 // Step 1: from world coordinates to image coordinates
1026 origin[this->SliceOrientation] -= mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1027 origin[this->SliceOrientation] /= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1029 // Step 2: round to nearest grid positionInc. This has been validated as the only
1030 // way to have something consistent with the thickness of a 2D slice visible on the
1031 // other slices. The thickness is accounted for so if the 2D slice is to thin and
1032 // between two slices, one will never be able to see this 2D slice (bug #1883).
1033 origin[this->SliceOrientation] = itk::Math::Round<double>(origin[this->SliceOrientation]);
1035 // Step 3: back to world coordinates
1036 origin[this->SliceOrientation] *= mImageReslice->GetOutput()->GetSpacing()[this->SliceOrientation];
1037 origin[this->SliceOrientation] += mImageReslice->GetOutput()->GetOrigin()[this->SliceOrientation];
1039 // Set new spacing and origin
1040 reslice->SetOutputOrigin(origin);
1041 reslice->SetOutputSpacing(spacing);
1042 reslice->UpdateInformation();
1044 //------------------------------------------------------------------------------
1046 //----------------------------------------------------------------------------
1047 int * vvSlicer::GetExtent()
1048 { //out << __func__ << endl;
1050 if (mUseReducedExtent) {
1051 w_ext = mReducedExtent;
1054 #if VTK_MAJOR_VERSION <= 5
1055 w_ext = GetInput()->GetWholeExtent();
1057 w_ext = mImageReslice->GetInputInformation()->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
1062 //----------------------------------------------------------------------------
1065 //----------------------------------------------------------------------------
1066 int vvSlicer::GetOrientation()
1067 { //out << __func__ << endl;
1068 return this->SliceOrientation;
1070 //----------------------------------------------------------------------------
1073 //----------------------------------------------------------------------------
1074 void vvSlicer::UpdateDisplayExtent()
1075 { cout << __func__ << endl;
1076 vtkImageData *input = this->GetInput();
1078 if (!input || !this->ImageActor) {
1082 #if VTK_MAJOR_VERSION <= 5
1083 input->UpdateInformation();
1085 this->SetSlice( this->GetSlice() ); //SR: make sure the update let the slice in extents
1087 // Local copy of extent
1089 int* ext = GetExtent();
1090 copyExtent(ext, w_ext);
1094 w_ext[ this->SliceOrientation*2 ] = this->Slice;
1095 w_ext[ this->SliceOrientation*2+1 ] = this->Slice;
1098 this->ImageActor->SetVisibility(mImageVisibility);
1099 #if VTK_MAJOR_VERSION <= 5
1100 this->ImageActor->SetDisplayExtent(w_ext);
1102 vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
1104 mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
1105 } catch (const std::bad_cast& e) {
1106 std::cerr << e.what() << std::endl;
1107 std::cerr << "Conversion error" << std::endl;
1110 if (mFirstSetSliceOrientation) {
1111 copyExtent(ext, mRegisterExtent);
1112 this->ImageActor->SetDisplayExtent(w_ext); //initialisation
1114 int w_croppingRegion[6];
1115 copyExtent(mRegisterExtent, w_croppingRegion);
1116 this->ImageActor->SetDisplayExtent(w_ext);
1117 w_croppingRegion[ this->SliceOrientation*2 ] = this->Slice;
1118 w_croppingRegion[ this->SliceOrientation*2+1 ] = this->Slice;
1119 mapperOpenGL->SetCroppingRegion(w_croppingRegion);
1123 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1124 // Fix for bug #1882
1125 dynamic_cast<vtkImageSliceMapper *>(this->ImageActor->GetMapper())->SetOrientation(this->GetOrientation());
1128 // Overlay image actor
1129 if (mOverlay && mOverlayVisibility) {
1130 //mOverlayMapper->GetOutput()->Print(cout);
1131 AdjustResliceToSliceOrientation(mOverlayReslice);
1133 this->ConvertImageToImageDisplayExtent(input, w_ext, mOverlayReslice->GetOutput(), overExtent);
1134 #if VTK_MAJOR_VERSION <= 5
1135 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetWholeExtent());
1137 bool out = ClipDisplayedExtent(overExtent, mOverlayMapper->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT()));
1139 mOverlayActor->SetVisibility(!out);
1140 mOverlayActor->SetDisplayExtent( overExtent );
1141 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1142 // Fix for bug #1882
1143 dynamic_cast<vtkImageSliceMapper *>(mOverlayActor->GetMapper())->SetOrientation(this->GetOrientation());
1147 mOverlayActor->SetVisibility(false);
1149 // Fusion image actor
1150 if (mFusion && mFusionVisibility) {
1151 AdjustResliceToSliceOrientation(mFusionReslice);
1153 this->ConvertImageToImageDisplayExtent(input, w_ext, mFusionReslice->GetOutput(), fusExtent);
1154 #if VTK_MAJOR_VERSION <= 5
1155 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetWholeExtent());
1157 bool out = ClipDisplayedExtent(fusExtent, mFusionMapper->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT()));
1159 mFusionActor->SetVisibility(!out);
1160 mFusionActor->SetDisplayExtent( fusExtent );
1161 #if VTK_MAJOR_VERSION >= 6 || (VTK_MAJOR_VERSION >= 5 && VTK_MINOR_VERSION >= 10)
1162 // Fix for bug #1882
1163 dynamic_cast<vtkImageSliceMapper *>(mFusionActor->GetMapper())->SetOrientation(this->GetOrientation());
1167 mFusionActor->SetVisibility(false);
1168 // Vector field actor
1169 double* camera = Renderer->GetActiveCamera()->GetPosition();
1170 double* image_bounds = ImageActor->GetBounds();
1171 double position[3] = {0, 0, 0};
1172 position[this->SliceOrientation] = image_bounds[this->SliceOrientation*2];
1174 //print_vector<double, 6>("camera", camera);
1175 //print_vector<double, 6>("image_bounds", image_bounds);
1176 //print_vector<double, 3>("position", position);
1178 // find where to place the VF actor. to deal with
1179 // z-buffer issues, the VF is placed right in front of the image,
1180 // subject to a small offset. the position actually depends on the
1181 // the location of the camera relative to the image.
1183 if (camera[this->SliceOrientation] < image_bounds[this->SliceOrientation*2])
1186 if (mVF && mVFVisibility) {
1188 #if VTK_MAJOR_VERSION <= 5
1189 mVF->GetVTKImages()[0]->UpdateInformation();
1191 //this->UpdateInformation();
1193 this->ConvertImageToImageDisplayExtent(input, w_ext, mVF->GetVTKImages()[0], vfExtent);
1194 #if VTK_MAJOR_VERSION <= 5
1195 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetWholeExtent());
1197 bool out = ClipDisplayedExtent(vfExtent, mVOIFilter->GetInput()->GetInformation()->Get(vtkDataObject::DATA_EXTENT()));
1199 mVFActor->SetVisibility(!out);
1200 mVOIFilter->SetVOI(vfExtent);
1201 int orientation[3] = {1,1,1};
1202 orientation[this->SliceOrientation] = 0;
1203 mGlyphFilter->SetOrientation(orientation[0], orientation[1], orientation[2]);
1204 mVFMapper->Update();
1206 position[this->SliceOrientation] += offset;
1207 mVFActor->SetPosition(position);
1210 mVFActor->SetVisibility(false);
1216 for(unsigned int i=0; i<6; i++)
1217 bounds[i] = ImageActor->GetBounds()[i];
1218 bounds[ this->SliceOrientation*2 ] = ImageActor->GetBounds()[ this->SliceOrientation*2 ]-fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1219 bounds[ this->SliceOrientation*2+1 ] = ImageActor->GetBounds()[ this->SliceOrientation*2+1 ]+fabs(this->GetInput()->GetSpacing()[this->SliceOrientation]);
1220 mClipBox->SetBounds(bounds);
1224 position[this->SliceOrientation] = offset;
1225 mLandActor->SetPosition(position);
1228 // Figure out the correct clipping range
1229 if (this->Renderer) {
1230 if (this->InteractorStyle &&
1231 this->InteractorStyle->GetAutoAdjustCameraClippingRange()) {
1232 this->Renderer->ResetCameraClippingRange();
1234 vtkCamera *cam = this->Renderer->GetActiveCamera();
1237 this->ImageActor->GetBounds(bounds);
1238 double spos = (double)bounds[this->SliceOrientation * 2];
1239 double cpos = (double)cam->GetPosition()[this->SliceOrientation];
1240 double range = fabs(spos - cpos);
1241 double *spacing = input->GetSpacing();
1242 double sumSpacing = spacing[0] + spacing[1] + spacing[2];
1243 cam->SetClippingRange(range - sumSpacing, range + sumSpacing);
1248 //----------------------------------------------------------------------------
1250 //----------------------------------------------------------------------------
1251 void vvSlicer::ConvertImageToImageDisplayExtent(vtkImageData *sourceImage, const int sourceExtent[6],
1252 vtkImageData *targetImage, int targetExtent[6])
1253 { //out << __func__ << endl;
1255 for(unsigned int i=0; i<6; i++) {
1256 // From source voxel coordinates to world coordinates
1257 dExtents[i] = sourceImage->GetOrigin()[i/2] + sourceImage->GetSpacing()[i/2] * sourceExtent[i];
1259 // From world coordinates to floating point target voxel coordinates
1260 dExtents[i] = (dExtents[i]- targetImage->GetOrigin()[i/2]) / targetImage->GetSpacing()[i/2];
1262 // Round to current slice or larger extent
1263 if(i/2==this->GetOrientation())
1264 targetExtent[i] = itk::Math::Round<double>(dExtents[i]);
1266 targetExtent[i] = itk::Math::Ceil<double>(dExtents[i]);
1268 targetExtent[i] = itk::Math::Floor<double>(dExtents[i]);
1271 //----------------------------------------------------------------------------
1273 //----------------------------------------------------------------------------
1274 bool vvSlicer::ClipDisplayedExtent(int extent[6], int refExtent[6])
1275 { //out << __func__ << endl;
1279 for (int i = 0; i < maxBound; i = i+2) {
1280 //if we are totally outside the image
1281 if ( extent[i] > refExtent[i+1] || extent[i+1] < refExtent[i] ) {
1285 //crop to the limit of the image
1286 extent[i] = std::max(extent[i], refExtent[i]);
1287 extent[i] = std::min(extent[i], refExtent[i+1]);;
1288 extent[i+1] = std::max(extent[i+1], refExtent[i]);
1289 extent[i+1] = std::min(extent[i+1], refExtent[i+1]);;
1292 for (int i = 0; i < maxBound; i = i+2) {
1293 extent[i] = refExtent[i];
1294 extent[i+1] = refExtent[i];
1298 //----------------------------------------------------------------------------
1301 //----------------------------------------------------------------------------
1302 void vvSlicer::UpdateOrientation()
1303 { //out << __func__ << endl;
1304 // Set the camera position
1305 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1307 switch (this->SliceOrientation) {
1308 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1309 cam->SetFocalPoint(0,0,0);
1310 cam->SetPosition(0,0,-1); // -1 if medical ?
1311 cam->SetViewUp(0,-1,0);
1314 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1315 cam->SetFocalPoint(0,0,0);
1316 cam->SetPosition(0,-1,0); // 1 if medical ?
1317 cam->SetViewUp(0,0,1);
1320 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1321 cam->SetFocalPoint(0,0,0);
1322 cam->SetPosition(-1,0,0); // -1 if medical ?
1323 cam->SetViewUp(0,0,1);
1328 //----------------------------------------------------------------------------
1331 //----------------------------------------------------------------------------
1332 void vvSlicer::SetOpacity(double s)
1333 { //out << __func__ << endl;
1334 this->GetImageActor()->SetOpacity(s);
1336 //----------------------------------------------------------------------------
1339 //----------------------------------------------------------------------------
1340 void vvSlicer::SetRenderWindow(int orientation, vtkRenderWindow * rw)
1341 { //out << __func__ << endl;
1342 this->Superclass::SetRenderWindow(rw);
1343 this->SetupInteractor(rw->GetInteractor());
1344 ca->SetImageActor(this->GetImageActor());
1345 ca->SetWindowLevel(this->GetWindowLevel());
1346 ca->SetText(3, "<window>\n<level>");
1357 crossCursor->SetModelBounds(bounds);
1359 this->GetRenderer()->AddActor(pdmA);
1360 this->GetRenderer()->AddActor(ca);
1361 this->GetRenderer()->ResetCamera();
1363 //this is just a mapping between the labeling of the orientations presented to the user and
1364 //the one used by vtk
1365 SetSliceOrientation(2-(orientation%3));
1368 //----------------------------------------------------------------------------
1371 //----------------------------------------------------------------------------
1372 void vvSlicer::ResetCamera()
1373 { //out << __func__ << endl;
1374 this->GetRenderer()->ResetCamera();
1376 //----------------------------------------------------------------------------
1379 //----------------------------------------------------------------------------
1380 void vvSlicer::SetDisplayMode(bool i)
1381 { //out << __func__ << endl;
1382 this->GetRenderer()->SetDraw(i);
1383 if (i) UpdateDisplayExtent();
1385 //----------------------------------------------------------------------------
1388 //----------------------------------------------------------------------------
1389 void vvSlicer::FlipHorizontalView()
1390 { //out << __func__ << endl;
1391 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1393 double *position = cam->GetPosition();
1394 double factor[3] = {1, 1, 1};
1395 factor[this->SliceOrientation] = -1;
1396 cam->SetPosition(factor[0]*position[0],factor[1]*position[1],factor[2]*position[2]);
1398 /* switch (this->SliceOrientation) {
1399 case vtkImageViewer2::SLICE_ORIENTATION_XY:
1400 cam->SetPosition(position[0],position[1],-position[2]);
1403 case vtkImageViewer2::SLICE_ORIENTATION_XZ:
1404 cam->SetPosition(position[0],-position[1],position[2]);
1407 case vtkImageViewer2::SLICE_ORIENTATION_YZ:
1408 cam->SetPosition(-position[0],position[1],position[2]);
1412 this->Renderer->ResetCameraClippingRange();
1413 this->UpdateDisplayExtent();
1416 //----------------------------------------------------------------------------
1419 //----------------------------------------------------------------------------
1420 void vvSlicer::FlipVerticalView()
1421 { //out << __func__ << endl;
1422 vtkCamera *cam = this->Renderer ? this->Renderer->GetActiveCamera() : NULL;
1424 FlipHorizontalView();
1425 double *viewup = cam->GetViewUp();
1426 cam->SetViewUp(-viewup[0],-viewup[1],-viewup[2]);
1427 this->UpdateDisplayExtent();
1430 //----------------------------------------------------------------------------
1433 //----------------------------------------------------------------------------
1434 void vvSlicer::SetColorWindow(double window)
1435 { //out << __func__ << endl;
1436 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1438 double level = this->GetWindowLevel()->GetLevel();
1439 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1442 this->vtkImageViewer2::SetColorWindow(window);
1444 //----------------------------------------------------------------------------
1446 //----------------------------------------------------------------------------
1447 void vvSlicer::SetColorLevel(double level)
1448 { //out << __func__ << endl;
1449 vtkLookupTable* LUT = static_cast<vtkLookupTable*>(this->GetWindowLevel()->GetLookupTable());
1451 double window = this->GetWindowLevel()->GetWindow();
1452 LUT->SetTableRange(level-fabs(window)/2,level+fabs(window)/2);
1455 this->vtkImageViewer2::SetColorLevel(level);
1457 //----------------------------------------------------------------------------
1459 //----------------------------------------------------------------------------
1460 double vvSlicer::GetOverlayColorWindow()
1461 { //out << __func__ << endl;
1463 return mOverlayMapper->GetWindow();
1467 //----------------------------------------------------------------------------
1469 //----------------------------------------------------------------------------
1470 double vvSlicer::GetOverlayColorLevel()
1471 { //out << __func__ << endl;
1473 return mOverlayMapper->GetLevel();
1477 //----------------------------------------------------------------------------
1479 //----------------------------------------------------------------------------
1480 void vvSlicer::SetOverlayColorWindow(double window)
1481 { //out << __func__ << endl;
1483 mOverlayMapper->SetWindow(window);
1485 //----------------------------------------------------------------------------
1487 //----------------------------------------------------------------------------
1488 void vvSlicer::SetOverlayColorLevel(double level)
1489 { //out << __func__ << endl;
1491 mOverlayMapper->SetLevel(level);
1493 //----------------------------------------------------------------------------
1495 //----------------------------------------------------------------------------
1496 // Returns the min an the max value in a 20%x20% region around the mouse pointer
1497 void vvSlicer::GetExtremasAroundMousePointer(double & min, double & max, vtkImageData *image, vtkTransform *transform)
1498 { //out << __func__ << endl;
1499 //Get mouse pointer position in view coordinates
1502 for(int i=0; i<3; i++) {
1503 corner1[i] = mCurrent[i];
1504 corner2[i] = mCurrent[i];
1507 this->Renderer->WorldToView(corner1[0], corner1[1], corner1[2]);
1508 this->Renderer->WorldToView(corner2[0], corner2[1], corner2[2]);
1510 // In view coordinates, x is the slicer width and y is the slicer height are the in-plane axis
1512 this->Renderer->GetTiledSize(&w, &h);
1513 corner1[0] -= 0.2*h/(double)w;
1514 corner2[0] += 0.2*h/(double)w;
1517 this->Renderer->ViewToWorld(corner1[0], corner1[1], corner1[2]);
1518 this->Renderer->ViewToWorld(corner2[0], corner2[1], corner2[2]);
1520 //Convert to image pixel coordinates (rounded)
1521 transform->TransformPoint(corner1, corner1);
1522 transform->TransformPoint(corner2, corner2);
1523 int iLocalExtents[6];
1524 for(int i=0; i<3; i++) {
1525 corner1[i] = (corner1[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1526 corner2[i] = (corner2[i] - image->GetOrigin()[i])/image->GetSpacing()[i];
1528 iLocalExtents[i*2 ] = lrint(corner1[i]);
1529 iLocalExtents[i*2+1] = lrint(corner2[i]);
1531 if(iLocalExtents[i*2 ]>iLocalExtents[i*2+1])
1532 std::swap(iLocalExtents[i*2], iLocalExtents[i*2+1]);
1535 vtkSmartPointer<vtkExtractVOI> voiFilter = vtkSmartPointer<vtkExtractVOI>::New();
1536 #if VTK_MAJOR_VERSION <= 5
1537 voiFilter->SetInput(image);
1539 voiFilter->SetInputData(image);
1541 voiFilter->SetVOI(iLocalExtents);
1542 voiFilter->Update();
1543 if (!voiFilter->GetOutput()->GetNumberOfPoints()) {
1549 vtkSmartPointer<vtkImageAccumulate> accFilter = vtkSmartPointer<vtkImageAccumulate>::New();
1550 #if VTK_MAJOR_VERSION <= 5
1551 accFilter->SetInput(voiFilter->GetOutput());
1553 accFilter->SetInputData(voiFilter->GetOutput());
1555 accFilter->Update();
1557 min = *(accFilter->GetMin());
1558 max = *(accFilter->GetMax());
1560 //----------------------------------------------------------------------------
1562 //----------------------------------------------------------------------------
1563 double vvSlicer::GetScalarComponentAsDouble(vtkImageData *image, double X, double Y, double Z, int &ix, int &iy, int &iz, int component)
1564 { //out << __func__ << endl;
1568 #if VTK_MAJOR_VERSION <= 5
1569 if (ix < image->GetWholeExtent()[0] ||
1570 ix > image->GetWholeExtent()[1] ||
1571 iy < image->GetWholeExtent()[2] ||
1572 iy > image->GetWholeExtent()[3] ||
1573 iz < image->GetWholeExtent()[4] ||
1574 iz > image->GetWholeExtent()[5] )
1575 return std::numeric_limits<double>::quiet_NaN();
1576 image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1579 if (ix < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0] ||
1580 ix > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1] ||
1581 iy < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2] ||
1582 iy > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3] ||
1583 iz < image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4] ||
1584 iz > image->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5] )
1585 return std::numeric_limits<double>::quiet_NaN();
1586 //image->SetUpdateExtent(ix, ix, iy, iy, iz, iz);
1590 return image->GetScalarComponentAsDouble(ix, iy, iz, component);
1592 //----------------------------------------------------------------------------
1594 //----------------------------------------------------------------------------
1595 void vvSlicer::Render()
1596 { cout << __func__ << endl;
1597 if (this->mFusion && mFusionActor->GetVisibility() && showFusionLegend) {
1598 legend->SetLookupTable(this->GetFusionMapper()->GetLookupTable());
1599 legend->UseOpacityOn();
1600 legend->SetVisibility(1);
1602 else if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay) {
1603 legend->SetLookupTable(this->GetWindowLevel()->GetLookupTable());
1604 legend->UseOpacityOff();
1605 legend->SetVisibility(1);
1606 } else legend->SetVisibility(0);
1608 if (ca->GetVisibility()) {
1610 std::stringstream worldPos(" ");
1612 mConcatenatedTransform->TransformPoint(mCurrent, pt);
1613 double X = (pt[0] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[0])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[0];
1614 double Y = (pt[1] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[1])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[1];
1615 double Z = (pt[2] - mImage->GetVTKImages()[mCurrentTSlice]->GetOrigin()[2])/mImage->GetVTKImages()[mCurrentTSlice]->GetSpacing()[2];
1616 #if VTK_MAJOR_VERSION <= 5
1617 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[0]-0.5 &&
1618 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[1]+0.5 &&
1619 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[2]-0.5 &&
1620 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[3]+0.5 &&
1621 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[4]-0.5 &&
1622 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetWholeExtent()[5]+0.5) {
1626 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1628 if(ImageActor->GetVisibility())
1629 worldPos << "data value : " << value << std::endl;
1631 worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
1632 << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
1633 << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
1636 worldPos << "pixel : " << ix << ' '
1643 if (X >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[0]-0.5 &&
1644 X <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[1]+0.5 &&
1645 Y >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[2]-0.5 &&
1646 Y <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[3]+0.5 &&
1647 Z >= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[4]-0.5 &&
1648 Z <= mImage->GetVTKImages()[mCurrentTSlice]->GetInformation()->Get(vtkDataObject::DATA_EXTENT())[5]+0.5) {
1651 double value = this->GetScalarComponentAsDouble(mImage->GetVTKImages()[mCurrentTSlice], X, Y, Z, ix, iy, iz);
1653 if(ImageActor->GetVisibility())
1654 worldPos << "data value : " << value << std::endl;
1656 worldPos << "mm : " << lrint(mCurrentBeforeSlicingTransform[0]) << ' '
1657 << lrint(mCurrentBeforeSlicingTransform[1]) << ' '
1658 << lrint(mCurrentBeforeSlicingTransform[2]) << ' '
1661 worldPos << "pixel : " << ix << ' '
1669 ca->SetText(1,worldPos.str().c_str());
1671 std::stringstream slicePos;
1672 slicePos << "Slice: " << this->GetSlice();
1673 ca->SetText(2, slicePos.str().c_str());
1676 if (pdmA->GetVisibility()) {
1677 double x = mCursor[0];
1678 double y = mCursor[1];
1679 double z = mCursor[2];
1680 double xCursor = (x - this->GetInput()->GetOrigin()[0])/this->GetInput()->GetSpacing()[0];
1681 double yCursor = (y - this->GetInput()->GetOrigin()[1])/this->GetInput()->GetSpacing()[1];
1682 double zCursor = (z - this->GetInput()->GetOrigin()[2])/this->GetInput()->GetSpacing()[2];
1683 #if VTK_MAJOR_VERSION <= 5
1684 if (xCursor >= this->GetImageActor()->GetDisplayExtent()[0]-0.5 &&
1685 xCursor < this->GetImageActor()->GetDisplayExtent()[1]+0.5 &&
1686 yCursor >= this->GetImageActor()->GetDisplayExtent()[2]-0.5 &&
1687 yCursor < this->GetImageActor()->GetDisplayExtent()[3]+0.5 &&
1688 zCursor >= this->GetImageActor()->GetDisplayExtent()[4]-0.5 &&
1689 zCursor < this->GetImageActor()->GetDisplayExtent()[5]+0.5 ) {
1690 vtkRenderer * renderer = this->Renderer;
1692 renderer->WorldToView(x,y,z);
1693 renderer->ViewToNormalizedViewport(x,y,z);
1694 renderer->NormalizedViewportToViewport(x,y);
1695 renderer->ViewportToNormalizedDisplay(x,y);
1696 renderer->NormalizedDisplayToDisplay(x,y);
1697 crossCursor->SetFocalPoint(x,y,z);
1699 crossCursor->SetFocalPoint(-1,-1,z);
1700 crossCursor->Update();
1703 vtkSmartPointer<vtkOpenGLImageSliceMapper> mapperOpenGL= vtkSmartPointer<vtkOpenGLImageSliceMapper>::New();
1705 mapperOpenGL = dynamic_cast<vtkOpenGLImageSliceMapper*>(GetImageActor()->GetMapper());
1706 } catch (const std::bad_cast& e) {
1707 std::cerr << e.what() << std::endl;
1708 std::cerr << "Conversion error" << std::endl;
1712 if (xCursor >= mapperOpenGL->GetCroppingRegion()[0]-0.5 &&
1713 xCursor < mapperOpenGL->GetCroppingRegion()[1]+0.5 &&
1714 yCursor >= mapperOpenGL->GetCroppingRegion()[2]-0.5 &&
1715 yCursor < mapperOpenGL->GetCroppingRegion()[3]+0.5 &&
1716 zCursor >= mapperOpenGL->GetCroppingRegion()[4]-0.5 &&
1717 zCursor < mapperOpenGL->GetCroppingRegion()[5]+0.5 ) {
1718 vtkRenderer * renderer = this->Renderer;
1720 renderer->WorldToView(x,y,z);
1721 renderer->ViewToNormalizedViewport(x,y,z);
1722 renderer->NormalizedViewportToViewport(x,y);
1723 renderer->ViewportToNormalizedDisplay(x,y);
1724 renderer->NormalizedDisplayToDisplay(x,y);
1725 crossCursor->SetFocalPoint(x,y,z);
1727 crossCursor->SetFocalPoint(-1,-1,z);
1728 crossCursor->Update();
1732 if (mOverlay && mOverlayActor->GetVisibility()) {
1733 if(mLinkOverlayWindowLevel) {
1734 mOverlayMapper->SetWindow(this->GetColorWindow());
1735 mOverlayMapper->SetLevel(this->GetColorLevel());
1737 #if VTK_MAJOR_VERSION <= 5
1738 mOverlayMapper->GetOutput()->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1740 mOverlayMapper->SetUpdateExtent(mOverlayActor->GetDisplayExtent());
1742 mOverlayActor->Print(cout);
1743 mOverlayMapper->Update();
1745 if (mFusion && mFusionActor->GetVisibility()) {
1746 #if VTK_MAJOR_VERSION <= 5
1747 mFusionMapper->GetOutput()->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1749 mFusionMapper->SetUpdateExtent(mFusionActor->GetDisplayExtent());
1751 mFusionMapper->Update();
1756 this->GetRenderWindow()->Render();
1758 //----------------------------------------------------------------------------
1761 //----------------------------------------------------------------------------
1762 void vvSlicer::UpdateCursorPosition()
1763 { //out << __func__ << endl;
1764 pdmA->SetVisibility(true);
1765 mCursor[0] = mCurrent[0];
1766 mCursor[1] = mCurrent[1];
1767 mCursor[2] = mCurrent[2];
1768 mCursor[3] = mCurrentTSlice;
1770 //----------------------------------------------------------------------------
1773 //----------------------------------------------------------------------------
1774 void vvSlicer::UpdateLandmarks()
1775 { //out << __func__ << endl;
1776 vtkPolyData *pd = static_cast<vtkPolyData*>(mLandClipper->GetInput());
1777 if (pd->GetPoints()) {
1778 //mLandGlyph->SetRange(0,1);
1779 //mLandGlyph->Modified();
1780 //mLandGlyph->Update();
1782 mClipBox->Modified();
1783 mLandClipper->Update();
1784 mLandMapper->Update();
1785 //Let's add the captions
1786 //First remove all captions:
1787 for(unsigned int i=0;i<mLandLabelActors.size();i++) {
1788 this->Renderer->RemoveActor2D(mLandLabelActors[i]);
1789 //allActors2D->Remove (mLandLabelActors[i]);
1791 mLandLabelActors.clear();
1792 //Next add the captions to the displayed points
1793 for (vtkIdType id=0; id<mLandClipper->GetOutput()->GetNumberOfPoints(); id++) {
1794 double *position = mLandClipper->GetOutput()->GetPoint(id);
1795 vtkStdString label = static_cast<vtkStringArray*>(mLandClipper->GetOutput()->GetPointData()->GetAbstractArray("labels"))->GetValue(id);
1796 vtkSmartPointer<vtkCaptionActor2D> label_actor = vtkSmartPointer<vtkCaptionActor2D>::New();
1797 label_actor->SetCaption(label);
1798 label_actor->SetAttachmentPoint(position);
1799 label_actor->GetCaptionTextProperty()->SetColor(1,0,0);
1800 label_actor->GetCaptionTextProperty()->SetOrientation(33.333333);
1801 label_actor->GetCaptionTextProperty()->SetFontFamilyToTimes();
1802 label_actor->GetCaptionTextProperty()->SetBold(0);
1803 label_actor->GetCaptionTextProperty()->SetFontSize(6);
1804 label_actor->BorderOff();
1805 label_actor->LeaderOff();
1806 label_actor->ThreeDimensionalLeaderOff();
1807 mLandLabelActors.push_back(label_actor);
1808 this->Renderer->AddActor2D(mLandLabelActors[id]);
1813 //----------------------------------------------------------------------------
1816 //----------------------------------------------------------------------------
1817 void vvSlicer::SetSlice(int slice)
1818 { //out << __func__ << endl;
1819 int *range = this->GetSliceRange();
1821 if (slice < range[0]) {
1823 } else if (slice > range[1]) {
1828 if (this->Slice == slice) {
1832 this->Slice = slice;
1835 this->UpdateDisplayExtent();
1837 // Seems to work without this line
1840 //----------------------------------------------------------------------------
1842 //----------------------------------------------------------------------------
1843 int vvSlicer::GetTMax()
1844 { //out << __func__ << endl;
1845 int tmax = (int)mImage->GetVTKImages().size() - 1;
1847 tmax = std::max(tmax, (int)mOverlay->GetVTKImages().size()-1);
1850 //----------------------------------------------------------------------------
1852 //----------------------------------------------------------------------------
1853 void vvSlicer::SetContourSlice()
1854 { //out << __func__ << endl;
1855 if (mSurfaceCutActors.size() > 0)
1856 for (std::vector<vvMeshActor*>::iterator i=mSurfaceCutActors.begin();
1857 i!=mSurfaceCutActors.end(); i++) {
1859 (*i)->SetSlicingOrientation(this->SliceOrientation);
1860 (*i)->SetCutSlice((this->Slice)*this->GetImage()->GetSpacing()[this->SliceOrientation]+
1861 this->GetImage()->GetOrigin()[this->SliceOrientation]);
1864 //----------------------------------------------------------------------------
1867 //----------------------------------------------------------------------------
1868 void vvSlicer::ForceUpdateDisplayExtent()
1869 { //out << __func__ << endl;
1870 this->UpdateDisplayExtent();
1872 //----------------------------------------------------------------------------
1875 //----------------------------------------------------------------------------
1876 int* vvSlicer::GetDisplayExtent()
1877 { //out << __func__ << endl;
1878 return this->GetImageActor()->GetDisplayExtent();
1880 //----------------------------------------------------------------------------
1883 //----------------------------------------------------------------------------
1884 void vvSlicer::PrintSelf(ostream& os, vtkIndent indent)
1885 { //out << __func__ << endl;
1886 this->Superclass::PrintSelf(os, indent);
1888 //----------------------------------------------------------------------------
1891 //----------------------------------------------------------------------------
1892 void vvSlicer::SetVFColor(double r, double g, double b)
1893 { //out << __func__ << endl;
1894 double mVFColorHSV[3];
1899 vtkMath::RGBToHSV(mVFColor, mVFColorHSV);
1900 mVFColorLUT->SetHueRange(mVFColorHSV[0], mVFColorHSV[0]);
1901 mVFColorLUT->SetSaturationRange(mVFColorHSV[1],mVFColorHSV[1]);
1902 mVFColorLUT->SetValueRange(mVFColorHSV[2], mVFColorHSV[2]);
1906 //----------------------------------------------------------------------------
1909 //----------------------------------------------------------------------------
1910 void vvSlicer::SetRegisterExtent(int ext[6])
1911 { //out << __func__ << endl;
1912 copyExtent(ext, mRegisterExtent);
1914 //----------------------------------------------------------------------------
1917 //----------------------------------------------------------------------------
1918 void vvSlicer::GetRegisterExtent(int ext[6])
1919 { //out << __func__ << endl;
1920 copyExtent(mRegisterExtent, ext);
1922 //----------------------------------------------------------------------------