#include <cpPlugins/Extensions/Visualization/MPRActors.h>
#include <vtkImageData.h>
+#include <vtkLookupTable.h>
#include <vtkOutlineSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
for( int i = 0; i < 3; ++i )
{
- Slices[ i ]->SetInputConnection(
+ this->Slices[ i ]->SetInputConnection(
this->ImageToWindowLevel->GetOutputPort( ), i
);
- Slices[ i ]->UpdateText( this->GetWindow( ), this->GetLevel( ) );
+ this->Slices[ i ]->UpdateText( this->GetWindow( ), this->GetLevel( ) );
} // rof
void cpPlugins::Extensions::Visualization::MPRActors::
SetSegmentationData( vtkImageData* segmentation )
{
+ double range[ 2 ];
+ this->Segmentation = segmentation;
+ this->Segmentation->GetScalarRange( range );
+
+ vtkSmartPointer< vtkLookupTable > lut =
+ vtkSmartPointer< vtkLookupTable >::New( );
+ lut->SetNumberOfTableValues( 2 );
+ lut->SetTableRange( range );
+ lut->SetTableValue( 0, 0, 0, 0, 0 );
+ lut->SetTableValue( 1, 1, 0, 0, 0.4 );
+
+ this->SegmentationToColors->SetInputData( this->Segmentation );
+ this->SegmentationToColors->SetLookupTable( lut );
+ this->SegmentationToColors->Update( );
+
+ for( int i = 0; i < 3; ++i )
+ this->Slices[ i ]->SetSegmentationConnection(
+ this->SegmentationToColors->GetOutputPort( )
+ );
}
// -------------------------------------------------------------------------
vtkPlane* cpPlugins::Extensions::Visualization::MPRActors::
GetSlicePlane( const int& axis ) const
{
+ return( NULL );
}
// -------------------------------------------------------------------------
int cpPlugins::Extensions::Visualization::MPRActors::
GetSliceNumberMinValue( const int& axis ) const
{
+ return( this->Slices[ axis ]->GetSliceNumberMinValue( ) );
}
// -------------------------------------------------------------------------
int cpPlugins::Extensions::Visualization::MPRActors::
GetSliceNumberMaxValue( const int& axis ) const
{
+ return( this->Slices[ axis ]->GetSliceNumberMaxValue( ) );
}
// -------------------------------------------------------------------------
int cpPlugins::Extensions::Visualization::MPRActors::
GetSlice( const int& axis ) const
{
+ return( this->Slices[ axis ]->GetSliceNumber( ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
SetSlice( const int& axis, const int& slice )
{
+ // Get image data extent
+ if( this->Image == NULL )
+ return;
+ int ext[ 6 ];
+ this->Image->GetExtent( ext );
+
+ // Check if the slice is valid
+ int real = slice;
+ if( slice < ext[ axis << 1 ] )
+ real = ext[ axis << 1 ];
+ if( ext[ ( axis << 1 ) + 1 ] < slice )
+ real = ext[ ( axis << 1 ) + 1 ];
+
+ // Change slice
+ this->Slices[ axis ]->SetSliceNumber( real );
+ this->Modified( );
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
SetSlice( const int& axis, const double& slice )
{
+ if( this->Image == NULL )
+ return;
+
+ double x[ 3 ] = { double( 0 ) };
+ double pcoords[ 3 ];
+ int ijk[ 3 ];
+
+ x[ axis ] = slice;
+ this->Image->ComputeStructuredCoordinates( x, ijk, pcoords );
+ this->SetSlice( axis, ijk[ axis ] );
}
// -------------------------------------------------------------------------