1 #include <cpExtensions/Visualization/ImageSliceActors.h>
2 #include <cpExtensions/Visualization/ImageOutlineActor.h>
3 #include <cpExtensions/Visualization/LUTImageActor.h>
4 #include <cpExtensions/Visualization/WindowLevelImageActor.h>
6 #include <vtkImageData.h>
9 // -------------------------------------------------------------------------
10 cpExtensions::Visualization::ImageSliceActors::
11 Self* cpExtensions::Visualization::ImageSliceActors::
14 return( new Self( ) );
17 // -------------------------------------------------------------------------
18 vtkImageData* cpExtensions::Visualization::ImageSliceActors::
21 if( this->m_WindowLevelImageActor.GetPointer( ) != NULL )
22 return( this->m_WindowLevelImageActor->GetImage( ) );
27 // -------------------------------------------------------------------------
28 const vtkImageData* cpExtensions::Visualization::ImageSliceActors::
31 if( this->m_WindowLevelImageActor.GetPointer( ) != NULL )
32 return( this->m_WindowLevelImageActor->GetImage( ) );
37 // -------------------------------------------------------------------------
38 cpExtensions::Visualization::
39 WindowLevelImageActor* cpExtensions::Visualization::ImageSliceActors::
40 GetWindowLevelImageActor( )
42 return( this->m_WindowLevelImageActor.GetPointer( ) );
45 // -------------------------------------------------------------------------
46 const cpExtensions::Visualization::
47 WindowLevelImageActor* cpExtensions::Visualization::ImageSliceActors::
48 GetWindowLevelImageActor( ) const
50 return( this->m_WindowLevelImageActor.GetPointer( ) );
53 // -------------------------------------------------------------------------
54 cpExtensions::Visualization::
55 LUTImageActor* cpExtensions::Visualization::ImageSliceActors::
58 return( this->m_LUTImageActor.GetPointer( ) );
61 // -------------------------------------------------------------------------
62 const cpExtensions::Visualization::
63 LUTImageActor* cpExtensions::Visualization::ImageSliceActors::
64 GetLUTImageActor( ) const
66 return( this->m_LUTImageActor.GetPointer( ) );
69 // -------------------------------------------------------------------------
70 cpExtensions::Visualization::
71 ImageOutlineActor* cpExtensions::Visualization::ImageSliceActors::
72 GetImageOutlineActor( )
74 return( this->m_ImageOutlineActor.GetPointer( ) );
77 // -------------------------------------------------------------------------
78 const cpExtensions::Visualization::
79 ImageOutlineActor* cpExtensions::Visualization::ImageSliceActors::
80 GetImageOutlineActor( ) const
82 return( this->m_ImageOutlineActor.GetPointer( ) );
85 // -------------------------------------------------------------------------
86 int cpExtensions::Visualization::ImageSliceActors::
87 GetOrientation( ) const
89 if( this->m_WindowLevelImageActor.GetPointer( ) != NULL )
90 return( this->m_WindowLevelImageActor->GetOrientation( ) );
95 // -------------------------------------------------------------------------
96 void cpExtensions::Visualization::ImageSliceActors::
97 SetImage( vtkImageData* image, int orientation )
99 this->m_WindowLevelImageActor =
100 vtkSmartPointer< WindowLevelImageActor >::New( );
101 this->m_WindowLevelImageActor->SetImage( image );
102 this->m_WindowLevelImageActor->SetOrientation( orientation );
103 this->m_ImageOutlineActor = vtkSmartPointer< ImageOutlineActor >::New( );
104 this->m_LUTImageActor = NULL;
106 // Put an initial slice
108 image->GetExtent( ext );
109 this->SetSliceNumber(
110 ext[ this->m_WindowLevelImageActor->GetOrientation( ) << 1 ]
114 this->RemoveAllItems( );
115 this->AddItem( this->m_ImageOutlineActor );
116 this->AddItem( this->m_WindowLevelImageActor );
119 // -------------------------------------------------------------------------
120 unsigned int cpExtensions::Visualization::ImageSliceActors::
121 AddLUTImage( vtkImageData* image )
123 if( this->GetImage( ) != NULL )
125 if( this->m_LUTImageActor.GetPointer( ) == NULL )
127 this->m_LUTImageActor = vtkSmartPointer< LUTImageActor >::New( );
128 this->m_LUTImageActor->SetOrientation( this->GetOrientation( ) );
129 this->AddItem( this->m_LUTImageActor );
132 this->m_LUTImageActor->AddImage( image );
133 return( this->m_LUTImageActor->GetNumberOfImages( ) );
139 // -------------------------------------------------------------------------
140 int cpExtensions::Visualization::ImageSliceActors::
141 GetSliceNumber( ) const
143 return( this->m_WindowLevelImageActor->GetSliceNumber( ) );
146 // -------------------------------------------------------------------------
147 void cpExtensions::Visualization::ImageSliceActors::
148 SetSliceNumber( int slice )
150 this->m_WindowLevelImageActor->SetSliceNumber( slice );
151 if( this->m_LUTImageActor.GetPointer( ) != NULL )
152 this->m_LUTImageActor->SetSliceNumber( slice );
155 this->m_WindowLevelImageActor->GetImage( )->GetBounds( bounds );
156 int o = this->m_WindowLevelImageActor->GetOrientation( );
157 double p = this->m_WindowLevelImageActor->GetSlicePlane( )->GetOrigin( )[ o ];
158 this->m_ImageOutlineActor->SetBounds( o, p, bounds );
161 // -------------------------------------------------------------------------
162 cpExtensions::Visualization::ImageSliceActors::
168 // -------------------------------------------------------------------------
169 cpExtensions::Visualization::ImageSliceActors::