#include "ImageMPR.h"
#include "ui_ImageMPR.h"
+#include <vtkProperty.h>
#include <vtkRenderWindow.h>
#include <QFileDialog>
this->m_UI->actionOpenInputImage, SIGNAL( triggered( ) ),
this, SLOT( _triggered_actionOpenInputImage( ) )
);
+ QObject::connect(
+ this->m_UI->actionOpenInputPolyData, SIGNAL( triggered( ) ),
+ this, SLOT( _triggered_actionOpenInputPolyData( ) )
+ );
// Start: load all disponible plugins
this->_triggered_actionOpenPlugins( );
this->m_BaseClasses[ "ImageReader" ] =
"cpPlugins::Plugins::ImageReader";
- this->m_BaseClasses[ "ImageSeriesReader" ] =
- "cpPlugins::Plugins::ImageSeriesReader";
+ this->m_BaseClasses[ "PolyDataReader" ] =
+ "cpPlugins::Plugins::PolyDataReader";
}
// -------------------------------------------------------------------------
return;
this->m_InputImage = NULL;
- unsigned int nFiles = dialog.selectedFiles( ).size( );
- if( nFiles == 1 )
+
+ // Get a reader from plugins
+ TPlugin::Pointer reader =
+ this->m_Plugins.CreateProcessObject(
+ this->m_BaseClasses[ "ImageReader" ]
+ );
+
+ // Configure plugins
+ TParameters reader_params = reader->GetDefaultParameters( );
+
+ // File names
+ QStringList q_fnames = dialog.selectedFiles( );
+ QStringList::const_iterator qIt = q_fnames.begin( );
+ for( ; qIt != q_fnames.end( ); ++qIt )
+ reader_params.AddValueToStringList( "FileNames", qIt->toStdString( ) );
+
+ // Other parameters
+ reader_params.SetValueAsString( "PixelType", "short" );
+ reader_params.SetValueAsUint( "ImageDimension", 3 );
+ reader_params.SetValueAsUint( "IsColorImage", 0 );
+ reader->SetParameters( reader_params );
+
+ // Execute and get error message, if any
+ std::string err = reader->Update( );
+
+ // Assign fresh image, if any
+ if( err == "" )
{
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
-
- TPlugin::Pointer reader =
- this->m_Plugins.CreateProcessObject(
- this->m_BaseClasses[ "ImageReader" ]
- );
-
- TParameters reader_params = reader->GetDefaultParameters( );
- reader_params.SetValueAsString( "FileName", fname );
- reader_params.SetValueAsString( "PixelType", "short" );
- reader_params.SetValueAsUint( "ImageDimension", 3 );
- reader_params.SetValueAsUint( "IsColorImage", 0 );
- reader->SetParameters( reader_params );
- std::string err = reader->Update( );
-
- if( err == "" )
- {
- this->m_InputImage =
- dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
- reader->DisconnectOutputs( );
- }
- else
- QMessageBox::critical(
- this,
- tr( "Error reading single image" ),
- tr( err.c_str( ) )
- );
+ this->m_InputImage =
+ dynamic_cast< TPluginImage* >( reader->GetOutput( 0 ) );
+ reader->DisconnectOutputs( );
+ if( this->m_InputImage.IsNotNull( ) )
+ this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );
}
- else if( nFiles > 1 )
- {
- /* TODO
- if( this->m_ImageSeriesReaderClassName == "" )
- {
- QMessageBox::critical(
- this,
- tr( "No plugin to read an image series found!" ),
- tr( "No plugin to read an image series found!" )
- );
- return( ret );
-
- } // fi
- std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
- this->m_LastOpenedFile = fname;
- return( ret );
- */
+ else
+ QMessageBox::critical(
+ this,
+ tr( "Error reading single image" ),
+ tr( err.c_str( ) )
+ );
+}
- } // fi
+// -------------------------------------------------------------------------
+void ImageMPR::
+_triggered_actionOpenInputPolyData( )
+{
+ // Show dialog and check if it was accepted
+ QFileDialog dialog( this );
+ dialog.setFileMode( QFileDialog::ExistingFile );
+ dialog.setDirectory( "." );
+ dialog.setNameFilter( tr( "VTK file (*.vtk);;All files (*)" ) );
+ dialog.setDefaultSuffix( tr( "vtk" ) );
+ if( !( dialog.exec( ) ) )
+ return;
+
+ std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( );
+
+ this->m_InputPolyData = NULL;
+
+ // Get a reader from plugins
+ TPlugin::Pointer reader =
+ this->m_Plugins.CreateProcessObject(
+ this->m_BaseClasses[ "PolyDataReader" ]
+ );
- if( this->m_InputImage.IsNotNull( ) )
- this->m_MPR->SetImage( this->m_InputImage->GetVTKImageData( ) );
+ // Configure plugin
+ TParameters reader_params = reader->GetDefaultParameters( );
+ reader_params.SetValueAsString( "FileName", fname );
+ reader->SetParameters( reader_params );
+
+ // Execute and get error message, if any
+ std::string err = reader->Update( );
+
+ // Assign fresh image, if any
+ if( err == "" )
+ {
+ this->m_InputPolyData =
+ dynamic_cast< TPluginPolyData* >( reader->GetOutput( 0 ) );
+ reader->DisconnectOutputs( );
+ if( this->m_InputPolyData.IsNotNull( ) )
+ {
+ this->m_InputPolyData->GetActor( )->GetProperty( )->SetColor( 1, 0, 1 );
+ this->m_MPR->Add3DActor( this->m_InputPolyData->GetActor( ) );
+
+ } // fi
+ }
+ else
+ QMessageBox::critical(
+ this,
+ tr( "Error reading polydata" ),
+ tr( err.c_str( ) )
+ );
}
// eof - $RCSfile$
#include <cpPlugins/Interface/Interface.h>
#include <cpPlugins/Interface/ProcessObject.h>
#include <cpPlugins/Interface/Image.h>
+#include <cpPlugins/Interface/PolyData.h>
#include <cpPlugins/Interface/DataObject.h>
#include <cpPlugins/Extensions/Visualization/MPRWithDifferentWindows.h>
typedef cpPlugins::Interface::Object TPluginObject;
typedef cpPlugins::Interface::DataObject TPluginData;
typedef cpPlugins::Interface::Image TPluginImage;
+ typedef cpPlugins::Interface::PolyData TPluginPolyData;
typedef cpPlugins::Interface::ProcessObject TPlugin;
typedef cpPlugins::Interface::Parameters TParameters;
private slots:
void _triggered_actionOpenPlugins( );
void _triggered_actionOpenInputImage( );
+ void _triggered_actionOpenInputPolyData( );
private:
Ui::ImageMPR* m_UI;
TStringMap m_BaseClasses;
// Real data
- TPluginImage::Pointer m_InputImage;
+ TPluginImage::Pointer m_InputImage;
+ TPluginPolyData::Pointer m_InputPolyData;
// Visualization stuff
TMPR* m_MPR;
<addaction name="actionOpenPlugins"/>
<addaction name="separator"/>
<addaction name="actionOpenInputImage"/>
+ <addaction name="actionOpenInputPolyData"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<string>Exit</string>
</property>
</action>
+ <action name="actionOpenInputPolyData">
+ <property name="text">
+ <string>Open polydata</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+M</string>
+ </property>
+ </action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
// Configure reader
TParameters reader_params = reader->GetDefaultParameters( );
for( int i = 6; i < argc; ++i )
- reader_params.AddValueToStringList( "FileNames", argv[ 1 ] );
+ reader_params.AddValueToStringList( "FileNames", argv[ i ] );
reader_params.SetValueAsString( "PixelType", pixel_type );
reader_params.SetValueAsUint( "ImageDimension", dimensions );
reader_params.SetValueAsUint( "IsColorImage", ( is_color? 1: 0 ) );
#include <vtkAlgorithmOutput.h>
#include <vtkCellArray.h>
+#include <vtkImageData.h>
#include <vtkInformation.h>
#include <vtkPlane.h>
#include <vtkPoints.h>
void cpPlugins::Extensions::Visualization::ImageSliceActors::
SetInputConnection( vtkAlgorithmOutput* aout, int axis )
{
- this->InputAlgorithm = aout;
this->SliceMapper->SetInputConnection( aout );
this->SliceMapper->SetOrientation( axis );
this->SliceMapper->Update( );
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageSliceActors::
-SetSegmentationConnection( vtkAlgorithmOutput* aout )
+SetInputData( vtkImageData* data, int axis )
{
- this->SegmentationAlgorithm = aout;
- this->SegmentationSliceMapper->SetInputConnection( aout );
- this->SegmentationSliceMapper->
- SetOrientation( this->SliceMapper->GetOrientation( ) );
- this->SegmentationSliceMapper->
- SetSliceNumber( this->SliceMapper->GetSliceNumber( ) );
- this->SegmentationActor->SetMapper( this->SegmentationSliceMapper );
- this->SegmentationActor->Modified( );
+ this->SliceMapper->SetInputData( data );
+ this->SliceMapper->SetOrientation( axis );
+ this->SliceMapper->Update( );
+ this->SetSliceNumber( this->SliceMapper->GetSliceNumber( ) );
+ this->ImageActor->SetMapper( this->SliceMapper );
+ this->ImageActor->Modified( );
this->Modified( );
}
void cpPlugins::Extensions::Visualization::ImageSliceActors::
SetSliceNumber( const int& slice )
{
- if( this->InputAlgorithm == NULL )
- return;
this->SliceMapper->SetSliceNumber( slice );
this->SliceMapper->Update( );
- if( this->SegmentationAlgorithm != NULL )
- {
- this->SegmentationSliceMapper->SetSliceNumber( slice );
- this->SegmentationSliceMapper->Update( );
-
- } // fi
-
// Compute plane
vtkAlgorithm* algo = this->SliceMapper->GetInputAlgorithm( );
vtkInformation* info = algo->GetOutputInformation( 0 );
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::ImageSliceActors::
-UpdateText( const double& w, const double& l )
+UpdateText( )
{
char axis;
int axId = this->SliceMapper->GetOrientation( );
else if( axId == 2 ) axis = 'Z';
std::sprintf(
- this->TextBuffer, "Axis: %c (%d)\nWin/Lev: %.2f/%.2f",
- axis, this->SliceMapper->GetSliceNumber( ), w, l
+ this->TextBuffer, "Axis: %c (%d)",
+ axis, this->SliceMapper->GetSliceNumber( )
);
this->TextActor->SetInput( this->TextBuffer );
this->TextActor->Modified( );
// -------------------------------------------------------------------------
cpPlugins::Extensions::Visualization::ImageSliceActors::
ImageSliceActors( )
- : Superclass( ),
- InputAlgorithm( NULL ),
- SegmentationAlgorithm( NULL )
+ : Superclass( )
{
this->SliceMapper = vtkSmartPointer< vtkImageSliceMapper >::New( );
- this->SegmentationSliceMapper =
- vtkSmartPointer< vtkImageSliceMapper >::New( );
this->PlaneSource = vtkSmartPointer< vtkPolyData >::New( );
this->PlaneMapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
- this->ImageActor = vtkSmartPointer< vtkImageActor >::New( );
- this->SegmentationActor = vtkSmartPointer< vtkImageActor >::New( );
- this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
- this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
+ this->ImageActor = vtkSmartPointer< vtkImageActor >::New( );
+ this->TextActor = vtkSmartPointer< vtkTextActor >::New( );
+ this->PlaneActor = vtkSmartPointer< vtkActor >::New( );
this->ImageActorIndex = this->GetNumberOfItems( );
- this->SegmentationActorIndex = this->ImageActorIndex + 1;
- this->TextActorIndex = this->ImageActorIndex + 2;
- this->PlaneActorIndex = this->ImageActorIndex + 3;
+ this->TextActorIndex = this->ImageActorIndex + 1;
+ this->PlaneActorIndex = this->ImageActorIndex + 2;
this->AddItem( this->ImageActor );
- this->AddItem( this->SegmentationActor );
this->AddItem( this->TextActor );
this->AddItem( this->PlaneActor );
vtkCoordinate* coord = this->TextActor->GetPositionCoordinate( );
coord->SetCoordinateSystemToNormalizedViewport( );
coord->SetValue( 0.01, 0.01 );
-
}
// -------------------------------------------------------------------------
); \
}
+// -------------------------------------------------------------------------
class vtkAlgorithmOutput;
+class vtkImageData;
+// -------------------------------------------------------------------------
namespace cpPlugins
{
namespace Extensions
vtkTypeMacro( ImageSliceActors, vtkPropCollection );
cpPlugins_ImageSliceActors( Image, vtkImageActor );
- cpPlugins_ImageSliceActors( Segmentation, vtkImageActor );
cpPlugins_ImageSliceActors( Text, vtkTextActor );
cpPlugins_ImageSliceActors( Plane, vtkActor );
static ImageSliceActors* New( );
void SetInputConnection( vtkAlgorithmOutput* aout, int axis );
- void SetSegmentationConnection( vtkAlgorithmOutput* aout );
+ void SetInputData( vtkImageData* data, int axis );
double* GetDisplayBounds( ) const;
void GetDisplayBounds( double bounds[ 6 ] ) const;
int GetSliceNumberMinValue( ) const;
int GetSliceNumberMaxValue( ) const;
void SetSliceNumber( const int& slice );
- void UpdateText( const double& w, const double& l );
+ void UpdateText( );
protected:
ImageSliceActors( );
Self& operator=( const Self& );
protected:
- vtkAlgorithmOutput* InputAlgorithm;
- vtkAlgorithmOutput* SegmentationAlgorithm;
-
vtkSmartPointer< vtkImageSliceMapper > SliceMapper;
- vtkSmartPointer< vtkImageSliceMapper > SegmentationSliceMapper;
vtkSmartPointer< vtkPolyData > PlaneSource;
vtkSmartPointer< vtkPolyDataMapper > PlaneMapper;
- char TextBuffer[ 512 ];
+ char TextBuffer[ 1024 ];
vtkSmartPointer< vtkImageActor > ImageActor;
- vtkSmartPointer< vtkImageActor > SegmentationActor;
vtkSmartPointer< vtkTextActor > TextActor;
vtkSmartPointer< vtkActor > PlaneActor;
unsigned int ImageActorIndex;
- unsigned int SegmentationActorIndex;
unsigned int TextActorIndex;
unsigned int PlaneActorIndex;
};
#include <cpPlugins/Extensions/Visualization/MPRActors.h>
#include <vtkImageData.h>
-#include <vtkLookupTable.h>
+#include <vtkInformation.h>
#include <vtkOutlineSource.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
+#include <vtkWindowLevelLookupTable.h>
// -------------------------------------------------------------------------
cpPlugins::Extensions::Visualization::MPRActors*
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
-SetInputData( vtkImageData* image )
+SetInputConnection( vtkAlgorithmOutput* aout )
{
- if( image == NULL )
- return;
-
- this->Image = image;
-
- this->ImageToWindowLevel->SetInputData( this->Image );
- this->ResetWindowLevel( );
- this->ImageToWindowLevel->Update( );
-
- for( int i = 0; i < 3; ++i )
- {
- this->Slices[ i ]->SetInputConnection(
- this->ImageToWindowLevel->GetOutputPort( ), i
- );
- this->Slices[ i ]->UpdateText( this->GetWindow( ), this->GetLevel( ) );
-
- } // rof
-
- // Create 3D outline
- vtkSmartPointer< vtkOutlineSource > img_ol =
- vtkSmartPointer< vtkOutlineSource >::New( );
- img_ol->SetBounds( this->Image->GetBounds( ) );
-
- 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->ImageOutlineActorIndex = this->GetNumberOfItems( );
- this->AddItem( this->ImageOutlineActor );
-
- /*
- // Cursor radius
- double spac[ 3 ];
- image->GetSpacing( spac );
- double radius = spac[ 0 ];
- radius = ( spac[ 1 ] < radius )? spac[ 1 ]: radius;
- radius = ( spac[ 2 ] < radius )? spac[ 2 ]: radius;
- radius *= double( 6 );
- this->Cursor->SetRadius( radius );
- this->CursorMapper->Modified( );
- this->CursorActor->Modified( );
-
- // Plane actors
- for( int a = 0; a < 3; ++a )
- {
- // Configure actors
- this->Planes[ a ].Configure( this->ImageToWindowLevel->GetOutputPort( ), a );
- this->Planes[ a ].ConfigureRegion( this->Region->GetOutputPort( ) );
- this->Planes[ a ].UpdateText( this->GetWindow( ), this->GetLevel( ) );
-
- // Add them to renderer
- vtkRenderer* ren = this->Interactors[ a ]->GetRenderWindow( )->
- GetRenderers( )->GetFirstRenderer( );
- if( ren == NULL )
- vtkErrorMacro( "At least one interactor doesn't have a valid renderer" );
- ren->AddActor( this->Planes[ a ].ImageActor );
- ren->AddActor( this->Planes[ a ].TextActor );
-
- for( int i = 0; i < 3; ++i )
- this->Interactors[ a ]->GetRenderWindow( )->
- GetRenderers( )->GetFirstRenderer( )->
- AddActor( this->Planes[ i ].PlaneActor );
-
- } // rof
- */
- // Keep track into collection
-/*
- this->XPlaneIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 0 ].ImageActor.GetPointer( ) );
- this->XTextIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 0 ].TextActor.GetPointer( ) );
- this->XBoundsIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 0 ].PlaneActor.GetPointer( ) );
-
- this->YPlaneIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 1 ].ImageActor.GetPointer( ) );
- this->YTextIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 1 ].TextActor.GetPointer( ) );
- this->YBoundsIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 1 ].PlaneActor.GetPointer( ) );
-
- this->ZPlaneIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 2 ].ImageActor.GetPointer( ) );
- this->ZTextIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 2 ].TextActor.GetPointer( ) );
- this->ZBoundsIndex = this->GetNumberOfItems( );
- this->AddItem( this->Planes[ 2 ].PlaneActor.GetPointer( ) );
-*/
- // Initialize slice visualization
- this->ResetSlices( );
-
- /*
- #error CONTOUR_WIDGET <- ACA VOY
- static vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
- vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
- static vtkSmartPointer<vtkContourWidget> contourWidget =
- vtkSmartPointer<vtkContourWidget>::New();
- contourWidget->SetInteractor( zi );
- contourWidget->SetRepresentation( contourRep );
- contourWidget->On( );
- */
+ this->ImageMapToColors->SetInputConnection( aout );
+ this->SetLookupTableToWindowLevel( );
+ this->_UpdateSlices( );
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
-SetSegmentationData( vtkImageData* segmentation )
+SetInputData( vtkImageData* image )
{
- 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( )
- );
+ this->ImageMapToColors->SetInputData( image );
+ this->SetLookupTableToWindowLevel( );
+ this->_UpdateSlices( );
}
// -------------------------------------------------------------------------
rends[ i ]->AddActor( this->Slices[ i ]->GetTextActor( ) );
for( int j = 0; j < 3; ++j )
rends[ i ]->AddActor( this->Slices[ j ]->GetPlaneActor( ) );
- if( this->Segmentation != NULL )
- rends[ i ]->AddActor( this->Slices[ i ]->GetSegmentationActor( ) );
if( w != NULL )
+ {
+ w->AddActor( this->Slices[ i ]->GetImageActor( ) );
w->AddActor( this->Slices[ i ]->GetPlaneActor( ) );
+ } // fi
+
} // fi
} // rof
void cpPlugins::Extensions::Visualization::MPRActors::
PopDataFrom( vtkRenderer* x, vtkRenderer* y, vtkRenderer* z, vtkRenderer* w )
{
+ vtkRenderer* rends[] = { x, y, z };
+ for( int i = 0; i < 3; ++i )
+ {
+ if( rends[ i ] != NULL )
+ {
+ rends[ i ]->RemoveActor( this->Slices[ i ]->GetImageActor( ) );
+ rends[ i ]->RemoveActor( this->Slices[ i ]->GetTextActor( ) );
+ for( int j = 0; j < 3; ++j )
+ rends[ i ]->RemoveActor( this->Slices[ j ]->GetPlaneActor( ) );
+ if( w != NULL )
+ {
+ w->RemoveActor( this->Slices[ i ]->GetImageActor( ) );
+ w->RemoveActor( this->Slices[ i ]->GetPlaneActor( ) );
+
+ } // fi
+
+ } // fi
+
+ } // rof
+
+ if( w != NULL )
+ {
+ w->RemoveActor( this->ImageOutlineActor );
+
+ } // fi
+}
+
+// -------------------------------------------------------------------------
+vtkScalarsToColors* cpPlugins::Extensions::Visualization::MPRActors::
+GetLookupTable( ) const
+{
+ return( this->ImageMapToColors->GetLookupTable( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetLookupTable( vtkScalarsToColors* lut )
+{
+ this->ImageMapToColors->SetLookupTable( lut );
+ this->ImageMapToColors->Update( );
+ this->Modified( );
+}
+
+// -------------------------------------------------------------------------
+vtkWindowLevelLookupTable* cpPlugins::Extensions::Visualization::MPRActors::
+GetLookupTableAsWindowLevel( ) const
+{
+ return(
+ dynamic_cast< vtkWindowLevelLookupTable* >( this->GetLookupTable( ) )
+ );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+SetLookupTableToWindowLevel( )
+{
+ // Check if the input has been configured
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
+ return;
+
+ double r[ 2 ];
+ image->GetScalarRange( r );
+
+ vtkSmartPointer< vtkWindowLevelLookupTable > lut =
+ vtkSmartPointer< vtkWindowLevelLookupTable >::New( );
+ lut->SetScaleToLinear( );
+ lut->SetTableRange( r );
+ lut->Build( );
+
+ this->SetLookupTable( lut );
}
// -------------------------------------------------------------------------
double cpPlugins::Extensions::Visualization::MPRActors::
GetMaxWindow( ) const
{
- if( this->Image == NULL )
+ // Check if the input has been configured
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
return( double( 0 ) );
- double range[ 2 ];
- this->Image->GetScalarRange( range );
- return( range[ 1 ] - range[ 0 ] );
+ double r[ 2 ];
+ image->GetScalarRange( r );
+ return( r[ 1 ] - r[ 0 ] );
}
// -------------------------------------------------------------------------
double cpPlugins::Extensions::Visualization::MPRActors::
GetMinLevel( ) const
{
- if( this->Image == NULL )
+ // Check if the input has been configured
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
return( double( 0 ) );
- double range[ 2 ];
- this->Image->GetScalarRange( range );
- return( range[ 0 ] );
+ double r[ 2 ];
+ image->GetScalarRange( r );
+ return( r[ 0 ] );
}
// -------------------------------------------------------------------------
double cpPlugins::Extensions::Visualization::MPRActors::
GetMaxLevel( ) const
{
- if( this->Image == NULL )
+ // Check if the input has been configured
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
return( double( 0 ) );
- double range[ 2 ];
- this->Image->GetScalarRange( range );
- return( range[ 1 ] );
+ double r[ 2 ];
+ image->GetScalarRange( r );
+ return( r[ 1 ] );
}
// -------------------------------------------------------------------------
double cpPlugins::Extensions::Visualization::MPRActors::
GetWindow( ) const
{
- if( this->Image != NULL )
- return( this->ImageToWindowLevel->GetWindow( ) );
+ vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ if( lut != NULL )
+ return( lut->GetWindow( ) );
else
- return( 0 );
+ return( double( 0 ) );
}
// -------------------------------------------------------------------------
double cpPlugins::Extensions::Visualization::MPRActors::
GetLevel( ) const
{
- if( this->Image != NULL )
- return( this->ImageToWindowLevel->GetLevel( ) );
+ vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ if( lut != NULL )
+ return( lut->GetLevel( ) );
else
- return( 0 );
+ return( double( 0 ) );
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
SetWindow( const double& w )
{
- if( this->Image != NULL )
- this->ImageToWindowLevel->SetWindow( w );
+ vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ if( lut != NULL )
+ {
+ lut->SetWindow( w );
+ lut->Build( );
+ this->ImageMapToColors->Modified( );
+ this->Modified( );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
SetLevel( const double& l )
{
- if( this->Image != NULL )
- this->ImageToWindowLevel->SetLevel( l );
+ vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ if( lut != NULL )
+ {
+ lut->SetLevel( l );
+ lut->Build( );
+ this->ImageMapToColors->Modified( );
+ this->Modified( );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
SetWindowLevel( const double& w, const double& l )
{
- this->ImageToWindowLevel->SetWindow( w );
- this->ImageToWindowLevel->SetLevel( l );
- for( int i = 0; i < 3; ++i )
- this->Slices[ i ]->UpdateText( w, l );
+ vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ if( lut != NULL )
+ {
+ lut->SetWindow( l );
+ lut->SetLevel( l );
+ lut->Build( );
+ this->ImageMapToColors->Modified( );
+ this->Modified( );
+
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
ResetWindowLevel( )
{
- double range[ 2 ];
- this->Image->GetScalarRange( range );
- this->SetWindowLevel(
- range[ 1 ] - range[ 0 ],
- ( ( range[ 1 ] + range[ 0 ] ) / double( 2 ) ) + range[ 0 ]
- );
-}
+ vtkImageData* image = this->_InputImage( );
+ vtkWindowLevelLookupTable* lut = this->GetLookupTableAsWindowLevel( );
+ if( image != NULL && lut != NULL )
+ {
+ double r[ 2 ];
+ image->GetScalarRange( r );
+ lut->SetTableRange( r );
+ lut->Build( );
+ this->ImageMapToColors->Modified( );
+ this->Modified( );
-// -------------------------------------------------------------------------
-vtkPlane* cpPlugins::Extensions::Visualization::MPRActors::
-GetSlicePlane( const int& axis ) const
-{
- return( NULL );
+ } // fi
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
SetSlice( const int& axis, const int& slice )
{
- // Get image data extent
- if( this->Image == NULL )
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
return;
+
+ // Get image data extent
int ext[ 6 ];
- this->Image->GetExtent( ext );
+ image->GetExtent( ext );
// Check if the slice is valid
int real = slice;
void cpPlugins::Extensions::Visualization::MPRActors::
SetSlice( const int& axis, const double& slice )
{
- if( this->Image == NULL )
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
return;
-
+
double x[ 3 ] = { double( 0 ) };
double pcoords[ 3 ];
int ijk[ 3 ];
x[ axis ] = slice;
- this->Image->ComputeStructuredCoordinates( x, ijk, pcoords );
+ image->ComputeStructuredCoordinates( x, ijk, pcoords );
this->SetSlice( axis, ijk[ axis ] );
}
void cpPlugins::Extensions::Visualization::MPRActors::
ResetSlices( )
{
+ // TODO
}
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRActors::
GetImageBounds( double bounds[ 6 ] ) const
{
+ vtkImageData* image = this->_InputImage( );
+ if( image != NULL )
+ image->GetBounds( bounds );
}
// -------------------------------------------------------------------------
cpPlugins::Extensions::Visualization::MPRActors::
MPRActors( )
- : Superclass( ),
- Image( NULL ),
- Segmentation( NULL )
+ : Superclass( )
{
- this->ImageToWindowLevel =
- vtkSmartPointer< vtkImageMapToWindowLevelColors >::New( );
- this->SegmentationToColors = vtkSmartPointer< vtkImageMapToColors >::New( );
+ this->ImageMapToColors = vtkSmartPointer< vtkImageMapToColors >::New( );
this->ImageOutlineActor = vtkSmartPointer< vtkActor >::New( );
- this->Slices[ 0 ] = vtkSmartPointer< TSlice >::New( );
- this->Slices[ 1 ] = vtkSmartPointer< TSlice >::New( );
- this->Slices[ 2 ] = vtkSmartPointer< TSlice >::New( );
+ this->Slices[ 0 ] = vtkSmartPointer< _TSlice >::New( );
+ this->Slices[ 1 ] = vtkSmartPointer< _TSlice >::New( );
+ this->Slices[ 2 ] = vtkSmartPointer< _TSlice >::New( );
}
// -------------------------------------------------------------------------
{
}
+// -------------------------------------------------------------------------
+vtkImageData* cpPlugins::Extensions::Visualization::MPRActors::
+_InputImage( ) const
+{
+ vtkAlgorithm* algo = this->ImageMapToColors->GetInputAlgorithm( );
+ vtkInformation* info = algo->GetOutputInformation( 0 );
+ return(
+ vtkImageData::SafeDownCast( info->Get( vtkDataObject::DATA_OBJECT( ) ) )
+ );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRActors::
+_UpdateSlices( )
+{
+ // Check if the input has been configured
+ vtkImageData* image = this->_InputImage( );
+ if( image == NULL )
+ return;
+ this->ImageMapToColors->Update( );
+
+ for( int i = 0; i < 3; ++i )
+ {
+ this->Slices[ i ]->SetInputConnection(
+ this->ImageMapToColors->GetOutputPort( ), i
+ );
+ this->Slices[ i ]->UpdateText( );
+
+ } // rof
+
+ // 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->ImageOutlineActorIndex = this->GetNumberOfItems( );
+ this->AddItem( this->ImageOutlineActor );
+
+ // Cursor radius
+ /*
+ double spac[ 3 ];
+ image->GetSpacing( spac );
+ double radius = spac[ 0 ];
+ radius = ( spac[ 1 ] < radius )? spac[ 1 ]: radius;
+ radius = ( spac[ 2 ] < radius )? spac[ 2 ]: radius;
+ radius *= double( 6 );
+ this->Cursor->SetRadius( radius );
+ this->CursorMapper->Modified( );
+ this->CursorActor->Modified( );
+
+ // Plane actors
+ for( int a = 0; a < 3; ++a )
+ {
+ // Configure actors
+ this->Planes[ a ].Configure( this->ImageToWindowLevel->GetOutputPort( ), a );
+ this->Planes[ a ].ConfigureRegion( this->Region->GetOutputPort( ) );
+ this->Planes[ a ].UpdateText( this->GetWindow( ), this->GetLevel( ) );
+
+ // Add them to renderer
+ vtkRenderer* ren = this->Interactors[ a ]->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( );
+ if( ren == NULL )
+ vtkErrorMacro( "At least one interactor doesn't have a valid renderer" );
+ ren->AddActor( this->Planes[ a ].ImageActor );
+ ren->AddActor( this->Planes[ a ].TextActor );
+
+ for( int i = 0; i < 3; ++i )
+ this->Interactors[ a ]->GetRenderWindow( )->
+ GetRenderers( )->GetFirstRenderer( )->
+ AddActor( this->Planes[ i ].PlaneActor );
+
+ } // rof
+ */
+ // Keep track into collection
+ /*
+ this->XPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].ImageActor.GetPointer( ) );
+ this->XTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].TextActor.GetPointer( ) );
+ this->XBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 0 ].PlaneActor.GetPointer( ) );
+
+ this->YPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].ImageActor.GetPointer( ) );
+ this->YTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].TextActor.GetPointer( ) );
+ this->YBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 1 ].PlaneActor.GetPointer( ) );
+
+ this->ZPlaneIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].ImageActor.GetPointer( ) );
+ this->ZTextIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].TextActor.GetPointer( ) );
+ this->ZBoundsIndex = this->GetNumberOfItems( );
+ this->AddItem( this->Planes[ 2 ].PlaneActor.GetPointer( ) );
+ */
+ // Initialize slice visualization
+ // this->ResetSlices( );
+
+ /*
+ #error CONTOUR_WIDGET <- ACA VOY
+ static vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
+ vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
+ static vtkSmartPointer<vtkContourWidget> contourWidget =
+ vtkSmartPointer<vtkContourWidget>::New();
+ contourWidget->SetInteractor( zi );
+ contourWidget->SetRepresentation( contourRep );
+ contourWidget->On( );
+ */
+}
+
// eof - $RCSfile$
#include <vtkActor.h>
#include <vtkImageMapToColors.h>
-#include <vtkImageMapToWindowLevelColors.h>
+// -------------------------------------------------------------------------
+class vtkAlgorithmOutput;
+class vtkImageData;
class vtkRenderer;
+class vtkScalarsToColors;
+class vtkWindowLevelLookupTable;
+// -------------------------------------------------------------------------
namespace cpPlugins
{
namespace Extensions
static MPRActors* New( );
ImageSliceActors* GetSliceActors( const int& i ) const;
+ void SetInputConnection( vtkAlgorithmOutput* aout );
void SetInputData( vtkImageData* image );
- void SetSegmentationData( vtkImageData* segmentation );
void PushDataInto(
vtkRenderer* x,
vtkRenderer* w
);
- // Window/Level
+ // Lookup table methods
+ vtkScalarsToColors* GetLookupTable( ) const;
+ void SetLookupTable( vtkScalarsToColors* lut );
+
+ // Grayscale window/level lookup
+ vtkWindowLevelLookupTable* GetLookupTableAsWindowLevel( ) const;
+ void SetLookupTableToWindowLevel( );
double GetMinWindow( ) const;
double GetMaxWindow( ) const;
double GetMinLevel( ) const;
void ResetWindowLevel( );
// Slice access
- vtkPlane* GetSlicePlane( const int& axis ) const;
int GetSliceNumberMinValue( const int& axis ) const;
int GetSliceNumberMaxValue( const int& axis ) const;
int GetSlice( const int& axis ) const;
MPRActors( );
virtual ~MPRActors( );
+ vtkImageData* _InputImage( ) const;
+ void _UpdateSlices( );
+
private:
// Purposely not implemented
MPRActors( const Self& );
Self& operator=( const Self& );
protected:
- vtkImageData* Image;
- vtkImageData* Segmentation;
-
- vtkSmartPointer< vtkImageMapToWindowLevelColors > ImageToWindowLevel;
- vtkSmartPointer< vtkImageMapToColors > SegmentationToColors;
-
- vtkSmartPointer< vtkActor > ImageOutlineActor;
+ vtkSmartPointer< vtkImageMapToColors > ImageMapToColors;
+ vtkSmartPointer< vtkActor > ImageOutlineActor;
- typedef cpPlugins::Extensions::Visualization::ImageSliceActors TSlice;
- vtkSmartPointer< TSlice > Slices[ 3 ];
+ typedef
+ cpPlugins::Extensions::Visualization::ImageSliceActors
+ _TSlice;
+ vtkSmartPointer< _TSlice > Slices[ 3 ];
unsigned int ImageOutlineActorIndex;
};
this->RenderAll( );
}
-// -------------------------------------------------------------------------
-void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
-SetSegmentation( vtkImageData* image )
-{
- this->m_MPRActors->SetSegmentationData( image );
- this->m_MPRActors->PushDataInto(
- this->m_Renderers[ 0 ],
- this->m_Renderers[ 1 ],
- this->m_Renderers[ 2 ],
- this->m_Renderers[ 3 ]
- );
-
- this->Render( 0 );
- this->Render( 1 );
- this->Render( 2 );
-}
-
// -------------------------------------------------------------------------
void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
SetModeToNavigation( )
this->m_Windows[ i ]->Render( );
}
+// -------------------------------------------------------------------------
+void cpPlugins::Extensions::Visualization::MPRWithDifferentWindows::
+Add3DActor( vtkProp3D* prop )
+{
+ if( this->m_Renderers[ 3 ] != NULL )
+ {
+ this->m_Renderers[ 3 ]->AddActor( prop );
+ this->ResetCamera( 3 );
+ this->Render( 3 );
+
+ } // fi
+}
+
// eof - $RCSfile$
virtual ~MPRWithDifferentWindows( );
void SetImage( vtkImageData* image );
- void SetSegmentation( vtkImageData* image );
void SetModeToNavigation( );
void SetModeToDeformation( );
void Render( const int& id );
void RenderAll( );
+ void Add3DActor( vtkProp3D* prop );
+
protected:
// Inputs
vtkRenderWindow* m_Windows[ 4 ];
--- /dev/null
+
+#include <cpPlugins/Interface/PolyData.h>
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::PolyData::
+GetClassName( ) const
+{
+ return( "cpPlugins::Interface::PolyData" );
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::PolyData::
+SetRealDataObject( itk::DataObject* dobj )
+{
+ // Nothing to be done here
+}
+
+// -------------------------------------------------------------------------
+void cpPlugins::Interface::PolyData::
+SetRealDataObject( vtkDataObject* dobj )
+{
+ this->m_Data = dynamic_cast< vtkPolyData* >( dobj );
+ if( this->m_Data == NULL )
+ return;
+ this->m_Mapper->SetInputData( this->m_Data );
+ this->m_Actor->SetMapper( this->m_Mapper );
+}
+
+// -------------------------------------------------------------------------
+vtkPolyData* cpPlugins::Interface::PolyData::
+GetData( ) const
+{
+ return( this->m_Data );
+}
+
+// -------------------------------------------------------------------------
+vtkPolyDataMapper* cpPlugins::Interface::PolyData::
+GetMapper( ) const
+{
+ return( this->m_Mapper );
+}
+
+// -------------------------------------------------------------------------
+vtkActor* cpPlugins::Interface::PolyData::
+GetActor( ) const
+{
+ return( this->m_Actor );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PolyData::
+PolyData( )
+ : Superclass( )
+{
+ this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( );
+ this->m_Actor = vtkSmartPointer< vtkActor >::New( );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PolyData::
+~PolyData( )
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__INTERFACE__POLYDATA__H__
+#define __CPPLUGINS__INTERFACE__POLYDATA__H__
+
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/DataObject.h>
+
+#include <vtkActor.h>
+#include <vtkPolyData.h>
+#include <vtkPolyDataMapper.h>
+#include <vtkSmartPointer.h>
+
+namespace cpPlugins
+{
+ namespace Interface
+ {
+ /**
+ */
+ class cpPlugins_Interface_EXPORT PolyData
+ : public DataObject
+ {
+ public:
+ typedef PolyData Self;
+ typedef DataObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( PolyData, DataObject );
+
+ public:
+ virtual std::string GetClassName( ) const;
+ virtual void SetRealDataObject( itk::DataObject* dobj );
+ virtual void SetRealDataObject( vtkDataObject* dobj );
+
+ vtkPolyData* GetData( ) const;
+ vtkPolyDataMapper* GetMapper( ) const;
+ vtkActor* GetActor( ) const;
+
+ protected:
+ PolyData( );
+ virtual ~PolyData( );
+
+ private:
+ // Purposely not implemented
+ PolyData( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ vtkSmartPointer< vtkPolyData > m_Data;
+ vtkSmartPointer< vtkPolyDataMapper > m_Mapper;
+ vtkSmartPointer< vtkActor > m_Actor;
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__POLYDATA__H__
+
+// eof - $RCSfile$
--- /dev/null
+#include <cpPlugins/Interface/PolyDataSource.h>
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::PolyDataSource::
+GetClassName( ) const
+{
+ return( "cpPlugins::Interface::PolyDataSource" );
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Interface::PolyDataSource::
+GetClassType( ) const
+{
+ return( "PolyDataSource" );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PolyDataSource::
+PolyDataSource( )
+ : Superclass( )
+{
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Interface::PolyDataSource::
+~PolyDataSource( )
+{
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__INTERFACE__POLYDATASOURCE__H__
+#define __CPPLUGINS__INTERFACE__POLYDATASOURCE__H__
+
+#include <cpPlugins/Interface/cpPlugins_Interface_Export.h>
+#include <cpPlugins/Interface/SourceObject.h>
+
+namespace cpPlugins
+{
+ namespace Interface
+ {
+ /**
+ */
+ class cpPlugins_Interface_EXPORT PolyDataSource
+ : public SourceObject
+ {
+ public:
+ typedef PolyDataSource Self;
+ typedef SourceObject Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkTypeMacro( PolyDataSource, SourceObject );
+
+ public:
+ virtual std::string GetClassName( ) const;
+ virtual std::string GetClassType( ) const;
+
+ protected:
+ PolyDataSource( );
+ virtual ~PolyDataSource( );
+
+ private:
+ // Purposely not implemented
+ PolyDataSource( const Self& );
+ Self& operator=( const Self& );
+ };
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__INTERFACE__POLYDATASOURCE__H__
+
+// eof - $RCSfile$
${LIBRARY_NAME}
cpPlugins_Interface
${ITK_LIBRARIES}
+ ${VTK_LIBRARIES}
+ vtkIOLegacy
)
## eof - $RCSfile$
#include <cpPlugins/Plugins/ImageWriter.h>
#include <cpPlugins/Plugins/MarchingCubes.h>
#include <cpPlugins/Plugins/MeshReader.h>
+#include <cpPlugins/Plugins/PolyDataReader.h>
#include <cpPlugins/Plugins/RGBImageToHSVChannelsFilter.h>
/// TODO: doc
host.add( new ImageWriterProvider( ) );
host.add( new MarchingCubesProvider( ) );
host.add( new MeshReaderProvider( ) );
+ host.add( new PolyDataReaderProvider( ) );
host.add( new RGBImageToHSVChannelsFilterProvider( ) );
return( true );
}
#include <cpPlugins/Interface/Image.h>
#include <itkImageFileReader.h>
+#include <itkImageSeriesReader.h>
#define ITK_MANUAL_INSTANTIATION
#include <itkImage.h>
this->_MakeOutput< cpPlugins::Interface::Image >( 0 );
using namespace cpPlugins::Interface;
- this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
+ this->m_DefaultParameters.Configure( Parameters::StringList, "FileNames" );
this->m_DefaultParameters.Configure( Parameters::String, "PixelType" );
this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" );
this->m_DefaultParameters.Configure( Parameters::Uint, "IsColorImage" );
std::string cpPlugins::Plugins::ImageReader::
_GD1( )
{
- // Get filename
- using namespace cpPlugins::Interface;
- Parameters::TString fname =
- this->m_Parameters.GetValueAsString( "FileName" );
-
typedef itk::Image< P, D > _TImage;
- typedef itk::ImageFileReader< _TImage > _TReader;
- _TReader* reader =
- dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
- if( reader == NULL )
- {
- this->m_RealProcessObject = _TReader::New( );
- reader =
- dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) );
+ // Get filenames
+ using namespace cpPlugins::Interface;
+ std::vector< Parameters::TString > unordered_names;
+ this->m_Parameters.GetValueAsStringList( unordered_names, "FileNames" );
- } // fi
- reader->SetFileName( fname );
- try
+ if( unordered_names.size( ) == 1 )
{
- reader->Update( );
+ // Read single image
+ typedef itk::ImageFileReader< _TImage > _TSingleReader;
+
+ _TSingleReader* singleReader =
+ dynamic_cast< _TSingleReader* >(
+ this->m_RealProcessObject.GetPointer( )
+ );
+ if( singleReader == NULL )
+ {
+ this->m_RealProcessObject = _TSingleReader::New( );
+ singleReader =
+ dynamic_cast< _TSingleReader* >(
+ this->m_RealProcessObject.GetPointer( )
+ );
+
+ } // fi
+ singleReader->SetFileName( unordered_names.front( ) );
+ try
+ {
+ singleReader->Update( );
+ }
+ catch( itk::ExceptionObject& err )
+ {
+ return( err.GetDescription( ) );
+
+ } // yrt
+ this->_SetOutput( 0, singleReader->GetOutput( ) );
+ return( "" );
}
- catch( itk::ExceptionObject& err )
+ else if( unordered_names.size( ) > 1 )
{
- return( err.GetDescription( ) );
-
- } // yrt
- this->_SetOutput( 0, reader->GetOutput( ) );
- return( "" );
+ // Read image series
+ std::set< std::string > ordered_names;
+ for( unsigned int i = 0; i < unordered_names.size( ); ++i )
+ ordered_names.insert( unordered_names[ i ] );
+
+ typedef itk::ImageSeriesReader< _TImage > _TMultiReader;
+ _TMultiReader* multiReader =
+ dynamic_cast< _TMultiReader* >(
+ this->m_RealProcessObject.GetPointer( )
+ );
+ if( multiReader == NULL )
+ {
+ this->m_RealProcessObject = _TMultiReader::New( );
+ multiReader =
+ dynamic_cast< _TMultiReader* >(
+ this->m_RealProcessObject.GetPointer( )
+ );
+
+ } // fi
+ std::set< std::string >::const_iterator fnIt = ordered_names.begin( );
+ for( ; fnIt != ordered_names.end( ); ++fnIt )
+ multiReader->AddFileName( *fnIt );
+ try
+ {
+ multiReader->Update( );
+ }
+ catch( itk::ExceptionObject& err )
+ {
+ return( err.GetDescription( ) );
+
+ } // yrt
+ this->_SetOutput( 0, multiReader->GetOutput( ) );
+ return( "" );
+ }
+ else
+ return( "No image filename(s) given." );
}
// eof - $RCSfile$
virtual std::string _GenerateData( );
template< unsigned int D >
- std::string _GD0( );
+ std::string _GD0( );
template< class P, unsigned int D >
- std::string _GD1( );
+ std::string _GD1( );
private:
// Purposely not implemented
--- /dev/null
+#include <cpPlugins/Plugins/PolyDataReader.h>
+#include <cpPlugins/Interface/PolyData.h>
+
+#include <vtkErrorCode.h>
+#include <vtkPolyDataReader.h>
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::PolyDataReader::
+GetClassName( ) const
+{
+ return( "cpPlugins::Plugins::PolyDataReader" );
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::PolyDataReader::
+PolyDataReader( )
+ : Superclass( )
+{
+ this->SetNumberOfOutputs( 1 );
+ this->_MakeOutput< cpPlugins::Interface::PolyData >( 0 );
+
+ using namespace cpPlugins::Interface;
+ this->m_DefaultParameters.Configure( Parameters::String, "FileName" );
+ this->m_Parameters = this->m_DefaultParameters;
+}
+
+// -------------------------------------------------------------------------
+cpPlugins::Plugins::PolyDataReader::
+~PolyDataReader( )
+{
+}
+
+// -------------------------------------------------------------------------
+std::string cpPlugins::Plugins::PolyDataReader::
+_GenerateData( )
+{
+ // Get filename
+ using namespace cpPlugins::Interface;
+ Parameters::TString fname =
+ this->m_Parameters.GetValueAsString( "FileName" );
+
+ // Create a possible reader
+ vtkPolyDataReader* reader =
+ dynamic_cast< vtkPolyDataReader* >( this->m_Reader.GetPointer( ) );
+ if( reader == NULL )
+ {
+ this->m_Reader = vtkSmartPointer< vtkPolyDataReader >::New( );
+ reader =
+ dynamic_cast< vtkPolyDataReader* >( this->m_Reader.GetPointer( ) );
+
+ } // fi
+ reader->SetFileName( fname.c_str( ) );
+ reader->Update( );
+ unsigned long error = reader->GetErrorCode( );
+ if( error == vtkErrorCode::NoError )
+ {
+ if( this->m_Outputs[ 0 ].IsNotNull( ) )
+ {
+ cpPlugins::Interface::PolyData* pdata =
+ dynamic_cast< cpPlugins::Interface::PolyData* >(
+ this->m_Outputs[ 0 ].GetPointer( )
+ );
+ if( pdata != NULL )
+ pdata->SetRealDataObject( reader->GetOutput( ) );
+
+ } // fi
+ return( "" );
+ }
+ else
+ return( vtkErrorCode::GetStringFromErrorCode( error ) );
+}
+
+// eof - $RCSfile$
--- /dev/null
+#ifndef __CPPLUGINS__PLUGINS__POLYDATAREADER__H__
+#define __CPPLUGINS__PLUGINS__POLYDATAREADER__H__
+
+#include <cpPlugins/Plugins/cpPlugins_Export.h>
+#include <cpPlugins/Interface/PolyDataSource.h>
+
+#include <vtkAlgorithm.h>
+#include <vtkSmartPointer.h>
+
+namespace cpPlugins
+{
+ namespace Plugins
+ {
+ /**
+ */
+ class cpPlugins_EXPORT PolyDataReader
+ : public cpPlugins::Interface::PolyDataSource
+ {
+ public:
+ typedef PolyDataReader Self;
+ typedef cpPlugins::Interface::PolyDataSource Superclass;
+ typedef itk::SmartPointer< Self > Pointer;
+ typedef itk::SmartPointer< const Self > ConstPointer;
+
+ public:
+ itkNewMacro( Self );
+ itkTypeMacro( PolyDataReader, cpPluginsInterfacePolyDataSource );
+
+ public:
+ virtual std::string GetClassName( ) const;
+
+ protected:
+ PolyDataReader( );
+ virtual ~PolyDataReader( );
+
+ virtual std::string _GenerateData( );
+
+ private:
+ // Purposely not implemented
+ PolyDataReader( const Self& );
+ Self& operator=( const Self& );
+
+ protected:
+ vtkSmartPointer< vtkAlgorithm > m_Reader;
+ };
+
+ // ---------------------------------------------------------------------
+ CPPLUGINS_INHERIT_PROVIDER( PolyDataReader );
+
+ } // ecapseman
+
+} // ecapseman
+
+#endif // __CPPLUGINS__PLUGINS__POLYDATAREADER__H__
+
+// eof - $RCSfile$