+++ /dev/null
-#include <cpExtensions/Visualization/LUTImageActor.h>
-#include <cpExtensions/Visualization/ImageSliceMapper.h>
-
-#include <vtkImageData.h>
-#include <vtkImageMapToColors.h>
-#include <vtkImageProperty.h>
-#include <vtkLookupTable.h>
-#include <cpExtensions/Algorithms/ImageBlender.h>
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::LUTImageActor::
-Self* cpExtensions::Visualization::LUTImageActor::
-New( )
-{
- return( new Self( ) );
-}
-
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::LUTImageActor::
-GetNumberOfImages( ) const
-{
- return( this->m_Images.size( ) );
-}
-
-// -------------------------------------------------------------------------
-vtkImageData* cpExtensions::Visualization::LUTImageActor::
-GetImage( unsigned int id )
-{
- if( id < this->m_Images.size( ) )
- return( this->m_Images[ id ] );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-const vtkImageData* cpExtensions::Visualization::LUTImageActor::
-GetImage( unsigned int id ) const
-{
- if( id < this->m_Images.size( ) )
- return( this->m_Images[ id ] );
- else
- return( NULL );
-}
-
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::LUTImageActor::
-GetImageId( vtkImageData* image ) const
-{
- unsigned int i = 0;
- bool f = false;
- while( i < this->m_Images.size( ) && !f )
- {
- if( this->m_Images[ i ].GetPointer( ) == image )
- f = true;
- else
- i++;
-
- } // elihw
- return( i );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::LUTImageActor::
-GetLUTColor(
- unsigned int id, double& r, double& g, double& b, double& a
- ) const
-{
- double rgba[ 4 ];
- this->m_LUT->GetTableValue( id, rgba );
- r = rgba[ 0 ];
- g = rgba[ 1 ];
- b = rgba[ 2 ];
- a = rgba[ 3 ];
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::LUTImageActor::
-GetLUTColor(
- vtkImageData* image, double& r, double& g, double& b, double& a
- ) const
-{
- this->GetLUTColor( this->GetImageId( image ), r, g, b, a );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::LUTImageActor::
-SetLUTColor( unsigned int id, double r, double g, double b, double a )
-{
- if( id >= ( unsigned int )( this->m_LUT->GetNumberOfTableValues( ) ) )
- this->m_LUT->SetNumberOfTableValues( id + 1 );
- this->m_LUT->SetTableValue( id, r, g, b, a );
- this->m_LUT->Modified( );
-}
-
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::LUTImageActor::
-SetLUTColor( vtkImageData* image, double r, double g, double b, double a )
-{
- this->SetLUTColor( this->GetImageId( image ), r, g, b, a );
-}
-
-// TODO: !!!!!
-#include <vtkImageCast.h>
-
-// -------------------------------------------------------------------------
-unsigned int cpExtensions::Visualization::LUTImageActor::
-AddImage( vtkImageData* image, double r, double g, double b, double a )
-{
- static vtkSmartPointer< vtkImageCast > cast;
- cast = vtkSmartPointer< vtkImageCast >::New( );
-
- if( image != NULL )
- {
- cast->SetOutputScalarTypeToUnsignedChar( );
- cast->SetInputData( image );
- cast->Update( );
-
- this->m_Images.push_back( image );
- this->SetLUTColor( this->m_Images.size( ), r, g, b, a );
- this->m_Blender->AddInputData( cast->GetOutput( ) );
- this->m_Blender->Update( );
-
- if( this->m_Images.size( ) == 1 )
- {
- this->m_ImageMap->
- SetInputConnection( this->m_Blender->GetOutputPort( ) );
- this->m_Mapper->
- SetInputConnection( this->m_ImageMap->GetOutputPort( ) );
-
- } // fi
- this->Modified( );
-
- this->GetProperty( )->SetInterpolationTypeToNearest( );
-
- } // fi
- return( this->m_Images.size( ) );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::LUTImageActor::
-LUTImageActor( )
- : Superclass( )
-{
- this->m_LUT = vtkSmartPointer< vtkLookupTable >::New( );
- this->m_LUT->SetNumberOfTableValues( 1 );
- this->m_LUT->SetNanColor( 0, 0, 0, 0 );
- this->m_LUT->SetTableValue( 0, 0, 0, 0, 0 );
-
- this->m_Blender = vtkSmartPointer< _TImageBlender >::New( );
- this->m_ImageMap = vtkSmartPointer< vtkImageMapToColors >::New( );
- this->m_ImageMap->SetLookupTable( this->m_LUT );
-}
-
-// -------------------------------------------------------------------------
-cpExtensions::Visualization::LUTImageActor::
-~LUTImageActor( )
-{
-}
-
-// eof - $RCSfile$