From 94a44f4cdf4747eccc933df0a9c75ec86e825d2e Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Tue, 29 Sep 2015 18:02:30 -0500 Subject: [PATCH] ... --- CMakeLists.txt | 6 + appli/CMakeLists.txt | 4 + appli/ImageMPR/ImageMPR.cxx | 189 +++--- appli/ImageMPR/ImageMPR.h | 10 +- appli/bash/CMakeLists.txt | 15 + appli/bash/cpPlugins_createHost.cxx | 59 ++ appli/examples/CMakeLists.txt | 10 +- appli/examples/example_LoadPlugins.cxx | 16 +- appli/examples/example_ReadWriteImage.cxx | 34 +- lib/cpExtensions/Visualization/MPRObjects.cxx | 19 + lib/cpExtensions/Visualization/MPRObjects.h | 1 + lib/cpPlugins/Interface/CMakeLists.txt | 5 +- .../Interface/Instances_itkImage.cxx | 248 ++++---- .../Interface/Instances_itkVectorImage.cxx | 100 +++ lib/cpPlugins/Interface/Macros.h | 7 - .../BinaryThresholdImageFilter.cxx | 14 +- .../BinaryThresholdImageFilter.h | 6 +- .../Plugins/BasicFilters/CMakeLists.txt | 56 ++ .../{ => BasicFilters}/MarchingCubes.cxx | 10 +- .../{ => BasicFilters}/MarchingCubes.h | 6 +- .../{ => BasicFilters}/MedianImageFilter.cxx | 14 +- .../{ => BasicFilters}/MedianImageFilter.h | 6 +- .../OtsuThresholdImageFilter.cxx | 14 +- .../OtsuThresholdImageFilter.h | 6 +- .../RGBImageToOtherChannelsFilter.cxx | 14 +- .../RGBImageToOtherChannelsFilter.h | 6 +- lib/cpPlugins/Plugins/CMakeLists.txt | 102 +-- lib/cpPlugins/Plugins/Host.cxx | 33 - lib/cpPlugins/Plugins/IO/CMakeLists.txt | 55 ++ lib/cpPlugins/Plugins/IO/ImageReader.cxx | 396 ++++++++++++ lib/cpPlugins/Plugins/{ => IO}/ImageReader.h | 9 +- .../Plugins/{ => IO}/ImageWriter.cxx | 12 +- lib/cpPlugins/Plugins/{ => IO}/ImageWriter.h | 6 +- lib/cpPlugins/Plugins/{ => IO}/MeshReader.cxx | 14 +- lib/cpPlugins/Plugins/{ => IO}/MeshReader.h | 6 +- lib/cpPlugins/Plugins/{ => IO}/MeshWriter.cxx | 10 +- lib/cpPlugins/Plugins/{ => IO}/MeshWriter.h | 6 +- lib/cpPlugins/Plugins/ImageReader.cxx | 586 ------------------ 38 files changed, 1085 insertions(+), 1025 deletions(-) create mode 100644 appli/bash/CMakeLists.txt create mode 100644 appli/bash/cpPlugins_createHost.cxx create mode 100644 lib/cpPlugins/Interface/Instances_itkVectorImage.cxx rename lib/cpPlugins/Plugins/{ => BasicFilters}/BinaryThresholdImageFilter.cxx (90%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/BinaryThresholdImageFilter.h (90%) create mode 100644 lib/cpPlugins/Plugins/BasicFilters/CMakeLists.txt rename lib/cpPlugins/Plugins/{ => BasicFilters}/MarchingCubes.cxx (90%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/MarchingCubes.h (89%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/MedianImageFilter.cxx (87%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/MedianImageFilter.h (90%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/OtsuThresholdImageFilter.cxx (88%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/OtsuThresholdImageFilter.h (90%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/RGBImageToOtherChannelsFilter.cxx (91%) rename lib/cpPlugins/Plugins/{ => BasicFilters}/RGBImageToOtherChannelsFilter.h (90%) delete mode 100644 lib/cpPlugins/Plugins/Host.cxx create mode 100644 lib/cpPlugins/Plugins/IO/CMakeLists.txt create mode 100644 lib/cpPlugins/Plugins/IO/ImageReader.cxx rename lib/cpPlugins/Plugins/{ => IO}/ImageReader.h (88%) rename lib/cpPlugins/Plugins/{ => IO}/ImageWriter.cxx (90%) rename lib/cpPlugins/Plugins/{ => IO}/ImageWriter.h (91%) rename lib/cpPlugins/Plugins/{ => IO}/MeshReader.cxx (89%) rename lib/cpPlugins/Plugins/{ => IO}/MeshReader.h (92%) rename lib/cpPlugins/Plugins/{ => IO}/MeshWriter.cxx (87%) rename lib/cpPlugins/Plugins/{ => IO}/MeshWriter.h (91%) delete mode 100644 lib/cpPlugins/Plugins/ImageReader.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 83c4b84..d1ed48a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,12 @@ ENDIF(BUILD_SHARED_LIBRARIES) # Prepare header to build shared libs (windows) INCLUDE(GenerateExportHeader) +# Find boost +FIND_PACKAGE(Boost 1.30 COMPONENTS filesystem system REQUIRED) +IF(Boost_FOUND) + INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) +ENDIF(Boost_FOUND) + # Find ITK and VTK FIND_PACKAGE(ITK REQUIRED) FIND_PACKAGE(VTK REQUIRED) diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt index 7ca64d4..2568ba0 100644 --- a/appli/CMakeLists.txt +++ b/appli/CMakeLists.txt @@ -1,3 +1,7 @@ +SUBDIRS( + bash + ) + IF(BUILD_EXAMPLES) SUBDIRS( examples diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index f9a7934..f9613cb 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -1,8 +1,6 @@ #include "ImageMPR.h" #include "ui_ImageMPR.h" -#include - #include #include @@ -59,7 +57,7 @@ ImageMPR::ImageMPR( QWidget* parent ) // Start: load all disponible plugins this->_LoadPlugins( std::string( PLUGIN_PREFIX ) + - std::string( "cpPlugins." ) + + std::string( "cpPluginsIO." ) + std::string( PLUGIN_EXT ) ); } @@ -86,17 +84,12 @@ _LoadPlugins( const std::string& filename ) this->m_ImageWriterClass = ""; this->m_MeshReaderClass = ""; this->m_MeshWriterClass = ""; - this->m_ImageToImageFilters.clear( ); - this->m_ImageToMeshFilters.clear( ); + this->m_UI->MenuImageToImage->clear( ); + this->m_UI->MenuImageToMesh->clear( ); - this->m_Plugins.UnloadAll( ); if( !( this->m_Plugins.Load( filename ) ) ) - { - this->m_Plugins.UnloadAll( ); return( false ); - } // fi - typedef TPluginsInterface::TClasses _TClasses; _TClasses::const_iterator cIt = this->m_Plugins.GetClasses( ).begin( ); for( ; cIt != this->m_Plugins.GetClasses( ).end( ); ++cIt ) @@ -115,7 +108,6 @@ _LoadPlugins( const std::string& filename ) this->m_MeshWriterClass = name; else if( category == "ImageToImageFilter" ) { - this->m_ImageToImageFilters.insert( name ); QAction* action = this->m_UI->MenuImageToImage->addAction( QString( name.c_str( ) ) ); QObject::connect( @@ -125,7 +117,6 @@ _LoadPlugins( const std::string& filename ) } else if( category == "ImageToMeshFilter" ) { - this->m_ImageToMeshFilters.insert( name ); QAction* action = this->m_UI->MenuImageToMesh->addAction( QString( name.c_str( ) ) ); QObject::connect( @@ -142,6 +133,50 @@ _LoadPlugins( const std::string& filename ) return( true ); } +// ------------------------------------------------------------------------- +std::string ImageMPR:: +_LoadImage( TPluginImage::Pointer& image, const QStringList& names ) +{ + // Block application + QApplication::setOverrideCursor( Qt::WaitCursor ); + this->setEnabled( false ); + + std::string ret = ""; + image = NULL; + + // Get a reader from loaded plugins + TPluginFilter::Pointer reader = + this->m_Plugins.CreateProcessObject( this->m_ImageReaderClass ); + if( reader.IsNotNull( ) ) + { + // Configure reader + TParameters params = reader->GetDefaultParameters( ); + QStringList::const_iterator qIt = names.begin( ); + for( ; qIt != names.end( ); ++qIt ) + params.AddValueToStringList( "FileNames", qIt->toStdString( ) ); + params.SetValueAsBool( "VectorType", false ); + reader->SetParameters( params ); + + // Execute and get error message, if any + ret = reader->Update( ); + + // Assign fresh image, if any + if( ret == "" ) + { + image = reader->GetOutput< TPluginImage >( 0 ); + reader->DisconnectOutputs( ); + + } // fi + } + else + ret = "No suitable reader object found in loaded plugins."; + + // Finish reading + QApplication::restoreOverrideCursor( ); + this->setEnabled( true ); + return( ret ); +} + // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionOpenPlugins( ) @@ -179,50 +214,25 @@ _triggered_actionOpenInputImage( ) if( !( dialog.exec( ) ) ) return; - this->m_InputImage = NULL; - - // Get a reader from plugins - TPluginFilter::Pointer reader = - this->m_Plugins.CreateProcessObject( this->m_ImageReaderClass ); - - // Configure reader - TParameters reader_params = reader->GetDefaultParameters( ); - QStringList q_fnames = dialog.selectedFiles( ); - QStringList::const_iterator qIt = q_fnames.begin( ); - for( ; qIt != q_fnames.end( ); ++qIt ) - reader_params.AddValueToStringList( "FileNames", qIt->toStdString( ) ); - reader->SetParameters( reader_params ); - - // Execute and get error message, if any - QApplication::setOverrideCursor( Qt::WaitCursor ); - this->setEnabled( false ); - std::string err = reader->Update( ); - QApplication::restoreOverrideCursor( ); - this->setEnabled( true ); - - // Assign fresh image, if any + // Read image + std::string err = + this->_LoadImage( this->m_InputImage, dialog.selectedFiles( ) ); if( err == "" ) { - this->m_InputImage = reader->GetOutput< TPluginImage >( 0 ); - reader->DisconnectOutputs( ); - if( this->m_InputImage.IsNotNull( ) ) + vtkImageData* vtk_id = this->m_InputImage->GetVTKImageData( ); + if( vtk_id != NULL ) { - vtkImageData* vtk_id = this->m_InputImage->GetVTKImageData( ); - if( vtk_id != NULL ) - { - this->m_MPRObjects->SetImage( vtk_id ); - this->m_MPRObjects->ActivateInteractors( ); - this->m_MPRObjects->ResetCameras( ); - this->m_MPRObjects->RenderAll( ); - } - else - QMessageBox::critical( - this, - tr( "Error message" ), - tr( "Read image does not have a valid VTK converter." ) - ); - - } // fi + this->m_MPRObjects->SetImage( vtk_id ); + this->m_MPRObjects->ActivateInteractors( ); + this->m_MPRObjects->ResetCameras( ); + this->m_MPRObjects->RenderAll( ); + } + else + QMessageBox::critical( + this, + tr( "Error message" ), + tr( "Read image does not have a valid VTK converter." ) + ); } else QMessageBox::critical( @@ -236,6 +246,17 @@ _triggered_actionOpenInputImage( ) void ImageMPR:: _triggered_actionOpenSegmentation( ) { + if( this->m_InputImage.IsNull( ) ) + { + QMessageBox::critical( + this, + tr( "Error message" ), + tr( "Before reading a segmentation, first load a raw image." ) + ); + return; + + } // fi + // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::ExistingFiles ); @@ -247,51 +268,23 @@ _triggered_actionOpenSegmentation( ) if( !( dialog.exec( ) ) ) return; - this->m_InputImage = NULL; - - // Get a reader from plugins - TPluginFilter::Pointer reader = - this->m_Plugins.CreateProcessObject( this->m_ImageReaderClass ); - - // Configure reader - TParameters reader_params = reader->GetDefaultParameters( ); - QStringList q_fnames = dialog.selectedFiles( ); - QStringList::const_iterator qIt = q_fnames.begin( ); - for( ; qIt != q_fnames.end( ); ++qIt ) - reader_params.AddValueToStringList( "FileNames", qIt->toStdString( ) ); - reader->SetParameters( reader_params ); - - // Execute and get error message, if any - QApplication::setOverrideCursor( Qt::WaitCursor ); - this->setEnabled( false ); - std::string err = reader->Update( ); - QApplication::restoreOverrideCursor( ); - this->setEnabled( true ); - - // Assign fresh image, if any + // Read image + std::string err = + this->_LoadImage( this->m_InputSegmentation, dialog.selectedFiles( ) ); if( err == "" ) { - this->m_InputSegmentation = reader->GetOutput< TPluginImage >( 0 ); - reader->DisconnectOutputs( ); - if( this->m_InputSegmentation.IsNotNull( ) ) + vtkImageData* vtk_id = this->m_InputSegmentation->GetVTKImageData( ); + if( vtk_id != NULL ) { - vtkImageData* vtk_id = this->m_InputSegmentation->GetVTKImageData( ); - if( vtk_id != NULL ) - { - /* - this->m_MPRObjects->SetImage( vtk_id ); - this->m_MPRObjects->ResetCameras( ); - this->m_MPRObjects->RenderAll( ); - */ - } - else - QMessageBox::critical( - this, - tr( "Error message" ), - tr( "Read image does not have a valid VTK converter." ) - ); - - } // fi + this->m_MPRObjects->AddAuxiliaryImage( vtk_id ); + this->m_MPRObjects->RenderAll( ); + } + else + QMessageBox::critical( + this, + tr( "Error message" ), + tr( "Read image does not have a valid VTK converter." ) + ); } else QMessageBox::critical( @@ -305,6 +298,7 @@ _triggered_actionOpenSegmentation( ) void ImageMPR:: _triggered_actionOpenInputPolyData( ) { + /* // Show dialog and check if it was accepted QFileDialog dialog( this ); dialog.setFileMode( QFileDialog::ExistingFile ); @@ -366,12 +360,14 @@ _triggered_actionOpenInputPolyData( ) tr( "Error reading mesh" ), tr( err.c_str( ) ) ); + */ } // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionImageToImage( ) { + /* if( this->m_InputImage.IsNull( ) ) return; @@ -411,12 +407,14 @@ _triggered_actionImageToImage( ) tr( "Error executing filter" ), tr( err.c_str( ) ) ); + */ } // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionImageToMesh( ) { + /* if( this->m_InputImage.IsNull( ) ) return; @@ -458,6 +456,7 @@ _triggered_actionImageToMesh( ) tr( "Error executing filter" ), tr( err.c_str( ) ) ); + */ } // eof - $RCSfile$ diff --git a/appli/ImageMPR/ImageMPR.h b/appli/ImageMPR/ImageMPR.h index 1b56805..cf3e5c1 100644 --- a/appli/ImageMPR/ImageMPR.h +++ b/appli/ImageMPR/ImageMPR.h @@ -1,9 +1,7 @@ #ifndef __IMAGEMPR__H__ #define __IMAGEMPR__H__ -// Standard stuff -#include -#include +#include // Qt stuff #include @@ -42,7 +40,6 @@ public: typedef cpPlugins::Interface::ProcessObject TPluginFilter; typedef cpPlugins::Interface::Parameters TParameters; - typedef std::set< std::string > TStringContainer; typedef cpExtensions::Visualization::MPRObjects TMPRObjects; public: @@ -51,6 +48,9 @@ public: protected: bool _LoadPlugins( const std::string& filename ); + std::string _LoadImage( + TPluginImage::Pointer& image, const QStringList& names + ); private slots: void _triggered_actionOpenPlugins( ); @@ -71,8 +71,6 @@ private: std::string m_ImageWriterClass; std::string m_MeshReaderClass; std::string m_MeshWriterClass; - TStringContainer m_ImageToImageFilters; - TStringContainer m_ImageToMeshFilters; // Real data TPluginImage::Pointer m_InputImage; diff --git a/appli/bash/CMakeLists.txt b/appli/bash/CMakeLists.txt new file mode 100644 index 0000000..33785d1 --- /dev/null +++ b/appli/bash/CMakeLists.txt @@ -0,0 +1,15 @@ +## ========================= +## = Command line programs = +## ========================= + +SET( + BASH_PROGRAMS + cpPlugins_createHost + ) + +FOREACH(prog ${BASH_PROGRAMS}) + ADD_EXECUTABLE(${prog} ${prog}.cxx) + TARGET_LINK_LIBRARIES(${prog} ${Boost_LIBRARIES}) +ENDFOREACH(prog) + +## eof - $RCSfile$ diff --git a/appli/bash/cpPlugins_createHost.cxx b/appli/bash/cpPlugins_createHost.cxx new file mode 100644 index 0000000..0914cca --- /dev/null +++ b/appli/bash/cpPlugins_createHost.cxx @@ -0,0 +1,59 @@ +#include +#include +#include + +#include + +int main( int argc, char* argv[] ) +{ + // Open file + if( argc < 4 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " output_code namespace filter1 filter2 ..." + << std::endl; + return( 1 ); + + } // fi + std::ofstream output_code( argv[ 1 ] ); + if( !output_code ) + { + std::cerr + << "Could not open file \"" << argv[ 1 ] << "\" for writing" + << std::endl; + return( 1 ); + + } // fi + + output_code << "#include " << std::endl; + for( int i = 3; i < argc; ++i ) + output_code << "#include \"" << argv[ i ] << "\"" << std::endl; + output_code + << std::endl + << "PLUMA_CONNECTOR" << std::endl + << "bool connect( pluma::Host& host )" << std::endl + << "{" << std::endl + << " using namespace " << argv[ 2 ] << ";" << std::endl; + + for( int i = 3; i < argc; ++i ) + { + boost::filesystem::path p( argv[ i ] ); + output_code + << " host.add( new " + << p.stem( ).generic_string( ) + << "Provider( ) );" + << std::endl; + + } // rof + + output_code + << " return( true );" << std::endl + << "}" << std::endl; + + // Finish + output_code.close( ); + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index a4fb5d7..59af9a6 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -8,14 +8,14 @@ SET( example_TestParameters example_LoadPlugins example_ReadWriteImage - example_MarchingCubes - example_OtsuFilter - example_RGBImageToHSVChannels - example_RGBImageToYPbPrChannels + ##example_MarchingCubes + ##example_OtsuFilter + ##example_RGBImageToHSVChannels + ##example_RGBImageToYPbPrChannels ## example_ReadImageSeriesWriteImage ## example_ReadQuadEdgeMesh ## example_RenderQuadEdgeMesh - example_MPR + ##example_MPR ) diff --git a/appli/examples/example_LoadPlugins.cxx b/appli/examples/example_LoadPlugins.cxx index e46a5db..d090d38 100644 --- a/appli/examples/example_LoadPlugins.cxx +++ b/appli/examples/example_LoadPlugins.cxx @@ -7,30 +7,30 @@ int main( int argc, char* argv[] ) { if( argc < 2 ) { - std::cerr << "Usage: " << argv[ 0 ] << " plugins_file" << std::endl; + std::cerr << "Usage: " << argv[ 0 ] << " plugins_file(s)" << std::endl; return( 1 ); } // fi - std::string plugins_file = argv[ 1 ]; // Create interface typedef cpPlugins::Interface::Interface TInterface; typedef TInterface::TClasses TClasses; TInterface plugins; - if( !plugins.Load( plugins_file ) ) - { - std::cerr << "Error loading plugins file." << std::endl; - return( 1 ); + for( int i = 1; i < argc; ++i ) + if( !plugins.Load( argv[ i ] ) ) + std::cerr + << "Error loading plugins file \"" + << argv[ i ] << "\"" + << std::endl; - } // fi - std::cout << "---------------------------------------------" << std::endl; std::cout << "Loaded classes:" << std::endl; TClasses::const_iterator cIt = plugins.GetClasses( ).begin( ); for( ; cIt != plugins.GetClasses( ).end( ); ++cIt ) std::cout << " := " << cIt->first << std::endl; std::cout << "---------------------------------------------" << std::endl; + return( 0 ); } diff --git a/appli/examples/example_ReadWriteImage.cxx b/appli/examples/example_ReadWriteImage.cxx index 5f01b44..b051277 100644 --- a/appli/examples/example_ReadWriteImage.cxx +++ b/appli/examples/example_ReadWriteImage.cxx @@ -4,9 +4,16 @@ #include #include - #include +// ------------------------------------------------------------------------- +typedef cpPlugins::Interface::Interface TInterface; +typedef cpPlugins::Interface::ProcessObject TProcessObject; +typedef cpPlugins::Interface::DataObject TDataObject; +typedef cpPlugins::Interface::Parameters TParameters; +typedef TInterface::TClasses TClasses; + +// ------------------------------------------------------------------------- int main( int argc, char* argv[] ) { if( argc < 4 ) @@ -20,8 +27,6 @@ int main( int argc, char* argv[] ) } // fi // Create interface - typedef cpPlugins::Interface::Interface TInterface; - typedef TInterface::TClasses TClasses; TInterface plugins; if( !plugins.Load( argv[ 1 ] ) ) { @@ -31,21 +36,16 @@ int main( int argc, char* argv[] ) } // fi // Create objects - typedef cpPlugins::Interface::ProcessObject TProcessObject; - typedef cpPlugins::Interface::DataObject TDataObject; - typedef cpPlugins::Interface::Parameters TParameters; - cpPlugins::Interface::ProcessObject::Pointer reader, writer; - reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" ); - if( reader.IsNull( ) ) + TProcessObject::Pointer reader, writer; + reader = plugins.CreateProcessObject( "cpPlugins::IO::ImageReader" ); + writer = plugins.CreateProcessObject( "cpPlugins::IO::ImageWriter" ); + if( reader.IsNull( ) || writer.IsNull( ) ) { - std::cerr << "No suitable reader found in plugins." << std::endl; - return( 1 ); - - } // fi - writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" ); - if( writer.IsNull( ) ) - { - std::cerr << "No suitable writer found in plugins." << std::endl; + std::cerr + << "No suitable reader found in plugins." << std::endl + << "Reader: " << reader.GetPointer( ) << std::endl + << "Writer: " << writer.GetPointer( ) << std::endl + << std::endl; return( 1 ); } // fi diff --git a/lib/cpExtensions/Visualization/MPRObjects.cxx b/lib/cpExtensions/Visualization/MPRObjects.cxx index aaadf31..ddc1747 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.cxx +++ b/lib/cpExtensions/Visualization/MPRObjects.cxx @@ -68,6 +68,25 @@ SetImage( vtkImageData* image ) this->RenderAll( ); } +// ------------------------------------------------------------------------- +void cpExtensions::Visualization::MPRObjects:: +AddAuxiliaryImage( vtkImageData* image ) +{ + this->m_MPRActors->AddInputData( image ); + +#error Definir LUT de la nueva imagen + + this->m_MPRActors->PushDataInto( + this->m_Renderers[ 0 ], + this->m_Renderers[ 1 ], + this->m_Renderers[ 2 ], + this->m_Renderers[ 3 ] + ); + + // Rendering + this->RenderAll( ); +} + // ------------------------------------------------------------------------- void cpExtensions::Visualization::MPRObjects:: ActivateInteractors( ) diff --git a/lib/cpExtensions/Visualization/MPRObjects.h b/lib/cpExtensions/Visualization/MPRObjects.h index a348e91..1a81350 100644 --- a/lib/cpExtensions/Visualization/MPRObjects.h +++ b/lib/cpExtensions/Visualization/MPRObjects.h @@ -35,6 +35,7 @@ namespace cpExtensions vtkRenderWindow* wz, vtkRenderWindow* w3D ); void SetImage( vtkImageData* image ); + void AddAuxiliaryImage( vtkImageData* image ); void ActivateInteractors( ); void ResetCamera( const int& id ); diff --git a/lib/cpPlugins/Interface/CMakeLists.txt b/lib/cpPlugins/Interface/CMakeLists.txt index 6d73928..a3990cc 100644 --- a/lib/cpPlugins/Interface/CMakeLists.txt +++ b/lib/cpPlugins/Interface/CMakeLists.txt @@ -44,11 +44,12 @@ SET( SET( LIB_SOURCES_CXX + Instances_itkImage.cxx + Instances_itkVectorImage.cxx + Instances_itkMesh.cxx BaseProcessObjects.cxx DataObject.cxx Image.cxx - Instances_itkImage.cxx - Instances_itkMesh.cxx Interface.cxx Mesh.cxx Object.cxx diff --git a/lib/cpPlugins/Interface/Instances_itkImage.cxx b/lib/cpPlugins/Interface/Instances_itkImage.cxx index 8fadae0..b9229dd 100644 --- a/lib/cpPlugins/Interface/Instances_itkImage.cxx +++ b/lib/cpPlugins/Interface/Instances_itkImage.cxx @@ -14,170 +14,132 @@ #include // ------------------------------------------------------------------------- -#define cpPlugins_Image_Export( T, D ) \ - cpPlugins_TEMPLATE_EXPORT( \ - 2(class cpPlugins_Interface_EXPORT itk::Image< T, D >) \ +#define cpPlugins_ITKImage_Export( T, D ) \ + cpPlugins_TEMPLATE_EXPORT( \ + 2(class cpPlugins_Interface_EXPORT itk::Image< T, D >) \ ) // ------------------------------------------------------------------------- -#define cpPlugins_VTKImage_Export( T, D ) \ +#define cpPlugins_ITKArrayImage_Export( A, T, DA, DI ) \ cpPlugins_TEMPLATE_EXPORT( \ - 2( \ - class cpPlugins_Interface_EXPORT \ - itk::ImageToVTKImageFilter< itk::Image< T, D > > \ - ) \ + 3(class cpPlugins_Interface_EXPORT itk::Image< A< T, DA >, DI >) \ ) // ------------------------------------------------------------------------- -#define cpPlugins_ImageArray_Export( A, T, DA, DI ) \ - cpPlugins_TEMPLATE_EXPORT( \ - 3( \ - class cpPlugins_Interface_EXPORT \ - itk::Image< itk::A< T, DA >, DI > \ - ) \ - ) +#define cpPlugins_ITKImage_AllDims_Export( T ) \ + cpPlugins_ITKImage_Export( T, 2 ); \ + cpPlugins_ITKImage_Export( T, 3 ); \ + cpPlugins_ITKImage_Export( T, 4 ) // ------------------------------------------------------------------------- -#define cpPlugins_VTKImageArray_Export( A, T, DA, DI ) \ - cpPlugins_TEMPLATE_EXPORT( \ - 3( \ - class cpPlugins_Interface_EXPORT \ - itk::ImageToVTKImageFilter< itk::Image< itk::A< T, DA >, DI > > \ - ) \ +#define cpPlugins_ITKArrayImage_AllDims_Export( A, T ) \ + cpPlugins_ITKArrayImage_Export( A, T, 2, 2 ); \ + cpPlugins_ITKArrayImage_Export( A, T, 3, 3 ); \ + cpPlugins_ITKArrayImage_Export( A, T, 4, 4 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_VTKImage_Export( T, D ) \ + cpPlugins_TEMPLATE_EXPORT( \ + 2( \ + class cpPlugins_Interface_EXPORT \ + itk::ImageToVTKImageFilter< itk::Image< T, D > > \ + ) \ ) // ------------------------------------------------------------------------- -#define cpPlugins_Image_Export_AllDimensions( T ) \ - cpPlugins_Image_Export( T, 2 ); \ - cpPlugins_Image_Export( T, 3 ); \ - cpPlugins_Image_Export( T, 4 ) +#define cpPlugins_VTKArrayImage_Export( A, T, DA, DI ) \ + cpPlugins_TEMPLATE_EXPORT( \ + 3(class \ + cpPlugins_Interface_EXPORT \ + itk::ImageToVTKImageFilter< itk::Image< A< T, DA >, DI > >) \ + ) // ------------------------------------------------------------------------- -#define cpPlugins_VTKImage_Export_AllDimensions( T ) \ - cpPlugins_VTKImage_Export( T, 2 ); \ +#define cpPlugins_VTKImage_AllDims_Export( T ) \ + cpPlugins_VTKImage_Export( T, 2 ); \ cpPlugins_VTKImage_Export( T, 3 ) // ------------------------------------------------------------------------- -#define cpPlugins_ImageArray_Export_AllDimensions( A, T ) \ - cpPlugins_ImageArray_Export( A, T, 2, 2 ); \ - cpPlugins_ImageArray_Export( A, T, 3, 3 ); \ - cpPlugins_ImageArray_Export( A, T, 4, 4 ) +#define cpPlugins_VTKArrayImage_AllDims_Export( A, T ) \ + cpPlugins_VTKArrayImage_Export( A, T, 2, 2 ); \ + cpPlugins_VTKArrayImage_Export( A, T, 3, 3 ) // ------------------------------------------------------------------------- -#define cpPlugins_VTKImageArray_Export_AllDimensions( A, T ) \ - cpPlugins_VTKImageArray_Export( A, T, 2, 2 ); \ - cpPlugins_VTKImageArray_Export( A, T, 3, 3 ) - +#define cpPlugins_Image_Export( T, D ) \ + cpPlugins_ITKImage_Export( T, D ); \ + cpPlugins_VTKImage_Export( T, D ) \ + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_AllDims_Export( T ) \ + cpPlugins_ITKImage_AllDims_Export( T ); \ + cpPlugins_VTKImage_AllDims_Export( T ) \ + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_AllDims_Export( A, T ) \ + cpPlugins_ITKArrayImage_AllDims_Export( A, T ); \ + cpPlugins_VTKArrayImage_AllDims_Export( A, T ) \ + +// ------------------------------------------------------------------------- +// ITK-VTK base clases // ------------------------------------------------------------------------- -// ITK base clases -cpPlugins_Image_Export_AllDimensions( char ); -cpPlugins_Image_Export_AllDimensions( short ); -cpPlugins_Image_Export_AllDimensions( int ); -cpPlugins_Image_Export_AllDimensions( long ); -cpPlugins_Image_Export_AllDimensions( unsigned char ); -cpPlugins_Image_Export_AllDimensions( unsigned short ); -cpPlugins_Image_Export_AllDimensions( unsigned int ); -cpPlugins_Image_Export_AllDimensions( unsigned long ); -cpPlugins_Image_Export_AllDimensions( float ); -cpPlugins_Image_Export_AllDimensions( double ); - -cpPlugins_Image_Export_AllDimensions( std::complex< float > ); -cpPlugins_Image_Export_AllDimensions( std::complex< double > ); - -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< char > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< short > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< int > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< long > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned char > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned short > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned int > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< unsigned long > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< float > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBPixel< double > ); - -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< char > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< short > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< int > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< long > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned char > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned short > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned int > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< unsigned long > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< float > ); -cpPlugins_Image_Export_AllDimensions( itk::RGBAPixel< double > ); - -cpPlugins_ImageArray_Export_AllDimensions( Vector, float ); -cpPlugins_ImageArray_Export_AllDimensions( Vector, double ); - -cpPlugins_ImageArray_Export_AllDimensions( CovariantVector, float ); -cpPlugins_ImageArray_Export_AllDimensions( CovariantVector, double ); - -cpPlugins_ImageArray_Export_AllDimensions( Point, float ); -cpPlugins_ImageArray_Export_AllDimensions( Point, double ); - -cpPlugins_ImageArray_Export_AllDimensions( - SymmetricSecondRankTensor, float - ); -cpPlugins_ImageArray_Export_AllDimensions( - SymmetricSecondRankTensor, double - ); - -cpPlugins_Image_Export( itk::DiffusionTensor3D< float >, 3 ); -cpPlugins_Image_Export( itk::DiffusionTensor3D< double >, 3 ); -cpPlugins_Image_Export( itk::DiffusionTensor3D< float >, 4 ); -cpPlugins_Image_Export( itk::DiffusionTensor3D< double >, 4 ); -cpPlugins_Image_Export( itk::Offset< 2 >, 2 ); -cpPlugins_Image_Export( itk::Offset< 3 >, 3 ); -cpPlugins_Image_Export( itk::Offset< 4 >, 4 ); +cpPlugins_Image_AllDims_Export( char ); +cpPlugins_Image_AllDims_Export( short ); +cpPlugins_Image_AllDims_Export( int ); +cpPlugins_Image_AllDims_Export( long ); +cpPlugins_Image_AllDims_Export( unsigned char ); +cpPlugins_Image_AllDims_Export( unsigned short ); +cpPlugins_Image_AllDims_Export( unsigned int ); +cpPlugins_Image_AllDims_Export( unsigned long ); +cpPlugins_Image_AllDims_Export( float ); +cpPlugins_Image_AllDims_Export( double ); + +cpPlugins_Image_AllDims_Export( itk::RGBPixel< char > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< short > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< int > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< long > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned char > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned short > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned int > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned long > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< float > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< double > ); + +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< char > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< short > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< int > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< long > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned char > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned short > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned int > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned long > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< float > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< double > ); + +cpPlugins_Image_AllDims_Export( itk::DiffusionTensor3D< float > ); +cpPlugins_Image_AllDims_Export( itk::DiffusionTensor3D< double > ); + +cpPlugins_ArrayImage_AllDims_Export( itk::Vector, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::Vector, double ); + +cpPlugins_ArrayImage_AllDims_Export( itk::CovariantVector, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::CovariantVector, double ); + +cpPlugins_ArrayImage_AllDims_Export( itk::Point, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::Point, double ); + +cpPlugins_ArrayImage_AllDims_Export( itk::SymmetricSecondRankTensor, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::SymmetricSecondRankTensor, double ); + +// ------------------------------------------------------------------------- +// ITK-only base clases // ------------------------------------------------------------------------- -// ITK<->VTK base clases -cpPlugins_VTKImage_Export_AllDimensions( char ); -cpPlugins_VTKImage_Export_AllDimensions( short ); -cpPlugins_VTKImage_Export_AllDimensions( int ); -cpPlugins_VTKImage_Export_AllDimensions( long ); -cpPlugins_VTKImage_Export_AllDimensions( unsigned char ); -cpPlugins_VTKImage_Export_AllDimensions( unsigned short ); -cpPlugins_VTKImage_Export_AllDimensions( unsigned int ); -cpPlugins_VTKImage_Export_AllDimensions( unsigned long ); -cpPlugins_VTKImage_Export_AllDimensions( float ); -cpPlugins_VTKImage_Export_AllDimensions( double ); - -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< char > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< short > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< int > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< long > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< unsigned char > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< unsigned short > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< unsigned int > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBPixel< unsigned long > ); - -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< char > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< short > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< int > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< long > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< unsigned char > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< unsigned short > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< unsigned int > ); -cpPlugins_VTKImage_Export_AllDimensions( itk::RGBAPixel< unsigned long > ); - -cpPlugins_VTKImageArray_Export_AllDimensions( Vector, float ); -cpPlugins_VTKImageArray_Export_AllDimensions( Vector, double ); - -cpPlugins_VTKImageArray_Export_AllDimensions( CovariantVector, float ); -cpPlugins_VTKImageArray_Export_AllDimensions( CovariantVector, double ); - -cpPlugins_VTKImageArray_Export_AllDimensions( Point, float ); -cpPlugins_VTKImageArray_Export_AllDimensions( Point, double ); - -cpPlugins_VTKImageArray_Export_AllDimensions( - SymmetricSecondRankTensor, float - ); -cpPlugins_VTKImageArray_Export_AllDimensions( - SymmetricSecondRankTensor, double - ); - -cpPlugins_VTKImage_Export( itk::DiffusionTensor3D< float >, 3 ); -cpPlugins_VTKImage_Export( itk::DiffusionTensor3D< double >, 3 ); + +cpPlugins_ITKImage_AllDims_Export( std::complex< float > ); +cpPlugins_ITKImage_AllDims_Export( std::complex< double > ); + +cpPlugins_ITKImage_Export( itk::Offset< 2 >, 2 ); +cpPlugins_ITKImage_Export( itk::Offset< 3 >, 3 ); +cpPlugins_ITKImage_Export( itk::Offset< 4 >, 4 ); // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Instances_itkVectorImage.cxx b/lib/cpPlugins/Interface/Instances_itkVectorImage.cxx new file mode 100644 index 0000000..3db15c6 --- /dev/null +++ b/lib/cpPlugins/Interface/Instances_itkVectorImage.cxx @@ -0,0 +1,100 @@ +#include + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_Export( T, D ) \ + cpPlugins_TEMPLATE_EXPORT( \ + 2(class cpPlugins_Interface_EXPORT itk::VectorImage< T, D >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_Export( A, T, DA, DI ) \ + cpPlugins_TEMPLATE_EXPORT( \ + 3(class \ + cpPlugins_Interface_EXPORT \ + itk::VectorImage< A< T, DA >, DI >) \ + ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_AllDims_Export( T ) \ + cpPlugins_Image_Export( T, 2 ); \ + cpPlugins_Image_Export( T, 3 ); \ + cpPlugins_Image_Export( T, 4 ) + +// ------------------------------------------------------------------------- +#define cpPlugins_ArrayImage_AllDims_Export( A, T ) \ + cpPlugins_ArrayImage_Export( A, T, 2, 2 ); \ + cpPlugins_ArrayImage_Export( A, T, 3, 3 ); \ + cpPlugins_ArrayImage_Export( A, T, 4, 4 ) + +// ------------------------------------------------------------------------- +// ITK-VTK base clases +// ------------------------------------------------------------------------- + +cpPlugins_Image_AllDims_Export( char ); +cpPlugins_Image_AllDims_Export( short ); +cpPlugins_Image_AllDims_Export( int ); +cpPlugins_Image_AllDims_Export( long ); +cpPlugins_Image_AllDims_Export( unsigned char ); +cpPlugins_Image_AllDims_Export( unsigned short ); +cpPlugins_Image_AllDims_Export( unsigned int ); +cpPlugins_Image_AllDims_Export( unsigned long ); +cpPlugins_Image_AllDims_Export( float ); +cpPlugins_Image_AllDims_Export( double ); + +cpPlugins_Image_AllDims_Export( std::complex< float > ); +cpPlugins_Image_AllDims_Export( std::complex< double > ); + +cpPlugins_Image_Export( itk::Offset< 2 >, 2 ); +cpPlugins_Image_Export( itk::Offset< 3 >, 3 ); +cpPlugins_Image_Export( itk::Offset< 4 >, 4 ); + +cpPlugins_Image_AllDims_Export( itk::RGBPixel< char > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< short > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< int > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< long > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned char > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned short > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned int > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< unsigned long > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< float > ); +cpPlugins_Image_AllDims_Export( itk::RGBPixel< double > ); + +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< char > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< short > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< int > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< long > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned char > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned short > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned int > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< unsigned long > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< float > ); +cpPlugins_Image_AllDims_Export( itk::RGBAPixel< double > ); + +cpPlugins_Image_AllDims_Export( itk::DiffusionTensor3D< float > ); +cpPlugins_Image_AllDims_Export( itk::DiffusionTensor3D< double > ); + +cpPlugins_ArrayImage_AllDims_Export( itk::Vector, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::Vector, double ); + +cpPlugins_ArrayImage_AllDims_Export( itk::CovariantVector, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::CovariantVector, double ); + +cpPlugins_ArrayImage_AllDims_Export( itk::Point, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::Point, double ); + +cpPlugins_ArrayImage_AllDims_Export( itk::SymmetricSecondRankTensor, float ); +cpPlugins_ArrayImage_AllDims_Export( itk::SymmetricSecondRankTensor, double ); + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Macros.h b/lib/cpPlugins/Interface/Macros.h index 0a6bd60..c85cd0c 100644 --- a/lib/cpPlugins/Interface/Macros.h +++ b/lib/cpPlugins/Interface/Macros.h @@ -32,13 +32,6 @@ #define cpPlugins_TEMPLATE_IMPORT( X ) \ extern template cpPlugins_TEMPLATE_##X; -/* TODO - #define cpPlugins_EXPORT_TEMPLATE( E, c, T ) \ - cpPlugins_TEMPLATE_##c( cpPlugins_TEMPLATE_EXPORT, E, T ) - #define cpPlugins_IMPORT_TEMPLATE( E, c, T ) \ - cpPlugins_TEMPLATE_##c( cpPlugins_TEMPLATE_IMPORT, E, T ) -*/ - #endif // __CPPLUGINS__INTERFACE__MACROS__H__ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/BinaryThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx similarity index 90% rename from lib/cpPlugins/Plugins/BinaryThresholdImageFilter.cxx rename to lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx index 65195e2..d3d541e 100644 --- a/lib/cpPlugins/Plugins/BinaryThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.cxx @@ -1,14 +1,14 @@ -#include +#include "BinaryThresholdImageFilter.h" #include #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::BinaryThresholdImageFilter:: +cpPlugins::BasicFilters::BinaryThresholdImageFilter:: BinaryThresholdImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::BinaryThresholdImageFilter"; + this->m_ClassName = "cpPlugins::BasicFilters::BinaryThresholdImageFilter"; this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); @@ -38,13 +38,13 @@ BinaryThresholdImageFilter( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::BinaryThresholdImageFilter:: +cpPlugins::BasicFilters::BinaryThresholdImageFilter:: ~BinaryThresholdImageFilter( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::BinaryThresholdImageFilter:: +std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = @@ -69,7 +69,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > -std::string cpPlugins::Plugins::BinaryThresholdImageFilter:: +std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _DemangleOutput( itk::DataObject* image ) { return( @@ -81,7 +81,7 @@ _DemangleOutput( itk::DataObject* image ) // ------------------------------------------------------------------------- template< class I, class O > -inline std::string cpPlugins::Plugins::BinaryThresholdImageFilter:: +inline std::string cpPlugins::BasicFilters::BinaryThresholdImageFilter:: _RealGD( itk::DataObject* image ) { typedef itk::BinaryThresholdImageFilter< I, O > _F; diff --git a/lib/cpPlugins/Plugins/BinaryThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h similarity index 90% rename from lib/cpPlugins/Plugins/BinaryThresholdImageFilter.h rename to lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h index d108fb2..b410151 100644 --- a/lib/cpPlugins/Plugins/BinaryThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/BinaryThresholdImageFilter.h @@ -1,16 +1,16 @@ #ifndef __CPPLUGINS__PLUGINS__BINARYTHRESHOLDIMAGEFILTER__H__ #define __CPPLUGINS__PLUGINS__BINARYTHRESHOLDIMAGEFILTER__H__ -#include +#include #include namespace cpPlugins { - namespace Plugins + namespace BasicFilters { /** */ - class cpPlugins_EXPORT BinaryThresholdImageFilter + class cpPluginsBasicFilters_EXPORT BinaryThresholdImageFilter : public cpPlugins::Interface::ImageToImageFilter { public: diff --git a/lib/cpPlugins/Plugins/BasicFilters/CMakeLists.txt b/lib/cpPlugins/Plugins/BasicFilters/CMakeLists.txt new file mode 100644 index 0000000..820b54d --- /dev/null +++ b/lib/cpPlugins/Plugins/BasicFilters/CMakeLists.txt @@ -0,0 +1,56 @@ +SET(LIBRARY_NAME cpPluginsBasicFilters) + +## =============== +## = Source code = +## =============== + +FILE(GLOB LIB_HEADERS_H "*.h") +FILE(GLOB LIB_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_SOURCES_C "*.c") +FILE(GLOB LIB_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_SOURCES_CXX "*.cxx") + +## ===================== +## = Compilation rules = +## ===================== + +ADD_CUSTOM_COMMAND( + OUTPUT ${LIBRARY_NAME}_Host.cxx + DEPENDS ${PROJECT_BINARY_DIR}/cpPlugins_createHost ${LIB_HEADERS_H} ${LIB_HEADERS_HPP} ${LIB_HEADERS_HXX} + COMMAND ${PROJECT_BINARY_DIR}/cpPlugins_createHost ${LIBRARY_NAME}_Host.cxx cpPlugins::BasicFilters ${LIB_HEADERS_H} + ) + +ADD_LIBRARY( + ${LIBRARY_NAME} + SHARED + ${LIBRARY_NAME}_Host.cxx + ${LIB_SOURCES_C} + ${LIB_SOURCES_CPP} + ${LIB_SOURCES_CXX} + ) +GENERATE_EXPORT_HEADER( + ${LIBRARY_NAME} + BASE_NAME ${LIBRARY_NAME} + EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/BasicFilters/${LIBRARY_NAME}_Export.h + STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC + ) +TARGET_LINK_LIBRARIES( + ${LIBRARY_NAME} + cpPlugins_Interface + cpExtensions + ) + +## ======================== +## -- Installation rules -- +## ======================== + +INSTALL( + TARGETS ${LIBRARY_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + ) + +## eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/MarchingCubes.cxx b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx similarity index 90% rename from lib/cpPlugins/Plugins/MarchingCubes.cxx rename to lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx index 94af090..38f7dbc 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.cxx @@ -1,4 +1,4 @@ -#include +#include "MarchingCubes.h" #include #include @@ -7,12 +7,12 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::MarchingCubes:: +cpPlugins::BasicFilters::MarchingCubes:: MarchingCubes( ) : Superclass( ), m_Algorithm( NULL ) { - this->m_ClassName = "cpPlugins::MarchingCubes"; + this->m_ClassName = "cpPlugins::BasicFilters::MarchingCubes"; this->m_ClassCategory = "ImageToMeshFilter"; this->SetNumberOfInputs( 1 ); @@ -25,7 +25,7 @@ MarchingCubes( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::MarchingCubes:: +cpPlugins::BasicFilters::MarchingCubes:: ~MarchingCubes( ) { if( this->m_Algorithm != NULL ) @@ -33,7 +33,7 @@ cpPlugins::Plugins::MarchingCubes:: } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MarchingCubes:: +std::string cpPlugins::BasicFilters::MarchingCubes:: _GenerateData( ) { // Get input diff --git a/lib/cpPlugins/Plugins/MarchingCubes.h b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h similarity index 89% rename from lib/cpPlugins/Plugins/MarchingCubes.h rename to lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h index b675bba..a5790e9 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MarchingCubes.h @@ -1,18 +1,18 @@ #ifndef __CPPLUGINS__PLUGINS__MARCHINGCUBES__H__ #define __CPPLUGINS__PLUGINS__MARCHINGCUBES__H__ -#include +#include #include class vtkPolyDataAlgorithm; namespace cpPlugins { - namespace Plugins + namespace BasicFilters { /** */ - class cpPlugins_EXPORT MarchingCubes + class cpPluginsBasicFilters_EXPORT MarchingCubes : public cpPlugins::Interface::ImageToMeshFilter { public: diff --git a/lib/cpPlugins/Plugins/MedianImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx similarity index 87% rename from lib/cpPlugins/Plugins/MedianImageFilter.cxx rename to lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx index e207967..53a9d28 100644 --- a/lib/cpPlugins/Plugins/MedianImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.cxx @@ -1,14 +1,14 @@ -#include +#include "MedianImageFilter.h" #include #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::MedianImageFilter:: +cpPlugins::BasicFilters::MedianImageFilter:: MedianImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::MedianImageFilter"; + this->m_ClassName = "cpPlugins::BasicFilters::MedianImageFilter"; this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); @@ -23,13 +23,13 @@ MedianImageFilter( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::MedianImageFilter:: +cpPlugins::BasicFilters::MedianImageFilter:: ~MedianImageFilter( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MedianImageFilter:: +std::string cpPlugins::BasicFilters::MedianImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = @@ -54,7 +54,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > -std::string cpPlugins::Plugins::MedianImageFilter:: +std::string cpPlugins::BasicFilters::MedianImageFilter:: _DemangleOutput( itk::DataObject* image ) { return( @@ -66,7 +66,7 @@ _DemangleOutput( itk::DataObject* image ) // ------------------------------------------------------------------------- template< class I, class O > -inline std::string cpPlugins::Plugins::MedianImageFilter:: +inline std::string cpPlugins::BasicFilters::MedianImageFilter:: _RealGD( itk::DataObject* image ) { typedef itk::MedianImageFilter< I, O > _F; diff --git a/lib/cpPlugins/Plugins/MedianImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h similarity index 90% rename from lib/cpPlugins/Plugins/MedianImageFilter.h rename to lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h index 3ee8db4..a4d4679 100644 --- a/lib/cpPlugins/Plugins/MedianImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/MedianImageFilter.h @@ -1,16 +1,16 @@ #ifndef __CPPLUGINS__PLUGINS__MEDIANIMAGEFILTER__H__ #define __CPPLUGINS__PLUGINS__MEDIANIMAGEFILTER__H__ -#include +#include #include namespace cpPlugins { - namespace Plugins + namespace BasicFilters { /** */ - class cpPlugins_EXPORT MedianImageFilter + class cpPluginsBasicFilters_EXPORT MedianImageFilter : public cpPlugins::Interface::ImageToImageFilter { public: diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx similarity index 88% rename from lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx rename to lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx index dc6fd94..6e0d36f 100644 --- a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.cxx @@ -1,14 +1,14 @@ -#include +#include "OtsuThresholdImageFilter.h" #include #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::OtsuThresholdImageFilter:: +cpPlugins::BasicFilters::OtsuThresholdImageFilter:: OtsuThresholdImageFilter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::OtsuThresholdImageFilter"; + this->m_ClassName = "cpPlugins::BasicFilters::OtsuThresholdImageFilter"; this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); @@ -27,13 +27,13 @@ OtsuThresholdImageFilter( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::OtsuThresholdImageFilter:: +cpPlugins::BasicFilters::OtsuThresholdImageFilter:: ~OtsuThresholdImageFilter( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: +std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = @@ -58,7 +58,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > -std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: +std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _DemangleOutput( itk::DataObject* image ) { return( @@ -70,7 +70,7 @@ _DemangleOutput( itk::DataObject* image ) // ------------------------------------------------------------------------- template< class I, class O > -inline std::string cpPlugins::Plugins::OtsuThresholdImageFilter:: +inline std::string cpPlugins::BasicFilters::OtsuThresholdImageFilter:: _RealGD( itk::DataObject* image ) { typedef itk::OtsuThresholdImageFilter< I, O > _F; diff --git a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h similarity index 90% rename from lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h rename to lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h index 3d35287..6a112d0 100644 --- a/lib/cpPlugins/Plugins/OtsuThresholdImageFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/OtsuThresholdImageFilter.h @@ -1,16 +1,16 @@ #ifndef __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__ #define __CPPLUGINS__PLUGINS__OTSUTHRESHOLDIMAGEFILTER__H__ -#include +#include #include namespace cpPlugins { - namespace Plugins + namespace BasicFilters { /** */ - class cpPlugins_EXPORT OtsuThresholdImageFilter + class cpPluginsBasicFilters_EXPORT OtsuThresholdImageFilter : public cpPlugins::Interface::ImageToImageFilter { public: diff --git a/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.cxx b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx similarity index 91% rename from lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.cxx rename to lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx index 6cc0d1c..7f5b1fc 100644 --- a/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.cxx +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.cxx @@ -1,4 +1,4 @@ -#include +#include "RGBImageToOtherChannelsFilter.h" #include #include @@ -7,13 +7,13 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: RGBImageToOtherChannelsFilter( ) : Superclass( ) { typedef cpPlugins::Interface::Parameters TParameters; - this->m_ClassName = "cpPlugins::RGBImageToOtherChannelsFilter"; + this->m_ClassName = "cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter"; this->m_ClassCategory = "ImageToImageFilter"; this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); @@ -24,7 +24,7 @@ RGBImageToOtherChannelsFilter( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: ~RGBImageToOtherChannelsFilter( ) { } @@ -49,7 +49,7 @@ cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: ) // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: _GenerateData( ) { cpPlugins::Interface::Image* image = @@ -74,7 +74,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > -std::string cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: _DemangleOutput( itk::DataObject* image ) { typedef typename I::PixelType _P; @@ -98,7 +98,7 @@ _DemangleOutput( itk::DataObject* image ) // ------------------------------------------------------------------------- template< class I, class C > -std::string cpPlugins::Plugins::RGBImageToOtherChannelsFilter:: +std::string cpPlugins::BasicFilters::RGBImageToOtherChannelsFilter:: _RealGD( itk::DataObject* image ) { typedef itk::Image< itk::RGBPixel< double >, I::ImageDimension > _O; diff --git a/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h similarity index 90% rename from lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h rename to lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h index 0ccb16c..6d215f1 100644 --- a/lib/cpPlugins/Plugins/RGBImageToOtherChannelsFilter.h +++ b/lib/cpPlugins/Plugins/BasicFilters/RGBImageToOtherChannelsFilter.h @@ -1,16 +1,16 @@ #ifndef __CPPLUGINS__PLUGINS__RGBIMAGETOOTHERCHANNELSFILTER__H__ #define __CPPLUGINS__PLUGINS__RGBIMAGETOOTHERCHANNELSFILTER__H__ -#include +#include #include namespace cpPlugins { - namespace Plugins + namespace BasicFilters { /** */ - class cpPlugins_EXPORT RGBImageToOtherChannelsFilter + class cpPluginsBasicFilters_EXPORT RGBImageToOtherChannelsFilter : public cpPlugins::Interface::ImageToImageFilter { public: diff --git a/lib/cpPlugins/Plugins/CMakeLists.txt b/lib/cpPlugins/Plugins/CMakeLists.txt index d908e42..477f500 100644 --- a/lib/cpPlugins/Plugins/CMakeLists.txt +++ b/lib/cpPlugins/Plugins/CMakeLists.txt @@ -1,49 +1,61 @@ -SET(LIBRARY_NAME cpPlugins) - -## =============== -## = Source code = -## =============== - -FILE(GLOB LIB_HEADERS_H "*.h") -FILE(GLOB LIB_HEADERS_HPP "*.hpp") -FILE(GLOB LIB_HEADERS_HXX "*.hxx") -FILE(GLOB LIB_SOURCES_C "*.c") -FILE(GLOB LIB_SOURCES_CPP "*.cpp") -FILE(GLOB LIB_SOURCES_CXX "*.cxx") - -## ===================== -## = Compilation rules = -## ===================== - -ADD_LIBRARY( - ${LIBRARY_NAME} - SHARED - ${LIB_SOURCES_C} - ${LIB_SOURCES_CPP} - ${LIB_SOURCES_CXX} - ) -GENERATE_EXPORT_HEADER( - ${LIBRARY_NAME} - BASE_NAME ${LIBRARY_NAME} - EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT - EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/Plugins/${LIBRARY_NAME}_Export.h - STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC - ) -TARGET_LINK_LIBRARIES( - ${LIBRARY_NAME} - cpExtensions - cpPlugins_Interface +SUBDIRS( + IO + BasicFilters ) -## ======================== -## -- Installation rules -- -## ======================== +# SET(LIBRARY_NAME cpPlugins) -INSTALL( - TARGETS ${LIBRARY_NAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib/static - ) +# ## =============== +# ## = Source code = +# ## =============== + +# FILE(GLOB LIB_HEADERS_H "*.h") +# FILE(GLOB LIB_HEADERS_HPP "*.hpp") +# FILE(GLOB LIB_HEADERS_HXX "*.hxx") +# FILE(GLOB LIB_SOURCES_C "*.c") +# FILE(GLOB LIB_SOURCES_CPP "*.cpp") +# FILE(GLOB LIB_SOURCES_CXX "*.cxx") + +# ## ===================== +# ## = Compilation rules = +# ## ===================== + +# ADD_CUSTOM_COMMAND( +# OUTPUT ${LIBRARY_NAME}_Host.cxx +# DEPENDS ${PROJECT_BINARY_DIR}/cpPlugins_createHost ${LIB_HEADERS_H} ${LIB_HEADERS_HPP} ${LIB_HEADERS_HXX} +# COMMAND ${PROJECT_BINARY_DIR}/cpPlugins_createHost ${LIBRARY_NAME}_Host.cxx cpPlugins::Plugins ${LIB_HEADERS_H} +# ) + +# ADD_LIBRARY( +# ${LIBRARY_NAME} +# SHARED +# ${LIBRARY_NAME}_Host.cxx +# ${LIB_SOURCES_C} +# ${LIB_SOURCES_CPP} +# ${LIB_SOURCES_CXX} +# ) +# GENERATE_EXPORT_HEADER( +# ${LIBRARY_NAME} +# BASE_NAME ${LIBRARY_NAME} +# EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT +# EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/Plugins/${LIBRARY_NAME}_Export.h +# STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC +# ) +# TARGET_LINK_LIBRARIES( +# ${LIBRARY_NAME} +# cpExtensions +# cpPlugins_Interface +# ) + +# ## ======================== +# ## -- Installation rules -- +# ## ======================== + +# INSTALL( +# TARGETS ${LIBRARY_NAME} +# RUNTIME DESTINATION bin +# LIBRARY DESTINATION lib +# ARCHIVE DESTINATION lib/static +# ) -## eof - $RCSfile$ +# ## eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/Host.cxx b/lib/cpPlugins/Plugins/Host.cxx deleted file mode 100644 index e16e01e..0000000 --- a/lib/cpPlugins/Plugins/Host.cxx +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/// TODO: doc -PLUMA_CONNECTOR -bool connect( pluma::Host& host ) -{ - using namespace cpPlugins::Plugins; - - host.add( new ImageReaderProvider( ) ); - host.add( new ImageWriterProvider( ) ); - host.add( new MeshReaderProvider( ) ); - host.add( new MeshWriterProvider( ) ); - host.add( new MarchingCubesProvider( ) ); - host.add( new OtsuThresholdImageFilterProvider( ) ); - host.add( new RGBImageToOtherChannelsFilterProvider( ) ); - host.add( new SecondRankDiffusionTensorToPolyDataProvider( ) ); - host.add( new BinaryThresholdImageFilterProvider( ) ); - host.add( new MedianImageFilterProvider( ) ); - - return( true ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/IO/CMakeLists.txt b/lib/cpPlugins/Plugins/IO/CMakeLists.txt new file mode 100644 index 0000000..f1a7a46 --- /dev/null +++ b/lib/cpPlugins/Plugins/IO/CMakeLists.txt @@ -0,0 +1,55 @@ +SET(LIBRARY_NAME cpPluginsIO) + +## =============== +## = Source code = +## =============== + +FILE(GLOB LIB_HEADERS_H "*.h") +FILE(GLOB LIB_HEADERS_HPP "*.hpp") +FILE(GLOB LIB_HEADERS_HXX "*.hxx") +FILE(GLOB LIB_SOURCES_C "*.c") +FILE(GLOB LIB_SOURCES_CPP "*.cpp") +FILE(GLOB LIB_SOURCES_CXX "*.cxx") + +## ===================== +## = Compilation rules = +## ===================== + +ADD_CUSTOM_COMMAND( + OUTPUT ${LIBRARY_NAME}_Host.cxx + DEPENDS ${PROJECT_BINARY_DIR}/cpPlugins_createHost ${LIB_HEADERS_H} ${LIB_HEADERS_HPP} ${LIB_HEADERS_HXX} + COMMAND ${PROJECT_BINARY_DIR}/cpPlugins_createHost ${LIBRARY_NAME}_Host.cxx cpPlugins::IO ${LIB_HEADERS_H} + ) + +ADD_LIBRARY( + ${LIBRARY_NAME} + SHARED + ${LIBRARY_NAME}_Host.cxx + ${LIB_SOURCES_C} + ${LIB_SOURCES_CPP} + ${LIB_SOURCES_CXX} + ) +GENERATE_EXPORT_HEADER( + ${LIBRARY_NAME} + BASE_NAME ${LIBRARY_NAME} + EXPORT_MACRO_NAME ${LIBRARY_NAME}_EXPORT + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/lib/cpPlugins/IO/${LIBRARY_NAME}_Export.h + STATIC_DEFINE ${LIBRARY_NAME}_BUILT_AS_STATIC + ) +TARGET_LINK_LIBRARIES( + ${LIBRARY_NAME} + cpPlugins_Interface + ) + +## ======================== +## -- Installation rules -- +## ======================== + +INSTALL( + TARGETS ${LIBRARY_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib/static + ) + +## eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/IO/ImageReader.cxx b/lib/cpPlugins/Plugins/IO/ImageReader.cxx new file mode 100644 index 0000000..38739df --- /dev/null +++ b/lib/cpPlugins/Plugins/IO/ImageReader.cxx @@ -0,0 +1,396 @@ +#include "ImageReader.h" +#include + +#include + +#include +#include + +// ------------------------------------------------------------------------- +cpPlugins::IO::ImageReader:: +ImageReader( ) + : Superclass( ) +{ + this->m_ClassName = "cpPlugins::IO::ImageReader"; + this->m_ClassCategory = "ImageReader"; + + this->SetNumberOfOutputs( 1 ); + this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); + + using namespace cpPlugins::Interface; + this->m_DefaultParameters.Configure( Parameters::StringList, "FileNames" ); + this->m_DefaultParameters.Configure( Parameters::Bool, "VectorType" ); + this->m_DefaultParameters.SetValueAsBool( "VectorType", false ); + this->m_Parameters = this->m_DefaultParameters; +} + +// ------------------------------------------------------------------------- +cpPlugins::IO::ImageReader:: +~ImageReader( ) +{ +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::IO::ImageReader:: +_GenerateData( ) +{ + // Get filenames + TStringList names; + this->m_Parameters.GetValueAsStringList( names, "FileNames" ); + + std::string r = ""; + if( names.size( ) >= 1 ) + { + // Guess image properties + itk::ImageIOBase::Pointer io = + itk::ImageIOFactory::CreateImageIO( + names[ 0 ].c_str( ), + itk::ImageIOFactory::ReadMode + ); + if( io.IsNotNull( ) ) + { + io->SetFileName( names[ 0 ] ); + io->ReadImageInformation( ); + if( names.size( ) >= 1 ) + { + switch( io->GetNumberOfDimensions( ) ) + { + case 2: r = this->_GD0< 2 >( io, names ); break; + case 3: r = this->_GD0< 3 >( io, names ); break; + case 4: r = this->_GD0< 4 >( io, names ); break; + default: + r = "ImageReader: Image dimension not supported."; + break; + } // hctiws + + } // fi + } + else + r = "ImageReader: Could not CreateImageIO for \"" + names[ 0 ] + "\""; + } + else + r = "No image files given"; + return( r ); +} + +// ------------------------------------------------------------------------- +template< unsigned int D > +std::string cpPlugins::IO::ImageReader:: +_GD0( itk::ImageIOBase* io, const TStringList& names ) +{ + itk::ImageIOBase::IOComponentType ct = io->GetComponentType( ); + itk::ImageIOBase::IOPixelType pt = io->GetPixelType( ); + std::string r = ""; + + if( pt == itk::ImageIOBase::SCALAR ) + { + switch( ct ) + { + case itk::ImageIOBase::UCHAR: + r = this->_GD1< unsigned char, D >( names ); + break; + case itk::ImageIOBase::CHAR: + r = this->_GD1< char, D >( names ); + break; + case itk::ImageIOBase::USHORT: + r = this->_GD1< unsigned short, D >( names ); + break; + case itk::ImageIOBase::SHORT: + r = this->_GD1< short, D >( names ); + break; + case itk::ImageIOBase::UINT: + r = this->_GD1< unsigned int, D >( names ); + break; + case itk::ImageIOBase::INT: + r = this->_GD1< int, D >( names ); + break; + case itk::ImageIOBase::ULONG: + r = this->_GD1< unsigned long, D >( names ); + break; + case itk::ImageIOBase::LONG: + r = this->_GD1< long, D >( names ); + break; + case itk::ImageIOBase::FLOAT: + r = this->_GD1< float, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< double, D >( names ); + break; + default: + r = "ImageReader: Scalar pixel type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::RGB ) + { + switch( ct ) + { + case itk::ImageIOBase::UCHAR: + r = this->_GD1< itk::RGBPixel< unsigned char >, D >( names ); + break; + case itk::ImageIOBase::CHAR: + r = this->_GD1< itk::RGBPixel< char >, D >( names ); + break; + case itk::ImageIOBase::USHORT: + r = this->_GD1< itk::RGBPixel< unsigned short >, D >( names ); + break; + case itk::ImageIOBase::SHORT: + r = this->_GD1< itk::RGBPixel< short >, D >( names ); + break; + case itk::ImageIOBase::UINT: + r = this->_GD1< itk::RGBPixel< unsigned int >, D >( names ); + break; + case itk::ImageIOBase::INT: + r = this->_GD1< itk::RGBPixel< int >, D >( names ); + break; + case itk::ImageIOBase::ULONG: + r = this->_GD1< itk::RGBPixel< unsigned long >, D >( names ); + break; + case itk::ImageIOBase::LONG: + r = this->_GD1< itk::RGBPixel< long >, D >( names ); + break; + case itk::ImageIOBase::FLOAT: + r = this->_GD1< itk::RGBPixel< float >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< itk::RGBPixel< double >, D >( names ); + break; + default: + r = "ImageReader: RGB pixel type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::RGBA ) + { + switch( ct ) + { + case itk::ImageIOBase::UCHAR: + r = this->_GD1< itk::RGBAPixel< unsigned char >, D >( names ); + break; + case itk::ImageIOBase::CHAR: + r = this->_GD1< itk::RGBAPixel< char >, D >( names ); + break; + case itk::ImageIOBase::USHORT: + r = this->_GD1< itk::RGBAPixel< unsigned short >, D >( names ); + break; + case itk::ImageIOBase::SHORT: + r = this->_GD1< itk::RGBAPixel< short >, D >( names ); + break; + case itk::ImageIOBase::UINT: + r = this->_GD1< itk::RGBAPixel< unsigned int >, D >( names ); + break; + case itk::ImageIOBase::INT: + r = this->_GD1< itk::RGBAPixel< int >, D >( names ); + break; + case itk::ImageIOBase::ULONG: + r = this->_GD1< itk::RGBAPixel< unsigned long >, D >( names ); + break; + case itk::ImageIOBase::LONG: + r = this->_GD1< itk::RGBAPixel< long >, D >( names ); + break; + case itk::ImageIOBase::FLOAT: + r = this->_GD1< itk::RGBAPixel< float >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< itk::RGBAPixel< double >, D >( names ); + break; + default: + r = "ImageReader: RGBA pixel type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::VECTOR ) + { + switch( ct ) + { + case itk::ImageIOBase::FLOAT: + r = this->_GD1< itk::Vector< float, D >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< itk::Vector< double, D >, D >( names ); + break; + default: + r = "ImageReader: Vector type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::POINT ) + { + switch( ct ) + { + case itk::ImageIOBase::FLOAT: + r = this->_GD1< itk::Point< float, D >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< itk::Point< double, D >, D >( names ); + break; + default: + r = "ImageReader: Point type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::COVARIANTVECTOR ) + { + switch( ct ) + { + case itk::ImageIOBase::FLOAT: + r = this->_GD1< itk::CovariantVector< float, D >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< itk::CovariantVector< double, D >, D >( names ); + break; + default: + r = "ImageReader: CovariantVector type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR ) + { + switch( ct ) + { + case itk::ImageIOBase::FLOAT: + r = + this->_GD1< itk::SymmetricSecondRankTensor< float, D >, D >( + names + ); + break; + case itk::ImageIOBase::DOUBLE: + r = + this->_GD1< itk::SymmetricSecondRankTensor< double, D >, D >( + names + ); + break; + default: + r = "ImageReader: Vector type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::DIFFUSIONTENSOR3D ) + { + switch( ct ) + { + case itk::ImageIOBase::FLOAT: + r = this->_GD1< itk::DiffusionTensor3D< float >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< itk::DiffusionTensor3D< double >, D >( names ); + break; + default: + r = "ImageReader: Diffusion tensor type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::COMPLEX ) + { + switch( ct ) + { + case itk::ImageIOBase::FLOAT: + r = this->_GD1< std::complex< float >, D >( names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< std::complex< double >, D >( names ); + break; + default: + r = "ImageReader: Complex type not supported."; + break; + } // hctiws + } + else if( pt == itk::ImageIOBase::OFFSET ) + r = this->_GD1< itk::Offset< D >, D >( names ); + else + r = "ImageReader: Image pixel type not yet supported."; + /* TODO + itk::ImageIOBase::FIXEDARRAY + itk::ImageIOBase::MATRIX + */ + return( r ); +} + +// ------------------------------------------------------------------------- +template< class P, unsigned int D > +std::string cpPlugins::IO::ImageReader:: +_GD1( const TStringList& names ) +{ + if( this->m_Parameters.GetValueAsBool( "VectorType" ) ) + return( this->_RealGD< itk::VectorImage< P, D > >( names ) ); + else + return( this->_RealGD< itk::Image< P, D > >( names ) ); +} + +// ------------------------------------------------------------------------- +template< class I > +std::string cpPlugins::IO::ImageReader:: +_RealGD( const TStringList& names ) +{ + cpPlugins::Interface::Image* out = + this->GetOutput< cpPlugins::Interface::Image >( 0 ); + if( out == NULL ) + return( "ImageReader: No output object properly created." ); + + std::string r = ""; + if( names.size( ) == 1 ) + { + // Read single image + typedef itk::ImageFileReader< I > _SR; + _SR* reader = + dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); + if( reader == NULL ) + { + this->m_RealProcessObject = _SR::New( ); + reader = + dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); + + } // fi + reader->SetFileName( names[ 0 ] ); + try + { + reader->Update( ); + out->SetITKImage< I >( reader->GetOutput( ) ); + } + catch( itk::ExceptionObject& err ) + { + r = "ImageReader: " + std::string( err.GetDescription( ) ); + out->SetITKImage< I >( NULL ); + + } // yrt + } + else if( names.size( ) > 1 ) + { + // Read image series + std::set< std::string > ordered_names; + for( unsigned int i = 0; i < names.size( ); ++i ) + ordered_names.insert( names[ i ] ); + + typedef itk::ImageSeriesReader< I > _MR; + _MR* reader = + dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); + if( reader == NULL ) + { + this->m_RealProcessObject = _MR::New( ); + reader = + dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); + + } // fi + std::set< std::string >::const_iterator fnIt = ordered_names.begin( ); + for( ; fnIt != ordered_names.end( ); ++fnIt ) + { + reader->AddFileName( *fnIt ); + } + try + { + reader->Update( ); + out->SetITKImage< I >( reader->GetOutput( ) ); + } + catch( itk::ExceptionObject& err ) + { + r = "ImageReader: " + std::string( err.GetDescription( ) ); + out->SetITKImage< I >( NULL ); + + } // yrt + } + else + r = "ImageReader: No image files given"; + return( r ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/ImageReader.h b/lib/cpPlugins/Plugins/IO/ImageReader.h similarity index 88% rename from lib/cpPlugins/Plugins/ImageReader.h rename to lib/cpPlugins/Plugins/IO/ImageReader.h index 1bcf6ae..803e5f8 100644 --- a/lib/cpPlugins/Plugins/ImageReader.h +++ b/lib/cpPlugins/Plugins/IO/ImageReader.h @@ -3,7 +3,7 @@ #include -#include +#include #include namespace itk @@ -13,11 +13,11 @@ namespace itk namespace cpPlugins { - namespace Plugins + namespace IO { /** */ - class cpPlugins_EXPORT ImageReader + class cpPluginsIO_EXPORT ImageReader : public cpPlugins::Interface::ImageSource { public: @@ -44,6 +44,9 @@ namespace cpPlugins std::string _GD0( itk::ImageIOBase* io, const TStringList& names ); template< class P, unsigned int D > + std::string _GD1( const TStringList& names ); + + template< class I > std::string _RealGD( const TStringList& names ); private: diff --git a/lib/cpPlugins/Plugins/ImageWriter.cxx b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx similarity index 90% rename from lib/cpPlugins/Plugins/ImageWriter.cxx rename to lib/cpPlugins/Plugins/IO/ImageWriter.cxx index 59dbe83..6a0de2e 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.cxx @@ -1,14 +1,14 @@ -#include +#include "ImageWriter.h" #include #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::ImageWriter:: +cpPlugins::IO::ImageWriter:: ImageWriter( ) : Superclass( ) { - this->m_ClassName = "cpPlugins::ImageWriter"; + this->m_ClassName = "cpPlugins::IO::ImageWriter"; this->m_ClassCategory = "ImageWriter"; this->SetNumberOfInputs( 1 ); @@ -18,13 +18,13 @@ ImageWriter( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::ImageWriter:: +cpPlugins::IO::ImageWriter:: ~ImageWriter( ) { } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageWriter:: +std::string cpPlugins::IO::ImageWriter:: _GenerateData( ) { cpPlugins::Interface::Image* image = @@ -58,7 +58,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< class I > -std::string cpPlugins::Plugins::ImageWriter:: +std::string cpPlugins::IO::ImageWriter:: _RealGD( itk::DataObject* image ) { typedef itk::ImageFileWriter< I > _W; diff --git a/lib/cpPlugins/Plugins/ImageWriter.h b/lib/cpPlugins/Plugins/IO/ImageWriter.h similarity index 91% rename from lib/cpPlugins/Plugins/ImageWriter.h rename to lib/cpPlugins/Plugins/IO/ImageWriter.h index 4fc04f5..9c3b0ce 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.h +++ b/lib/cpPlugins/Plugins/IO/ImageWriter.h @@ -1,16 +1,16 @@ #ifndef __CPPLUGINS__PLUGINS__IMAGEWRITER__H__ #define __CPPLUGINS__PLUGINS__IMAGEWRITER__H__ -#include +#include #include namespace cpPlugins { - namespace Plugins + namespace IO { /** */ - class cpPlugins_EXPORT ImageWriter + class cpPluginsIO_EXPORT ImageWriter : public cpPlugins::Interface::ImageSink { public: diff --git a/lib/cpPlugins/Plugins/MeshReader.cxx b/lib/cpPlugins/Plugins/IO/MeshReader.cxx similarity index 89% rename from lib/cpPlugins/Plugins/MeshReader.cxx rename to lib/cpPlugins/Plugins/IO/MeshReader.cxx index 1993259..6706904 100644 --- a/lib/cpPlugins/Plugins/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshReader.cxx @@ -1,16 +1,16 @@ -#include +#include "MeshReader.h" #include #include #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::MeshReader:: +cpPlugins::IO::MeshReader:: MeshReader( ) : Superclass( ), m_Reader( NULL ) { - this->m_ClassName = "cpPlugins::MeshReader"; + this->m_ClassName = "cpPlugins::IO::MeshReader"; this->m_ClassCategory = "MeshReader"; this->SetNumberOfOutputs( 1 ); @@ -26,7 +26,7 @@ MeshReader( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::MeshReader:: +cpPlugins::IO::MeshReader:: ~MeshReader( ) { if( this->m_Reader != NULL ) @@ -34,7 +34,7 @@ cpPlugins::Plugins::MeshReader:: } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MeshReader:: +std::string cpPlugins::IO::MeshReader:: _GenerateData( ) { using namespace cpPlugins::Interface; @@ -49,7 +49,7 @@ _GenerateData( ) // ------------------------------------------------------------------------- template< unsigned int D > -std::string cpPlugins::Plugins::MeshReader:: +std::string cpPlugins::IO::MeshReader:: _GD0( ) { using namespace cpPlugins::Interface; @@ -62,7 +62,7 @@ _GD0( ) // ------------------------------------------------------------------------- template< class P, unsigned int D > -std::string cpPlugins::Plugins::MeshReader:: +std::string cpPlugins::IO::MeshReader:: _GD1( ) { // Get filename diff --git a/lib/cpPlugins/Plugins/MeshReader.h b/lib/cpPlugins/Plugins/IO/MeshReader.h similarity index 92% rename from lib/cpPlugins/Plugins/MeshReader.h rename to lib/cpPlugins/Plugins/IO/MeshReader.h index 394f6a8..224cc03 100644 --- a/lib/cpPlugins/Plugins/MeshReader.h +++ b/lib/cpPlugins/Plugins/IO/MeshReader.h @@ -1,18 +1,18 @@ #ifndef __CPPLUGINS__PLUGINS__MESHREADER__H__ #define __CPPLUGINS__PLUGINS__MESHREADER__H__ -#include +#include #include class vtkDataReader; namespace cpPlugins { - namespace Plugins + namespace IO { /** */ - class cpPlugins_EXPORT MeshReader + class cpPluginsIO_EXPORT MeshReader : public cpPlugins::Interface::MeshSource { public: diff --git a/lib/cpPlugins/Plugins/MeshWriter.cxx b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx similarity index 87% rename from lib/cpPlugins/Plugins/MeshWriter.cxx rename to lib/cpPlugins/Plugins/IO/MeshWriter.cxx index 6cc7841..ade28b8 100644 --- a/lib/cpPlugins/Plugins/MeshWriter.cxx +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.cxx @@ -1,4 +1,4 @@ -#include +#include "MeshWriter.h" #include #include @@ -6,12 +6,12 @@ #include // ------------------------------------------------------------------------- -cpPlugins::Plugins::MeshWriter:: +cpPlugins::IO::MeshWriter:: MeshWriter( ) : Superclass( ), m_Writer( NULL ) { - this->m_ClassName = "cpPlugins::MeshWriter"; + this->m_ClassName = "cpPlugins::IO::MeshWriter"; this->m_ClassCategory = "MeshWriter"; this->SetNumberOfInputs( 1 ); @@ -21,7 +21,7 @@ MeshWriter( ) } // ------------------------------------------------------------------------- -cpPlugins::Plugins::MeshWriter:: +cpPlugins::IO::MeshWriter:: ~MeshWriter( ) { if( this->m_Writer != NULL ) @@ -29,7 +29,7 @@ cpPlugins::Plugins::MeshWriter:: } // ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MeshWriter:: +std::string cpPlugins::IO::MeshWriter:: _GenerateData( ) { cpPlugins::Interface::Mesh* mesh = diff --git a/lib/cpPlugins/Plugins/MeshWriter.h b/lib/cpPlugins/Plugins/IO/MeshWriter.h similarity index 91% rename from lib/cpPlugins/Plugins/MeshWriter.h rename to lib/cpPlugins/Plugins/IO/MeshWriter.h index d1fc2cc..cd776f6 100644 --- a/lib/cpPlugins/Plugins/MeshWriter.h +++ b/lib/cpPlugins/Plugins/IO/MeshWriter.h @@ -1,18 +1,18 @@ #ifndef __CPPLUGINS__PLUGINS__MESHWRITER__H__ #define __CPPLUGINS__PLUGINS__MESHWRITER__H__ -#include +#include #include class vtkDataWriter; namespace cpPlugins { - namespace Plugins + namespace IO { /** */ - class cpPlugins_EXPORT MeshWriter + class cpPluginsIO_EXPORT MeshWriter : public cpPlugins::Interface::MeshSink { public: diff --git a/lib/cpPlugins/Plugins/ImageReader.cxx b/lib/cpPlugins/Plugins/ImageReader.cxx deleted file mode 100644 index 73611cb..0000000 --- a/lib/cpPlugins/Plugins/ImageReader.cxx +++ /dev/null @@ -1,586 +0,0 @@ -#include -#include - -#include - -#include -#include - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::ImageReader:: -ImageReader( ) - : Superclass( ) -{ - this->m_ClassName = "cpPlugins::ImageReader"; - this->m_ClassCategory = "ImageReader"; - - this->SetNumberOfOutputs( 1 ); - this->_MakeOutput< cpPlugins::Interface::Image >( 0 ); - - using namespace cpPlugins::Interface; - this->m_DefaultParameters.Configure( Parameters::StringList, "FileNames" ); - this->m_Parameters = this->m_DefaultParameters; -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::ImageReader:: -~ImageReader( ) -{ -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageReader:: -_GenerateData( ) -{ - // Get filenames - TStringList names; - this->m_Parameters.GetValueAsStringList( names, "FileNames" ); - - std::string r = ""; - if( names.size( ) >= 1 ) - { - // Guess image properties - itk::ImageIOBase::Pointer io = - itk::ImageIOFactory::CreateImageIO( - names[ 0 ].c_str( ), - itk::ImageIOFactory::ReadMode - ); - if( io.IsNotNull( ) ) - { - io->SetFileName( names[ 0 ] ); - io->ReadImageInformation( ); - if( names.size( ) >= 1 ) - { - switch( io->GetNumberOfDimensions( ) ) - { - case 2: r = this->_GD0< 2 >( io, names ); break; - case 3: r = this->_GD0< 3 >( io, names ); break; - case 4: r = this->_GD0< 4 >( io, names ); break; - default: - r = "ImageReader: Image dimension not supported."; - break; - } // hctiws - - } // fi - } - else - r = "ImageReader: Could not CreateImageIO for \"" + names[ 0 ] + "\""; - } - else - r = "No image files given"; - return( r ); -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -std::string cpPlugins::Plugins::ImageReader:: -_GD0( itk::ImageIOBase* io, const TStringList& names ) -{ - itk::ImageIOBase::IOComponentType ct = io->GetComponentType( ); - itk::ImageIOBase::IOPixelType pt = io->GetPixelType( ); - std::string r = ""; - - if( pt == itk::ImageIOBase::SCALAR ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< unsigned char, D >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< char, D >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< unsigned short, D >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< short, D >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< unsigned int, D >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< int, D >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< unsigned long, D >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< long, D >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< float, D >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< double, D >( names ); - break; - default: - r = "ImageReader: Scalar pixel type not supported."; - break; - } // hctiws - } - else if( pt == itk::ImageIOBase::RGB ) - { - if( D == 2 ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< itk::RGBPixel< unsigned char >, 2 >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< itk::RGBPixel< char >, 2 >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< itk::RGBPixel< unsigned short >, 2 >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< itk::RGBPixel< short >, 2 >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< itk::RGBPixel< unsigned int >, 2 >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< itk::RGBPixel< int >, 2 >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< itk::RGBPixel< unsigned long >, 2 >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< itk::RGBPixel< long >, 2 >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::RGBPixel< float >, 2 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::RGBPixel< double >, 2 >( names ); - break; - default: - r = "ImageReader: RGB pixel type not supported."; - break; - } // hctiws - } - else if( D == 3 ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< itk::RGBPixel< unsigned char >, 3 >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< itk::RGBPixel< char >, 3 >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< itk::RGBPixel< unsigned short >, 3 >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< itk::RGBPixel< short >, 3 >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< itk::RGBPixel< unsigned int >, 3 >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< itk::RGBPixel< int >, 3 >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< itk::RGBPixel< unsigned long >, 3 >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< itk::RGBPixel< long >, 3 >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::RGBPixel< float >, 3 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::RGBPixel< double >, 3 >( names ); - break; - default: - r = "ImageReader: RGB pixel type not supported."; - break; - } // hctiws - } - else if( D == 4 ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< itk::RGBPixel< unsigned char >, 4 >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< itk::RGBPixel< char >, 4 >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< itk::RGBPixel< unsigned short >, 4 >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< itk::RGBPixel< short >, 4 >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< itk::RGBPixel< unsigned int >, 4 >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< itk::RGBPixel< int >, 4 >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< itk::RGBPixel< unsigned long >, 4 >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< itk::RGBPixel< long >, 4 >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::RGBPixel< float >, 4 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::RGBPixel< double >, 4 >( names ); - break; - default: - r = "ImageReader: RGB pixel type not supported."; - break; - } // hctiws - - } // fi - } - else if( pt == itk::ImageIOBase::RGBA ) - { - if( D == 2 ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< itk::RGBAPixel< unsigned char >, 2 >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< itk::RGBAPixel< char >, 2 >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< itk::RGBAPixel< unsigned short >, 2 >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< itk::RGBAPixel< short >, 2 >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< itk::RGBAPixel< unsigned int >, 2 >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< itk::RGBAPixel< int >, 2 >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< itk::RGBAPixel< unsigned long >, 2 >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< itk::RGBAPixel< long >, 2 >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::RGBAPixel< float >, 2 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::RGBAPixel< double >, 2 >( names ); - break; - default: - r = "ImageReader: RGBA pixel type not supported."; - break; - } // hctiws - } - else if( D == 3 ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< itk::RGBAPixel< unsigned char >, 3 >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< itk::RGBAPixel< char >, 3 >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< itk::RGBAPixel< unsigned short >, 3 >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< itk::RGBAPixel< short >, 3 >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< itk::RGBAPixel< unsigned int >, 3 >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< itk::RGBAPixel< int >, 3 >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< itk::RGBAPixel< unsigned long >, 3 >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< itk::RGBAPixel< long >, 3 >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::RGBAPixel< float >, 3 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::RGBAPixel< double >, 3 >( names ); - break; - default: - r = "ImageReader: RGBA pixel type not supported."; - break; - } // hctiws - } - else if( D == 4 ) - { - switch( ct ) - { - case itk::ImageIOBase::UCHAR: - r = this->_RealGD< itk::RGBAPixel< unsigned char >, 4 >( names ); - break; - case itk::ImageIOBase::CHAR: - r = this->_RealGD< itk::RGBAPixel< char >, 4 >( names ); - break; - case itk::ImageIOBase::USHORT: - r = this->_RealGD< itk::RGBAPixel< unsigned short >, 4 >( names ); - break; - case itk::ImageIOBase::SHORT: - r = this->_RealGD< itk::RGBAPixel< short >, 4 >( names ); - break; - case itk::ImageIOBase::UINT: - r = this->_RealGD< itk::RGBAPixel< unsigned int >, 4 >( names ); - break; - case itk::ImageIOBase::INT: - r = this->_RealGD< itk::RGBAPixel< int >, 4 >( names ); - break; - case itk::ImageIOBase::ULONG: - r = this->_RealGD< itk::RGBAPixel< unsigned long >, 4 >( names ); - break; - case itk::ImageIOBase::LONG: - r = this->_RealGD< itk::RGBAPixel< long >, 4 >( names ); - break; - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::RGBAPixel< float >, 4 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::RGBAPixel< double >, 4 >( names ); - break; - default: - r = "ImageReader: RGBA pixel type not supported."; - break; - } // hctiws - - } // fi - } - else if( pt == itk::ImageIOBase::OFFSET ) - { - switch( D ) - { - case 2: - r = this->_RealGD< itk::Offset< 2 >, 2 >( names ); - break; - case 3: - r = this->_RealGD< itk::Offset< 3 >, 3 >( names ); - break; - case 4: - r = this->_RealGD< itk::Offset< 4 >, 4 >( names ); - break; - default: - r = "ImageReader: Offset pixel dimension not supported."; - break; - } // hctiws - } - else if( pt == itk::ImageIOBase::VECTOR ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::Vector< float, D >, D >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::Vector< double, D >, D >( names ); - break; - default: - r = "ImageReader: Vector type not supported."; - break; - } // hctiws - } - else if( pt == itk::ImageIOBase::POINT ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::Point< float, D >, D >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::Point< double, D >, D >( names ); - break; - default: - r = "ImageReader: Point type not supported."; - break; - } // hctiws - } - else if( pt == itk::ImageIOBase::COVARIANTVECTOR ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::CovariantVector< float, D >, D >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::CovariantVector< double, D >, D >( names ); - break; - default: - r = "ImageReader: CovariantVector type not supported."; - break; - } // hctiws - } - else if( pt == itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = - this->_RealGD< itk::SymmetricSecondRankTensor< float, D >, D >( - names - ); - break; - case itk::ImageIOBase::DOUBLE: - r = - this->_RealGD< itk::SymmetricSecondRankTensor< double, D >, D >( - names - ); - break; - default: - r = "ImageReader: Vector type not supported."; - break; - } // hctiws - } - else if( pt == itk::ImageIOBase::DIFFUSIONTENSOR3D ) - { - if( D == 3 ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::DiffusionTensor3D< float >, 3 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::DiffusionTensor3D< double >, 3 >( names ); - break; - default: - r = "ImageReader: Diffusion tensor type not supported."; - break; - } // hctiws - } - else if( D == 4 ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< itk::DiffusionTensor3D< float >, 4 >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< itk::DiffusionTensor3D< double >, 4 >( names ); - break; - default: - r = "ImageReader: Diffusion tensor type not supported."; - break; - } // hctiws - } - else - r = "ImageReader: Diffusion tensor dimension not supported."; - } - else if( pt == itk::ImageIOBase::COMPLEX ) - { - switch( ct ) - { - case itk::ImageIOBase::FLOAT: - r = this->_RealGD< std::complex< float >, D >( names ); - break; - case itk::ImageIOBase::DOUBLE: - r = this->_RealGD< std::complex< double >, D >( names ); - break; - default: - r = "ImageReader: Complex type not supported."; - break; - } // hctiws - } - else - r = "ImageReader: Image pixel type not yet supported."; - /* TODO - itk::ImageIOBase::FIXEDARRAY - itk::ImageIOBase::MATRIX - */ - - return( r ); -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -std::string cpPlugins::Plugins::ImageReader:: -_RealGD( const TStringList& names ) -{ - typedef itk::Image< P, D > _I; - - cpPlugins::Interface::Image* out = - this->GetOutput< cpPlugins::Interface::Image >( 0 ); - if( out == NULL ) - return( "ImageReader: No output object properly created." ); - - std::string r = ""; - if( names.size( ) == 1 ) - { - // Read single image - typedef itk::ImageFileReader< _I > _SR; - _SR* reader = - dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); - if( reader == NULL ) - { - this->m_RealProcessObject = _SR::New( ); - reader = - dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi - reader->SetFileName( names[ 0 ] ); - try - { - reader->Update( ); - out->SetITKImage< _I >( reader->GetOutput( ) ); - } - catch( itk::ExceptionObject& err ) - { - r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITKImage< _I >( NULL ); - - } // yrt - } - else if( names.size( ) > 1 ) - { - // Read image series - std::set< std::string > ordered_names; - for( unsigned int i = 0; i < names.size( ); ++i ) - ordered_names.insert( names[ i ] ); - - typedef itk::ImageSeriesReader< _I > _MR; - _MR* reader = - dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); - if( reader == NULL ) - { - this->m_RealProcessObject = _MR::New( ); - reader = - dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi - std::set< std::string >::const_iterator fnIt = ordered_names.begin( ); - for( ; fnIt != ordered_names.end( ); ++fnIt ) - { - reader->AddFileName( *fnIt ); - } - try - { - reader->Update( ); - out->SetITKImage< _I >( reader->GetOutput( ) ); - } - catch( itk::ExceptionObject& err ) - { - r = "ImageReader: " + std::string( err.GetDescription( ) ); - out->SetITKImage< _I >( NULL ); - - } // yrt - } - else - r = "ImageReader: No image files given"; - return( r ); -} - -// eof - $RCSfile$ -- 2.47.1