From 9015cf98c60cf4ab304a639990004ee783a8bec0 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Tue, 15 Sep 2015 19:26:06 +0200 Subject: [PATCH] Major refactoring: API-HCI bug corrected. --- appli/ImageMPR/ImageMPR.cxx | 63 ++-- appli/ImageMPR/ImageMPR.h | 16 +- appli/examples/CMakeLists.txt | 39 +-- appli/examples/example_MarchingCubes.cxx | 76 +++++ appli/examples/example_ReadWriteImage.cxx | 48 ++- lib/cpPlugins/Interface/DataObject.cxx | 61 +++- lib/cpPlugins/Interface/DataObject.h | 22 +- lib/cpPlugins/Interface/FilterObject.cxx | 16 +- lib/cpPlugins/Interface/FilterObject.h | 4 - lib/cpPlugins/Interface/Image.cxx | 207 ++++++++---- lib/cpPlugins/Interface/Image.h | 19 +- lib/cpPlugins/Interface/ImageSink.cxx | 16 +- lib/cpPlugins/Interface/ImageSink.h | 4 - lib/cpPlugins/Interface/ImageSource.cxx | 16 +- lib/cpPlugins/Interface/ImageSource.h | 4 - .../Interface/ImageToImageFilter.cxx | 16 +- lib/cpPlugins/Interface/ImageToImageFilter.h | 4 - lib/cpPlugins/Interface/ImageToMeshFilter.cxx | 16 +- lib/cpPlugins/Interface/ImageToMeshFilter.h | 4 - .../ImageToPolyLineParametricPathFilter.cxx | 30 -- .../ImageToPolyLineParametricPathFilter.h | 45 --- .../Interface/Instances_itkImage.cxx | 157 +++++++--- lib/cpPlugins/Interface/Instances_itkMesh.cxx | 18 +- .../Instances_itkPolyLineParametricPath.cxx | 19 -- lib/cpPlugins/Interface/Interface.h | 4 +- lib/cpPlugins/Interface/Mesh.cxx | 85 ++--- lib/cpPlugins/Interface/Mesh.h | 28 +- lib/cpPlugins/Interface/MeshSink.cxx | 16 +- lib/cpPlugins/Interface/MeshSink.h | 4 - lib/cpPlugins/Interface/MeshSource.cxx | 16 +- lib/cpPlugins/Interface/MeshSource.h | 4 - lib/cpPlugins/Interface/MeshToImageFilter.cxx | 16 +- lib/cpPlugins/Interface/MeshToImageFilter.h | 4 - lib/cpPlugins/Interface/MeshToMeshFilter.cxx | 16 +- lib/cpPlugins/Interface/MeshToMeshFilter.h | 4 - lib/cpPlugins/Interface/Object.cxx | 16 +- lib/cpPlugins/Interface/Object.h | 12 +- lib/cpPlugins/Interface/PolyData.cxx | 65 ---- lib/cpPlugins/Interface/PolyData.h | 61 ---- lib/cpPlugins/Interface/PolyDataSource.cxx | 30 -- lib/cpPlugins/Interface/PolyDataSource.h | 45 --- .../Interface/PolyLineParametricPath.cxx | 107 ------- .../Interface/PolyLineParametricPath.h | 61 ---- .../PolyLineParametricPathSource.cxx | 30 -- .../Interface/PolyLineParametricPathSource.h | 45 --- lib/cpPlugins/Interface/ProcessObject.cxx | 50 ++- lib/cpPlugins/Interface/ProcessObject.h | 26 +- lib/cpPlugins/Interface/SinkObject.cxx | 16 +- lib/cpPlugins/Interface/SinkObject.h | 4 - lib/cpPlugins/Interface/SourceObject.cxx | 16 +- lib/cpPlugins/Interface/SourceObject.h | 4 - lib/cpPlugins/Plugins/CMakeLists.txt | 31 +- lib/cpPlugins/Plugins/Host.cxx | 21 +- lib/cpPlugins/Plugins/ImageReader.cxx | 295 +++++++++++------- lib/cpPlugins/Plugins/ImageReader.h | 20 +- lib/cpPlugins/Plugins/ImageSeriesReader.cxx | 160 ---------- lib/cpPlugins/Plugins/ImageSeriesReader.h | 57 ---- lib/cpPlugins/Plugins/ImageWriter.cxx | 106 +++---- lib/cpPlugins/Plugins/ImageWriter.h | 8 +- lib/cpPlugins/Plugins/MarchingCubes.cxx | 185 +++-------- lib/cpPlugins/Plugins/MarchingCubes.h | 15 +- lib/cpPlugins/Plugins/MeshReader.cxx | 49 +-- lib/cpPlugins/Plugins/MeshReader.h | 9 +- lib/cpPlugins/Plugins/MeshWriter.cxx | 55 ++++ lib/cpPlugins/Plugins/MeshWriter.h | 52 +++ 65 files changed, 1088 insertions(+), 1680 deletions(-) create mode 100644 appli/examples/example_MarchingCubes.cxx delete mode 100644 lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx delete mode 100644 lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h delete mode 100644 lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx delete mode 100644 lib/cpPlugins/Interface/PolyData.cxx delete mode 100644 lib/cpPlugins/Interface/PolyData.h delete mode 100644 lib/cpPlugins/Interface/PolyDataSource.cxx delete mode 100644 lib/cpPlugins/Interface/PolyDataSource.h delete mode 100644 lib/cpPlugins/Interface/PolyLineParametricPath.cxx delete mode 100644 lib/cpPlugins/Interface/PolyLineParametricPath.h delete mode 100644 lib/cpPlugins/Interface/PolyLineParametricPathSource.cxx delete mode 100644 lib/cpPlugins/Interface/PolyLineParametricPathSource.h delete mode 100644 lib/cpPlugins/Plugins/ImageSeriesReader.cxx delete mode 100644 lib/cpPlugins/Plugins/ImageSeriesReader.h create mode 100644 lib/cpPlugins/Plugins/MeshWriter.cxx create mode 100644 lib/cpPlugins/Plugins/MeshWriter.h diff --git a/appli/ImageMPR/ImageMPR.cxx b/appli/ImageMPR/ImageMPR.cxx index 71b8e9d..931ff3a 100644 --- a/appli/ImageMPR/ImageMPR.cxx +++ b/appli/ImageMPR/ImageMPR.cxx @@ -8,9 +8,11 @@ #include #ifdef _WIN32 +# define PLUGIN_PREFIX "" # define PLUGIN_EXT "dll" # define PLUGIN_REGEX "Plugins file (*.dll);;All files (*)" #else +# define PLUGIN_PREFIX "lib" # define PLUGIN_EXT "so" # define PLUGIN_REGEX "Plugins file (*.so);;All files (*)" #endif // _WIN32 @@ -46,7 +48,11 @@ ImageMPR::ImageMPR( QWidget* parent ) ); // Start: load all disponible plugins - this->_triggered_actionOpenPlugins( ); + this->_LoadPlugins( + std::string( PLUGIN_PREFIX ) + + std::string( "cpPlugins." ) + + std::string( PLUGIN_EXT ) + ); } // ------------------------------------------------------------------------- @@ -61,6 +67,22 @@ ImageMPR:: delete this->m_MPR; } +// ------------------------------------------------------------------------- +bool ImageMPR:: +_LoadPlugins( const std::string& filename ) +{ + this->m_Plugins.UnloadAll( ); + if( !( this->m_Plugins.Load( filename ) ) ) + { + this->m_Plugins.UnloadAll( ); + return( false ); + + } // fi + this->m_BaseClasses[ "ImageReader" ] = "cpPlugins::ImageReader"; + this->m_BaseClasses[ "MeshReader" ] = "cpPlugins::MeshReader"; + return( true ); +} + // ------------------------------------------------------------------------- void ImageMPR:: _triggered_actionOpenPlugins( ) @@ -75,23 +97,12 @@ _triggered_actionOpenPlugins( ) return; std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( ); - this->m_Plugins.UnloadAll( ); - if( !( this->m_Plugins.Load( fname ) ) ) - { + if( !( _LoadPlugins( fname ) ) ) QMessageBox::critical( this, tr( "Ignoring plugin" ), tr( fname.c_str( ) ) ); - this->m_Plugins.UnloadAll( ); - return; - - } // fi - - this->m_BaseClasses[ "ImageReader" ] = - "cpPlugins::Plugins::ImageReader"; - this->m_BaseClasses[ "PolyDataReader" ] = - "cpPlugins::Plugins::PolyDataReader"; } // ------------------------------------------------------------------------- @@ -112,7 +123,7 @@ _triggered_actionOpenInputImage( ) this->m_InputImage = NULL; // Get a reader from plugins - TPlugin::Pointer reader = + TPluginFilter::Pointer reader = this->m_Plugins.CreateProcessObject( this->m_BaseClasses[ "ImageReader" ] ); @@ -125,11 +136,6 @@ _triggered_actionOpenInputImage( ) QStringList::const_iterator qIt = q_fnames.begin( ); for( ; qIt != q_fnames.end( ); ++qIt ) reader_params.AddValueToStringList( "FileNames", qIt->toStdString( ) ); - - // Other parameters - reader_params.SetValueAsString( "PixelType", "short" ); - reader_params.SetValueAsUint( "ImageDimension", 3 ); - reader_params.SetValueAsUint( "IsColorImage", 0 ); reader->SetParameters( reader_params ); // Execute and get error message, if any @@ -167,12 +173,12 @@ _triggered_actionOpenInputPolyData( ) std::string fname = dialog.selectedFiles( ).at( 0 ).toStdString( ); - this->m_InputPolyData = NULL; + this->m_InputMesh = NULL; // Get a reader from plugins - TPlugin::Pointer reader = + TPluginFilter::Pointer reader = this->m_Plugins.CreateProcessObject( - this->m_BaseClasses[ "PolyDataReader" ] + this->m_BaseClasses[ "MeshReader" ] ); // Configure plugin @@ -186,13 +192,16 @@ _triggered_actionOpenInputPolyData( ) // Assign fresh image, if any if( err == "" ) { - this->m_InputPolyData = - dynamic_cast< TPluginPolyData* >( reader->GetOutput( 0 ) ); + this->m_InputMesh = + dynamic_cast< TPluginMesh* >( reader->GetOutput( 0 ) ); reader->DisconnectOutputs( ); - if( this->m_InputPolyData.IsNotNull( ) ) + if( this->m_InputMesh.IsNotNull( ) ) { - this->m_InputPolyData->GetActor( )->GetProperty( )->SetColor( 1, 0, 1 ); - this->m_MPR->Add3DActor( this->m_InputPolyData->GetActor( ) ); + this->m_InputMeshMapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); + this->m_InputMeshMapper->SetInputData( this->m_InputMesh->GetVTKPolyData( ) ); + this->m_InputMeshActor = vtkSmartPointer< vtkActor >::New( ); + this->m_InputMeshActor->SetMapper( this->m_InputMeshMapper ); + this->m_MPR->Add3DActor( this->m_InputMeshActor ); } // fi } diff --git a/appli/ImageMPR/ImageMPR.h b/appli/ImageMPR/ImageMPR.h index b8d91f1..959daf1 100644 --- a/appli/ImageMPR/ImageMPR.h +++ b/appli/ImageMPR/ImageMPR.h @@ -15,8 +15,7 @@ #include #include #include -#include -#include +#include #include // ------------------------------------------------------------------------- @@ -39,8 +38,8 @@ public: typedef cpPlugins::Interface::Object TPluginObject; typedef cpPlugins::Interface::DataObject TPluginData; typedef cpPlugins::Interface::Image TPluginImage; - typedef cpPlugins::Interface::PolyData TPluginPolyData; - typedef cpPlugins::Interface::ProcessObject TPlugin; + typedef cpPlugins::Interface::Mesh TPluginMesh; + typedef cpPlugins::Interface::ProcessObject TPluginFilter; typedef cpPlugins::Interface::Parameters TParameters; typedef std::map< std::string, std::string > TStringMap; @@ -50,6 +49,9 @@ public: explicit ImageMPR( QWidget* parent = 0 ); virtual ~ImageMPR( ); +protected: + bool _LoadPlugins( const std::string& filename ); + private slots: void _triggered_actionOpenPlugins( ); void _triggered_actionOpenInputImage( ); @@ -65,11 +67,13 @@ private: TStringMap m_BaseClasses; // Real data - TPluginImage::Pointer m_InputImage; - TPluginPolyData::Pointer m_InputPolyData; + TPluginImage::Pointer m_InputImage; + TPluginMesh::Pointer m_InputMesh; // Visualization stuff TMPR* m_MPR; + vtkSmartPointer< vtkPolyDataMapper > m_InputMeshMapper; + vtkSmartPointer< vtkActor > m_InputMeshActor; /* TODO vtkSmartPointer< vtkOrientationMarkerWidget > m_3DOrientationWidget; diff --git a/appli/examples/CMakeLists.txt b/appli/examples/CMakeLists.txt index 97801d4..3ea2797 100644 --- a/appli/examples/CMakeLists.txt +++ b/appli/examples/CMakeLists.txt @@ -5,15 +5,16 @@ SET( EXAMPLES_PROGRAMS - example_TestParameters - example_LoadPlugins + ## example_TestParameters + ## example_LoadPlugins example_ReadWriteImage - example_ReadImageSeriesWriteImage - example_ReadQuadEdgeMesh - example_RenderQuadEdgeMesh - example_RGBImageToHSVChannels - example_RGBImageToYPbPrChannels - example_MPR + ## example_ReadImageSeriesWriteImage + ## example_ReadQuadEdgeMesh + ## example_RenderQuadEdgeMesh + ## example_RGBImageToHSVChannels + ## example_RGBImageToYPbPrChannels + ## example_MPR + example_MarchingCubes ) FOREACH(prog ${EXAMPLES_PROGRAMS}) @@ -29,17 +30,17 @@ ENDFOREACH(prog) SET( NOPLUGINS_EXAMPLES_PROGRAMS - example_ExtractDICOMSeries - example_ImageGaussianModelEstimator - example_ReadQuadEdgeMeshWithoutPlugins - example_RenderQuadEdgeMeshWithoutPlugins - example_ParallelImageMean - example_LightCompensation - example_1DImageGradient - example_2DImageGradient - example_3DImageGradient - example_2DGulsunTekMedialness - example_3DGulsunTekMedialness + ## example_ExtractDICOMSeries + ## example_ImageGaussianModelEstimator + ## example_ReadQuadEdgeMeshWithoutPlugins + ## example_RenderQuadEdgeMeshWithoutPlugins + ## example_ParallelImageMean + ## example_LightCompensation + ## example_1DImageGradient + ## example_2DImageGradient + ## example_3DImageGradient + ## example_2DGulsunTekMedialness + ## example_3DGulsunTekMedialness ## example_KalmanVelocity ) FOREACH(prog ${NOPLUGINS_EXAMPLES_PROGRAMS}) diff --git a/appli/examples/example_MarchingCubes.cxx b/appli/examples/example_MarchingCubes.cxx new file mode 100644 index 0000000..7894fe0 --- /dev/null +++ b/appli/examples/example_MarchingCubes.cxx @@ -0,0 +1,76 @@ +#include +#include +#include + +#include +#include + +int main( int argc, char* argv[] ) +{ + if( argc < 5 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " plugins_file" + << " input_image value output_mesh" << std::endl; + return( 1 ); + + } // fi + + // Create interface + typedef cpPlugins::Interface::Interface TInterface; + typedef TInterface::TClasses TClasses; + TInterface plugins; + if( !plugins.Load( argv[ 1 ] ) ) + { + std::cerr << "Failed to load plugins." << std::endl; + return( 1 ); + + } // fi + + // Create objects + typedef cpPlugins::Interface::ProcessObject TProcessObject; + typedef cpPlugins::Interface::Parameters TParameters; + cpPlugins::Interface::ProcessObject::Pointer reader, writer, mc; + reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" ); + writer = plugins.CreateProcessObject( "cpPlugins::MeshWriter" ); + mc = plugins.CreateProcessObject( "cpPlugins::MarchingCubes" ); + if( reader.IsNull( ) || writer.IsNull( ) || mc.IsNull( ) ) + { + std::cerr << "No suitable objects found in plugins." << std::endl; + return( 1 ); + + } // fi + + // Configure reader + TParameters reader_params = reader->GetDefaultParameters( ); + for( int i = 2; i < argc - 2; ++i ) + reader_params.AddValueToStringList( "FileNames", argv[ i ] ); + reader->SetParameters( reader_params ); + + // Configure marching cubes + TParameters mc_params = mc->GetDefaultParameters( ); + mc_params.AddValueToRealList( "Thresholds", std::atof( argv[ argc - 2 ] ) ); + mc->SetParameters( mc_params ); + + // Configure writer + TParameters writer_params = writer->GetDefaultParameters( ); + writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] ); + writer->SetParameters( writer_params ); + + // Connect pipeline + mc->SetInput( 0, reader->GetOutput( 0 ) ); + writer->SetInput( 0, mc->GetOutput( 0 ) ); + + // Execute pipeline + std::string err = writer->Update( ); + if( err != "" ) + { + std::cerr << "ERROR: " << err << std::endl; + return( 1 ); + + } // fi + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/appli/examples/example_ReadWriteImage.cxx b/appli/examples/example_ReadWriteImage.cxx index fa644d0..8c562a9 100644 --- a/appli/examples/example_ReadWriteImage.cxx +++ b/appli/examples/example_ReadWriteImage.cxx @@ -7,44 +7,39 @@ int main( int argc, char* argv[] ) { - if( argc < 7 ) + if( argc < 4 ) { std::cerr << "Usage: " << argv[ 0 ] << " plugins_file" - << " input_image output_image" - << " dimensions pixel_type is_color" << std::endl; + << " input_image output_image" << std::endl; return( 1 ); } // fi - std::string plugins_file = argv[ 1 ]; - std::string input_image_file = argv[ 2 ]; - std::string output_image_file = argv[ 3 ]; - unsigned int dimensions = std::atoi( argv[ 4 ] ); - std::string pixel_type = argv[ 5 ]; - bool is_color = ( std::atoi( argv[ 6 ] ) == 1 ); // Create interface typedef cpPlugins::Interface::Interface TInterface; typedef TInterface::TClasses TClasses; - TInterface plugins; - plugins.Load( plugins_file ); + if( !plugins.Load( argv[ 1 ] ) ) + { + std::cerr << "Failed to load plugins." << std::endl; + return( 1 ); + + } // fi // Create objects typedef cpPlugins::Interface::ProcessObject TProcessObject; typedef cpPlugins::Interface::Parameters TParameters; - cpPlugins::Interface::ProcessObject::Pointer reader; - cpPlugins::Interface::ProcessObject::Pointer writer; - - reader = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageReader" ); + cpPlugins::Interface::ProcessObject::Pointer reader, writer; + reader = plugins.CreateProcessObject( "cpPlugins::ImageReader" ); if( reader.IsNull( ) ) { std::cerr << "No suitable reader found in plugins." << std::endl; return( 1 ); } // fi - writer = plugins.CreateProcessObject( "cpPlugins::Plugins::ImageWriter" ); + writer = plugins.CreateProcessObject( "cpPlugins::ImageWriter" ); if( writer.IsNull( ) ) { std::cerr << "No suitable writer found in plugins." << std::endl; @@ -54,25 +49,26 @@ int main( int argc, char* argv[] ) // Configure reader TParameters reader_params = reader->GetDefaultParameters( ); - reader_params.AddValueToStringList( "FileNames", input_image_file ); - reader_params.SetValueAsString( "PixelType", pixel_type ); - reader_params.SetValueAsUint( "ImageDimension", dimensions ); - reader_params.SetValueAsUint( "IsColorImage", ( is_color? 1: 0 ) ); + for( int i = 2; i < argc - 1; ++i ) + reader_params.AddValueToStringList( "FileNames", argv[ i ] ); reader->SetParameters( reader_params ); - // Configure reader + // Configure writer TParameters writer_params = writer->GetDefaultParameters( ); - writer_params.SetValueAsString( "FileName", output_image_file ); + writer_params.SetValueAsString( "FileName", argv[ argc - 1 ] ); writer->SetParameters( writer_params ); // Connect pipeline writer->SetInput( 0, reader->GetOutput( 0 ) ); - std::string msg = writer->Update( ); - - if( msg != "" ) - std::cerr << "ERROR: " << msg << std::endl; + // Execute pipeline + std::string err = writer->Update( ); + if( err != "" ) + { + std::cerr << "ERROR: " << err << std::endl; + return( 1 ); + } // fi return( 0 ); } diff --git a/lib/cpPlugins/Interface/DataObject.cxx b/lib/cpPlugins/Interface/DataObject.cxx index 21b5f1d..73ff662 100644 --- a/lib/cpPlugins/Interface/DataObject.cxx +++ b/lib/cpPlugins/Interface/DataObject.cxx @@ -1,31 +1,33 @@ #include +#include +#include // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::DataObject:: -GetClassName( ) const +itk::DataObject* cpPlugins::Interface::DataObject:: +GetITKDataObject( ) { - return( "cpPlugins::Interface::DataObject" ); + return( this->m_ITKObject.GetPointer( ) ); } // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::DataObject:: -GetClassType( ) const +const itk::DataObject* cpPlugins::Interface::DataObject:: +GetITKDataObject( ) const { - return( "DataObject" ); + return( this->m_ITKObject.GetPointer( ) ); } // ------------------------------------------------------------------------- -itk::DataObject* cpPlugins::Interface::DataObject:: -GetRealDataObject( ) const +vtkDataObject* cpPlugins::Interface::DataObject:: +GetVTKDataObject( ) { - return( this->m_RealDataObject ); + return( this->m_VTKObject.GetPointer( ) ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::DataObject:: -SetRealDataObject( itk::DataObject* dobj ) +const vtkDataObject* cpPlugins::Interface::DataObject:: +GetVTKDataObject( ) const { - this->m_RealDataObject = dobj; + return( this->m_VTKObject.GetPointer( ) ); } // ------------------------------------------------------------------------- @@ -46,16 +48,43 @@ GetSource( ) const void cpPlugins::Interface::DataObject:: SetSource( cpPlugins::Interface::Object* src ) { - this->m_Source = src; + if( this->m_Source.GetPointer( ) != src ) + { + this->m_Source = src; + this->Modified( ); + + } // fi } // ------------------------------------------------------------------------- void cpPlugins::Interface::DataObject:: DisconnectPipeline( ) { - if( this->m_RealDataObject.IsNotNull( ) ) + if( this->m_ITKObject.IsNotNull( ) ) { - this->m_RealDataObject->DisconnectPipeline( ); + // Disconnect input pipelines + this->m_ITKObject->DisconnectPipeline( ); + vtkImageData* vtk_image = + dynamic_cast< vtkImageData* >( this->m_VTKObject.GetPointer( ) ); + vtkPolyData* vtk_pd = + dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ); + if( vtk_image != NULL ) + { + vtkSmartPointer< vtkImageData > d = + vtkSmartPointer< vtkImageData >::New( ); + d->ShallowCopy( vtk_image ); + this->m_VTKObject = d; + } + else if( vtk_pd != NULL ) + { + vtkSmartPointer< vtkPolyData > d = + vtkSmartPointer< vtkPolyData >::New( ); + d->ShallowCopy( vtk_pd ); + this->m_VTKObject = d; + + } // fi + + // Unbind source if( this->m_Source.IsNotNull( ) ) this->m_Source->Delete( ); this->Register( ); @@ -68,6 +97,8 @@ cpPlugins::Interface::DataObject:: DataObject( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::DataObject"; + this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/DataObject.h b/lib/cpPlugins/Interface/DataObject.h index c6a2129..e61da5c 100644 --- a/lib/cpPlugins/Interface/DataObject.h +++ b/lib/cpPlugins/Interface/DataObject.h @@ -3,10 +3,14 @@ #include #include -#include +#include +#include #include #include +#define ITK_MANUAL_INSTANTIATION +#include + namespace cpPlugins { namespace Interface @@ -23,15 +27,16 @@ namespace cpPlugins typedef itk::SmartPointer< const Self > ConstPointer; public: - itkNewMacro( Self ); itkTypeMacro( DataObject, Object ); public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; + virtual itk::DataObject* GetITKDataObject( ); + virtual const itk::DataObject* GetITKDataObject( ) const; + virtual void SetITKDataObject( itk::DataObject* o ) = 0; - itk::DataObject* GetRealDataObject( ) const; - virtual void SetRealDataObject( itk::DataObject* dobj ); + virtual vtkDataObject* GetVTKDataObject( ); + virtual const vtkDataObject* GetVTKDataObject( ) const; + virtual void SetVTKDataObject( vtkDataObject* o ) = 0; Object* GetSource( ); const Object* GetSource( ) const; @@ -49,8 +54,9 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::DataObject::Pointer m_RealDataObject; - Object::Pointer m_Source; + itk::DataObject::Pointer m_ITKObject; + vtkSmartPointer< vtkDataObject > m_VTKObject; + Object::Pointer m_Source; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/FilterObject.cxx b/lib/cpPlugins/Interface/FilterObject.cxx index b7b5218..24f7c50 100644 --- a/lib/cpPlugins/Interface/FilterObject.cxx +++ b/lib/cpPlugins/Interface/FilterObject.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::FilterObject:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::FilterObject" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::FilterObject:: -GetClassType( ) const -{ - return( "FilterObject" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::FilterObject:: FilterObject( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::FilterObject"; + this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/FilterObject.h b/lib/cpPlugins/Interface/FilterObject.h index 9718d76..0c1aafb 100644 --- a/lib/cpPlugins/Interface/FilterObject.h +++ b/lib/cpPlugins/Interface/FilterObject.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( FilterObject, ProcessObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: FilterObject( ); virtual ~FilterObject( ); diff --git a/lib/cpPlugins/Interface/Image.cxx b/lib/cpPlugins/Interface/Image.cxx index c72663d..a8b1d1b 100644 --- a/lib/cpPlugins/Interface/Image.cxx +++ b/lib/cpPlugins/Interface/Image.cxx @@ -1,67 +1,102 @@ #include -#define ITK_MANUAL_INSTANTIATION +#undef ITK_MANUAL_INSTANTIATION #include +#include #include +#include +#include +#include +#include #include +#include // ------------------------------------------------------------------------- -#define cpPlugins_Image_Dimension( d, o, f ) \ - if( dynamic_cast< itk::ImageBase< d >* >( o ) != NULL ) \ - this->f< d >( ) +#define cpPlugins_Image_Pixel( p, d, o ) \ + if( dynamic_cast< itk::Image< p, d >* >( o ) != NULL ) \ + this->_ITK_2_VTK_1< p, d >( o ) // ------------------------------------------------------------------------- -#define cpPlugins_Image_Pixel( p, d, o, f ) \ - if( dynamic_cast< itk::Image< p, d >* >( o ) != NULL ) \ - this->f< p, d >( ) +#define cpPlugins_Image_Vector( p, d, o ) \ + if( \ + dynamic_cast< itk::Image< itk::Vector< p, d >, d >* >( o ) != NULL \ + ) \ + this->_ITK_2_VTK_1< itk::Vector< p, d >, d >( o ) // ------------------------------------------------------------------------- -#define cpPlugins_Image_RGB( p, d, o, f ) \ +#define cpPlugins_Image_CovVector( p, d, o ) \ if( \ - dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL \ + dynamic_cast< itk::Image< itk::CovariantVector< p, d >, d >* >( o ) \ + != \ + NULL \ ) \ - this->f< itk::RGBPixel< p >, d >( ) + this->_ITK_2_VTK_1< itk::CovariantVector< p, d >, d >( o ) // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Image:: -GetClassName( ) const +#define cpPlugins_Image_SymTensor( p, d, o ) \ + if( \ + dynamic_cast< itk::Image< itk::SymmetricSecondRankTensor< p, d >, d >* >( o ) \ + != \ + NULL \ + ) \ + this->_ITK_2_VTK_1< itk::SymmetricSecondRankTensor< p, d >, d >( o ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_RGB( p, d, o ) \ + cpPlugins_Image_Pixel( itk::RGBPixel< p >, d, o ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_RGBA( p, d, o ) \ + cpPlugins_Image_Pixel( itk::RGBAPixel< p >, d, o ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Image_DiffTensor( p, d, o ) \ + cpPlugins_Image_Pixel( itk::DiffusionTensor3D< p >, d, o ) + +// ------------------------------------------------------------------------- +void cpPlugins::Interface::Image:: +SetITKDataObject( itk::DataObject* o ) { - return( "cpPlugins::Interface::Image" ); + if( dynamic_cast< itk::ImageBase< 1 >* >( o ) != NULL ) + this->_ITK_2_VTK_0< 1 >( o ); + else if( dynamic_cast< itk::ImageBase< 2 >* >( o ) != NULL ) + this->_ITK_2_VTK_0< 2 >( o ); + else if( dynamic_cast< itk::ImageBase< 3 >* >( o ) != NULL ) + this->_ITK_2_VTK_0< 3 >( o ); + else + this->m_ITKObject = NULL; } // ------------------------------------------------------------------------- void cpPlugins::Interface::Image:: -SetRealDataObject( itk::DataObject* dobj ) +SetVTKDataObject( vtkDataObject* o ) { - this->Superclass::SetRealDataObject( dobj ); - - // NOTE: Only 2 and 3 dimensions at this moment to connect with VTK - cpPlugins_Image_Dimension( 2, dobj, _VTK_0 ); - else cpPlugins_Image_Dimension( 3, dobj, _VTK_0 ); + // this->m_VTKObject = o; + std::cerr << "Image: TODO this!!!!" << std::endl; + std::exit( 1 ); } // ------------------------------------------------------------------------- vtkImageData* cpPlugins::Interface::Image:: -GetVTKImageData( ) const +GetVTKImageData( ) { - return( this->m_VTKImageData ); + return( dynamic_cast< vtkImageData* >( this->GetVTKDataObject( ) ) ); } // ------------------------------------------------------------------------- -void cpPlugins::Interface::Image:: -UpdateVTKImageData( ) +const vtkImageData* cpPlugins::Interface::Image:: +GetVTKImageData( ) const { - this->m_Image2VTKImageData->Modified( ); - this->m_Image2VTKImageData->Update( ); - this->m_VTKImageData->Modified( ); + return( dynamic_cast< const vtkImageData* >( this->GetVTKDataObject( ) ) ); } // ------------------------------------------------------------------------- cpPlugins::Interface::Image:: Image( ) - : Superclass( ), - m_VTKImageData( NULL ) + : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::Image"; + this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- @@ -73,47 +108,95 @@ cpPlugins::Interface::Image:: // ------------------------------------------------------------------------- template< unsigned int D > void cpPlugins::Interface::Image:: -_VTK_0( ) +_ITK_2_VTK_0( itk::DataObject* o ) { - itk::DataObject* dobj = this->Superclass::GetRealDataObject( ); - - cpPlugins_Image_Pixel( char, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( short, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( int, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( long, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( unsigned char, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( unsigned short, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( unsigned int, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( unsigned long, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( float, D, dobj, _VTK_1 ); - else cpPlugins_Image_Pixel( double, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( char, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( short, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( int, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( long, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( unsigned char, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( unsigned short, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( unsigned int, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( unsigned long, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( float, D, dobj, _VTK_1 ); - else cpPlugins_Image_RGB( double, D, dobj, _VTK_1 ); + cpPlugins_Image_Pixel( char, D, o ); + else cpPlugins_Image_Pixel( short, D, o ); + else cpPlugins_Image_Pixel( int, D, o ); + else cpPlugins_Image_Pixel( long, D, o ); + else cpPlugins_Image_Pixel( float, D, o ); + else cpPlugins_Image_Pixel( double, D, o ); + else cpPlugins_Image_Pixel( unsigned char, D, o ); + else cpPlugins_Image_Pixel( unsigned short, D, o ); + else cpPlugins_Image_Pixel( unsigned int, D, o ); + else cpPlugins_Image_Pixel( unsigned long, D, o ); + else cpPlugins_Image_RGB( char, D, o ); + else cpPlugins_Image_RGB( short, D, o ); + else cpPlugins_Image_RGB( int, D, o ); + else cpPlugins_Image_RGB( long, D, o ); + else cpPlugins_Image_RGB( float, D, o ); + else cpPlugins_Image_RGB( double, D, o ); + else cpPlugins_Image_RGB( unsigned char, D, o ); + else cpPlugins_Image_RGB( unsigned short, D, o ); + else cpPlugins_Image_RGB( unsigned int, D, o ); + else cpPlugins_Image_RGB( unsigned long, D, o ); + else cpPlugins_Image_RGBA( char, D, o ); + else cpPlugins_Image_RGBA( short, D, o ); + else cpPlugins_Image_RGBA( int, D, o ); + else cpPlugins_Image_RGBA( long, D, o ); + else cpPlugins_Image_RGBA( float, D, o ); + else cpPlugins_Image_RGBA( double, D, o ); + else cpPlugins_Image_RGBA( unsigned char, D, o ); + else cpPlugins_Image_RGBA( unsigned short, D, o ); + else cpPlugins_Image_RGBA( unsigned int, D, o ); + else cpPlugins_Image_RGBA( unsigned long, D, o ); + else cpPlugins_Image_Vector( char, D, o ); + else cpPlugins_Image_Vector( short, D, o ); + else cpPlugins_Image_Vector( int, D, o ); + else cpPlugins_Image_Vector( long, D, o ); + else cpPlugins_Image_Vector( float, D, o ); + else cpPlugins_Image_Vector( double, D, o ); + else cpPlugins_Image_Vector( unsigned char, D, o ); + else cpPlugins_Image_Vector( unsigned short, D, o ); + else cpPlugins_Image_Vector( unsigned int, D, o ); + else cpPlugins_Image_Vector( unsigned long, D, o ); + else cpPlugins_Image_CovVector( char, D, o ); + else cpPlugins_Image_CovVector( short, D, o ); + else cpPlugins_Image_CovVector( int, D, o ); + else cpPlugins_Image_CovVector( long, D, o ); + else cpPlugins_Image_CovVector( float, D, o ); + else cpPlugins_Image_CovVector( double, D, o ); + else cpPlugins_Image_CovVector( unsigned char, D, o ); + else cpPlugins_Image_CovVector( unsigned short, D, o ); + else cpPlugins_Image_CovVector( unsigned int, D, o ); + else cpPlugins_Image_CovVector( unsigned long, D, o ); + else cpPlugins_Image_SymTensor( char, D, o ); + else cpPlugins_Image_SymTensor( short, D, o ); + else cpPlugins_Image_SymTensor( int, D, o ); + else cpPlugins_Image_SymTensor( long, D, o ); + else cpPlugins_Image_SymTensor( float, D, o ); + else cpPlugins_Image_SymTensor( double, D, o ); + else cpPlugins_Image_SymTensor( unsigned char, D, o ); + else cpPlugins_Image_SymTensor( unsigned short, D, o ); + else cpPlugins_Image_SymTensor( unsigned int, D, o ); + else cpPlugins_Image_SymTensor( unsigned long, D, o ); + else cpPlugins_Image_DiffTensor( char, D, o ); + else cpPlugins_Image_DiffTensor( short, D, o ); + else cpPlugins_Image_DiffTensor( int, D, o ); + else cpPlugins_Image_DiffTensor( long, D, o ); + else cpPlugins_Image_DiffTensor( float, D, o ); + else cpPlugins_Image_DiffTensor( double, D, o ); + else cpPlugins_Image_DiffTensor( unsigned char, D, o ); + else cpPlugins_Image_DiffTensor( unsigned short, D, o ); + else cpPlugins_Image_DiffTensor( unsigned int, D, o ); + else cpPlugins_Image_DiffTensor( unsigned long, D, o ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > void cpPlugins::Interface::Image:: -_VTK_1( ) +_ITK_2_VTK_1( itk::DataObject* o ) { - typedef itk::Image< P, D > _TImage; - typedef itk::ImageToVTKImageFilter< _TImage > _TFilter; - - _TImage* img = - dynamic_cast< _TImage* >( this->Superclass::GetRealDataObject( ) ); - typename _TFilter::Pointer filter = _TFilter::New( ); - filter->SetInput( img ); - filter->Update( ); - this->m_VTKImageData = filter->GetOutput( ); - this->m_Image2VTKImageData = filter; + typedef itk::Image< P, D > _I; + typedef itk::ImageToVTKImageFilter< _I > _F; + + typename _F::Pointer f = _F::New( ); + f->SetInput( dynamic_cast< _I* >( o ) ); + f->Update( ); + + this->m_ITKObject = o; + this->m_VTKObject = f->GetOutput( ); + this->m_ITKvVTKConnection = f; } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Image.h b/lib/cpPlugins/Interface/Image.h index 4ba14cb..04d9507 100644 --- a/lib/cpPlugins/Interface/Image.h +++ b/lib/cpPlugins/Interface/Image.h @@ -3,10 +3,12 @@ #include #include -#include #include #include +#define ITK_MANUAL_INSTANTIATION +#include + class vtkImageData; namespace cpPlugins @@ -29,21 +31,21 @@ namespace cpPlugins itkTypeMacro( Image, DataObject ); public: - virtual std::string GetClassName( ) const; - virtual void SetRealDataObject( itk::DataObject* dobj ); + virtual void SetITKDataObject( itk::DataObject* o ); + virtual void SetVTKDataObject( vtkDataObject* o ); - vtkImageData* GetVTKImageData( ) const; - void UpdateVTKImageData( ); + virtual vtkImageData* GetVTKImageData( ); + virtual const vtkImageData* GetVTKImageData( ) const; protected: Image( ); virtual ~Image( ); template< unsigned int D > - void _VTK_0( ); + void _ITK_2_VTK_0( itk::DataObject* o ); template< class P, unsigned int D > - void _VTK_1( ); + void _ITK_2_VTK_1( itk::DataObject* o ); private: // Purposely not implemented @@ -51,8 +53,7 @@ namespace cpPlugins Self& operator=( const Self& ); protected: - itk::ProcessObject::Pointer m_Image2VTKImageData; - vtkImageData* m_VTKImageData; + itk::ProcessObject::Pointer m_ITKvVTKConnection; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/ImageSink.cxx b/lib/cpPlugins/Interface/ImageSink.cxx index e22c14b..3eda9e9 100644 --- a/lib/cpPlugins/Interface/ImageSink.cxx +++ b/lib/cpPlugins/Interface/ImageSink.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageSink:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::ImageSink" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageSink:: -GetClassType( ) const -{ - return( "ImageSink" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::ImageSink:: ImageSink( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::ImageSink"; + this->m_ClassCategory = "ImageSink"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ImageSink.h b/lib/cpPlugins/Interface/ImageSink.h index 526a466..d8af19b 100644 --- a/lib/cpPlugins/Interface/ImageSink.h +++ b/lib/cpPlugins/Interface/ImageSink.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( ImageSink, SinkObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: ImageSink( ); virtual ~ImageSink( ); diff --git a/lib/cpPlugins/Interface/ImageSource.cxx b/lib/cpPlugins/Interface/ImageSource.cxx index b58afd9..8fd69b6 100644 --- a/lib/cpPlugins/Interface/ImageSource.cxx +++ b/lib/cpPlugins/Interface/ImageSource.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageSource:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::ImageSource" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageSource:: -GetClassType( ) const -{ - return( "ImageSource" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::ImageSource:: ImageSource( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::ImageSource"; + this->m_ClassCategory = "ImageSource"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ImageSource.h b/lib/cpPlugins/Interface/ImageSource.h index 56004bf..d2e0c52 100644 --- a/lib/cpPlugins/Interface/ImageSource.h +++ b/lib/cpPlugins/Interface/ImageSource.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( ImageSource, SourceObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: ImageSource( ); virtual ~ImageSource( ); diff --git a/lib/cpPlugins/Interface/ImageToImageFilter.cxx b/lib/cpPlugins/Interface/ImageToImageFilter.cxx index 962c7a0..80e8779 100644 --- a/lib/cpPlugins/Interface/ImageToImageFilter.cxx +++ b/lib/cpPlugins/Interface/ImageToImageFilter.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToImageFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::ImageToImageFilter" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToImageFilter:: -GetClassType( ) const -{ - return( "ImageToImageFilter" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::ImageToImageFilter:: ImageToImageFilter( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::ImageToImageFilter"; + this->m_ClassCategory = "ImageToImageFilter"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ImageToImageFilter.h b/lib/cpPlugins/Interface/ImageToImageFilter.h index 5da8bf2..2cc56ae 100644 --- a/lib/cpPlugins/Interface/ImageToImageFilter.h +++ b/lib/cpPlugins/Interface/ImageToImageFilter.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( ImageToImageFilter, FilterObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: ImageToImageFilter( ); virtual ~ImageToImageFilter( ); diff --git a/lib/cpPlugins/Interface/ImageToMeshFilter.cxx b/lib/cpPlugins/Interface/ImageToMeshFilter.cxx index b2a2a29..ad53521 100644 --- a/lib/cpPlugins/Interface/ImageToMeshFilter.cxx +++ b/lib/cpPlugins/Interface/ImageToMeshFilter.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToMeshFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::ImageToMeshFilter" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToMeshFilter:: -GetClassType( ) const -{ - return( "ImageToMeshFilter" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::ImageToMeshFilter:: ImageToMeshFilter( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::ImageToMeshFilter"; + this->m_ClassCategory = "ImageToMeshFilter"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/ImageToMeshFilter.h b/lib/cpPlugins/Interface/ImageToMeshFilter.h index 70dc9a2..f919c96 100644 --- a/lib/cpPlugins/Interface/ImageToMeshFilter.h +++ b/lib/cpPlugins/Interface/ImageToMeshFilter.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( ImageToMeshFilter, FilterObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: ImageToMeshFilter( ); virtual ~ImageToMeshFilter( ); diff --git a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx deleted file mode 100644 index 85c03c1..0000000 --- a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.cxx +++ /dev/null @@ -1,30 +0,0 @@ -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::ImageToPolyLineParametricPathFilter" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: -GetClassType( ) const -{ - return( "ImageToPolyLineParametricPathFilter" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: -ImageToPolyLineParametricPathFilter( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::ImageToPolyLineParametricPathFilter:: -~ImageToPolyLineParametricPathFilter( ) -{ -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h b/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h deleted file mode 100644 index 716bfad..0000000 --- a/lib/cpPlugins/Interface/ImageToPolyLineParametricPathFilter.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__IMAGETOPOLYLINEPARAMETRICPATHFILTER__H__ -#define __CPPLUGINS__INTERFACE__IMAGETOPOLYLINEPARAMETRICPATHFILTER__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT ImageToPolyLineParametricPathFilter - : public FilterObject - { - public: - typedef ImageToPolyLineParametricPathFilter Self; - typedef FilterObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkTypeMacro( ImageToPolyLineParametricPathFilter, FilterObject ); - - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - - protected: - ImageToPolyLineParametricPathFilter( ); - virtual ~ImageToPolyLineParametricPathFilter( ); - - private: - // Purposely not implemented - ImageToPolyLineParametricPathFilter( const Self& ); - Self& operator=( const Self& ); - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__INTERFACE__IMAGETOPOLYLINEPARAMETRICPATHFILTER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Instances_itkImage.cxx b/lib/cpPlugins/Interface/Instances_itkImage.cxx index ba4d66e..f33d8d4 100644 --- a/lib/cpPlugins/Interface/Instances_itkImage.cxx +++ b/lib/cpPlugins/Interface/Instances_itkImage.cxx @@ -1,69 +1,124 @@ +#undef ITK_MANUAL_INSTANTIATION #include +#include #include +#include +#include +#include +#include #include // ------------------------------------------------------------------------- -#define cpPlugins_Instance_itkImage( t, d ) \ - template class itk::Image< t, d >; \ - template class itk::Image< itk::RGBPixel< t >, d > +#define cpPlugins_Instance_itkImage_Pixel( p, d ) \ + template class itk::Image< p, d >; \ + template class itk::ImageToVTKImageFilter< itk::Image< p, d > > // ------------------------------------------------------------------------- -#define cpPlugins_Instance_itkImage2vtkImage( t, d ) \ - template class itk::ImageToVTKImageFilter< itk::Image< t, d > >; \ +#define cpPlugins_Instance_itkImage_RGB( p, d ) \ + cpPlugins_Instance_itkImage_Pixel( itk::RGBPixel< p >, d ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Instance_itkImage_RGBA( p, d ) \ + cpPlugins_Instance_itkImage_Pixel( itk::RGBAPixel< p >, d ) + +// ------------------------------------------------------------------------- +#define cpPlugins_Instance_itkImage_Vector( p, d ) \ + template class itk::Image< itk::Vector< p, d >, d >; \ template class \ - itk::ImageToVTKImageFilter< itk::Image< itk::RGBPixel< t >, d > > + itk::ImageToVTKImageFilter< itk::Image< itk::Vector< p, d >, d > > // ------------------------------------------------------------------------- -#define cpPlugins_Instance_All_itkImage( t, d ) \ - cpPlugins_Instance_itkImage( t, d ); \ - cpPlugins_Instance_itkImage2vtkImage( t, d ) +#define cpPlugins_Instance_itkImage_CovVector( p, d ) \ + template class itk::Image< itk::CovariantVector< p, d >, d >; \ + template class \ + itk::ImageToVTKImageFilter< itk::Image< itk::CovariantVector< p, d >, d > > // ------------------------------------------------------------------------- -// Images without vtk conversion -cpPlugins_Instance_itkImage( char, 1 ); -cpPlugins_Instance_itkImage( short, 1 ); -cpPlugins_Instance_itkImage( int, 1 ); -cpPlugins_Instance_itkImage( long, 1 ); -cpPlugins_Instance_itkImage( unsigned char, 1 ); -cpPlugins_Instance_itkImage( unsigned short, 1 ); -cpPlugins_Instance_itkImage( unsigned int, 1 ); -cpPlugins_Instance_itkImage( unsigned long, 1 ); -cpPlugins_Instance_itkImage( float, 1 ); -cpPlugins_Instance_itkImage( double, 1 ); +#define cpPlugins_Instance_itkImage_SymTensor( p, d ) \ + template class itk::Image< itk::SymmetricSecondRankTensor< p, d >, d >; \ + template class \ + itk::ImageToVTKImageFilter< itk::Image< itk::SymmetricSecondRankTensor< p, d >, d > > -cpPlugins_Instance_itkImage( char, 4 ); -cpPlugins_Instance_itkImage( short, 4 ); -cpPlugins_Instance_itkImage( int, 4 ); -cpPlugins_Instance_itkImage( long, 4 ); -cpPlugins_Instance_itkImage( unsigned char, 4 ); -cpPlugins_Instance_itkImage( unsigned short, 4 ); -cpPlugins_Instance_itkImage( unsigned int, 4 ); -cpPlugins_Instance_itkImage( unsigned long, 4 ); -cpPlugins_Instance_itkImage( float, 4 ); -cpPlugins_Instance_itkImage( double, 4 ); +// ------------------------------------------------------------------------- +#define cpPlugins_Instance_itkImage_DiffTensor( p, d ) \ + cpPlugins_Instance_itkImage_Pixel( itk::DiffusionTensor3D< p >, d ) // ------------------------------------------------------------------------- -// Images with vtk conversion -cpPlugins_Instance_All_itkImage( char, 2 ); -cpPlugins_Instance_All_itkImage( short, 2 ); -cpPlugins_Instance_All_itkImage( int, 2 ); -cpPlugins_Instance_All_itkImage( long, 2 ); -cpPlugins_Instance_All_itkImage( unsigned char, 2 ); -cpPlugins_Instance_All_itkImage( unsigned short, 2 ); -cpPlugins_Instance_All_itkImage( unsigned int, 2 ); -cpPlugins_Instance_All_itkImage( unsigned long, 2 ); -cpPlugins_Instance_All_itkImage( float, 2 ); -cpPlugins_Instance_All_itkImage( double, 2 ); +#define cpPlugins_Instance_itkImage_DIM( d ) \ + cpPlugins_Instance_itkImage_Pixel( char, d ); \ + cpPlugins_Instance_itkImage_Pixel( short, d ); \ + cpPlugins_Instance_itkImage_Pixel( int, d ); \ + cpPlugins_Instance_itkImage_Pixel( long, d ); \ + cpPlugins_Instance_itkImage_Pixel( float, d ); \ + cpPlugins_Instance_itkImage_Pixel( double, d ); \ + cpPlugins_Instance_itkImage_Pixel( unsigned char, d ); \ + cpPlugins_Instance_itkImage_Pixel( unsigned short, d ); \ + cpPlugins_Instance_itkImage_Pixel( unsigned int, d ); \ + cpPlugins_Instance_itkImage_Pixel( unsigned long, d ); \ + cpPlugins_Instance_itkImage_RGB( char, d ); \ + cpPlugins_Instance_itkImage_RGB( short, d ); \ + cpPlugins_Instance_itkImage_RGB( int, d ); \ + cpPlugins_Instance_itkImage_RGB( long, d ); \ + cpPlugins_Instance_itkImage_RGB( float, d ); \ + cpPlugins_Instance_itkImage_RGB( double, d ); \ + cpPlugins_Instance_itkImage_RGB( unsigned char, d ); \ + cpPlugins_Instance_itkImage_RGB( unsigned short, d ); \ + cpPlugins_Instance_itkImage_RGB( unsigned int, d ); \ + cpPlugins_Instance_itkImage_RGB( unsigned long, d ); \ + cpPlugins_Instance_itkImage_RGBA( char, d ); \ + cpPlugins_Instance_itkImage_RGBA( short, d ); \ + cpPlugins_Instance_itkImage_RGBA( int, d ); \ + cpPlugins_Instance_itkImage_RGBA( long, d ); \ + cpPlugins_Instance_itkImage_RGBA( float, d ); \ + cpPlugins_Instance_itkImage_RGBA( double, d ); \ + cpPlugins_Instance_itkImage_RGBA( unsigned char, d ); \ + cpPlugins_Instance_itkImage_RGBA( unsigned short, d ); \ + cpPlugins_Instance_itkImage_RGBA( unsigned int, d ); \ + cpPlugins_Instance_itkImage_RGBA( unsigned long, d ); \ + cpPlugins_Instance_itkImage_Vector( char, d ); \ + cpPlugins_Instance_itkImage_Vector( short, d ); \ + cpPlugins_Instance_itkImage_Vector( int, d ); \ + cpPlugins_Instance_itkImage_Vector( long, d ); \ + cpPlugins_Instance_itkImage_Vector( float, d ); \ + cpPlugins_Instance_itkImage_Vector( double, d ); \ + cpPlugins_Instance_itkImage_Vector( unsigned char, d ); \ + cpPlugins_Instance_itkImage_Vector( unsigned short, d ); \ + cpPlugins_Instance_itkImage_Vector( unsigned int, d ); \ + cpPlugins_Instance_itkImage_Vector( unsigned long, d ); \ + cpPlugins_Instance_itkImage_CovVector( char, d ); \ + cpPlugins_Instance_itkImage_CovVector( short, d ); \ + cpPlugins_Instance_itkImage_CovVector( int, d ); \ + cpPlugins_Instance_itkImage_CovVector( long, d ); \ + cpPlugins_Instance_itkImage_CovVector( float, d ); \ + cpPlugins_Instance_itkImage_CovVector( double, d ); \ + cpPlugins_Instance_itkImage_CovVector( unsigned char, d ); \ + cpPlugins_Instance_itkImage_CovVector( unsigned short, d ); \ + cpPlugins_Instance_itkImage_CovVector( unsigned int, d ); \ + cpPlugins_Instance_itkImage_CovVector( unsigned long, d ); \ + cpPlugins_Instance_itkImage_SymTensor( char, d ); \ + cpPlugins_Instance_itkImage_SymTensor( short, d ); \ + cpPlugins_Instance_itkImage_SymTensor( int, d ); \ + cpPlugins_Instance_itkImage_SymTensor( long, d ); \ + cpPlugins_Instance_itkImage_SymTensor( float, d ); \ + cpPlugins_Instance_itkImage_SymTensor( double, d ); \ + cpPlugins_Instance_itkImage_SymTensor( unsigned char, d ); \ + cpPlugins_Instance_itkImage_SymTensor( unsigned short, d ); \ + cpPlugins_Instance_itkImage_SymTensor( unsigned int, d ); \ + cpPlugins_Instance_itkImage_SymTensor( unsigned long, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( char, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( short, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( int, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( long, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( float, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( double, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( unsigned char, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( unsigned short, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( unsigned int, d ); \ + cpPlugins_Instance_itkImage_DiffTensor( unsigned long, d ); -cpPlugins_Instance_All_itkImage( char, 3 ); -cpPlugins_Instance_All_itkImage( short, 3 ); -cpPlugins_Instance_All_itkImage( int, 3 ); -cpPlugins_Instance_All_itkImage( long, 3 ); -cpPlugins_Instance_All_itkImage( unsigned char, 3 ); -cpPlugins_Instance_All_itkImage( unsigned short, 3 ); -cpPlugins_Instance_All_itkImage( unsigned int, 3 ); -cpPlugins_Instance_All_itkImage( unsigned long, 3 ); -cpPlugins_Instance_All_itkImage( float, 3 ); -cpPlugins_Instance_All_itkImage( double, 3 ); +// ------------------------------------------------------------------------- +cpPlugins_Instance_itkImage_DIM( 1 ); +cpPlugins_Instance_itkImage_DIM( 2 ); +cpPlugins_Instance_itkImage_DIM( 3 ); // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Instances_itkMesh.cxx b/lib/cpPlugins/Interface/Instances_itkMesh.cxx index 14952cc..575db64 100644 --- a/lib/cpPlugins/Interface/Instances_itkMesh.cxx +++ b/lib/cpPlugins/Interface/Instances_itkMesh.cxx @@ -1,10 +1,14 @@ -/* TODO - #include +#undef ITK_MANUAL_INSTANTIATION +#include +#include - template class itk::Mesh< float, 2 >; - template class itk::Mesh< double, 2 >; - template class itk::Mesh< float, 3 >; - template class itk::Mesh< double, 3 >; -*/ +template class itk::Mesh< float, 2 >; +template class itk::Mesh< float, 3 >; +template class itk::Mesh< double, 2 >; +template class itk::Mesh< double, 3 >; +template class itk::QuadEdgeMesh< float, 2 >; +template class itk::QuadEdgeMesh< float, 3 >; +template class itk::QuadEdgeMesh< double, 2 >; +template class itk::QuadEdgeMesh< double, 3 >; // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx b/lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx deleted file mode 100644 index 9c450fd..0000000 --- a/lib/cpPlugins/Interface/Instances_itkPolyLineParametricPath.cxx +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - -template class itk::PolyLineParametricPath< 1 >; -template class itk::PolyLineParametricPath< 2 >; -template class itk::PolyLineParametricPath< 3 >; -template class itk::PolyLineParametricPath< 4 >; - -template class -itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 1 > >; -template class -itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 2 > >; -template class -itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 3 > >; -template class -itk::VectorContainer< unsigned int, itk::ContinuousIndex< double, 4 > >; - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Interface.h b/lib/cpPlugins/Interface/Interface.h index 585e2d5..a51f8be 100644 --- a/lib/cpPlugins/Interface/Interface.h +++ b/lib/cpPlugins/Interface/Interface.h @@ -29,7 +29,7 @@ namespace cpPlugins Interface( ); virtual ~Interface( ); - /// Plugin access + // Plugin access TClasses& GetClasses( ); const TClasses& GetClasses( ) const; Object::Pointer CreateObject( const std::string& name ) const; @@ -37,7 +37,7 @@ namespace cpPlugins const std::string& name ) const; - /// Interface to PLUMA + // Interface to PLUMA bool Load( const std::string& path ); bool Load( const std::string& folder, const std::string& name ); int LoadFromFolder( const std::string& folder, bool r = false ); diff --git a/lib/cpPlugins/Interface/Mesh.cxx b/lib/cpPlugins/Interface/Mesh.cxx index 9841f7e..c052e6a 100644 --- a/lib/cpPlugins/Interface/Mesh.cxx +++ b/lib/cpPlugins/Interface/Mesh.cxx @@ -1,72 +1,87 @@ #include -#include - -#include -#include +#include // ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Mesh:: -GetClassName( ) const +void cpPlugins::Interface::Mesh:: +SetITKDataObject( itk::DataObject* o ) { - return( "cpPlugins::Interface::Mesh" ); + // TODO: conversion!!! + std::cout << "Mesh: SetITKDataObject " << std::endl; + std::exit( 1 ); } // ------------------------------------------------------------------------- void cpPlugins::Interface::Mesh:: -SetRealDataObject( itk::DataObject* dobj ) +SetVTKDataObject( vtkDataObject* o ) { - this->Superclass::SetRealDataObject( dobj ); + if( dynamic_cast< vtkPolyData* >( o ) != NULL ) + { + this->m_VTKObject = o; - // NOTE: Only 2 and 3 dimensions at this moment - using namespace cpPlugins::Extensions; - typedef DataStructures::QuadEdgeMesh< float, 2 > _TF2; - typedef DataStructures::QuadEdgeMesh< double, 2 > _TD2; - typedef DataStructures::QuadEdgeMesh< float, 3 > _TF3; - typedef DataStructures::QuadEdgeMesh< double, 3 > _TD3; + // TODO: conversion!!! + } + else + this->m_VTKObject = NULL; +} - if ( dynamic_cast< _TF2* >( dobj ) ) this->_Map< _TF2 >( ); - else if( dynamic_cast< _TD2* >( dobj ) ) this->_Map< _TD2 >( ); - else if( dynamic_cast< _TF3* >( dobj ) ) this->_Map< _TF3 >( ); - else if( dynamic_cast< _TD3* >( dobj ) ) this->_Map< _TD3 >( ); +// ------------------------------------------------------------------------- +vtkPolyData* cpPlugins::Interface::Mesh:: +GetVTKPolyData( ) +{ + return( dynamic_cast< vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) ); } // ------------------------------------------------------------------------- -vtkMapper* cpPlugins::Interface::Mesh:: -GetVTKMapper( ) const +const vtkPolyData* cpPlugins::Interface::Mesh:: +GetVTKPolyData( ) const { - return( this->m_Mapper ); + return( + dynamic_cast< const vtkPolyData* >( this->m_VTKObject.GetPointer( ) ) + ); } // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: Mesh( ) - : Superclass( ), - m_Mapper( NULL ) + : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::Mesh"; + this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- cpPlugins::Interface::Mesh:: ~Mesh( ) { - if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); } // ------------------------------------------------------------------------- -template< class M > +template< unsigned int D > void cpPlugins::Interface::Mesh:: -_Map( ) +_ITK_2_VTK_0( itk::DataObject* o ) { - typedef - cpPlugins::Extensions::Visualization::OpenGLMeshMapper< M > - _TMapper; +} - if( this->m_Mapper != NULL ) this->m_Mapper->Delete( ); - M* mesh = dynamic_cast< M* >( this->Superclass::GetRealDataObject( ) ); - _TMapper* mapper = _TMapper::New( ); - mapper->SetInputData( mesh ); - this->m_Mapper = mapper; +// ------------------------------------------------------------------------- +template< class P, unsigned int D > +void cpPlugins::Interface::Mesh:: +_ITK_2_VTK_1( itk::DataObject* o ) +{ +} + +// ------------------------------------------------------------------------- +template< unsigned int D > +void cpPlugins::Interface::Mesh:: +_VTK_2_ITK_0( itk::DataObject* o ) +{ +} + +// ------------------------------------------------------------------------- +template< class P, unsigned int D > +void cpPlugins::Interface::Mesh:: +_VTK_2_ITK_1( itk::DataObject* o ) +{ } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/Mesh.h b/lib/cpPlugins/Interface/Mesh.h index a1f0677..ffaec80 100644 --- a/lib/cpPlugins/Interface/Mesh.h +++ b/lib/cpPlugins/Interface/Mesh.h @@ -1,13 +1,10 @@ #ifndef __CPPLUGINS__INTERFACE__MESH__H__ #define __CPPLUGINS__INTERFACE__MESH__H__ -#include -#include -#include #include #include -class vtkMapper; +class vtkPolyData; namespace cpPlugins { @@ -29,25 +26,32 @@ namespace cpPlugins itkTypeMacro( Mesh, DataObject ); public: - virtual std::string GetClassName( ) const; - virtual void SetRealDataObject( itk::DataObject* dobj ); + virtual void SetITKDataObject( itk::DataObject* o ); + virtual void SetVTKDataObject( vtkDataObject* o ); - vtkMapper* GetVTKMapper( ) const; + vtkPolyData* GetVTKPolyData( ); + const vtkPolyData* GetVTKPolyData( ) const; protected: Mesh( ); virtual ~Mesh( ); - template< class M > - void _Map( ); + template< unsigned int D > + void _ITK_2_VTK_0( itk::DataObject* o ); + + template< class P, unsigned int D > + void _ITK_2_VTK_1( itk::DataObject* o ); + + template< unsigned int D > + void _VTK_2_ITK_0( itk::DataObject* o ); + + template< class P, unsigned int D > + void _VTK_2_ITK_1( itk::DataObject* o ); private: // Purposely not implemented Mesh( const Self& ); Self& operator=( const Self& ); - - protected: - vtkMapper* m_Mapper; }; } // ecapseman diff --git a/lib/cpPlugins/Interface/MeshSink.cxx b/lib/cpPlugins/Interface/MeshSink.cxx index dffacef..e27259e 100644 --- a/lib/cpPlugins/Interface/MeshSink.cxx +++ b/lib/cpPlugins/Interface/MeshSink.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshSink:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::MeshSink" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshSink:: -GetClassType( ) const -{ - return( "MeshSink" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::MeshSink:: MeshSink( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::MeshSink"; + this->m_ClassCategory = "MeshSink"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/MeshSink.h b/lib/cpPlugins/Interface/MeshSink.h index 5eab768..3438e3a 100644 --- a/lib/cpPlugins/Interface/MeshSink.h +++ b/lib/cpPlugins/Interface/MeshSink.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( MeshSink, SinkObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: MeshSink( ); virtual ~MeshSink( ); diff --git a/lib/cpPlugins/Interface/MeshSource.cxx b/lib/cpPlugins/Interface/MeshSource.cxx index c608147..91d7ed3 100644 --- a/lib/cpPlugins/Interface/MeshSource.cxx +++ b/lib/cpPlugins/Interface/MeshSource.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshSource:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::MeshSource" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshSource:: -GetClassType( ) const -{ - return( "MeshSource" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::MeshSource:: MeshSource( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::MeshSource"; + this->m_ClassCategory = "MeshSource"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/MeshSource.h b/lib/cpPlugins/Interface/MeshSource.h index 745f62d..fe1a979 100644 --- a/lib/cpPlugins/Interface/MeshSource.h +++ b/lib/cpPlugins/Interface/MeshSource.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( MeshSource, SourceObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: MeshSource( ); virtual ~MeshSource( ); diff --git a/lib/cpPlugins/Interface/MeshToImageFilter.cxx b/lib/cpPlugins/Interface/MeshToImageFilter.cxx index 804a381..394b9f9 100644 --- a/lib/cpPlugins/Interface/MeshToImageFilter.cxx +++ b/lib/cpPlugins/Interface/MeshToImageFilter.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshToImageFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::MeshToImageFilter" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshToImageFilter:: -GetClassType( ) const -{ - return( "MeshToImageFilter" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::MeshToImageFilter:: MeshToImageFilter( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::MeshToImageFilter"; + this->m_ClassCategory = "MeshToImageFilter"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/MeshToImageFilter.h b/lib/cpPlugins/Interface/MeshToImageFilter.h index e8f0b83..698ad0a 100644 --- a/lib/cpPlugins/Interface/MeshToImageFilter.h +++ b/lib/cpPlugins/Interface/MeshToImageFilter.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( MeshToImageFilter, FilterObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: MeshToImageFilter( ); virtual ~MeshToImageFilter( ); diff --git a/lib/cpPlugins/Interface/MeshToMeshFilter.cxx b/lib/cpPlugins/Interface/MeshToMeshFilter.cxx index 4f5c76f..df88b17 100644 --- a/lib/cpPlugins/Interface/MeshToMeshFilter.cxx +++ b/lib/cpPlugins/Interface/MeshToMeshFilter.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshToMeshFilter:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::MeshToMeshFilter" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::MeshToMeshFilter:: -GetClassType( ) const -{ - return( "MeshToMeshFilter" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::MeshToMeshFilter:: MeshToMeshFilter( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::MeshToMeshFilter"; + this->m_ClassCategory = "MeshToMeshFilter"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/MeshToMeshFilter.h b/lib/cpPlugins/Interface/MeshToMeshFilter.h index d47197f..399c3f7 100644 --- a/lib/cpPlugins/Interface/MeshToMeshFilter.h +++ b/lib/cpPlugins/Interface/MeshToMeshFilter.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( MeshToMeshFilter, FilterObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: MeshToMeshFilter( ); virtual ~MeshToMeshFilter( ); diff --git a/lib/cpPlugins/Interface/Object.cxx b/lib/cpPlugins/Interface/Object.cxx index 1792a50..b4768fa 100644 --- a/lib/cpPlugins/Interface/Object.cxx +++ b/lib/cpPlugins/Interface/Object.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Object:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::Object" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::Object:: -GetClassType( ) const -{ - return( "Object" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::Object:: Object( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::Object"; + this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- diff --git a/lib/cpPlugins/Interface/Object.h b/lib/cpPlugins/Interface/Object.h index fe86f1b..b133fe7 100644 --- a/lib/cpPlugins/Interface/Object.h +++ b/lib/cpPlugins/Interface/Object.h @@ -3,9 +3,11 @@ #include #include +#include + +#define ITK_MANUAL_INSTANTIATION #include #include -#include // ------------------------------------------------------------------------- #define CPPLUGINS_PROVIDER_HEADER_BEGIN( TYPE ) \ @@ -70,8 +72,8 @@ namespace cpPlugins itkTypeMacro( Object, itkObject ); public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; + itkGetConstMacro( ClassName, std::string ); + itkGetConstMacro( ClassCategory, std::string ); protected: Object( ); @@ -81,6 +83,10 @@ namespace cpPlugins // Purposely not implemented Object( const Self& ); Self& operator=( const Self& ); + + protected: + std::string m_ClassName; + std::string m_ClassCategory; }; /** diff --git a/lib/cpPlugins/Interface/PolyData.cxx b/lib/cpPlugins/Interface/PolyData.cxx deleted file mode 100644 index 5abcd19..0000000 --- a/lib/cpPlugins/Interface/PolyData.cxx +++ /dev/null @@ -1,65 +0,0 @@ - -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::PolyData:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::PolyData" ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::PolyData:: -SetRealDataObject( itk::DataObject* dobj ) -{ - // Nothing to be done here -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::PolyData:: -SetRealDataObject( vtkDataObject* dobj ) -{ - this->m_Data = dynamic_cast< vtkPolyData* >( dobj ); - if( this->m_Data == NULL ) - return; - this->m_Mapper->SetInputData( this->m_Data ); - this->m_Actor->SetMapper( this->m_Mapper ); -} - -// ------------------------------------------------------------------------- -vtkPolyData* cpPlugins::Interface::PolyData:: -GetData( ) const -{ - return( this->m_Data ); -} - -// ------------------------------------------------------------------------- -vtkPolyDataMapper* cpPlugins::Interface::PolyData:: -GetMapper( ) const -{ - return( this->m_Mapper ); -} - -// ------------------------------------------------------------------------- -vtkActor* cpPlugins::Interface::PolyData:: -GetActor( ) const -{ - return( this->m_Actor ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyData:: -PolyData( ) - : Superclass( ) -{ - this->m_Mapper = vtkSmartPointer< vtkPolyDataMapper >::New( ); - this->m_Actor = vtkSmartPointer< vtkActor >::New( ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyData:: -~PolyData( ) -{ -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyData.h b/lib/cpPlugins/Interface/PolyData.h deleted file mode 100644 index e5ead8c..0000000 --- a/lib/cpPlugins/Interface/PolyData.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__POLYDATA__H__ -#define __CPPLUGINS__INTERFACE__POLYDATA__H__ - -#include -#include - -#include -#include -#include -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT PolyData - : public DataObject - { - public: - typedef PolyData Self; - typedef DataObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( PolyData, DataObject ); - - public: - virtual std::string GetClassName( ) const; - virtual void SetRealDataObject( itk::DataObject* dobj ); - virtual void SetRealDataObject( vtkDataObject* dobj ); - - vtkPolyData* GetData( ) const; - vtkPolyDataMapper* GetMapper( ) const; - vtkActor* GetActor( ) const; - - protected: - PolyData( ); - virtual ~PolyData( ); - - private: - // Purposely not implemented - PolyData( const Self& ); - Self& operator=( const Self& ); - - protected: - vtkSmartPointer< vtkPolyData > m_Data; - vtkSmartPointer< vtkPolyDataMapper > m_Mapper; - vtkSmartPointer< vtkActor > m_Actor; - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__INTERFACE__POLYDATA__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyDataSource.cxx b/lib/cpPlugins/Interface/PolyDataSource.cxx deleted file mode 100644 index e8f32d8..0000000 --- a/lib/cpPlugins/Interface/PolyDataSource.cxx +++ /dev/null @@ -1,30 +0,0 @@ -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::PolyDataSource:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::PolyDataSource" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::PolyDataSource:: -GetClassType( ) const -{ - return( "PolyDataSource" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyDataSource:: -PolyDataSource( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyDataSource:: -~PolyDataSource( ) -{ -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyDataSource.h b/lib/cpPlugins/Interface/PolyDataSource.h deleted file mode 100644 index 0022048..0000000 --- a/lib/cpPlugins/Interface/PolyDataSource.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__POLYDATASOURCE__H__ -#define __CPPLUGINS__INTERFACE__POLYDATASOURCE__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT PolyDataSource - : public SourceObject - { - public: - typedef PolyDataSource Self; - typedef SourceObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkTypeMacro( PolyDataSource, SourceObject ); - - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - - protected: - PolyDataSource( ); - virtual ~PolyDataSource( ); - - private: - // Purposely not implemented - PolyDataSource( const Self& ); - Self& operator=( const Self& ); - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__INTERFACE__POLYDATASOURCE__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.cxx b/lib/cpPlugins/Interface/PolyLineParametricPath.cxx deleted file mode 100644 index 37be8af..0000000 --- a/lib/cpPlugins/Interface/PolyLineParametricPath.cxx +++ /dev/null @@ -1,107 +0,0 @@ -#include - -#include -#include - -#define ITK_MANUAL_INSTANTIATION -#include -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::PolyLineParametricPath:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::PolyLineParametricPath" ); -} - -// ------------------------------------------------------------------------- -void cpPlugins::Interface::PolyLineParametricPath:: -SetRealDataObject( itk::DataObject* dobj, itk::DataObject* ref_image ) -{ - typedef itk::PolyLineParametricPath< 2 > _T2; - typedef itk::PolyLineParametricPath< 3 > _T3; - - this->Superclass::SetRealDataObject( dobj ); - - if( ref_image != NULL ) - { - if( dynamic_cast< _T2* >( dobj ) != NULL ) - this->_VTK< 2 >( ref_image ); - else if( dynamic_cast< _T3* >( dobj ) != NULL ) - this->_VTK< 3 >( ref_image ); - - } // fi -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyLineParametricPath:: -PolyLineParametricPath( ) - : Superclass( ) -{ - this->m_PolyData = vtkSmartPointer< vtkPolyData >::New( ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyLineParametricPath:: -~PolyLineParametricPath( ) -{ -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -void cpPlugins::Interface::PolyLineParametricPath:: -_VTK( itk::DataObject* ref_image ) -{ - typedef itk::PolyLineParametricPath< D > _TPath; - typedef typename _TPath::VertexListType _TVertices; - typedef typename _TPath::ContinuousIndexType _TIndex; - typedef itk::ImageBase< D > _TImage; - typedef typename _TImage::PointType _TPoint; - - _TPath* path = - dynamic_cast< _TPath* >( this->m_RealDataObject.GetPointer( ) ); - if( path == NULL ) - return; - const _TVertices* vertices = path->GetVertexList( ); - if( vertices == NULL ) - return; - const _TImage* image = dynamic_cast< const _TImage* >( ref_image ); - - vtkSmartPointer< vtkPoints > points = - vtkSmartPointer< vtkPoints >::New( ); - vtkSmartPointer< vtkCellArray > lines = - vtkSmartPointer< vtkCellArray >::New( ); - double x, y, z; - for( unsigned int i = 0; i < vertices->Size( ); ++i ) - { - _TIndex idx = vertices->GetElement( i ); - if( image != NULL ) - { - _TPoint pnt; - image->TransformContinuousIndexToPhysicalPoint( idx, pnt ); - x = double( pnt[ 0 ] ); - y = double( pnt[ 1 ] ); - z = ( D >= 3 )? double( pnt[ 2 ] ): double( 0 ); - } - else - { - x = double( idx[ 0 ] ); - y = double( idx[ 1 ] ); - z = ( D >= 3 )? double( idx[ 2 ] ): double( 0 ); - - } // fi - points->InsertNextPoint( x, y, z ); - if( i > 0 ) - { - lines->InsertNextCell( 2 ); - lines->InsertCellPoint( i - 1 ); - lines->InsertCellPoint( i ); - - } // fi - - } // rof - this->m_PolyData->SetPoints( points ); - this->m_PolyData->SetLines( lines ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPath.h b/lib/cpPlugins/Interface/PolyLineParametricPath.h deleted file mode 100644 index 0c3268b..0000000 --- a/lib/cpPlugins/Interface/PolyLineParametricPath.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ -#define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ - -#include -#include -#include -#include -#include - -#include -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT PolyLineParametricPath - : public DataObject - { - public: - typedef PolyLineParametricPath Self; - typedef DataObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( PolyLineParametricPath, DataObject ); - - public: - virtual std::string GetClassName( ) const; - virtual void SetRealDataObject( - itk::DataObject* dobj, - itk::DataObject* ref_image = NULL - ); - - protected: - PolyLineParametricPath( ); - virtual ~PolyLineParametricPath( ); - - template< unsigned int D > - void _VTK( itk::DataObject* ref_image ); - - private: - // Purposely not implemented - PolyLineParametricPath( const Self& ); - Self& operator=( const Self& ); - - protected: - vtkSmartPointer< vtkPolyData > m_PolyData; - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATH__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPathSource.cxx b/lib/cpPlugins/Interface/PolyLineParametricPathSource.cxx deleted file mode 100644 index 4930491..0000000 --- a/lib/cpPlugins/Interface/PolyLineParametricPathSource.cxx +++ /dev/null @@ -1,30 +0,0 @@ -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::PolyLineParametricPathSource:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::PolyLineParametricPathSource" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::PolyLineParametricPathSource:: -GetClassType( ) const -{ - return( "PolyLineParametricPathSource" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyLineParametricPathSource:: -PolyLineParametricPathSource( ) - : Superclass( ) -{ -} - -// ------------------------------------------------------------------------- -cpPlugins::Interface::PolyLineParametricPathSource:: -~PolyLineParametricPathSource( ) -{ -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/PolyLineParametricPathSource.h b/lib/cpPlugins/Interface/PolyLineParametricPathSource.h deleted file mode 100644 index 59578bf..0000000 --- a/lib/cpPlugins/Interface/PolyLineParametricPathSource.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATHSOURCE__H__ -#define __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATHSOURCE__H__ - -#include -#include - -namespace cpPlugins -{ - namespace Interface - { - /** - */ - class cpPlugins_Interface_EXPORT PolyLineParametricPathSource - : public SourceObject - { - public: - typedef PolyLineParametricPathSource Self; - typedef SourceObject Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkTypeMacro( PolyLineParametricPathSource, SourceObject ); - - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - - protected: - PolyLineParametricPathSource( ); - virtual ~PolyLineParametricPathSource( ); - - private: - // Purposely not implemented - PolyLineParametricPathSource( const Self& ); - Self& operator=( const Self& ); - }; - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__INTERFACE__POLYLINEPARAMETRICPATHSOURCE__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObject.cxx b/lib/cpPlugins/Interface/ProcessObject.cxx index 61eaf96..c6271ca 100644 --- a/lib/cpPlugins/Interface/ProcessObject.cxx +++ b/lib/cpPlugins/Interface/ProcessObject.cxx @@ -1,19 +1,5 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ProcessObject:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::ProcessObject" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::ProcessObject:: -GetClassType( ) const -{ - return( "ProcessObject" ); -} - // ------------------------------------------------------------------------- const cpPlugins::Interface::Parameters& cpPlugins::Interface::ProcessObject:: @@ -121,6 +107,8 @@ cpPlugins::Interface::ProcessObject:: ProcessObject( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::ProcessObject"; + this->m_ClassCategory = "BasicObject"; } // ------------------------------------------------------------------------- @@ -130,22 +118,24 @@ cpPlugins::Interface::ProcessObject:: } // ------------------------------------------------------------------------- -itk::DataObject* cpPlugins::Interface::ProcessObject:: -_GetInput( unsigned int idx ) -{ - if( idx < this->m_Inputs.size( ) ) - return( this->m_Inputs[ idx ]->GetRealDataObject( ) ); - else - return( NULL ); -} +/* TODO + itk::DataObject* cpPlugins::Interface::ProcessObject:: + _GetInput( unsigned int idx ) + { + if( idx < this->m_Inputs.size( ) ) + return( this->m_Inputs[ idx ]->GetRealDataObject( ) ); + else + return( NULL ); + } -// ------------------------------------------------------------------------- -void cpPlugins::Interface::ProcessObject:: -_SetOutput( unsigned int idx, itk::DataObject* dobj ) -{ - if( idx < this->m_Outputs.size( ) ) - if( this->m_Outputs[ idx ].IsNotNull( ) ) - this->m_Outputs[ idx ]->SetRealDataObject( dobj ); -} + // ------------------------------------------------------------------------- + void cpPlugins::Interface::ProcessObject:: + _SetOutput( unsigned int idx, itk::DataObject* dobj ) + { + if( idx < this->m_Outputs.size( ) ) + if( this->m_Outputs[ idx ].IsNotNull( ) ) + this->m_Outputs[ idx ]->SetRealDataObject( dobj ); + } +*/ // eof - $RCSfile$ diff --git a/lib/cpPlugins/Interface/ProcessObject.h b/lib/cpPlugins/Interface/ProcessObject.h index a977928..7cf6376 100644 --- a/lib/cpPlugins/Interface/ProcessObject.h +++ b/lib/cpPlugins/Interface/ProcessObject.h @@ -1,12 +1,14 @@ #ifndef __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ #define __CPPLUGINS__INTERFACE__PROCESSOBJECT__H__ -#include #include #include #include #include +#define ITK_MANUAL_INSTANTIATION +#include + namespace cpPlugins { namespace Interface @@ -26,8 +28,6 @@ namespace cpPlugins itkTypeMacro( ProcessObject, Object ); public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; virtual const Parameters& GetDefaultParameters( ) const; virtual void SetParameters( const Parameters& params ); @@ -47,17 +47,19 @@ namespace cpPlugins ProcessObject( ); virtual ~ProcessObject( ); - virtual itk::DataObject* _GetInput( unsigned int idx ); - virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj ); + /* TODO + virtual itk::DataObject* _GetInput( unsigned int idx ); + virtual void _SetOutput( unsigned int idx, itk::DataObject* dobj ); + */ template< class O > - void _MakeOutput( unsigned int idx ) - { - if( idx >= this->m_Outputs.size( ) ) - return; - this->m_Outputs[ idx ] = O::New( ); - this->m_Outputs[ idx ]->SetSource( this ); - } + void _MakeOutput( unsigned int idx ) + { + if( idx >= this->m_Outputs.size( ) ) + return; + this->m_Outputs[ idx ] = O::New( ); + this->m_Outputs[ idx ]->SetSource( this ); + } virtual std::string _GenerateData( ) = 0; diff --git a/lib/cpPlugins/Interface/SinkObject.cxx b/lib/cpPlugins/Interface/SinkObject.cxx index 309a3d1..6fdaf4c 100644 --- a/lib/cpPlugins/Interface/SinkObject.cxx +++ b/lib/cpPlugins/Interface/SinkObject.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::SinkObject:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::SinkObject" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::SinkObject:: -GetClassType( ) const -{ - return( "SinkObject" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::SinkObject:: SinkObject( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::SinkObject"; + this->m_ClassCategory = "BasicObject"; this->SetNumberOfOutputs( 0 ); } diff --git a/lib/cpPlugins/Interface/SinkObject.h b/lib/cpPlugins/Interface/SinkObject.h index 4edc44c..b03fb9d 100644 --- a/lib/cpPlugins/Interface/SinkObject.h +++ b/lib/cpPlugins/Interface/SinkObject.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( SinkObject, ProcessObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: SinkObject( ); virtual ~SinkObject( ); diff --git a/lib/cpPlugins/Interface/SourceObject.cxx b/lib/cpPlugins/Interface/SourceObject.cxx index 9ad0878..bcead3a 100644 --- a/lib/cpPlugins/Interface/SourceObject.cxx +++ b/lib/cpPlugins/Interface/SourceObject.cxx @@ -1,24 +1,12 @@ #include -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::SourceObject:: -GetClassName( ) const -{ - return( "cpPlugins::Interface::SourceObject" ); -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Interface::SourceObject:: -GetClassType( ) const -{ - return( "SourceObject" ); -} - // ------------------------------------------------------------------------- cpPlugins::Interface::SourceObject:: SourceObject( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::Interface::SourceObject"; + this->m_ClassCategory = "BasicObject"; this->SetNumberOfInputs( 0 ); } diff --git a/lib/cpPlugins/Interface/SourceObject.h b/lib/cpPlugins/Interface/SourceObject.h index ecb528c..5a030b2 100644 --- a/lib/cpPlugins/Interface/SourceObject.h +++ b/lib/cpPlugins/Interface/SourceObject.h @@ -22,10 +22,6 @@ namespace cpPlugins public: itkTypeMacro( SourceObject, ProcessObject ); - public: - virtual std::string GetClassName( ) const; - virtual std::string GetClassType( ) const; - protected: SourceObject( ); virtual ~SourceObject( ); diff --git a/lib/cpPlugins/Plugins/CMakeLists.txt b/lib/cpPlugins/Plugins/CMakeLists.txt index e8e9d5e..09b4b5a 100644 --- a/lib/cpPlugins/Plugins/CMakeLists.txt +++ b/lib/cpPlugins/Plugins/CMakeLists.txt @@ -4,12 +4,31 @@ 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") + +#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") + +SET( + LIB_HEADERS_H + ImageReader.h + ImageWriter.h + MeshReader.h + MeshWriter.h + MarchingCubes.h + ) +SET( + LIB_SOURCES_CXX + Host.cxx + ImageReader.cxx + ImageWriter.cxx + MeshReader.cxx + MeshWriter.cxx + MarchingCubes.cxx + ) ## ===================== ## = Compilation rules = diff --git a/lib/cpPlugins/Plugins/Host.cxx b/lib/cpPlugins/Plugins/Host.cxx index ad93e89..44f2257 100644 --- a/lib/cpPlugins/Plugins/Host.cxx +++ b/lib/cpPlugins/Plugins/Host.cxx @@ -1,27 +1,36 @@ #include #include -#include #include -#include #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 ImageSeriesReaderProvider( ) ); host.add( new ImageWriterProvider( ) ); + host.add( new MeshReaderProvider( ) ); + host.add( new MeshWriterProvider( ) ); host.add( new MarchingCubesProvider( ) ); +/* + host.add( new ImageSeriesReaderProvider( ) ); host.add( new MeshReaderProvider( ) ); host.add( new PolyDataReaderProvider( ) ); host.add( new RGBImageToHSVChannelsFilterProvider( ) ); host.add( new RGBImageToYPbPrChannelsFilterProvider( ) ); +*/ return( true ); } diff --git a/lib/cpPlugins/Plugins/ImageReader.cxx b/lib/cpPlugins/Plugins/ImageReader.cxx index da7b949..2d1ae04 100644 --- a/lib/cpPlugins/Plugins/ImageReader.cxx +++ b/lib/cpPlugins/Plugins/ImageReader.cxx @@ -1,36 +1,27 @@ #include #include -#include -#include +#include -#define ITK_MANUAL_INSTANTIATION +#undef ITK_MANUAL_INSTANTIATION #include #include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::ImageReader" ); -} +#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_DefaultParameters.Configure( Parameters::String, "PixelType" ); - this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" ); - this->m_DefaultParameters.Configure( Parameters::Uint, "IsColorImage" ); - this->m_DefaultParameters.SetValueAsString( "PixelType", "uchar" ); - this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 ); - this->m_DefaultParameters.SetValueAsUint( "IsColorImage", 0 ); this->m_Parameters = this->m_DefaultParameters; } @@ -44,157 +35,225 @@ cpPlugins::Plugins::ImageReader:: std::string cpPlugins::Plugins::ImageReader:: _GenerateData( ) { - using namespace cpPlugins::Interface; - Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" ); - std::string r = "cpPlugins::Plugins::ImageReader: itk::Image dimension not supported."; - if ( dim == 1 ) r = this->_GD0< 1 >( ); - else if( dim == 2 ) r = this->_GD0< 2 >( ); - else if( dim == 3 ) r = this->_GD0< 3 >( ); - else if( dim == 4 ) r = this->_GD0< 4 >( ); + // 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 1: r = this->_GD0< 1 >( io, names ); break; + case 2: r = this->_GD0< 2 >( io, names ); break; + case 3: r = this->_GD0< 3 >( io, names ); break; + default: + r = "ImageReader: Image dimension not supported."; + break; + } // hctiws + } + else if( names.size( ) > 1 ) + { + switch( io->GetNumberOfDimensions( ) ) + { + case 1: r = this->_GD0< 2 >( io, names ); break; + case 2: r = this->_GD0< 3 >( 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( ) +_GD0( itk::ImageIOBase* io, const TStringList& names ) { - using namespace cpPlugins::Interface; - Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" ); - Parameters::TUint ci = this->m_Parameters.GetValueAsUint( "IsColorImage" ); - - std::string r = "cpPlugins::Plugins::ImageReader: itk::Image pixel type not supported"; - if( ci == 0 ) - { - if( pt == "char" ) - r = this->_GD1< char, D >( ); - else if( pt == "short" ) - r = this->_GD1< short, D >( ); - else if( pt == "int" ) - r = this->_GD1< int, D >( ); - else if( pt == "long" ) - r = this->_GD1< long, D >( ); - else if( pt == "uchar" ) - r = this->_GD1< unsigned char, D >( ); - else if( pt == "ushort" ) - r = this->_GD1< unsigned short, D >( ); - else if( pt == "uint" ) - r = this->_GD1< unsigned int, D >( ); - else if( pt == "ulong" ) - r = this->_GD1< unsigned long, D >( ); - else if( pt == "float" ) - r = this->_GD1< float, D >( ); - else if( pt == "double" ) - r = this->_GD1< double, D >( ); - } - else + std::string r = ""; + switch( io->GetComponentType( ) ) { - if( pt == "char" ) - r = this->_GD1< itk::RGBPixel< char >, D >( ); - else if( pt == "short" ) - r = this->_GD1< itk::RGBPixel< short >, D >( ); - else if( pt == "int" ) - r = this->_GD1< itk::RGBPixel< int >, D >( ); - else if( pt == "long" ) - r = this->_GD1< itk::RGBPixel< long >, D >( ); - else if( pt == "uchar" ) - r = this->_GD1< itk::RGBPixel< unsigned char >, D >( ); - else if( pt == "ushort" ) - r = this->_GD1< itk::RGBPixel< unsigned short >, D >( ); - else if( pt == "uint" ) - r = this->_GD1< itk::RGBPixel< unsigned int >, D >( ); - else if( pt == "ulong" ) - r = this->_GD1< itk::RGBPixel< unsigned long >, D >( ); - else if( pt == "float" ) - r = this->_GD1< itk::RGBPixel< float >, D >( ); - else if( pt == "double" ) - r = this->_GD1< itk::RGBPixel< double >, D >( ); - } // fi + case itk::ImageIOBase::UCHAR: + r = this->_GD1< unsigned char, D >( io, names ); + break; + case itk::ImageIOBase::CHAR: + r = this->_GD1< char, D >( io, names ); + break; + case itk::ImageIOBase::USHORT: + r = this->_GD1< unsigned short, D >( io, names ); + break; + case itk::ImageIOBase::SHORT: + r = this->_GD1< short, D >( io, names ); + break; + case itk::ImageIOBase::UINT: + r = this->_GD1< unsigned int, D >( io, names ); + break; + case itk::ImageIOBase::INT: + r = this->_GD1< int, D >( io, names ); + break; + case itk::ImageIOBase::ULONG: + r = this->_GD1< unsigned long, D >( io, names ); + break; + case itk::ImageIOBase::LONG: + r = this->_GD1< long, D >( io, names ); + break; + case itk::ImageIOBase::FLOAT: + r = this->_GD1< float, D >( io, names ); + break; + case itk::ImageIOBase::DOUBLE: + r = this->_GD1< double, D >( io, names ); + break; + default: + r = "ImageReader: Atomic pixel type not supported."; + break; + } // hctiws return( r ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > std::string cpPlugins::Plugins::ImageReader:: -_GD1( ) +_GD1( itk::ImageIOBase* io, const TStringList& names ) { - typedef itk::Image< P, D > _TImage; + std::string r = ""; + switch( io->GetPixelType( ) ) + { + case itk::ImageIOBase::SCALAR: + r = this->_GD2< P, D >( names ); + break; + case itk::ImageIOBase::RGB: + r = this->_GD2< itk::RGBPixel< P >, D >( names ); + break; + case itk::ImageIOBase::RGBA: + r = this->_GD2< itk::RGBAPixel< P >, D >( names ); + break; + /* TODO + case itk::ImageIOBase::OFFSET: + r = this->_GD2< itk::Offset< P >, D >( names ); + break; + case itk::ImageIOBase::VECTOR: + r = this->_GD2< P, D >( names ); + break; + case itk::ImageIOBase::POINT: + r = this->_GD2< P, D >( names ); + break; + case itk::ImageIOBase::COVARIANTVECTOR: + r = this->_GD2< P, D >( names ); + break; + case itk::ImageIOBase::SYMMETRICSECONDRANKTENSOR: + r = this->_GD2< P, D >( names ); + break; + case itk::ImageIOBase::DIFFUSIONTENSOR3D: + r = this->_GD2< P, D >( names ); + break; + */ + /* TODO + case itk::ImageIOBase::COMPLEX: + r = this->_GD2< std::complex< P >, D >( names ); + break; + case itk::ImageIOBase::FIXEDARRAY: + r = this->_GD2< P, D >( names ); + break; + case itk::ImageIOBase::MATRIX: + r = this->_GD2< P, D >( names ); + break; + */ + default: + r = "ImageReader: Pixel type not supported."; + break; + } // hctiws + return( r ); +} - // Get filenames - using namespace cpPlugins::Interface; - std::vector< Parameters::TString > unordered_names; - this->m_Parameters.GetValueAsStringList( unordered_names, "FileNames" ); +// ------------------------------------------------------------------------- +template< class P, unsigned int D > +std::string cpPlugins::Plugins::ImageReader:: +_GD2( const TStringList& names ) +{ + typedef itk::Image< P, D > _I; - if( unordered_names.size( ) == 1 ) + std::string r = ""; + if( names.size( ) == 1 ) { // Read single image - typedef itk::ImageFileReader< _TImage > _TSingleReader; - - _TSingleReader* singleReader = - dynamic_cast< _TSingleReader* >( - this->m_RealProcessObject.GetPointer( ) - ); - if( singleReader == NULL ) + typedef itk::ImageFileReader< _I > _SR; + _SR* reader = + dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); + if( reader == NULL ) { - this->m_RealProcessObject = _TSingleReader::New( ); - singleReader = - dynamic_cast< _TSingleReader* >( - this->m_RealProcessObject.GetPointer( ) - ); + this->m_RealProcessObject = _SR::New( ); + reader = + dynamic_cast< _SR* >( this->m_RealProcessObject.GetPointer( ) ); } // fi - singleReader->SetFileName( unordered_names.front( ) ); + reader->SetFileName( names[ 0 ] ); try { - singleReader->Update( ); + reader->Update( ); + this->m_Outputs[ 0 ]->SetITKDataObject( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { - return( err.GetDescription( ) ); + r = "ImageReader: " + std::string( err.GetDescription( ) ); + this->m_Outputs[ 0 ]->SetITKDataObject( NULL ); } // yrt - this->_SetOutput( 0, singleReader->GetOutput( ) ); - return( "" ); } - else if( unordered_names.size( ) > 1 ) + else if( names.size( ) > 1 ) { // Read image series std::set< std::string > ordered_names; - for( unsigned int i = 0; i < unordered_names.size( ); ++i ) - ordered_names.insert( unordered_names[ i ] ); + for( unsigned int i = 0; i < names.size( ); ++i ) + ordered_names.insert( names[ i ] ); - typedef itk::ImageSeriesReader< _TImage > _TMultiReader; - _TMultiReader* multiReader = - dynamic_cast< _TMultiReader* >( - this->m_RealProcessObject.GetPointer( ) - ); - if( multiReader == NULL ) + typedef itk::ImageSeriesReader< _I > _MR; + _MR* reader = + dynamic_cast< _MR* >( this->m_RealProcessObject.GetPointer( ) ); + if( reader == NULL ) { - this->m_RealProcessObject = _TMultiReader::New( ); - multiReader = - dynamic_cast< _TMultiReader* >( - this->m_RealProcessObject.GetPointer( ) - ); + 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 ) - multiReader->AddFileName( *fnIt ); + reader->AddFileName( *fnIt ); try { - multiReader->Update( ); + reader->Update( ); + this->m_Outputs[ 0 ]->SetITKDataObject( reader->GetOutput( ) ); } catch( itk::ExceptionObject& err ) { - return( err.GetDescription( ) ); + r = "ImageReader: " + std::string( err.GetDescription( ) ); + this->m_Outputs[ 0 ]->SetITKDataObject( NULL ); } // yrt - this->_SetOutput( 0, multiReader->GetOutput( ) ); - return( "" ); } else - return( "No image filename(s) given." ); + r = "ImageReader: No image files given"; + return( r ); } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/ImageReader.h b/lib/cpPlugins/Plugins/ImageReader.h index 61efe0d..07aeeba 100644 --- a/lib/cpPlugins/Plugins/ImageReader.h +++ b/lib/cpPlugins/Plugins/ImageReader.h @@ -1,9 +1,13 @@ #ifndef __CPPLUGINS__PLUGINS__IMAGEREADER__H__ #define __CPPLUGINS__PLUGINS__IMAGEREADER__H__ +#include + #include #include -#include + +#define ITK_MANUAL_INSTANTIATION +#include namespace cpPlugins { @@ -20,13 +24,14 @@ namespace cpPlugins typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; + typedef + std::vector< cpPlugins::Interface::Parameters::TString > + TStringList; + public: itkNewMacro( Self ); itkTypeMacro( ImageReader, cpPluginsInterfaceImageSource ); - public: - virtual std::string GetClassName( ) const; - protected: ImageReader( ); virtual ~ImageReader( ); @@ -34,10 +39,13 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< unsigned int D > - std::string _GD0( ); + std::string _GD0( itk::ImageIOBase* io, const TStringList& names ); + + template< class P, unsigned int D > + std::string _GD1( itk::ImageIOBase* io, const TStringList& names ); template< class P, unsigned int D > - std::string _GD1( ); + std::string _GD2( const TStringList& names ); private: // Purposely not implemented diff --git a/lib/cpPlugins/Plugins/ImageSeriesReader.cxx b/lib/cpPlugins/Plugins/ImageSeriesReader.cxx deleted file mode 100644 index 30585e7..0000000 --- a/lib/cpPlugins/Plugins/ImageSeriesReader.cxx +++ /dev/null @@ -1,160 +0,0 @@ -#include -#include - -#include -#include - -#include - -#define ITK_MANUAL_INSTANTIATION -#include -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageSeriesReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::ImageSeriesReader" ); -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::ImageSeriesReader:: -ImageSeriesReader( ) - : Superclass( ) -{ - 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::String, "PixelType" ); - this->m_DefaultParameters.Configure( Parameters::Uint, "Dimension" ); - this->m_DefaultParameters.Configure( Parameters::Uint, "IsColorImage" ); - this->m_DefaultParameters.SetValueAsString( "PixelType", "uchar" ); - this->m_DefaultParameters.SetValueAsUint( "Dimension", 3 ); - this->m_DefaultParameters.SetValueAsUint( "IsColorImage", 0 ); - this->m_Parameters = this->m_DefaultParameters; -} - -// ------------------------------------------------------------------------- -cpPlugins::Plugins::ImageSeriesReader:: -~ImageSeriesReader( ) -{ -} - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageSeriesReader:: -_GenerateData( ) -{ - using namespace cpPlugins::Interface; - Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" ); - - std::string r = "cpPlugins::Plugins::ImageSeriesReader: itk::Image dimension not supported."; - if ( dim == 2 ) r = this->_GD0< 2 >( ); - else if( dim == 3 ) r = this->_GD0< 3 >( ); - else if( dim == 4 ) r = this->_GD0< 4 >( ); - - return( r ); -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -std::string cpPlugins::Plugins::ImageSeriesReader:: -_GD0( ) -{ - using namespace cpPlugins::Interface; - Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" ); - Parameters::TUint ci = this->m_Parameters.GetValueAsUint( "IsColorImage" ); - - std::string r = "cpPlugins::Plugins::ImageSeriesReader: itk::Image pixel type not supported"; - if( ci == 0 ) - { - if( pt == "char" ) - r = this->_GD1< char, D >( ); - else if( pt == "short" ) - r = this->_GD1< short, D >( ); - else if( pt == "int" ) - r = this->_GD1< int, D >( ); - else if( pt == "long" ) - r = this->_GD1< long, D >( ); - else if( pt == "uchar" ) - r = this->_GD1< unsigned char, D >( ); - else if( pt == "ushort" ) - r = this->_GD1< unsigned short, D >( ); - else if( pt == "uint" ) - r = this->_GD1< unsigned int, D >( ); - else if( pt == "ulong" ) - r = this->_GD1< unsigned long, D >( ); - else if( pt == "float" ) - r = this->_GD1< float, D >( ); - else if( pt == "double" ) - r = this->_GD1< double, D >( ); - } - else if( ci == 1 ) - { - if( pt == "char" ) - r = this->_GD1< itk::RGBPixel< char >, D >( ); - else if( pt == "short" ) - r = this->_GD1< itk::RGBPixel< short >, D >( ); - else if( pt == "int" ) - r = this->_GD1< itk::RGBPixel< int >, D >( ); - else if( pt == "long" ) - r = this->_GD1< itk::RGBPixel< long >, D >( ); - else if( pt == "uchar" ) - r = this->_GD1< itk::RGBPixel< unsigned char >, D >( ); - else if( pt == "ushort" ) - r = this->_GD1< itk::RGBPixel< unsigned short >, D >( ); - else if( pt == "uint" ) - r = this->_GD1< itk::RGBPixel< unsigned int >, D >( ); - else if( pt == "ulong" ) - r = this->_GD1< itk::RGBPixel< unsigned long >, D >( ); - else if( pt == "float" ) - r = this->_GD1< itk::RGBPixel< float >, D >( ); - else if( pt == "double" ) - r = this->_GD1< itk::RGBPixel< double >, D >( ); - } // fi - return( r ); -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -std::string cpPlugins::Plugins::ImageSeriesReader:: -_GD1( ) -{ - using namespace cpPlugins::Interface; - std::vector< Parameters::TString > unordered_names; - this->m_Parameters.GetValueAsStringList( unordered_names, "FileNames" ); - std::set< std::string > ordered_names; - for( unsigned int i = 0; i < unordered_names.size( ); ++i ) - ordered_names.insert( unordered_names[ i ] ); - - // Reader - typedef itk::Image< P, D > _TImage; - typedef itk::ImageSeriesReader< _TImage > _TReader; - - _TReader* reader = - dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); - if( reader == NULL ) - { - this->m_RealProcessObject = _TReader::New( ); - reader = - dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi - std::set< std::string >::const_iterator fnIt = ordered_names.begin( ); - for( ; fnIt != ordered_names.end( ); ++fnIt ) - reader->AddFileName( *fnIt ); - try - { - reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - return( err.GetDescription( ) ); - - } // yrt - this->_SetOutput( 0, reader->GetOutput( ) ); - return( "" ); -} - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/ImageSeriesReader.h b/lib/cpPlugins/Plugins/ImageSeriesReader.h deleted file mode 100644 index f2bcf03..0000000 --- a/lib/cpPlugins/Plugins/ImageSeriesReader.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef __CPPLUGINS__PLUGINS__IMAGESERIESREADER__H__ -#define __CPPLUGINS__PLUGINS__IMAGESERIESREADER__H__ - -#include -#include -#include - -namespace cpPlugins -{ - namespace Plugins - { - /** - */ - class cpPlugins_EXPORT ImageSeriesReader - : public cpPlugins::Interface::ImageSource - { - public: - typedef ImageSeriesReader Self; - typedef cpPlugins::Interface::ImageSource Superclass; - typedef itk::SmartPointer< Self > Pointer; - typedef itk::SmartPointer< const Self > ConstPointer; - - public: - itkNewMacro( Self ); - itkTypeMacro( ImageSeriesReader, cpPluginsInterfaceImageSource ); - - public: - virtual std::string GetClassName( ) const; - - protected: - ImageSeriesReader( ); - virtual ~ImageSeriesReader( ); - - virtual std::string _GenerateData( ); - - template< unsigned int D > - std::string _GD0( ); - - template< class P, unsigned int D > - std::string _GD1( ); - - private: - // Purposely not implemented - ImageSeriesReader( const Self& ); - Self& operator=( const Self& ); - }; - - // --------------------------------------------------------------------- - CPPLUGINS_INHERIT_PROVIDER( ImageSeriesReader ); - - } // ecapseman - -} // ecapseman - -#endif // __CPPLUGINS__PLUGINS__IMAGESERIESREADER__H__ - -// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/ImageWriter.cxx b/lib/cpPlugins/Plugins/ImageWriter.cxx index de74e90..9c99f2c 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.cxx +++ b/lib/cpPlugins/Plugins/ImageWriter.cxx @@ -1,40 +1,34 @@ #include -#include - -#define ITK_MANUAL_INSTANTIATION +#undef ITK_MANUAL_INSTANTIATION #include #include +#include // ------------------------------------------------------------------------- -#define cpPlugins_ImageWriter_Dimension( r, d, o, f ) \ - if( dynamic_cast< itk::ImageBase< d >* >( o ) != NULL ) \ - r = this->f< d >( ) +#define cpPlugins_ImageWriter_Dimension( r, d, i, f ) \ + if( dynamic_cast< itk::ImageBase< d >* >( i ) != NULL ) \ + r = this->f< d >( i ) // ------------------------------------------------------------------------- -#define cpPlugins_ImageWriter_Pixel( r, p, d, o, f ) \ - if( dynamic_cast< itk::Image< p, d >* >( o ) != NULL ) \ - r = this->f< p, d >( ) +#define cpPlugins_ImageWriter_Pixel( r, p, d, i, f ) \ + if( dynamic_cast< itk::Image< p, d >* >( i ) != NULL ) \ + r = this->f< p, d >( i ) // ------------------------------------------------------------------------- -#define cpPlugins_ImageWriter_RGB( r, p, d, o, f ) \ +#define cpPlugins_ImageWriter_RGB( r, p, d, i, f ) \ if( \ - dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( o ) != NULL \ + dynamic_cast< itk::Image< itk::RGBPixel< p >, d >* >( i ) != NULL \ ) \ - r = this->f< itk::RGBPixel< p >, d >( ) - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::ImageWriter:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::ImageWriter" ); -} + r = this->f< itk::RGBPixel< p >, d >( i ) // ------------------------------------------------------------------------- cpPlugins::Plugins::ImageWriter:: ImageWriter( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::ImageWriter"; + this->m_ClassCategory = "ImageWriter"; this->SetNumberOfInputs( 1 ); using namespace cpPlugins::Interface; @@ -52,79 +46,73 @@ cpPlugins::Plugins::ImageWriter:: std::string cpPlugins::Plugins::ImageWriter:: _GenerateData( ) { - itk::DataObject* o = this->_GetInput( 0 ); + itk::DataObject* i = this->m_Inputs[ 0 ]->GetITKDataObject( ); - std::string r = "cpPlugins::Plugins::ImageWriter: itk::Image dimension not supported."; - cpPlugins_ImageWriter_Dimension( r, 1, o, _GD0 ); - else cpPlugins_ImageWriter_Dimension( r, 2, o, _GD0 ); - else cpPlugins_ImageWriter_Dimension( r, 3, o, _GD0 ); - else cpPlugins_ImageWriter_Dimension( r, 4, o, _GD0 ); + std::string r = "ImageWriter: Image dimension not supported."; + cpPlugins_ImageWriter_Dimension ( r, 1, i, _GD0 ); + else cpPlugins_ImageWriter_Dimension( r, 2, i, _GD0 ); + else cpPlugins_ImageWriter_Dimension( r, 3, i, _GD0 ); return( r ); } // ------------------------------------------------------------------------- template< unsigned int D > std::string cpPlugins::Plugins::ImageWriter:: -_GD0( ) +_GD0( itk::DataObject* i ) { - itk::ImageBase< D >* i = - dynamic_cast< itk::ImageBase< D >* >( this->_GetInput( 0 ) ); - - std::string r = "cpPlugins::Plugins::ImageWriter: itk::Image pixel type not supported"; - cpPlugins_ImageWriter_Pixel( r, char, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, short, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, int, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, long, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, unsigned char, D, i, _GD1 ); + std::string r = "ImageWriter: Image pixel type not supported"; + cpPlugins_ImageWriter_Pixel ( r, char , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, short , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, int , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, long , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, unsigned char , D, i, _GD1 ); else cpPlugins_ImageWriter_Pixel( r, unsigned short, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, unsigned int, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, unsigned long, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, float, D, i, _GD1 ); - else cpPlugins_ImageWriter_Pixel( r, double, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, char, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, short, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, int, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, long, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, unsigned char, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, unsigned short, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, unsigned int, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, unsigned long, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, float, D, i, _GD1 ); - else cpPlugins_ImageWriter_RGB( r, double, D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, unsigned int , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, unsigned long , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, float , D, i, _GD1 ); + else cpPlugins_ImageWriter_Pixel( r, double , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, char , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, short , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, int , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, long , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, unsigned char , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, unsigned short, D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, unsigned int , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, unsigned long , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, float , D, i, _GD1 ); + else cpPlugins_ImageWriter_RGB ( r, double , D, i, _GD1 ); return( r ); } // ------------------------------------------------------------------------- template< class P, unsigned int D > std::string cpPlugins::Plugins::ImageWriter:: -_GD1( ) +_GD1( itk::DataObject* i ) { - typedef itk::Image< P, D > _TImage; - typedef itk::ImageFileWriter< _TImage > _TWriter; + typedef itk::Image< P, D > _I; + typedef itk::ImageFileWriter< _I > _W; // Get filename using namespace cpPlugins::Interface; Parameters::TString fname = this->m_Parameters.GetValueAsString( "FileName" ); - _TWriter* writer = - dynamic_cast< _TWriter* >( this->m_RealProcessObject.GetPointer( ) ); + _W* writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); if( writer == NULL ) { - this->m_RealProcessObject = _TWriter::New( ); - writer = - dynamic_cast< _TWriter* >( this->m_RealProcessObject.GetPointer( ) ); + this->m_RealProcessObject = _W::New( ); + writer = dynamic_cast< _W* >( this->m_RealProcessObject.GetPointer( ) ); } // fi writer->SetFileName( fname ); - writer->SetInput( dynamic_cast< _TImage* >( this->_GetInput( 0 ) ) ); + writer->SetInput( dynamic_cast< _I* >( i ) ); try { writer->Update( ); } catch( itk::ExceptionObject& err ) { - return( err.GetDescription( ) ); + return( "ImageWriter: " + std::string( err.GetDescription( ) ) ); } // yrt return( "" ); diff --git a/lib/cpPlugins/Plugins/ImageWriter.h b/lib/cpPlugins/Plugins/ImageWriter.h index 4a02fe2..dc8d5da 100644 --- a/lib/cpPlugins/Plugins/ImageWriter.h +++ b/lib/cpPlugins/Plugins/ImageWriter.h @@ -3,7 +3,6 @@ #include #include -#include namespace cpPlugins { @@ -24,9 +23,6 @@ namespace cpPlugins itkNewMacro( Self ); itkTypeMacro( ImageWriter, cpPluginsInterfaceImageSink ); - public: - virtual std::string GetClassName( ) const; - protected: ImageWriter( ); virtual ~ImageWriter( ); @@ -34,10 +30,10 @@ namespace cpPlugins virtual std::string _GenerateData( ); template< unsigned int D > - std::string _GD0( ); + std::string _GD0( itk::DataObject* i ); template< class P, unsigned int D > - std::string _GD1( ); + std::string _GD1( itk::DataObject* i ); private: // Purposely not implemented diff --git a/lib/cpPlugins/Plugins/MarchingCubes.cxx b/lib/cpPlugins/Plugins/MarchingCubes.cxx index 12aad40..bc56f9c 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.cxx +++ b/lib/cpPlugins/Plugins/MarchingCubes.cxx @@ -2,172 +2,79 @@ #include #include -#include - -#define ITK_MANUAL_INSTANTIATION -#include -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MarchingCubes:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::MarchingCubes" ); -} +#include +#include +#include // ------------------------------------------------------------------------- cpPlugins::Plugins::MarchingCubes:: MarchingCubes( ) - : Superclass( ) + : Superclass( ), + m_Algorithm( NULL ) { + this->m_ClassName = "cpPlugins::MarchingCubes"; + this->SetNumberOfInputs( 1 ); this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); - /* TODO - this->m_DefaultParameters[ "FileName" ] = - TParameter( "string", "no_file_name" ); - this->m_DefaultParameters[ "PixelType" ] = TParameter( "type", "uchar" ); - this->m_DefaultParameters[ "ImageDimension" ] = TParameter( "int", "2" ); - this->m_DefaultParameters[ "IsColorImage" ] = TParameter( "bool", "0" ); - */ + using namespace cpPlugins::Interface; + this->m_DefaultParameters.Configure( Parameters::RealList, "Thresholds" ); + this->m_Parameters = this->m_DefaultParameters; } // ------------------------------------------------------------------------- cpPlugins::Plugins::MarchingCubes:: ~MarchingCubes( ) { + if( this->m_Algorithm != NULL ) + this->m_Algorithm->Delete( ); } // ------------------------------------------------------------------------- std::string cpPlugins::Plugins::MarchingCubes:: _GenerateData( ) { - return( "" ); - /* TODO - TParameters::const_iterator dIt; - - // Get image dimension - dIt = this->m_Parameters.find( "ImageDimension" ); - if( dIt == this->m_Parameters.end( ) ) - dIt = this->m_DefaultParameters.find( "ImageDimension" ); - - std::string r = "cpPlugins::Plugins::MarchingCubes: itk::Image dimension not supported."; - if ( dIt->second.second == "1" ) r = this->_GD0< 1 >( ); - else if( dIt->second.second == "2" ) r = this->_GD0< 2 >( ); - else if( dIt->second.second == "3" ) r = this->_GD0< 3 >( ); - else if( dIt->second.second == "4" ) r = this->_GD0< 4 >( ); - - return( r ); - */ -} - -// ------------------------------------------------------------------------- -template< unsigned int D > -std::string cpPlugins::Plugins::MarchingCubes:: -_GD0( ) -{ - return( "" ); - /* TODO - TParameters::const_iterator tIt, cIt; - - // Get image pixel type - tIt = this->m_Parameters.find( "PixelType" ); - if( tIt == this->m_Parameters.end( ) ) - tIt = this->m_DefaultParameters.find( "PixelType" ); - cIt = this->m_Parameters.find( "IsColorImage" ); - if( cIt == this->m_Parameters.end( ) ) - cIt = this->m_DefaultParameters.find( "IsColorImage" ); - - std::string r = "cpPlugins::Plugins::MarchingCubes: itk::Image pixel type not supported"; - if( cIt->second.second == "0" ) + // Get input + cpPlugins::Interface::Image* input = + dynamic_cast< cpPlugins::Interface::Image* >( + this->m_Inputs[ 0 ].GetPointer( ) + ); + if( input == NULL ) + return( "MarchingCubes: Input data is not a valid image." ); + vtkImageData* vtk_input = + dynamic_cast< vtkImageData* >( input->GetVTKDataObject( ) ); + if( vtk_input == NULL ) + return( "MarchingCubes: Input does not have a valid conversion to VTK." ); + + if( this->m_Algorithm != NULL ) + this->m_Algorithm->Delete( ); + + std::vector< double > values; + this->m_Parameters.GetValueAsRealList( values, "Thresholds" ); + if( vtk_input->GetDataDimension( ) == 2 ) { - if( tIt->second.second == "char" ) - r = this->_GD1< char, D >( ); - else if( tIt->second.second == "short" ) - r = this->_GD1< short, D >( ); - else if( tIt->second.second == "int" ) - r = this->_GD1< int, D >( ); - else if( tIt->second.second == "long" ) - r = this->_GD1< long, D >( ); - else if( tIt->second.second == "uchar" ) - r = this->_GD1< unsigned char, D >( ); - else if( tIt->second.second == "ushort" ) - r = this->_GD1< unsigned short, D >( ); - else if( tIt->second.second == "uint" ) - r = this->_GD1< unsigned int, D >( ); - else if( tIt->second.second == "ulong" ) - r = this->_GD1< unsigned long, D >( ); - else if( tIt->second.second == "float" ) - r = this->_GD1< float, D >( ); - else if( tIt->second.second == "double" ) - r = this->_GD1< double, D >( ); + vtkMarchingSquares* ms = vtkMarchingSquares::New( ); + ms->SetInputData( vtk_input ); + for( unsigned int i = 0; i < values.size( ); ++i ) + ms->SetValue( i, values[ i ] ); + this->m_Algorithm = ms; } - else if( cIt->second.second == "1" ) - { - if( tIt->second.second == "char" ) - r = this->_GD1< itk::RGBPixel< char >, D >( ); - else if( tIt->second.second == "short" ) - r = this->_GD1< itk::RGBPixel< short >, D >( ); - else if( tIt->second.second == "int" ) - r = this->_GD1< itk::RGBPixel< int >, D >( ); - else if( tIt->second.second == "long" ) - r = this->_GD1< itk::RGBPixel< long >, D >( ); - else if( tIt->second.second == "uchar" ) - r = this->_GD1< itk::RGBPixel< unsigned char >, D >( ); - else if( tIt->second.second == "ushort" ) - r = this->_GD1< itk::RGBPixel< unsigned short >, D >( ); - else if( tIt->second.second == "uint" ) - r = this->_GD1< itk::RGBPixel< unsigned int >, D >( ); - else if( tIt->second.second == "ulong" ) - r = this->_GD1< itk::RGBPixel< unsigned long >, D >( ); - else if( tIt->second.second == "float" ) - r = this->_GD1< itk::RGBPixel< float >, D >( ); - else if( tIt->second.second == "double" ) - r = this->_GD1< itk::RGBPixel< double >, D >( ); - } // fi - return( r ); -*/ -} - -// ------------------------------------------------------------------------- -template< class P, unsigned int D > -std::string cpPlugins::Plugins::MarchingCubes:: -_GD1( ) -{ - return( "" ); - /* TODO - TParameters::const_iterator fIt; - - // Get filename - fIt = this->m_Parameters.find( "FileName" ); - if( fIt == this->m_Parameters.end( ) ) - fIt = this->m_DefaultParameters.find( "FileName" ); - - typedef itk::Image< P, D > _TImage; - typedef itk::ImageFileReader< _TImage > _TReader; - - _TReader* reader = - dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); - if( reader == NULL ) - { - this->m_Reader = _TReader::New( ); - reader = dynamic_cast< _TReader* >( this->m_Reader.GetPointer( ) ); - - } // fi - reader->SetFileName( fIt->second.second ); - try + else if( vtk_input->GetDataDimension( ) == 3 ) { - reader->Update( ); + vtkMarchingCubes* mc = vtkMarchingCubes::New( ); + mc->SetInputData( vtk_input ); + for( unsigned int i = 0; i < values.size( ); ++i ) + mc->SetValue( i, values[ i ] ); + this->m_Algorithm = mc; } - catch( itk::ExceptionObject& err ) - { - return( err.GetDescription( ) ); + else + return( "MarchingCubes: Input data does not have a valid dimension." ); - } // yrt - this->_SetOutput( 0, reader->GetOutput( ) ); + // Execute filter + this->m_Algorithm->Update( ); + this->m_Outputs[ 0 ]->SetVTKDataObject( this->m_Algorithm->GetOutput( ) ); return( "" ); -*/ } // eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/MarchingCubes.h b/lib/cpPlugins/Plugins/MarchingCubes.h index c84668b..4375842 100644 --- a/lib/cpPlugins/Plugins/MarchingCubes.h +++ b/lib/cpPlugins/Plugins/MarchingCubes.h @@ -3,7 +3,8 @@ #include #include -#include + +class vtkPolyDataAlgorithm; namespace cpPlugins { @@ -24,25 +25,19 @@ namespace cpPlugins itkNewMacro( Self ); itkTypeMacro( MarchingCubes, cpPluginsInterfaceImageToMeshFilter ); - public: - virtual std::string GetClassName( ) const; - protected: MarchingCubes( ); virtual ~MarchingCubes( ); virtual std::string _GenerateData( ); - template< unsigned int D > - std::string _GD0( ); - - template< class P, unsigned int D > - std::string _GD1( ); - private: // Purposely not implemented MarchingCubes( const Self& ); Self& operator=( const Self& ); + + protected: + vtkPolyDataAlgorithm* m_Algorithm; }; // --------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/MeshReader.cxx b/lib/cpPlugins/Plugins/MeshReader.cxx index b7ce4ba..5338c32 100644 --- a/lib/cpPlugins/Plugins/MeshReader.cxx +++ b/lib/cpPlugins/Plugins/MeshReader.cxx @@ -1,21 +1,17 @@ #include #include -#include -#include - -// ------------------------------------------------------------------------- -std::string cpPlugins::Plugins::MeshReader:: -GetClassName( ) const -{ - return( "cpPlugins::Plugins::MeshReader" ); -} +#include +#include // ------------------------------------------------------------------------- cpPlugins::Plugins::MeshReader:: MeshReader( ) : Superclass( ) { + this->m_ClassName = "cpPlugins::MeshReader"; + this->m_ClassCategory = "MeshReader"; + this->SetNumberOfOutputs( 1 ); this->_MakeOutput< cpPlugins::Interface::Mesh >( 0 ); @@ -40,7 +36,7 @@ _GenerateData( ) { using namespace cpPlugins::Interface; Parameters::TUint dim = this->m_Parameters.GetValueAsUint( "Dimension" ); - std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh dimension not supported."; + std::string r = "MeshReader: Mesh dimension not supported."; if( dim == 3 ) r = this->_GD0< 3 >( ); return( r ); @@ -53,7 +49,7 @@ _GD0( ) { using namespace cpPlugins::Interface; Parameters::TString pt = this->m_Parameters.GetValueAsString( "PixelType" ); - std::string r = "cpPlugins::Plugins::MeshReader: itk::Mesh pixel type not supported"; + std::string r = "MeshReader: Mesh pixel type not supported"; if( pt == "float" ) r = this->_GD1< float, D >( ); else if( pt == "double" ) r = this->_GD1< double, D >( ); return( r ); @@ -69,31 +65,14 @@ _GD1( ) Parameters::TString fname = this->m_Parameters.GetValueAsString( "FileName" ); - using namespace cpPlugins::Extensions; - typedef DataStructures::QuadEdgeMesh< P, D > _TMesh; - typedef IO::MeshReader< _TMesh > _TReader; - - _TReader* reader = - dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); - if( reader == NULL ) - { - this->m_RealProcessObject = _TReader::New( ); - reader = - dynamic_cast< _TReader* >( this->m_RealProcessObject.GetPointer( ) ); - - } // fi - reader->SetFileName( fname ); - try - { - reader->Update( ); - } - catch( itk::ExceptionObject& err ) - { - return( err.GetDescription( ) ); - - } // yrt - this->_SetOutput( 0, reader->GetOutput( ) ); + if( this->m_Reader != NULL ) + this->m_Reader->Delete( ); + vtkPolyDataReader* pdr = vtkPolyDataReader::New( ); + this->m_Reader = pdr; + pdr->SetFileName( fname.c_str( ) ); + pdr->Update( ); + this->m_Outputs[ 0 ]->SetVTKDataObject( pdr->GetOutput( ) ); return( "" ); } diff --git a/lib/cpPlugins/Plugins/MeshReader.h b/lib/cpPlugins/Plugins/MeshReader.h index 6689608..d2b42de 100644 --- a/lib/cpPlugins/Plugins/MeshReader.h +++ b/lib/cpPlugins/Plugins/MeshReader.h @@ -3,7 +3,8 @@ #include #include -#include + +class vtkDataReader; namespace cpPlugins { @@ -24,9 +25,6 @@ namespace cpPlugins itkNewMacro( Self ); itkTypeMacro( MeshReader, cpPluginsInterfaceMeshSource ); - public: - virtual std::string GetClassName( ) const; - protected: MeshReader( ); virtual ~MeshReader( ); @@ -43,6 +41,9 @@ namespace cpPlugins // Purposely not implemented MeshReader( const Self& ); Self& operator=( const Self& ); + + protected: + vtkDataReader* m_Reader; }; // --------------------------------------------------------------------- diff --git a/lib/cpPlugins/Plugins/MeshWriter.cxx b/lib/cpPlugins/Plugins/MeshWriter.cxx new file mode 100644 index 0000000..beaee04 --- /dev/null +++ b/lib/cpPlugins/Plugins/MeshWriter.cxx @@ -0,0 +1,55 @@ +#include + +#include +#include +#include + +// ------------------------------------------------------------------------- +cpPlugins::Plugins::MeshWriter:: +MeshWriter( ) + : Superclass( ), + m_Writer( NULL ) +{ + this->m_ClassName = "cpPlugins::MeshWriter"; + this->m_ClassCategory = "MeshWriter"; + this->SetNumberOfInputs( 1 ); + + using namespace cpPlugins::Interface; + this->m_DefaultParameters.Configure( Parameters::String, "FileName" ); + this->m_Parameters = this->m_DefaultParameters; +} + +// ------------------------------------------------------------------------- +cpPlugins::Plugins::MeshWriter:: +~MeshWriter( ) +{ + if( this->m_Writer != NULL ) + this->m_Writer->Delete( ); +} + +// ------------------------------------------------------------------------- +std::string cpPlugins::Plugins::MeshWriter:: +_GenerateData( ) +{ + vtkPolyData* i = + dynamic_cast< vtkPolyData* >( + this->m_Inputs[ 0 ]->GetVTKDataObject( ) + ); + if( i == NULL ) + return( "MeshWriter: No suitable input." ); + std::string fname = this->m_Parameters.GetValueAsString( "FileName" ); + + if( this->m_Writer != NULL ) + this->m_Writer->Delete( ); + + vtkPolyDataWriter* pdw = vtkPolyDataWriter::New( ); + this->m_Writer = pdw; + pdw->SetInputData( i ); + pdw->SetFileName( fname.c_str( ) ); + pdw->Update( ); + if( pdw->GetErrorCode( ) != 0 ) + return( "MeshWriter: someting wrong happened." ); + return( "" ); +} + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Plugins/MeshWriter.h b/lib/cpPlugins/Plugins/MeshWriter.h new file mode 100644 index 0000000..d0726ec --- /dev/null +++ b/lib/cpPlugins/Plugins/MeshWriter.h @@ -0,0 +1,52 @@ +#ifndef __CPPLUGINS__PLUGINS__MESHWRITER__H__ +#define __CPPLUGINS__PLUGINS__MESHWRITER__H__ + +#include +#include + +class vtkDataWriter; + +namespace cpPlugins +{ + namespace Plugins + { + /** + */ + class cpPlugins_EXPORT MeshWriter + : public cpPlugins::Interface::MeshSink + { + public: + typedef MeshWriter Self; + typedef cpPlugins::Interface::MeshSink Superclass; + typedef itk::SmartPointer< Self > Pointer; + typedef itk::SmartPointer< const Self > ConstPointer; + + public: + itkNewMacro( Self ); + itkTypeMacro( MeshWriter, cpPluginsInterfaceMeshSink ); + + protected: + MeshWriter( ); + virtual ~MeshWriter( ); + + virtual std::string _GenerateData( ); + + private: + // Purposely not implemented + MeshWriter( const Self& ); + Self& operator=( const Self& ); + + protected: + vtkDataWriter* m_Writer; + }; + + // --------------------------------------------------------------------- + CPPLUGINS_INHERIT_PROVIDER( MeshWriter ); + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__PLUGINS__MESHWRITER__H__ + +// eof - $RCSfile$ -- 2.47.1