NIREP

NIREPvtkViewImage.cxx

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   vtkINRIA3D
00004 Module:    $Id: NIREPvtkViewImage.cxx,v 1.5 2011/02/08 21:07:53 hawle Exp $
00005 Language:  C++
00006 Author:    $Author: hawle $
00007 Date:      $Date: 2011/02/08 21:07:53 $
00008 Version:   $Revision: 1.5 $
00009 
00010 Copyright (c) 2007 INRIA - Asclepios Project. All rights reserved.
00011 See Copyright.txt for details.
00012 
00013 This software is distributed WITHOUT ANY WARRANTY; without even
00014 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015 PURPOSE.  See the above copyright notices for more information.
00016 
00017 =========================================================================*/
00018 #include "NIREPvtkViewImage.h"
00019 
00020 #include "vtkObjectFactory.h"
00021 
00022 #include "vtkProp.h"
00023 #include "vtkTextActor.h"
00024 #include "vtkCoordinate.h"
00025 #include "vtkProperty.h"
00026 #include "vtkProperty2D.h"
00027 #include "vtkTextProperty.h"
00028 #include "vtkScalarsToColors.h"
00029 #include "vtkImageMapToWindowLevelColors.h"
00030 #include "vtkImageData.h"
00031 #include "vtkActor.h"
00032 #include "vtkRenderWindow.h"
00033 
00034 
00035 #include <vtkColorTransferFunction.h>
00036 #include <vtkDataArray.h>
00037 #include <vtkPointData.h>
00038 #include <vtkCellData.h>
00039 #include <vtkExtractGeometry.h>
00040 #include <vtkDataSet.h>
00041 #include <vtkUnstructuredGrid.h>
00042 #include <vtkDataSetMapper.h>
00043 #include <vtkPlane.h>
00044 #include <vtkPlaneCollection.h>
00045 #include <vtkPolyDataMapper2D.h>
00046 #include <vtkActor2D.h>
00047 #include <vtkClipDataSet.h>
00048 #include <vtkCutter.h>
00049 #include <vtkBox.h>
00050 #include <vtkPolyDataWriter.h>
00051 #include <vtkPolyDataNormals.h>
00052 #include <vtkImageAccumulate.h>
00053 #include <vtkDoubleArray.h>
00054 #include <vtkIntArray.h>
00055 #include <vtkMath.h>
00056 
00057 //#include <vtkScalarBarWidget.h>
00058 
00059 #ifdef vtkINRIA3D_USE_ITK
00060 #include <itkImageToVTKImageFilter.h>
00061 #endif
00062 
00063 #include <assert.h>
00064 #include <iostream>
00065 #include <sstream>
00066 #include <cmath>
00067 
00068 vtkCxxRevisionMacro(NIREPvtkViewImage, "$Revision: 1.5 $");
00069 vtkStandardNewMacro(NIREPvtkViewImage);
00070 
00071 
00072 NIREPvtkViewImage::NIREPvtkViewImage()
00073 {
00074 
00075   this->Image       = 0;
00076   this->MaskImage   = 0;
00077   this->OverlappingImage = 0;
00078   this->MaskLUT     = 0;
00079   this->Transform   = 0;
00080   this->LookupTable = 0;
00081   this->LinkWindowLevel = 1;
00082   this->LinkPosition    = 1;
00083   this->LinkZoom        = 0;
00084   this->FirstImage      = 1;
00085 
00086   this->Visibility = 1;
00087   this->SizeDataVisibility = 1;
00088   
00089   this->Shift = 0.0;
00090   this->Scale = 1.0;
00091   this->Level = 128.0;
00092   this->Window = 255.0;
00093   this->Zoom   = 1.0;
00094 
00095   this->ScalarBar = vtkScalarBarWidget::New();
00096   this->ScalarBar->GetScalarBarActor()->GetLabelTextProperty()->SetColor (1.0,1.0,1.0);
00097   this->ScalarBar->GetScalarBarActor()->GetTitleTextProperty()->SetColor (1.0,1.0,1.0);
00098   //this->ScalarBar->GetScalarBarActor()->SetTextPositionToPrecedeScalarBar();
00099   this->ScalarBar->GetScalarBarActor()->GetLabelTextProperty()->BoldOff();
00100   this->ScalarBar->GetScalarBarActor()->GetLabelTextProperty()->ShadowOff();
00101   this->ScalarBar->GetScalarBarActor()->GetLabelTextProperty()->ItalicOff();
00102   this->ScalarBar->GetScalarBarActor()->SetNumberOfLabels (3);
00103   this->ScalarBar->GetScalarBarActor()->GetLabelTextProperty()->SetFontSize (1);
00104   this->ScalarBar->GetScalarBarActor()->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport();
00105   this->ScalarBar->GetScalarBarActor()->SetWidth (0.1);
00106   this->ScalarBar->GetScalarBarActor()->SetHeight (0.5);
00107   this->ScalarBar->GetScalarBarActor()->SetPosition (0.9,0.3);
00108   //this->ScalarBar->GetScalarBarActor()->GetPositionCoordinate()->SetValue ( 0.1, 0.01);
00109   //this->ScalarBar->GetScalarBarActor()->PickableOff();
00110 
00111   vtkLookupTable* bwLut = vtkLookupTable::New();
00112   bwLut->SetTableRange (0, 1);
00113   bwLut->SetSaturationRange (0, 0);
00114   bwLut->SetHueRange (0, 0);
00115   bwLut->SetValueRange (0, 1);
00116   bwLut->SetAlphaRange (0, 1);
00117   bwLut->Build();
00118   this->SetLookupTable (bwLut);
00119   bwLut->Delete();
00120 
00121   this->CurrentPoint[0] = 0.0;
00122   this->CurrentPoint[1] = 0.0;
00123   this->CurrentPoint[2] = 0.0;
00124 
00125   this->ResetWindowLevelMode = UserDefinedPercentage;
00126   this->WindowLevelPercentage = 0.1;
00127 
00128   // Increase polygon offsets to support some OpenGL drivers
00129   //vtkMapper::SetResolveCoincidentTopologyToPolygonOffset();
00130   //vtkMapper::SetResolveCoincidentTopologyPolygonOffsetParameters(10,10);
00131 
00132 #ifdef vtkINRIA3D_USE_ITK
00133   this->ImageConverter = 0;
00134   this->ITKImage = 0;
00135 #endif
00136 
00137 }
00138 
00139 
00140 NIREPvtkViewImage::~NIREPvtkViewImage()
00141 {
00142   if( this->Transform )
00143   {
00144     this->Transform->Delete();
00145   }
00146 
00147   if( this->Image )
00148   {
00149     this->Image->Delete();
00150   }
00151 
00152 
00153   //this->ScalarBar->GetScalarBarActor()->Delete();
00154   this->ScalarBar->Delete();
00155 
00156   this->RemoveAllDataSet();
00157 
00158   this->LookupTable->Delete();
00159 
00160 #ifdef vtkINRIA3D_USE_ITK
00161   this->ImageConverter = 0;
00162   this->ITKImage = 0;
00163 #endif
00164 
00165 }
00166 
00167 
00168 void NIREPvtkViewImage::Initialize()
00169 {
00170   vtkSynchronizedView::Initialize();
00171   this->SetLookupTable( this->GetLookupTable() );
00172   this->AddActor (this->ScalarBar->GetScalarBarActor());
00173 }
00174 
00175 
00176 void NIREPvtkViewImage::Uninitialize()
00177 {
00178   this->RemoveActor (this->ScalarBar->GetScalarBarActor());
00179   vtkSynchronizedView::Uninitialize();
00180 }
00181 
00182 
00183 void NIREPvtkViewImage::RegisterImage(vtkImageData* image)
00184 {
00185   if(!image)  return;
00186 
00187   if( image != this->Image )
00188   {
00189     if( this->Image != NULL )
00190     {
00191       this->Image->UnRegister (this);
00192     }
00193 
00194     this->Image = image;
00195     this->Image->Register (this);
00196   }
00197 }
00198 
00199 
00200 double NIREPvtkViewImage::GetWholeMinPosition(unsigned int p_axis)
00201 {
00202   if(!this->Image)
00203   {
00204     return -VTK_LARGE_FLOAT;
00205   }
00206 
00207   return this->Image->GetBounds()[p_axis * 2];
00208 }
00209 
00210 
00211 double NIREPvtkViewImage::GetWholeMaxPosition(unsigned int p_axis)
00212 {
00213   if(!this->Image)
00214   {
00215     return VTK_LARGE_FLOAT;
00216   }
00217 
00218   return this->Image->GetBounds()[p_axis * 2 + 1];
00219 }
00220 
00221 
00222 unsigned int NIREPvtkViewImage::GetOrthogonalAxis(unsigned int p_plan)
00223 {
00224   assert(p_plan<NB_DIRECTION_IDS);
00225 
00226   switch(p_plan)
00227   {
00228       case SAGITTAL_ID:
00229         return X_ID;
00230         break;
00231 
00232       case CORONAL_ID:
00233         return Y_ID;
00234         break;
00235 
00236       case AXIAL_ID:
00237 
00238         return Z_ID;
00239         break;
00240   }
00241   return 0;
00242 }
00243 
00244 
00245 int NIREPvtkViewImage::GetSliceForPosition(const double pos[3], unsigned int p_plan)
00246 {
00247 
00248   if( !this->GetImage() )
00249   {
00250     return 0;
00251   }
00252 
00253   assert(p_plan < NB_DIRECTION_IDS);
00254 
00255   double*       spacing = this->GetImage()->GetSpacing();
00256   double*       origin  = this->GetImage()->GetOrigin();
00257 
00258   int   axis     = this->GetOrthogonalAxis(p_plan);
00259   double  soft_pos = pos[axis];
00260   
00261   // Treat extreme position at the end of the last pixel
00262   /*
00263     double  pos_max  = this->GetWholeMaxPosition(axis);
00264     double  pos_min  = this->GetWholeMinPosition(axis);
00265     
00266     if ((soft_pos > pos_max-0.005) && (soft_pos < pos_max+0.005))
00267     {
00268     soft_pos = pos_max-0.005;
00269     }
00270     if ((soft_pos > pos_min-0.005) && (soft_pos < pos_min+0.005))
00271     {
00272     soft_pos = pos_min+0.005;
00273     }
00274   */
00275   return (int)vtkMath::Round((soft_pos-origin[axis])/spacing[axis]);
00276 }
00277 
00278 
00279 int NIREPvtkViewImage::GetSlice(unsigned int p_plan)
00280 {
00281   const double* pos = this->GetCurrentPoint();
00282   return this->GetSliceForPosition (pos, p_plan);
00283 }
00284 
00285 
00286 void NIREPvtkViewImage::SetSlice (unsigned int p_plan, int p_zslice)
00287 {
00288   double pos[3];
00289   this->GetPositionForSlice (p_zslice, p_plan, pos);
00290   this->SetCurrentPoint(pos);
00291 }
00292 
00293 
00294 void NIREPvtkViewImage::GetPositionForSlice (int p_zslice, int orientation, double pos[3])
00295 {
00296   
00297   if( !this->GetImage() )
00298   {
00299     return;
00300   }
00301 
00302   unsigned int axis = this->GetOrthogonalAxis(orientation);
00303   
00304   double* spacing = this->GetImage()->GetSpacing();
00305   int*    extent  = this->GetImage()->GetWholeExtent();
00306   double* origin  = this->GetImage()->GetOrigin();
00307   int     slice   = p_zslice;
00308   
00309   int dims[3];
00310   dims[0] = extent[1];
00311   dims[1] = extent[3];
00312   dims[2] = extent[5];
00313   
00314   if(slice >= dims[axis])  slice = dims[axis];
00315   if(slice <  0)           slice = 0;
00316   
00317   this->GetCurrentPoint(pos);
00318   pos[axis] = origin[axis] + slice * spacing[axis];
00319 }
00320 
00321 
00322 void NIREPvtkViewImage::SyncSetSlice(unsigned int p_plan, int p_zslice)
00323 {
00324   if( this->IsLocked() )
00325   {
00326     return;
00327   }
00328   
00329   this->SetSlice(p_plan, p_zslice);
00330   
00331   this->Lock();
00332   for( unsigned int i=0; i<this->Children.size(); i++)
00333   {
00334     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00335     if( view && view->GetLinkPosition())
00336     {
00337       view->SyncSetSlice (p_plan, p_zslice);
00338       view->Update();
00339     }
00340   }
00341   this->UnLock();
00342 }
00343 
00344 
00345 void NIREPvtkViewImage::SyncSetZSlice(int p_zslice)
00346 {
00347   if( this->IsLocked() )
00348   {
00349     return;
00350   }
00351 
00352   this->SetZSlice(p_zslice);
00353 
00354   this->Lock();
00355   for( unsigned int i=0; i<this->Children.size(); i++)
00356   {
00357     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00358     if( view && view->GetLinkPosition())
00359     {
00360       view->SyncSetZSlice (p_zslice);
00361       view->Update();
00362     }
00363   }
00364   this->UnLock();
00365 }
00366 
00367 
00368 void NIREPvtkViewImage::SetCurrentPoint (const double p_point[3])
00369 {
00370   this->CurrentPoint[0] = p_point[0];
00371   this->CurrentPoint[1] = p_point[1];
00372   this->CurrentPoint[2] = p_point[2];
00373   this->UpdatePosition();
00374   this->InvokeEvent (NIREPvtkViewImage::ViewImagePositionChangeEvent, NULL);
00375 }
00376 
00377 
00378 void NIREPvtkViewImage::GetVoxelCoordinates(double pos[3], int p_coordinates[3])
00379 {
00380   if(!this->Image)
00381   {
00382     return;
00383   }
00384   p_coordinates[this->GetOrthogonalAxis(SAGITTAL_ID)] = this->GetSliceForPosition(pos, SAGITTAL_ID);
00385   p_coordinates[this->GetOrthogonalAxis(CORONAL_ID)]  = this->GetSliceForPosition(pos, CORONAL_ID);
00386   p_coordinates[this->GetOrthogonalAxis(AXIAL_ID)]    = this->GetSliceForPosition(pos, AXIAL_ID);
00387 }
00388 
00389 
00390 void NIREPvtkViewImage::GetCurrentVoxelCoordinates(int p_coordinates[3])
00391 {
00392   p_coordinates[this->GetOrthogonalAxis(SAGITTAL_ID)] = this->GetSlice(SAGITTAL_ID);
00393   p_coordinates[this->GetOrthogonalAxis(CORONAL_ID)]  = this->GetSlice(CORONAL_ID);
00394   p_coordinates[this->GetOrthogonalAxis(AXIAL_ID)]    = this->GetSlice(AXIAL_ID);
00395 }
00396 
00397 
00398 void NIREPvtkViewImage::SyncSetCurrentPoint(const double p_point[3])
00399 {
00400 
00401   if( this->IsLocked() )
00402   {
00403     return;
00404   }
00405 
00406   this->SetCurrentPoint (p_point);
00407 
00408   this->Lock();
00409 
00410   for( unsigned int i=0; i<this->Children.size(); i++)
00411   {
00412     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast( this->Children[i] );
00413     if( view && view->GetLinkPosition())
00414     {
00415       view->SyncSetCurrentPoint (p_point);
00416       view->Update();
00417     }
00418   }
00419 
00420   this->UnLock();
00421 
00422   
00423 
00424 }
00425 
00426 
00427 double NIREPvtkViewImage::GetCurrentPointDoubleValue ()
00428 {
00429   if (!this->Image)
00430   {
00431     return -1;
00432   }
00433 
00434   int coordinates[3];
00435   this->GetCurrentVoxelCoordinates(coordinates);
00436   
00437   void *scalar = this->GetImage()->GetScalarPointer(coordinates);
00438 
00439   if( !scalar ) return -1.0;
00440 
00441   switch (this->GetImage()->GetScalarType()) {
00442   case VTK_DOUBLE:
00443     return (*(double*)scalar);
00444   case VTK_FLOAT:
00445     return (double) (*(float*)scalar);
00446   case VTK_UNSIGNED_LONG:
00447     return (double) (*(unsigned long*)scalar);
00448   case VTK_LONG:
00449     return (double) (*(long*)scalar);
00450   case VTK_UNSIGNED_INT:
00451     return (double) (*(unsigned int*)scalar);
00452   case VTK_INT:
00453     return (double) (*(int*)scalar);
00454   case VTK_UNSIGNED_SHORT:
00455     return (double) (*(unsigned short*)scalar);
00456   case VTK_SHORT:
00457     return (double) (*(short*)scalar);
00458   case VTK_UNSIGNED_CHAR:
00459     return (double) (*(unsigned char*)scalar);
00460   case VTK_CHAR:
00461     return (double) (*(char*)scalar);
00462   }
00463   return -1;
00464 }
00465 
00466 
00467 void NIREPvtkViewImage::SyncResetCurrentPoint()
00468 {
00469   if( this->IsLocked() )
00470   {
00471     return;
00472   }
00473 
00474   this->ResetCurrentPoint();
00475   
00476   this->Lock();
00477   for( unsigned int i=0; i<this->Children.size(); i++)
00478   {
00479     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast( this->Children[i] );
00480     if( view && view->GetLinkPosition() )
00481     {
00482       view->SyncResetCurrentPoint ();
00483       view->Update();
00484     }
00485   }
00486   this->UnLock();
00487 
00488 }
00489 
00490 
00491 void NIREPvtkViewImage::ResetCurrentPoint()
00492 {
00493 
00494   if (!this->Image)
00495   {
00496     return;
00497   }
00498   
00499   double* bounds  = this->GetImage()->GetBounds();
00500   double  pos[3] =
00501     {
00502       (bounds[0]+bounds[1])/2.0,
00503       (bounds[2]+bounds[3])/2.0,
00504       (bounds[4]+bounds[5])/2.0
00505     };
00506   
00507   this->SetCurrentPoint(pos);
00508 }
00509 
00510 
00511 void NIREPvtkViewImage::SyncSetWindow (double w)
00512 {
00513   if( this->IsLocked() )
00514   {
00515     return;
00516   }
00517 
00518 
00519   this->SetWindow (w);
00520 
00521 
00522   // this boolean is used so that the other observe won't call
00523   // SetCurrentPoint again and again and again...
00524   this->Lock();
00525   for( unsigned int i=0; i<this->Children.size(); i++)
00526   {
00527 
00528     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00529 
00530     if( view && view->GetLinkWindowLevel() )
00531     {
00532       view->SyncSetWindow (w);
00533       view->Update();
00534     }
00535   }
00536 
00537   this->UnLock();
00538 }
00539 
00540 
00541 void NIREPvtkViewImage::SyncStartWindowing ()
00542 {
00543   if( this->IsLocked() )
00544   {
00545     return;
00546   }
00547 
00548 
00549   this->StartWindowing ();
00550 
00551 
00552   // this boolean is used so that the other observe won't call
00553   // SetCurrentPoint again and again and again...
00554   this->Lock();
00555   for( unsigned int i=0; i<this->Children.size(); i++)
00556   {
00557 
00558     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00559 
00560     if( view && view->GetLinkWindowLevel() )
00561     {
00562       view->SyncStartWindowing ();
00563       view->Update();
00564     }
00565   }
00566 
00567   this->UnLock();
00568 }
00569 
00570 
00571 void NIREPvtkViewImage::SyncEndWindowing ()
00572 {
00573   if( this->IsLocked() )
00574   {
00575     return;
00576   }
00577 
00578 
00579   this->EndWindowing ();
00580 
00581 
00582   // this boolean is used so that the other observe won't call
00583   // SetCurrentPoint again and again and again...
00584   this->Lock();
00585   for( unsigned int i=0; i<this->Children.size(); i++)
00586   {
00587 
00588     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00589 
00590     if( view && view->GetLinkWindowLevel() )
00591     {
00592       view->SyncEndWindowing ();
00593       view->Update();
00594     }
00595   }
00596 
00597   this->UnLock();
00598 }
00599 
00600 
00601 void NIREPvtkViewImage::SyncSetLevel (double l)
00602 {
00603 
00604   if( this->IsLocked() )
00605   {
00606     return;
00607   }
00608 
00609 
00610   this->SetLevel (l);
00611 
00612   // this boolean is used so that the other observe won't call
00613   // SetCurrentPoint again and again and again...
00614   this->Lock();
00615   for( unsigned int i=0; i<this->Children.size(); i++)
00616   {
00617     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00618 
00619     if( view && view->GetLinkWindowLevel() )
00620     {
00621       view->SyncSetLevel (l);
00622       view->Update();
00623     }
00624   }
00625 
00626   this->UnLock();
00627 
00628 }
00629 
00630 
00631 void NIREPvtkViewImage::SetWindowLevelFrom(NIREPvtkViewImage* p_view)
00632 {
00633   if (p_view)
00634   {
00635     this->SetWindow( p_view->GetWindow() );
00636     this->SetLevel( p_view->GetLevel() );
00637   }
00638 }
00639 
00640 
00641 
00642 void NIREPvtkViewImage::SyncResetWindowLevel()
00643 {
00644 
00645   if( this->IsLocked() )
00646   {
00647     return;
00648   }
00649 
00650 
00651   this->ResetWindowLevel();
00652 
00653   this->Lock();
00654   for( unsigned int i=0; i<this->Children.size(); i++)
00655   {
00656     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast(this->Children[i]);
00657     if( view && view->GetLinkWindowLevel() )
00658     {
00659       view->SyncResetWindowLevel ();
00660       view->Update();
00661     }
00662   }
00663   this->UnLock();
00664 }
00665 
00666 
00667 void NIREPvtkViewImage::ResetWindowLevel()
00668 {
00669 
00670   if (!this->Image)
00671   {
00672     return;
00673   }
00674   
00675 
00676   this->Image->UpdateInformation();
00677   int* extent = this->Image->GetWholeExtent();
00678   if( extent[0]==extent[1] && extent[2]==extent[3] && extent[4]==extent[5] ) // image has a null extent -> GetScalarRange() will crash
00679   {
00680     return;
00681   }
00682   
00683   this->Image->SetUpdateExtentToWholeExtent();
00684   this->Image->Update();
00685   
00686   
00687   if( this->Image->GetScalarType() == VTK_UNSIGNED_CHAR  && (this->Image->GetNumberOfScalarComponents()==3 || this->Image->GetNumberOfScalarComponents()==4) )
00688   {
00689     return;
00690   }
00691 
00692 
00693   double* range = this->Image->GetScalarRange();
00694 
00695   double window = range[1]-range[0];
00696   double level = 0.5*(range[1]+range[0]);
00697 
00698   if( this->ResetWindowLevelMode ==  FullRange )
00699   {
00700     // nothing to do
00701   }
00702   else if( this->ResetWindowLevelMode ==  UserDefinedPercentage )
00703   {
00704 
00705     vtkImageAccumulate* histogram = vtkImageAccumulate::New();
00706     histogram->SetInput ( this->Image );
00707 
00708     int extent[6] = {0, 1000, 0, 0, 0, 0};
00709     histogram->SetComponentExtent (extent);
00710 
00711     double spacing[3] = { (range[1]-range[0])/1000.0, 0.0, 0.0};
00712     histogram->SetComponentSpacing (spacing);
00713 
00714     double origin[3] = {range[0], 0.0, 0.0};
00715     histogram->SetComponentOrigin (origin);
00716     histogram->Update();
00717 
00718 
00719     vtkImageData* output = histogram->GetOutput();
00720     vtkIntArray*  ptData = vtkIntArray::SafeDownCast (output->GetPointData()->GetScalars());
00721 
00722     if( !ptData)
00723     {
00724       vtkErrorMacro( << "Error: Cannot cast point data to integers.");
00725       return;
00726     }
00727 
00728     double numVox = histogram->GetVoxelCount();
00729     double onePercent = numVox/100.0;
00730 
00731     int start=1;
00732     double currentPercent = 0.0;
00733     while( currentPercent<this->UserDefinedPercentage && start<1000-this->UserDefinedPercentage)
00734     {
00735       double tuple;
00736       ptData->GetTuple (start, &tuple);
00737       currentPercent += tuple/onePercent;
00738       start++;
00739     }
00740 
00741     currentPercent = 0.0;
00742     int end = 999;
00743     while( currentPercent<this->UserDefinedPercentage && end>0 )
00744     {
00745       double tuple;
00746       ptData->GetTuple (end, &tuple);
00747       currentPercent += tuple/onePercent;
00748       end--;
00749     }
00750 
00751     window = (end-start)*(range[1]-range[0])/1000.0;
00752     level = 0.5*(start + end)*(range[1]-range[0])/1000.0;
00753 
00754     histogram->Delete();
00755   }
00756 
00757 
00758   window = (window-this->GetShift())/this->GetScale();
00759   level = (level-this->GetShift())/this->GetScale();
00760 
00761 
00762   this->SetWindow ( window );
00763   this->SetLevel ( level );
00764 }
00765 
00766 
00767 bool NIREPvtkViewImage::HasDataSet (vtkDataSet* dataset)
00768 {
00769   if( !dataset )
00770   {
00771     return false;
00772   }
00773 
00774   bool res = false;
00775   for( unsigned int i=0; i<this->DataSetList.size(); i++)
00776   {
00777     if( dataset == this->DataSetList[i] )
00778     {
00779       res = true;
00780       break;
00781     }
00782   }
00783 
00784   return res;
00785 }
00786 
00787 
00788 vtkActor* NIREPvtkViewImage::SyncAddDataSet (vtkDataSet* dataset,  vtkProperty* property)
00789 {
00790 
00791   if( this->IsLocked() )
00792   {
00793     return NULL;
00794   }
00795 
00796 
00797   vtkActor* actor = this->AddDataSet (dataset, property);
00798 
00799   this->Lock();
00800   for( unsigned int i=0; i<this->Children.size(); i++)
00801   {
00802     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00803 
00804     if( view )
00805     {
00806       view->SyncAddDataSet (dataset, property);
00807     }
00808   }
00809   this->UnLock();
00810 
00811   return actor;
00812 }
00813 
00814 
00815 vtkActor* NIREPvtkViewImage::AddDataSet (vtkDataSet* dataset,  vtkProperty* property)
00816 {
00817   vtkErrorMacro(<<"You should not use this function here\nPlease use vtkViewImage2D or vtkViewImage3D classes instead (or any derived class).");
00818   return NULL;
00819 }
00820 
00821 
00822 void NIREPvtkViewImage::SyncRemoveDataSet (vtkDataSet* dataset)
00823 {
00824 
00825   if( this->IsLocked() )
00826   {
00827     return;
00828   }
00829 
00830 
00831   this->RemoveDataSet (dataset);
00832 
00833   this->Lock();
00834   for( unsigned int i=0; i<this->Children.size(); i++)
00835   {
00836     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00837 
00838     if( view )
00839     {
00840       view->SyncRemoveDataSet (dataset);
00841     }
00842   }
00843   this->UnLock();
00844 
00845 }
00846 
00847 
00848 void NIREPvtkViewImage::RemoveDataSet (vtkDataSet* dataset)
00849 {
00850 
00851   if (!dataset)
00852   {
00853     return;
00854   }
00855 
00856   std::vector<vtkActor*>   t_actorlist = this->DataSetActorList;
00857   std::vector<vtkDataSet*> t_datasetlist = this->DataSetList;
00858   this->DataSetActorList.clear();
00859   this->DataSetList.clear();
00860 
00861   for (unsigned int i=0; i<t_datasetlist.size(); i++)
00862   {
00863     if (dataset != t_datasetlist[i])
00864     {
00865       this->DataSetList.push_back (t_datasetlist[i]);
00866       this->DataSetActorList.push_back (t_actorlist[i]);
00867       }
00868     else
00869     {
00870       this->RemoveActor (t_actorlist[i]);
00871     }
00872   }
00873 }
00874 
00875 
00876 void NIREPvtkViewImage::SyncRemoveAllDataSet ()
00877 {
00878 
00879   if( this->IsLocked() )
00880   {
00881     return;
00882   }
00883 
00884 
00885   this->RemoveAllDataSet ();
00886 
00887   this->Lock();
00888   for( unsigned int i=0; i<this->Children.size(); i++)
00889   {
00890     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00891 
00892     if( view )
00893     {
00894       view->SyncRemoveAllDataSet ();
00895     }
00896   }
00897   this->UnLock();
00898 }
00899 
00900 
00901 void NIREPvtkViewImage::RemoveAllDataSet ()
00902 {
00903   for (unsigned int i=0; i<this->DataSetActorList.size(); i++)
00904   {
00905     this->RemoveActor (this->DataSetActorList[i]);
00906   }
00907   this->DataSetActorList.clear();
00908   this->DataSetList.clear();
00909 
00910 }
00911 
00912 
00913 void NIREPvtkViewImage::SyncModifyActors(vtkDataSet* dataset, bool cellColors)
00914 {
00915 
00916   if( this->IsLocked() )
00917   {
00918     return;
00919   }
00920 
00921 
00922   this->ModifyActors (dataset, cellColors);
00923 
00924 
00925   this->Lock();
00926   for( unsigned int i=0; i<this->Children.size(); i++)
00927   {
00928     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00929 
00930     if( view )
00931     {
00932       view->SyncModifyActors (dataset, cellColors);
00933     }
00934   }
00935   this->UnLock();
00936 
00937 }
00938 
00939 
00940 void NIREPvtkViewImage::ModifyActors(vtkDataSet* dataset, bool cellColors)
00941 {
00942   bool doit = true;
00943 
00944 
00945   if (!dataset)
00946   {
00947     doit = false;
00948   }
00949 
00950   vtkMapper* mapper = NULL;
00951 
00952   if (doit)
00953   {
00954     for (unsigned int i=0; i<this->DataSetList.size(); i++)
00955     {
00956       if (dataset == this->DataSetList[i])
00957       {
00958         mapper = this->DataSetActorList[i]->GetMapper();
00959         break;
00960       }
00961     }
00962     if (!mapper)
00963     {
00964       doit = false;
00965     }
00966   }
00967 
00968   if (doit)
00969   {
00970     mapper->Modified();
00971 
00972     if ( cellColors )
00973       mapper->SetScalarModeToUseCellData();
00974     else
00975       mapper->SetScalarModeToUsePointData();
00976   }
00977 }
00978 
00979 
00980 void NIREPvtkViewImage::SyncColorDataSetByArray(vtkDataSet* dataset, const char* arrayname, vtkColorTransferFunction* transfer)
00981 {
00982 
00983   if( this->IsLocked() )
00984   {
00985     return;
00986   }
00987 
00988 
00989   this->ColorDataSetByArray (dataset, arrayname, transfer);
00990 
00991 
00992   this->Lock();
00993   for( unsigned int i=0; i<this->Children.size(); i++)
00994   {
00995     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
00996 
00997     if( view )
00998     {
00999       view->SyncColorDataSetByArray (dataset, arrayname, transfer);
01000     }
01001   }
01002   this->UnLock();
01003 }
01004 
01005 
01006 void NIREPvtkViewImage::ColorDataSetByArray(vtkDataSet* dataset, const char* arrayname, vtkColorTransferFunction* transfer)
01007 {
01008 
01009   bool doit = true;
01010   
01011   if (!dataset)
01012   {
01013     doit = false;
01014   }
01015 
01016   vtkDataArray* array = NULL;
01017   vtkMapper* mapper = NULL;
01018 
01019   if (doit)
01020   {
01021     for (unsigned int i=0; i<this->DataSetList.size(); i++)
01022     {
01023       if (dataset == this->DataSetList[i])
01024       {
01025         mapper = this->DataSetActorList[i]->GetMapper();
01026         break;
01027       }
01028     }
01029     if (!mapper)
01030     {
01031       doit = false;
01032     }
01033   }
01034 
01035   if (doit)
01036   {
01037     mapper->Modified();
01038 
01039     if (dataset->GetCellData())
01040     {
01041       array = dataset->GetCellData()->GetArray (arrayname);
01042       if (array)
01043       {
01044         mapper->SetScalarModeToUseCellFieldData();
01045       }
01046     }
01047 
01048     if (!array && dataset->GetPointData())
01049     {
01050       array = dataset->GetPointData()->GetArray (arrayname);
01051       if (array)
01052       {
01053         mapper->SetScalarModeToUsePointFieldData();
01054       }
01055 
01056     }
01057 
01058     if (!array)
01059     {
01060       mapper->SetScalarModeToDefault();
01061       mapper->SetInterpolateScalarsBeforeMapping(0);
01062       doit = false;
01063     }
01064   }
01065 
01066   if (doit)
01067   {
01068     mapper->SetLookupTable (transfer);
01069     mapper->SetScalarRange (array->GetRange()[0], array->GetRange()[1]);
01070     mapper->SetInterpolateScalarsBeforeMapping(1);
01071     mapper->SelectColorArray (array->GetName());
01072   }
01073 }
01074 
01075 
01076 
01077 vtkDataSet* NIREPvtkViewImage::GetDataSet (unsigned int i)
01078 {
01079   if (i<0 || i>this->DataSetList.size())
01080     return NULL;
01081 
01082   return this->DataSetList[i];
01083 }
01084 
01085 
01086 vtkDataSet* NIREPvtkViewImage::GetDataSetFromActor (vtkActor* actor)
01087 {
01088   for (unsigned int i=0; i<this->DataSetActorList.size(); i++)
01089   {
01090     if (actor == this->DataSetActorList[i])
01091       return this->DataSetList[i];
01092   }
01093   return NULL;
01094 }
01095 
01096 
01097 vtkActor* NIREPvtkViewImage::GetDataSetActor (unsigned int i)
01098 {
01099   if (i<0 || i>=this->DataSetActorList.size())
01100     return NULL;
01101 
01102   return this->DataSetActorList[i];
01103 }
01104 
01105 
01106 vtkActor* NIREPvtkViewImage::GetDataSetActor (vtkDataSet* dataset)
01107 {
01108   if (!dataset)
01109     return NULL;
01110 
01111   for (unsigned int i=0; i<this->DataSetList.size(); i++)
01112   {
01113     if (dataset == this->DataSetList[i])
01114       return this->DataSetActorList[i];
01115   }
01116   return NULL;
01117 
01118 }
01119 
01120 
01121 void NIREPvtkViewImage::PrintSelf(ostream& os, vtkIndent indent)
01122 {
01123   this->Superclass::PrintSelf(os, indent);
01124 }
01125 
01126 
01127 void NIREPvtkViewImage::SyncSetZoom (double factor)
01128 {
01129 
01130   if( this->IsLocked() )
01131   {
01132     return;
01133   }
01134 
01135   this->SetZoom (factor);
01136 
01137   this->Lock();
01138   for( unsigned int i=0; i<this->Children.size(); i++)
01139   {
01140     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01141 
01142     if( view && view->GetLinkZoom() )
01143     {
01144       view->SyncSetZoom (factor);
01145       view->Update();
01146     }
01147   }
01148 
01149   this->UnLock();
01150 }
01151 
01152 
01153 void NIREPvtkViewImage::SyncSetLookupTable (vtkScalarsToColors* lut)
01154 {
01155 
01156   if( this->IsLocked() )
01157   {
01158     return;
01159   }
01160 
01161   this->SetLookupTable (lut);
01162 
01163   this->Lock();
01164   for( unsigned int i=0; i<this->Children.size(); i++)
01165   {
01166     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01167 
01168     if( view )
01169     {
01170       view->SyncSetLookupTable (lut);
01171       view->Update();
01172     }
01173   }
01174 
01175   this->UnLock();
01176 }
01177 
01178 
01179 void NIREPvtkViewImage::SyncResetZoom ()
01180 {
01181 
01182   if( this->IsLocked() )
01183   {
01184     return;
01185   }
01186 
01187   this->ResetZoom ();
01188 
01189   this->Lock();
01190   for( unsigned int i=0; i<this->Children.size(); i++)
01191   {
01192     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01193 
01194     if( view )
01195     {
01196       if( view->GetLinkZoom() )
01197       {
01198         view->SyncResetZoom ();
01199         view->Update();
01200       }
01201     }
01202   }
01203 
01204   this->UnLock();
01205 }
01206 
01207 
01208 void NIREPvtkViewImage::ResetZoom()
01209 {
01210   this->ResetCamera();
01211   this->Zoom = 1.0;
01212 }
01213 
01214 
01215 void NIREPvtkViewImage::SyncReset ()
01216 {
01217 
01218   if( this->IsLocked() )
01219   {
01220     return;
01221   }
01222 
01223   this->Reset ();
01224 
01225   this->Lock();
01226   for( unsigned int i=0; i<this->Children.size(); i++)
01227   {
01228     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01229 
01230     if( view )
01231     {
01232       view->SyncReset ();
01233       view->Update();
01234     }
01235   }
01236 
01237   this->UnLock();
01238 }
01239 
01240 
01241 void NIREPvtkViewImage::SetSizeData (const char* str)
01242 {
01243   this->SizeData_str = str;
01244   this->Modified();
01245 }
01246 
01247 
01248 void NIREPvtkViewImage::SetPatientNameData (const char* str)
01249 {
01250   this->PatientNameData = str;
01251   this->Modified();
01252 }
01253 
01254 
01255 void NIREPvtkViewImage::SetStudyNameData (const char* str)
01256 {
01257   this->StudyNameData = str;
01258   this->Modified();
01259 }
01260 
01261 
01262 void NIREPvtkViewImage::SetSerieNameData (const char* str)
01263 {
01264   this->SerieNameData = str;
01265   this->Modified();
01266 }
01267 
01268 
01269 void NIREPvtkViewImage::SetSizeDataVisibility (int val)
01270 {
01271   this->SizeDataVisibility = val;
01272   if( val )
01273   {
01274     this->SetUpLeftAnnotation ( this->GetSizeData() );
01275   }
01276   else
01277   {
01278     this->SetUpRightAnnotation ("");
01279   }
01280   
01281 }
01282 
01283 
01284 void NIREPvtkViewImage::SyncSetMaskImage (vtkImageData* mask, vtkLookupTable* lut)
01285 {
01286 
01287   if( this->IsLocked() )
01288   {
01289     return;
01290   }
01291 
01292   this->SetMaskImage (mask, lut);
01293 
01294   this->Lock();
01295   for( unsigned int i=0; i<this->Children.size(); i++)
01296   {
01297     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01298 
01299     if( view )
01300     {
01301       view->SyncSetMaskImage (mask, lut);
01302       view->Update();
01303     }
01304   }
01305 
01306   this->UnLock();
01307 }
01308 
01309 
01310 void NIREPvtkViewImage::SyncSetOverlappingImage (vtkImageData* image)
01311 {
01312 
01313   if( this->IsLocked() )
01314   {
01315     return;
01316   }
01317 
01318   this->SetOverlappingImage (image);
01319 
01320   this->Lock();
01321   for( unsigned int i=0; i<this->Children.size(); i++)
01322   {
01323     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01324 
01325     if( view )
01326     {
01327       view->SyncSetOverlappingImage (image);
01328       view->Update();
01329     }
01330   }
01331 
01332   this->UnLock();
01333 }
01334 
01335 
01336 
01337 void NIREPvtkViewImage::SyncRemoveMaskImage ()
01338 {
01339 
01340   if( this->IsLocked() )
01341   {
01342     return;
01343   }
01344 
01345   this->RemoveMaskImage ();
01346 
01347   this->Lock();
01348   for( unsigned int i=0; i<this->Children.size(); i++)
01349   {
01350     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01351 
01352     if( view )
01353     {
01354       view->SyncRemoveMaskImage ();
01355       view->Update();
01356     }
01357   }
01358 
01359   this->UnLock();
01360 }
01361 
01362 
01363 void NIREPvtkViewImage::SyncRemoveOverlappingImage ()
01364 {
01365 
01366   if( this->IsLocked() )
01367   {
01368     return;
01369   }
01370 
01371   this->RemoveOverlappingImage ();
01372 
01373   this->Lock();
01374   for( unsigned int i=0; i<this->Children.size(); i++)
01375   {
01376     NIREPvtkViewImage* view = NIREPvtkViewImage::SafeDownCast (this->Children[i]);
01377 
01378     if( view )
01379     {
01380       view->SyncRemoveOverlappingImage ();
01381       view->Update();
01382     }
01383   }
01384 
01385   this->UnLock();
01386 }
01387 
01388 
01389 #ifdef vtkINRIA3D_USE_ITK
01390 
01391 void NIREPvtkViewImage::SetITKImage (itk::Image<double, 3>::Pointer itkImage)
01392 {
01393   if( itkImage.IsNull() )
01394   {
01395     return;
01396   }
01397 
01398   typedef itk::ImageToVTKImageFilter< itk::Image<double, 3> > ConverterType;
01399   ConverterType::Pointer myConverter = ConverterType::New();
01400   myConverter->SetInput ( itkImage );
01401   myConverter->Update();
01402   
01403 
01404   this->SetImage ( myConverter->GetOutput() );
01405 
01406   this->ImageConverter = myConverter;
01407   this->ITKImage = itkImage;
01408 
01409 }
01410 
01411 
01412 void NIREPvtkViewImage::SetITKImage (itk::Image<float, 3>::Pointer itkImage)
01413 {
01414   if( itkImage.IsNull() )
01415   {
01416     return;
01417   }
01418   /*
01419   typedef itk::Image<float, 3>           ImageType;
01420   typedef itk::FlipImageFilter<ImageType> FlipFilerType;
01421 
01422   FlipFilerType::FlipAxesArrayType axesFlip;
01423   axesFlip.Fill (0);
01424   
01425   if (itkImage->GetDirection()(0,0) < 0 )
01426     axesFlip[0] = 1;
01427   if (itkImage->GetDirection()(1,1) < 0 )
01428     axesFlip[1] = 1;
01429   if (itkImage->GetDirection()(2,2) < 0 )
01430     axesFlip[2] = 1;
01431 
01432   std::cout << itkImage << std::endl;
01433 
01434   std::cout << "Flipping along: " << axesFlip[0] << " " << axesFlip[1] << " " << axesFlip[2] << std::endl;
01435   getchar();
01436   
01437   FlipFilerType::Pointer fliper = FlipFilerType::New();
01438   fliper->SetInput ( itkImage );
01439   fliper->SetFlipAxes ( axesFlip );
01440   try
01441   {
01442     fliper->Update();
01443   }
01444   catch (itk::ExceptionObject &e )
01445   {
01446     std::cerr << e;
01447     return;
01448   }
01449   ImageType::Pointer image = fliper->GetOutput();
01450   std::cout << image << std::endl;
01451   */
01452   
01453   typedef itk::ImageToVTKImageFilter< itk::Image<float, 3> > ConverterType;
01454   ConverterType::Pointer myConverter = ConverterType::New();
01455   myConverter->SetInput ( itkImage );
01456   myConverter->Update();
01457 
01458   this->SetImage ( myConverter->GetOutput() );
01459 
01460   this->ImageConverter = myConverter;
01461   this->ITKImage = itkImage;
01462 }
01463 
01464 void NIREPvtkViewImage::SetITKImage (itk::Image<int, 3>::Pointer itkImage)
01465 {
01466   if( itkImage.IsNull() )
01467   {
01468     return;
01469   }
01470 
01471   typedef itk::ImageToVTKImageFilter< itk::Image<int, 3> > ConverterType;
01472   ConverterType::Pointer myConverter = ConverterType::New();
01473   myConverter->SetInput ( itkImage );
01474   myConverter->Update();
01475 
01476   this->SetImage ( myConverter->GetOutput() );
01477 
01478   this->ImageConverter = myConverter;
01479   this->ITKImage = itkImage;
01480 }
01481 
01482 
01483 void NIREPvtkViewImage::SetITKImage (itk::Image<unsigned int, 3>::Pointer itkImage)
01484 {
01485   if( itkImage.IsNull() )
01486   {
01487     return;
01488   }
01489 
01490   typedef itk::ImageToVTKImageFilter< itk::Image<unsigned int, 3> > ConverterType;
01491   ConverterType::Pointer myConverter = ConverterType::New();
01492   myConverter->SetInput ( itkImage );
01493   myConverter->Update();
01494 
01495   this->SetImage ( myConverter->GetOutput() );
01496 
01497   this->ImageConverter = myConverter;
01498   this->ITKImage = itkImage;
01499 }
01500 
01501 
01502 void NIREPvtkViewImage::SetITKImage (itk::Image<short, 3>::Pointer itkImage)
01503 {
01504   if( itkImage.IsNull() )
01505   {
01506     return;
01507   }
01508   
01509   typedef itk::ImageToVTKImageFilter< itk::Image<short, 3> > ConverterType;
01510   ConverterType::Pointer myConverter = ConverterType::New();
01511   myConverter->SetInput ( itkImage );
01512   myConverter->Update();
01513 
01514   this->SetImage ( myConverter->GetOutput() );
01515 
01516   this->ImageConverter = myConverter;
01517   this->ITKImage = itkImage;
01518 }
01519 
01520 void NIREPvtkViewImage::SetITKImage (itk::Image<unsigned short, 3>::Pointer itkImage)
01521 {
01522   if( itkImage.IsNull() )
01523   {
01524     return;
01525   }
01526 
01527   typedef itk::ImageToVTKImageFilter< itk::Image<unsigned short, 3> > ConverterType;
01528   ConverterType::Pointer myConverter = ConverterType::New();
01529   myConverter->SetInput ( itkImage );
01530   myConverter->Update();
01531 
01532   this->SetImage ( myConverter->GetOutput() );
01533 
01534   this->ImageConverter = myConverter;
01535   this->ITKImage = itkImage;
01536 }
01537 
01538 
01539 void NIREPvtkViewImage::SetITKImage (itk::Image<char, 3>::Pointer itkImage)
01540 {
01541   if( itkImage.IsNull() )
01542   {
01543     return;
01544   }
01545   
01546   typedef itk::ImageToVTKImageFilter< itk::Image<char, 3> > ConverterType;
01547   ConverterType::Pointer myConverter = ConverterType::New();
01548   myConverter->SetInput ( itkImage );
01549   myConverter->Update();
01550 
01551   this->SetImage ( myConverter->GetOutput() );
01552 
01553   this->ImageConverter = myConverter;
01554   this->ITKImage = itkImage;
01555 }
01556 
01557 
01558 void NIREPvtkViewImage::SetITKImage (itk::Image<unsigned char, 3>::Pointer itkImage)
01559 {
01560   if( itkImage.IsNull() )
01561   {
01562     return;
01563   }
01564 
01565   typedef itk::ImageToVTKImageFilter< itk::Image<unsigned char, 3> > ConverterType;
01566   ConverterType::Pointer myConverter = ConverterType::New();
01567   myConverter->SetInput ( itkImage );
01568   myConverter->Update();
01569 
01570   this->SetImage ( myConverter->GetOutput() );
01571 
01572   this->ImageConverter = myConverter;
01573   this->ITKImage = itkImage;
01574 }
01575 
01576 void NIREPvtkViewImage::SetITKImage (itk::Image<long, 3>::Pointer itkImage)
01577 {
01578   if( itkImage.IsNull() )
01579   {
01580     return;
01581   }
01582 
01583   typedef itk::ImageToVTKImageFilter< itk::Image<long, 3> > ConverterType;
01584   ConverterType::Pointer myConverter = ConverterType::New();
01585   myConverter->SetInput ( itkImage );
01586   myConverter->Update();
01587 
01588   this->SetImage ( myConverter->GetOutput() );
01589 
01590   this->ImageConverter = myConverter;
01591   this->ITKImage = itkImage;
01592 }
01593 
01594 void NIREPvtkViewImage::SetITKImage (itk::Image<unsigned long, 3>::Pointer itkImage)
01595 {
01596   if( itkImage.IsNull() )
01597   {
01598     return;
01599   }
01600 
01601   typedef itk::ImageToVTKImageFilter< itk::Image<unsigned long, 3> > ConverterType;
01602   ConverterType::Pointer myConverter = ConverterType::New();
01603   myConverter->SetInput ( itkImage );
01604   myConverter->Update();
01605 
01606   this->SetImage ( myConverter->GetOutput() );
01607 
01608   this->ImageConverter = myConverter;
01609   this->ITKImage = itkImage;
01610 }
01611 
01612 itk::ImageBase<3>* NIREPvtkViewImage::GetITKImage (void) const
01613 {
01614   return this->ITKImage;
01615 }
01616 
01617 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines