int cpExtensions::Visualization::MPRActors::
AddInputConnection( vtkAlgorithmOutput* aout )
{
- int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
- if( N == 0 )
+ ImageBlender* blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
+ if( blender == NULL )
{
- this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 );
- vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
+ this->Slices[ 0 ][ 0 ]->AddInputConnection( aout );
+ blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
for( unsigned int i = 0; i < 2; ++i )
+ {
for( unsigned int j = 0; j < 3; ++j )
+ {
if( i != 0 || j != 0 )
- this->Slices[ i ][ j ]->AddInputConnection(
- ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j
- );
-
- // Create bounding box
- vtkImageData* new_image = dynamic_cast< vtkImageData* >(
- aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
- );
+ this->Slices[ i ][ j ]->SetBlender( blender );
+ this->Slices[ i ][ j ]->SetAxis( j );
- // Create 3D outline
- double bb[ 6 ];
- new_image->GetBounds( bb );
+ } // rof
- 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 );
+ } // rof
+ this->_CreateBoundingBox( );
}
else
- {
- // Check if the image share the same space
- vtkImageData* new_image = dynamic_cast< vtkImageData* >(
- aout->GetProducer( )->GetOutputDataObject( aout->GetIndex( ) )
- );
- if( new_image != NULL )
- {
- vtkAlgorithmOutput* ref_aout =
- this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( );
- vtkImageData* ref_image = dynamic_cast< vtkImageData* >(
- ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) )
- );
- if( ref_image != NULL )
- {
- int ref_ext[ 6 ], new_ext[ 6 ];
- ref_image->GetExtent( ref_ext );
- new_image->GetExtent( new_ext );
- if(
- ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
- ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
- ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
- )
- {
- this->Slices[ 0 ][ 0 ]->AddInputConnection( aout, 0 );
- vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N );
- for( unsigned int i = 0; i < 2; ++i )
- for( unsigned int j = 0; j < 3; ++j )
- if( i != 0 || j != 0 )
- this->Slices[ i ][ j ]->AddInputConnection(
- ( ( imap != NULL )? imap->GetOutputPort( ): aout ), j
- );
- }
- else
- N = -1;
- }
- else
- N = -1;
- }
- else
- N = -1;
-
- } // fi
- return( N );
+ blender->AddInputConnection( aout );
+ return( blender->GetNumberOfImages( ) - 1 );
}
// -------------------------------------------------------------------------
int cpExtensions::Visualization::MPRActors::
AddInputData( vtkImageData* new_image )
{
- int N = this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( );
- if( N == 0 )
+ ImageBlender* blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
+ if( blender == NULL )
{
- this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 );
- vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( 0 );
+ this->Slices[ 0 ][ 0 ]->AddInputData( new_image );
+ blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
for( unsigned int i = 0; i < 2; ++i )
+ {
for( unsigned int j = 0; j < 3; ++j )
+ {
if( i != 0 || j != 0 )
- {
- if( imap != NULL )
- this->Slices[ i ][ j ]->AddInputConnection(
- imap->GetOutputPort( ), j
- );
- else
- this->Slices[ i ][ j ]->AddInputData( new_image, j );
-
- } // fi
-
- // Create 3D outline
- double bb[ 6 ];
- new_image->GetBounds( bb );
+ this->Slices[ i ][ j ]->SetBlender( blender );
+ this->Slices[ i ][ j ]->SetAxis( j );
- 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 );
+ } // rof
- this->AddItem( this->ImageOutlineActor );
+ } // rof
+ this->_CreateBoundingBox( );
}
else
- {
- // Check if the image share the same space
- vtkAlgorithmOutput* ref_aout =
- this->Slices[ 0 ][ 0 ]->GetImageMap( 0 )->GetOutputPort( );
- vtkImageData* ref_image = dynamic_cast< vtkImageData* >(
- ref_aout->GetProducer( )->GetOutputDataObject( ref_aout->GetIndex( ) )
- );
- if( ref_image != NULL )
- {
- int ref_ext[ 6 ], new_ext[ 6 ];
- ref_image->GetExtent( ref_ext );
- new_image->GetExtent( new_ext );
- if(
- ref_ext[ 0 ] == new_ext[ 0 ] && ref_ext[ 1 ] == new_ext[ 1 ] &&
- ref_ext[ 2 ] == new_ext[ 2 ] && ref_ext[ 3 ] == new_ext[ 3 ] &&
- ref_ext[ 4 ] == new_ext[ 4 ] && ref_ext[ 5 ] == new_ext[ 5 ]
- )
- {
- this->Slices[ 0 ][ 0 ]->AddInputData( new_image, 0 );
- vtkImageMapToColors* imap = this->Slices[ 0 ][ 0 ]->GetImageMap( N );
- for( unsigned int i = 0; i < 2; ++i )
- for( unsigned int j = 0; j < 3; ++j )
- if( i != 0 || j != 0 )
- {
- if( imap != NULL )
- this->Slices[ i ][ j ]->AddInputConnection(
- imap->GetOutputPort( ), j
- );
- else
- this->Slices[ i ][ j ]->AddInputData( new_image, j );
-
- } // fi
- }
- else
- N = -1;
- }
- else
- N = -1;
-
- } // fi
- return( N );
+ blender->AddInputData( new_image );
+ return( blender->GetNumberOfImages( ) - 1 );
}
// -------------------------------------------------------------------------
unsigned int cpExtensions::Visualization::MPRActors::
GetNumberOfImages( ) const
{
- return( this->Slices[ 0 ][ 0 ]->GetNumberOfImageActors( ) );
+ ImageBlender* blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
+ if( blender != NULL )
+ return( blender->GetNumberOfImages( ) );
+ else
+ return( 0 );
}
// -------------------------------------------------------------------------
this->Slices[ 1 ][ 2 ]->Clear( );
}
-// -------------------------------------------------------------------------
-void cpExtensions::Visualization::MPRActors::
-SetLookupTableAsColor( unsigned int i, double r, double g, double b )
-{
- this->Slices[ 0 ][ 0 ]->SetLookupTableAsColor( 0, r, g, b );
- this->Slices[ 0 ][ 1 ]->Modified( );
- this->Slices[ 0 ][ 2 ]->Modified( );
- this->Slices[ 1 ][ 0 ]->Modified( );
- this->Slices[ 1 ][ 1 ]->Modified( );
- this->Slices[ 1 ][ 2 ]->Modified( );
- this->Modified( );
-}
-
// -------------------------------------------------------------------------
double cpExtensions::Visualization::MPRActors::
GetWindow( )
void cpExtensions::Visualization::MPRActors::
SetSlice( const int& axis, const int& slice )
{
- vtkImageData* image = this->Slices[ 0 ][ 0 ]->GetInputImage( 0 );
+ ImageBlender* blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
+ if( blender == NULL )
+ return;
+ vtkImageData* image =
+ dynamic_cast< vtkImageData* >( blender->GetInput( ) );
if( image == NULL )
return;
void cpExtensions::Visualization::MPRActors::
SetSlice( const int& axis, const double& slice )
{
- vtkImageData* image = this->Slices[ 0 ][ 0 ]->GetInputImage( 0 );
+ ImageBlender* blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
+ if( blender == NULL )
+ return;
+ vtkImageData* image =
+ dynamic_cast< vtkImageData* >( blender->GetInput( ) );
if( image == NULL )
return;
for( unsigned int i = 0; i < 2; ++i )
for( unsigned int j = 0; j < 3; ++j )
this->Slices[ i ][ j ]->SetSliceNumber(
- this->Slices[ i ][ j ]->GetSliceNumberMaxValue( )
+ this->Slices[ i ][ j ]->GetSliceNumberMinValue( )
);
}
{
}
+// -------------------------------------------------------------------------
+void cpExtensions::Visualization::MPRActors::
+_CreateBoundingBox( )
+{
+ ImageBlender* blender = this->Slices[ 0 ][ 0 ]->GetBlender( );
+ if( blender == NULL )
+ return;
+ if( blender->GetNumberOfImages( ) == 1 )
+ {
+ vtkImageData* image =
+ dynamic_cast< vtkImageData* >( blender->GetInput( ) );
+
+ // 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 );
+
+ } // fi
+}
+
// -------------------------------------------------------------------------
void cpExtensions::Visualization::MPRActors::
_SlicesCommand( double* pos, int axis, void* data )
{
actors->Slices[ 0 ][ j ]->SetSlice( pos );
actors->Slices[ 1 ][ j ]->SetSlice( pos );
- actors->Slices[ 0 ][ j ]->Render( );
- actors->Slices[ 1 ][ j ]->Render( );
+ actors->Slices[ 0 ][ j ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ j ]->Render( 1e-3 );
} // fi
MPRActors* actors = reinterpret_cast< MPRActors* >( data );
if( actors == NULL )
return;
- actors->Slices[ 0 ][ 0 ]->Render( );
- actors->Slices[ 0 ][ 1 ]->Render( );
- actors->Slices[ 0 ][ 2 ]->Render( );
- actors->Slices[ 1 ][ 0 ]->Render( );
- actors->Slices[ 1 ][ 1 ]->Render( );
- actors->Slices[ 1 ][ 2 ]->Render( );
+ actors->Slices[ 0 ][ 0 ]->Render( 1e-3 );
+ actors->Slices[ 0 ][ 1 ]->Render( 1e-3 );
+ actors->Slices[ 0 ][ 2 ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ 0 ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ 1 ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ 2 ]->Render( 1e-3 );
}
// -------------------------------------------------------------------------
MPRActors* actors = reinterpret_cast< MPRActors* >( data );
if( actors == NULL )
return;
- actors->Slices[ 0 ][ 0 ]->Render( );
- actors->Slices[ 0 ][ 1 ]->Render( );
- actors->Slices[ 0 ][ 2 ]->Render( );
- actors->Slices[ 1 ][ 0 ]->Render( );
- actors->Slices[ 1 ][ 1 ]->Render( );
- actors->Slices[ 1 ][ 2 ]->Render( );
+ actors->Slices[ 0 ][ 0 ]->Render( 1e-3 );
+ actors->Slices[ 0 ][ 1 ]->Render( 1e-3 );
+ actors->Slices[ 0 ][ 2 ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ 0 ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ 1 ]->Render( 1e-3 );
+ actors->Slices[ 1 ][ 2 ]->Render( 1e-3 );
}
// eof - $RCSfile$