]> Creatis software - cpPlugins.git/blob - lib/cpPlugins/Image.cxx
Code cleaning
[cpPlugins.git] / lib / cpPlugins / Image.cxx
1 #include <cpPlugins/Image.h>
2
3 #include <vtkImageActor.h>
4 #include <vtkImageProperty.h>
5 #include <vtkImageSliceMapper.h>
6
7 // -------------------------------------------------------------------------
8 void cpPlugins::Image::
9 SetITK( itk::LightObject* o )
10 {
11   this->Superclass::SetITK( o );
12   bool     s = this->_ITK_2_VTK_0_Scalar< 2 >( o );
13   if( !s ) s = this->_ITK_2_VTK_0_Scalar< 3 >( o );
14   if( !s ) s = this->_ITK_2_VTK_0_Color< 2 >( o );
15   if( !s ) s = this->_ITK_2_VTK_0_Color< 3 >( o );
16   if( !s )
17   {
18     this->m_VTKObject = NULL;
19     this->m_ITKvVTK = NULL;
20
21   } // fi
22   this->Modified( );
23 }
24
25 // -------------------------------------------------------------------------
26 void cpPlugins::Image::
27 SetVTK( vtkObjectBase* o )
28 {
29   this->Superclass::SetVTK( o );
30   std::cerr << "Image: TODO this!!!!" << std::endl;
31   std::exit( 1 );
32 }
33
34 // -------------------------------------------------------------------------
35 cpPlugins::Image::
36 Image( )
37   : Superclass( )
38 {
39 }
40
41 // -------------------------------------------------------------------------
42 cpPlugins::Image::
43 ~Image( )
44 {
45 }
46
47 // -------------------------------------------------------------------------
48 void cpPlugins::Image::
49 _CreateVTKActor( ) const
50 {
51   vtkImageData* image =
52     const_cast< vtkImageData* >( this->GetVTK< vtkImageData >( ) );
53   if( image != NULL )
54   {
55     vtkImageSliceMapper* mapper = vtkImageSliceMapper::New( );
56     vtkImageActor* actor = vtkImageActor::New( );
57     mapper->SetInputData( image );
58     actor->SetMapper( mapper );
59     actor->GetProperty( )->SetInterpolationTypeToNearest( );
60     this->m_Actor = actor;
61     mapper->Delete( );
62
63   } // fi
64 }
65
66 // eof - $RCSfile$