#include #include #include #include #include #include #include #include // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRActors* cpExtensions::Visualization::MPRActors:: New( ) { return( new Self( ) ); } // ------------------------------------------------------------------------- cpExtensions::Visualization:: ImageSliceActors* cpExtensions::Visualization::MPRActors:: GetSliceActors( const int& i ) const { if( i < 3 ) return( this->Slices[ 0 ][ i ] ); else return( NULL ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetInputConnection( vtkAlgorithmOutput* aout ) { for( int i = 0; i < 2; ++i ) { for( int j = 0; j < 3; ++j ) { this->Slices[ i ][ j ]->SetInputConnection( aout ); this->Slices[ i ][ j ]->SetAxis( j ); } // rof } // rof this->_CreateBoundingBox( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetInputImage( vtkImageData* data ) { for( int i = 0; i < 2; ++i ) { for( int j = 0; j < 3; ++j ) { this->Slices[ i ][ j ]->SetInputImage( data ); this->Slices[ i ][ j ]->SetAxis( j ); } // rof } // rof this->_CreateBoundingBox( ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: AddBinaryConnection( vtkAlgorithmOutput* aout, const double& r, const double& g, const double& b ) { this->Slices[ 0 ][ 0 ]->AddBinaryConnection( aout, r, g, b ); this->Slices[ 0 ][ 1 ]->AddBinaryConnection( aout, r, g, b ); this->Slices[ 0 ][ 2 ]->AddBinaryConnection( aout, r, g, b ); this->Slices[ 1 ][ 0 ]->AddBinaryConnection( aout, r, g, b ); this->Slices[ 1 ][ 1 ]->AddBinaryConnection( aout, r, g, b ); return( this->Slices[ 1 ][ 2 ]->AddBinaryConnection( aout, r, g, b ) ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: AddBinaryImage( vtkImageData* data, const double& r, const double& g, const double& b ) { this->Slices[ 0 ][ 0 ]->AddBinaryImage( data, r, g, b ); this->Slices[ 0 ][ 1 ]->AddBinaryImage( data, r, g, b ); this->Slices[ 0 ][ 2 ]->AddBinaryImage( data, r, g, b ); this->Slices[ 1 ][ 0 ]->AddBinaryImage( data, r, g, b ); this->Slices[ 1 ][ 1 ]->AddBinaryImage( data, r, g, b ); return( this->Slices[ 1 ][ 2 ]->AddBinaryImage( data, r, g, b ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: Clear( ) { this->Slices[ 0 ][ 0 ]->Clear( ); this->Slices[ 0 ][ 1 ]->Clear( ); this->Slices[ 0 ][ 2 ]->Clear( ); this->Slices[ 1 ][ 0 ]->Clear( ); this->Slices[ 1 ][ 1 ]->Clear( ); this->Slices[ 1 ][ 2 ]->Clear( ); } // ------------------------------------------------------------------------- vtkImageData* cpExtensions::Visualization::MPRActors:: GetInputImage( ) { return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); } // ------------------------------------------------------------------------- const vtkImageData* cpExtensions::Visualization::MPRActors:: GetInputImage( ) const { return( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); } // ------------------------------------------------------------------------- unsigned int cpExtensions::Visualization::MPRActors:: GetNumberOfImages( ) const { return( this->Slices[ 0 ][ 0 ]->GetNumberOfImages( ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetInterpolate( bool v ) { this->Slices[ 0 ][ 0 ]->SetInterpolate( v ); this->Slices[ 0 ][ 1 ]->SetInterpolate( v ); this->Slices[ 0 ][ 2 ]->SetInterpolate( v ); this->Slices[ 1 ][ 0 ]->SetInterpolate( v ); this->Slices[ 1 ][ 1 ]->SetInterpolate( v ); this->Slices[ 1 ][ 2 ]->SetInterpolate( v ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: InterpolateOn( ) { this->SetInterpolate( true ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: InterpolateOff( ) { this->SetInterpolate( false ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: PushActorsInto( vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z, vtkRenderWindow* w ) { this->Slices[ 0 ][ 0 ]->PushActorsInto( x, true ); this->Slices[ 0 ][ 1 ]->PushActorsInto( y, true ); this->Slices[ 0 ][ 2 ]->PushActorsInto( z, true ); this->Slices[ 1 ][ 0 ]->PushActorsInto( w, false ); this->Slices[ 1 ][ 1 ]->PushActorsInto( w, false ); this->Slices[ 1 ][ 2 ]->PushActorsInto( w, false ); vtkRenderer* wren = ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL; if( wren != NULL ) { wren->AddViewProp( this->ImageOutlineActor ); wren->AddViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) ); wren->AddViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) ); wren->AddViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) ); } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: PopActorsFrom( vtkRenderWindow* x, vtkRenderWindow* y, vtkRenderWindow* z, vtkRenderWindow* w ) { this->Slices[ 0 ][ 0 ]->PopActorsFrom( x ); this->Slices[ 0 ][ 1 ]->PopActorsFrom( y ); this->Slices[ 0 ][ 2 ]->PopActorsFrom( z ); this->Slices[ 1 ][ 0 ]->PopActorsFrom( w ); this->Slices[ 1 ][ 1 ]->PopActorsFrom( w ); this->Slices[ 1 ][ 2 ]->PopActorsFrom( w ); vtkRenderer* wren = ( w != NULL )? w->GetRenderers( )->GetFirstRenderer( ): NULL; if( wren != NULL ) { wren->RemoveViewProp( this->ImageOutlineActor ); wren->RemoveViewProp( this->Slices[ 1 ][ 0 ]->GetPlaneActor( ) ); wren->RemoveViewProp( this->Slices[ 1 ][ 1 ]->GetPlaneActor( ) ); wren->RemoveViewProp( this->Slices[ 1 ][ 2 ]->GetPlaneActor( ) ); } // fi } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetMinWindow( ) const { return( this->Slices[ 0 ][ 0 ]->GetMinWindow( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetMaxWindow( ) const { return( this->Slices[ 0 ][ 0 ]->GetMaxWindow( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetMinLevel( ) const { return( this->Slices[ 0 ][ 0 ]->GetMinLevel( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetMaxLevel( ) const { return( this->Slices[ 0 ][ 0 ]->GetMaxLevel( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetWindow( ) { return( this->Slices[ 0 ][ 0 ]->GetWindow( ) ); } // ------------------------------------------------------------------------- double cpExtensions::Visualization::MPRActors:: GetLevel( ) { return( this->Slices[ 0 ][ 0 ]->GetLevel( ) ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetWindow( double w ) { this->Slices[ 0 ][ 0 ]->SetWindow( w ); this->Slices[ 0 ][ 1 ]->SetWindow( w ); this->Slices[ 0 ][ 2 ]->SetWindow( w ); this->Slices[ 1 ][ 0 ]->SetWindow( w ); this->Slices[ 1 ][ 1 ]->SetWindow( w ); this->Slices[ 1 ][ 2 ]->SetWindow( w ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetLevel( double l ) { this->Slices[ 0 ][ 0 ]->SetLevel( l ); this->Slices[ 0 ][ 1 ]->SetLevel( l ); this->Slices[ 0 ][ 2 ]->SetLevel( l ); this->Slices[ 1 ][ 0 ]->SetLevel( l ); this->Slices[ 1 ][ 1 ]->SetLevel( l ); this->Slices[ 1 ][ 2 ]->SetLevel( l ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetWindowLevel( double w, double l ) { this->Slices[ 0 ][ 0 ]->SetWindowLevel( w, l ); this->Slices[ 0 ][ 1 ]->SetWindowLevel( w, l ); this->Slices[ 0 ][ 2 ]->SetWindowLevel( w, l ); this->Slices[ 1 ][ 0 ]->SetWindowLevel( w, l ); this->Slices[ 1 ][ 1 ]->SetWindowLevel( w, l ); this->Slices[ 1 ][ 2 ]->SetWindowLevel( w, l ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: ResetWindowLevel( ) { this->Slices[ 0 ][ 0 ]->ResetWindowLevel( ); this->Slices[ 0 ][ 1 ]->ResetWindowLevel( ); this->Slices[ 0 ][ 2 ]->ResetWindowLevel( ); this->Slices[ 1 ][ 0 ]->ResetWindowLevel( ); this->Slices[ 1 ][ 1 ]->ResetWindowLevel( ); this->Slices[ 1 ][ 2 ]->ResetWindowLevel( ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: GetSliceNumber( const int& axis ) const { if( axis < 3 ) return( this->Slices[ 0 ][ axis ]->GetSliceNumber( ) ); else return( -1 ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: GetSliceNumberMinValue( const int& axis ) const { if( axis < 3 ) return( this->Slices[ 0 ][ axis ]->GetSliceNumberMinValue( ) ); else return( -1 ); } // ------------------------------------------------------------------------- int cpExtensions::Visualization::MPRActors:: GetSliceNumberMaxValue( const int& axis ) const { if( axis < 3 ) return( this->Slices[ 0 ][ axis ]->GetSliceNumberMaxValue( ) ); else return( -1 ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetSliceNumber( const int& axis, const int& slice ) { if( axis < 3 ) { this->Slices[ 0 ][ axis ]->SetSliceNumber( slice ); this->Slices[ 1 ][ axis ]->SetSliceNumber( slice ); } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetSlice( const int& axis, double* pos ) { if( axis < 3 ) { this->Slices[ 0 ][ axis ]->SetSlice( pos ); this->Slices[ 1 ][ axis ]->SetSlice( pos ); } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: SetAxesCursor( const int& axis, double* pos ) { if( axis < 3 ) this->Slices[ 0 ][ axis ]->SetAxesCursor( pos ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: Render( const int& axis ) { if( axis < 3 ) { this->Slices[ 0 ][ axis ]->Render( ); this->Slices[ 1 ][ axis ]->Render( ); } // fi } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: Render( ) { this->Render( 0 ); this->Render( 1 ); this->Render( 2 ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: ResetCamera( const int& axis ) { if( axis < 3 ) this->Slices[ 0 ][ axis ]->ResetCamera( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: ResetCameras( ) { this->ResetCamera( 0 ); this->ResetCamera( 1 ); this->ResetCamera( 2 ); } // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRActors:: MPRActors( ) : Superclass( ) { this->ImageOutlineActor = vtkSmartPointer< vtkActor >::New( ); for( unsigned int i = 0; i < 2; ++i ) for( unsigned int j = 0; j < 3; ++j ) this->Slices[ i ][ j ] = vtkSmartPointer< ImageSliceActors >::New( ); this->Slices[ 0 ][ 0 ]->AssociateSlice( this->Slices[ 1 ][ 0 ] ); this->Slices[ 0 ][ 1 ]->AssociateSlice( this->Slices[ 1 ][ 1 ] ); this->Slices[ 0 ][ 2 ]->AssociateSlice( this->Slices[ 1 ][ 2 ] ); for( unsigned int i = 0; i < 3; ++ i ) { this->Slices[ 0 ][ i ]->AddRenderCommand( Self::_RenderCommand, this ); this->Slices[ 0 ][ i ]->AddWindowLevelCommand( Self::_WindowLevelCommand, this ); this->Slices[ 0 ][ i ]->AddSlicesCommand( Self::_SlicesCommand, this ); } // rof } // ------------------------------------------------------------------------- cpExtensions::Visualization::MPRActors:: ~MPRActors( ) { } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: _CreateBoundingBox( ) { vtkImageData* image = dynamic_cast< vtkImageData* >( this->Slices[ 0 ][ 0 ]->GetInputImage( ) ); if( image == NULL ) return; // Create 3D outline double bb[ 6 ]; image->GetBounds( bb ); vtkSmartPointer< vtkOutlineSource > img_ol = vtkSmartPointer< vtkOutlineSource >::New( ); img_ol->SetBounds( bb ); vtkSmartPointer< vtkPolyDataMapper > img_ol_mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); img_ol_mapper->SetInputConnection( img_ol->GetOutputPort( ) ); this->ImageOutlineActor->SetMapper( img_ol_mapper ); this->ImageOutlineActor->GetProperty( )->SetColor( 1, 1, 1 ); this->ImageOutlineActor->GetProperty( )->SetLineWidth( 1 ); this->AddItem( this->ImageOutlineActor ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: _SlicesCommand( double* pos, int axis, void* data ) { MPRActors* actors = reinterpret_cast< MPRActors* >( data ); if( actors == NULL ) return; for( unsigned int j = 0; j < 3; ++j ) { if( actors->Slices[ 0 ][ j ]->GetAxis( ) != axis ) { actors->SetSlice( j, pos ); actors->SetAxesCursor( j, pos ); actors->Render( j ); } // fi } // rof } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: _WindowLevelCommand( double window, double level, void* data ) { MPRActors* actors = reinterpret_cast< MPRActors* >( data ); if( actors == NULL ) return; actors->SetWindowLevel( window, level ); actors->Render( ); } // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRActors:: _RenderCommand( void* data ) { MPRActors* actors = reinterpret_cast< MPRActors* >( data ); if( actors == NULL ) return; actors->Render( ); } // eof - $RCSfile$